at.dms.kjc.backendSupport
Class ChannelAsArray

java.lang.Object
  extended by at.dms.kjc.backendSupport.Channel
      extended by at.dms.kjc.backendSupport.ChannelAsArray
Direct Known Subclasses:
ChannelAsCircularArray

public class ChannelAsArray
extends Channel

Channel implementation as an array. This implementation should work when there is no need of a copy-down or circular buffer. It can be a superclass for copy-down array channels or circular buffer array channels. TODO: missing support for multi-buffering, rotating buffers TODO: missing support for arrays passed over channels.

Author:
dimock

Field Summary
protected  JVariableDefinition bufDefn
          definition for array
protected  String bufName
          array name
protected  JExpression bufPrefix
          reference to whole array, prefix to element access
protected  int bufSize
          array size in elements
protected  CType bufType
          type of array: aray of element type
protected  JExpression head
          reference to head
protected  JVariableDefinition headDefn
          definition for head
protected  String headName
          name of variable containing head of array offset
protected  JExpression tail
          reference to tail
protected  JVariableDefinition tailDefn
          definition for tail
protected  String tailName
          name of variable containing tail of array offset
 
Fields inherited from class at.dms.kjc.backendSupport.Channel
bufferStore, extraCount, ident, rotationLength, theEdge, unique_id
 
Constructor Summary
ChannelAsArray(Edge edge)
          Constructor
ChannelAsArray(SliceNode src, SliceNode dst)
          Deprecated. 
 
Method Summary
 JMethodDeclaration assignFromPeekMethod()
          void peek(input_type val, int offset) generally assign if val is not an array, else memcpy
 JMethodDeclaration assignFromPopMethod()
          void pop(input_type val) generally assign if val is not an array, else memcpy
 List<JStatement> beginInitRead()
          Statements for beginning of init() on read (downstream) end of buffer
 List<JStatement> beginInitWrite()
          Statements for beginning of init() on write (upstream) end of buffer
 List<JStatement> beginSteadyRead()
          Statements for beginning of steady state iteration on read (downstream) end of buffer
 List<JStatement> beginSteadyWrite()
          Statements for beginning of steady state iteration on write (upstream) end of buffer
protected  JArrayAccessExpression bufRef(JExpression offset)
          Create an array reference given an offset
 List<JStatement> dataDecls()
          Statements for data declaration at top of .c / .cpp file
 List<JStatement> dataDeclsH()
          Statements for data declaration in .h file
 List<JStatement> endInitRead()
          Statements for end of init() on read (downstream) end of buffer
 List<JStatement> endInitWrite()
          Statements for end of init() on write (upstream) end of buffer
 List<JStatement> endSteadyRead()
          Statements for end of steady state iteration on read (downstream) end of buffer
 List<JStatement> endSteadyWrite()
          Statements for end of steady state iteration on write (upstream) end of buffer
 int getBufSize()
          Actual Buffer size: use for diagnostic info only.
static ChannelAsArray getChannel(Edge edge)
          Make a new Channel or return an already-made channel.
 JMethodDeclaration peekMethod()
          input_type peek(int offset)
 JMethodDeclaration popManyMethod()
          void pop(int N).
 JMethodDeclaration popMethod()
          input_type pop().
 JMethodDeclaration pushMethod()
          void push(output_type val)
 List<JStatement> readDecls()
          Statements for other declarations needed for read in steady state but at file scope in .c / .cpp
 List<JStatement> readDeclsExtern()
          Statements for extern declarations needed for read in steady state but at global scope in .c / .cpp
 List<JStatement> topOfWorkSteadyRead()
          Statements for beginning of work function.
 List<JStatement> topOfWorkSteadyWrite()
          Statements for beginning of work function.
 List<JStatement> writeDecls()
          Statements for other declarations needed for write in steady state but at file scope in .c / .cpp
 List<JStatement> writeDeclsExtern()
          Statements for extern declarations needed for write in steady state but at global scope in .c / .cpp
protected  JStatement zeroOutHead()
          Create statement zeroing out head
protected  JStatement zeroOutTail()
          Create statement zeroing out tail
 
Methods inherited from class at.dms.kjc.backendSupport.Channel
addChannel, assignFromPeekMethodName, assignFromPopMethodName, findChannel, getBuffers, getDest, getExtraCount, getIdent, getSource, getType, peekMethodName, popManyMethodName, popMethodName, postPreworkInitRead, printBuffers, pushMethodName, reset, setExtralength, setRotationLengths
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

bufSize

protected int bufSize
array size in elements


bufType

protected CType bufType
type of array: aray of element type


bufName

protected String bufName
array name


headName

protected String headName
name of variable containing head of array offset


tailName

protected String tailName
name of variable containing tail of array offset


bufDefn

protected JVariableDefinition bufDefn
definition for array


headDefn

protected JVariableDefinition headDefn
definition for head


tailDefn

