at.dms.kjc.cluster
Class TapeFixedBase

java.lang.Object
  extended by at.dms.kjc.cluster.TapeBase
      extended by at.dms.kjc.cluster.TapeFixedBase
All Implemented Interfaces:
Tape
Direct Known Subclasses:
TapeFixedCircular, TapeFixedCopydown

public abstract class TapeFixedBase
extends TapeBase
implements Tape

Class of tapes with fixed size buffers. Common elements go here, the rest in subclasses.

Author:
dimock

Field Summary
protected  String bufferName
          Name of buffer containing tape items
protected  int extra
          (Maximum) number of unpopped items left on tape for next iteration.
protected  String headName
          Name of variable with offset for push onto tape
protected  int items
          Maximum number of items ever on the tape: for buffer size.
protected  String popArrayRefPrefix
          in pop / peek refer to scalar as buffer[offset] but refer to array as &buffer[offset][0]...[0]
protected  String popArrayRefSuffix
           
protected  String tailName
          Name of variable with offset for pop from tape
 
Fields inherited from class at.dms.kjc.cluster.TapeBase
dst, peek_name, pop_name, push_name, src, type, typeString
 
Constructor Summary
TapeFixedBase(int source, int dest, CType type)
           
 
Method Summary
 String assignPeekToVar(String varName, String offset)
          Assign the result of peeking.
 String assignPopToVar(String varName)
          Statement, but no ";" to pop an item into a variable.
 String downstreamCleanup()
          Any cleanup needed before exit for downstream end of tape.
 String downstreamDeclaration()
          Data declaration: for code doing downstream processing.
 String downstreamDeclarationExtern()
          Data declaration: following "extern" if needed else noop.
 String getBufferName()
           
 int getExtra()
          for debugginf only
 String getHeadName()
           
 int getItems()
          for debugging only
 String getTailName()
           
protected abstract  String headIncrementStmts()
           
 String pushbackCleanup()
           
 String pushbackInit(int numberToPushBack)
           
 String pushbackPrefix()
           
 String pushbackSuffix()
           
protected abstract  String tailIncrementStmts()
           
protected abstract  String tailIncrementStmts(String numExpression)
           
protected abstract  String tailOffsetExpr(String offset)
           
 String upstreamCleanup()
          Any cleanup needed before exit for upstream end of tape.
 String upstreamDeclaration()
          Data declaration: for code doing upstream processing.
 String upstreamDeclarationExtern()
          Data declaration: following "extern" if needed else noop.
 
Methods inherited from class at.dms.kjc.cluster.TapeBase
dataDeclaration, dataDeclarationH, getDest, getPeekName, getPopName, getPushName, getSource, getType, newTape, peekPrefix, peekSuffix, popExpr, popExprCleanup, popExprNoCleanup, popManyItems, popNStmt, pushManyItems, pushPrefix, pushSuffix, topOfWorkIteration
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface at.dms.kjc.cluster.Tape
dataDeclaration, dataDeclarationH, getDest, getPeekName, getPopName, getPushName, getSource, getType, peekPrefix, peekSuffix, popExpr, popExprCleanup, popExprNoCleanup, popManyItems, popNStmt, pushManyItems, pushPrefix, pushSuffix, topOfWorkIteration
 

Field Detail

items

protected int items
Maximum number of items ever on the tape: for buffer size.


extra

protected int extra
(Maximum) number of unpopped items left on tape for next iteration.


bufferName

protected String bufferName
Name of buffer containing tape items


headName

protected String headName
Name of variable with offset for push onto tape


tailName

protected String tailName
Name of variable with offset for pop from tape


popArrayRefPrefix

protected String popArrayRefPrefix
in pop / peek refer to scalar as buffer[offset] but refer to array as &buffer[offset][0]...[0]


popArrayRefSuffix

protected String popArrayRefSuffix
Constructor Detail

TapeFixedBase

public TapeFixedBase(int source,
                     int dest,
                     CType type)
Parameters:
source -
dest -
type -
Method Detail

getItems

public int getItems()
for debugging only


getExtra

public int getExtra()
for debugginf only


upstreamDeclarationExtern

public String upstreamDeclarationExtern()
Description copied from interface: Tape
Data declaration: following "extern" if needed else noop. For upstream end of tape.

Specified by:
upstreamDeclarationExtern in interface Tape
Specified by:
upstreamDeclarationExtern in class TapeBase
Returns:
TODO

upstreamDeclaration

public String upstreamDeclaration()
Description copied from interface: Tape
Data declaration: for code doing upstream processing.

Specified by:
upstreamDeclaration in interface Tape
Specified by:
upstreamDeclaration in class TapeBase
Returns:
TODO

downstreamDeclarationExtern

public String downstreamDeclarationExtern()
Description copied from interface: Tape
Data declaration: following "extern" if needed else noop. For downstream end of tape.

Specified by:
downstreamDeclarationExtern in interface Tape
Specified by:
downstreamDeclarationExtern in class TapeBase
Returns:
TODO

downstreamDeclaration

public String downstreamDeclaration()
Description copied from interface: Tape
Data declaration: for code doing downstream processing.

Specified by:
downstreamDeclaration in interface Tape
Specified by:
downstreamDeclaration in class TapeBase
Returns:
TODO

tailOffsetExpr

protected abstract String tailOffsetExpr(String offset)
Returns:
string for expression for *offset* items from pop position on tape.

tailIncrementStmts

protected abstract String tailIncrementStmts(String numExpression)
Returns:
string for statements that increment the pop position by *numPosition* items.

tailIncrementStmts

protected abstract String tailIncrementStmts()
Returns:
string for statement(s) that increment the pop position by 1.

headIncrementStmts

protected abstract String headIncrementStmts()

upstreamCleanup

public String upstreamCleanup()
Description copied from interface: Tape
Any cleanup needed before exit for upstream end of tape.

Specified by:
upstreamCleanup in interface Tape
Specified by:
upstreamCleanup in class TapeBase
Returns:
TODO

downstreamCleanup

public String downstreamCleanup()
Description copied from interface: Tape
Any cleanup needed before exit for downstream end of tape.

Specified by:
downstreamCleanup in interface Tape
Specified by:
downstreamCleanup in class TapeBase
Returns:
TODO

pushbackInit

public String pushbackInit(int numberToPushBack)
Specified by:
pushbackInit in interface Tape
Specified by:
pushbackInit in class TapeBase

pushbackPrefix

public String pushbackPrefix()
Specified by:
pushbackPrefix in interface Tape
Specified by:
pushbackPrefix in class TapeBase

pushbackSuffix

public String pushbackSuffix()
Specified by:
pushbackSuffix in interface Tape
Specified by:
pushbackSuffix in class TapeBase

pushbackCleanup

public String pushbackCleanup()
Specified by:
pushbackCleanup in interface Tape
Specified by:
pushbackCleanup in class TapeBase

assignPopToVar

public String assignPopToVar(String varName)
Description copied from interface: Tape
Statement, but no ";" to pop an item into a variable. Useful since C can not handle arrays over tapes by simple assignment.

Specified by:
assignPopToVar in interface Tape
Specified by:
assignPopToVar in class TapeBase

assignPeekToVar

public String assignPeekToVar(String varName,
                              String offset)
Description copied from interface: Tape
Assign the result of peeking. Must deal with peeking an array.

Specified by:
assignPeekToVar in interface Tape
Specified by:
assignPeekToVar in class TapeBase
Returns:

getBufferName

public String getBufferName()

getHeadName

public String getHeadName()

getTailName

public String getTailName()