protected JVariableDefinition tailDefn
definition for tail


bufPrefix

protected JExpression bufPrefix
reference to whole array, prefix to element access


head

protected JExpression head
reference to head


tail

protected JExpression tail
reference to tail

Constructor Detail

ChannelAsArray

public ChannelAsArray(Edge edge)
Constructor

Parameters:
edge - should give enough information (indirectly) to calculate buffer size

ChannelAsArray

@Deprecated
public ChannelAsArray(SliceNode src,
                                 SliceNode dst)
Deprecated. 

Obsolete constructor, don't use.

Method Detail

bufRef

protected JArrayAccessExpression bufRef(JExpression offset)
Create an array reference given an offset


zeroOutHead

protected JStatement zeroOutHead()
Create statement zeroing out head


zeroOutTail

protected JStatement zeroOutTail()
Create statement zeroing out tail


getBufSize

public int getBufSize()
Actual Buffer size: use for diagnostic info only.


getChannel

public static ChannelAsArray getChannel(Edge edge)
Make a new Channel or return an already-made channel.

Parameters:
edge - The edge that this channel implements.
other - The channel that this delegates to.
Returns:
A channel for this edge, that

popMethod

public JMethodDeclaration popMethod()
input_type pop().

Overrides:
popMethod in class Channel

popManyMethod

public JMethodDeclaration popManyMethod()
void pop(int N).

Overrides:
popManyMethod in class Channel

assignFromPopMethod

public JMethodDeclaration assignFromPopMethod()
void pop(input_type val) generally assign if val is not an array, else memcpy

Overrides:
assignFromPopMethod in class Channel

peekMethod

public JMethodDeclaration peekMethod()
input_type peek(int offset)

Overrides:
peekMethod in class Channel

assignFromPeekMethod

public JMethodDeclaration assignFromPeekMethod()
void peek(input_type val, int offset) generally assign if val is not an array, else memcpy

Overrides:
assignFromPeekMethod in class Channel

pushMethod

public JMethodDeclaration pushMethod()
void push(output_type val)

Overrides:
pushMethod in class Channel

beginInitRead

public List<JStatement> beginInitRead()
Statements for beginning of init() on read (downstream) end of buffer

Overrides:
beginInitRead in class Channel

endInitRead

public List<JStatement> endInitRead()
Statements for end of init() on read (downstream) end of buffer

Overrides:
endInitRead in class Channel

beginInitWrite

public List<JStatement> beginInitWrite()
Statements for beginning of init() on write (upstream) end of buffer

Overrides:
beginInitWrite in class Channel

endInitWrite

public List<JStatement> endInitWrite()
Statements for end of init() on write (upstream) end of buffer

Overrides:
endInitWrite in class Channel

beginSteadyRead

public List<JStatement> beginSteadyRead()
Statements for beginning of steady state iteration on read (downstream) end of buffer

Overrides:
beginSteadyRead in class Channel

endSteadyRead

public List<JStatement> endSteadyRead()
Statements for end of steady state iteration on read (downstream) end of buffer

Overrides:
endSteadyRead in class Channel

beginSteadyWrite

public List<JStatement> beginSteadyWrite()
Statements for beginning of steady state iteration on write (upstream) end of buffer

Overrides:
beginSteadyWrite in class Channel

endSteadyWrite

public List<JStatement> endSteadyWrite()
Statements for end of steady state iteration on write (upstream) end of buffer

Overrides:
endSteadyWrite in class Channel

topOfWorkSteadyRead

public List<JStatement> topOfWorkSteadyRead()
Statements for beginning of work function. May be more convenient than at top of steady state if work function iterated.

Overrides:
topOfWorkSteadyRead in class Channel

topOfWorkSteadyWrite

public List<JStatement> topOfWorkSteadyWrite()
Statements for beginning of work function. May be more convenient than at top of steady state if work function iterated.

Overrides:
topOfWorkSteadyWrite in class Channel

dataDeclsH

public List<JStatement> dataDeclsH()
Statements for data declaration in .h file

Overrides:
dataDeclsH in class Channel

dataDecls

public List<JStatement> dataDecls()
Statements for data declaration at top of .c / .cpp file

Overrides:
dataDecls in class Channel

readDeclsExtern

public List<JStatement> readDeclsExtern()
Statements for extern declarations needed for read in steady state but at global scope in .c / .cpp

Overrides:
readDeclsExtern in class Channel

readDecls

public List<JStatement> readDecls()
Statements for other declarations needed for read in steady state but at file scope in .c / .cpp

Overrides:
readDecls in class Channel

writeDeclsExtern

public List<JStatement> writeDeclsExtern()
Statements for extern declarations needed for write in steady state but at global scope in .c / .cpp

Overrides:
writeDeclsExtern in class Channel

writeDecls

public List<JStatement> writeDecls()
Statements for other declarations needed for write in steady state but at file scope in .c / .cpp

Overrides:
writeDecls in class Channel