at.dms.kjc.rstream
Class GenerateCCode

java.lang.Object
  extended by at.dms.kjc.rstream.GenerateCCode

public class GenerateCCode
extends Object

This class is the driver that generates the c code for the application. It traverses the stream graph, generating code for each filter. It generates the init fucntion calls for each filter, the initialization stage, and the steady-state stage. It writes its output to *str.c*.

Author:
Michael Gordon

Field Summary
static boolean generateTimingCode
           
static String MAINMETHOD
           
 
Method Summary
static void addStmtArray(JBlock block, JStatement[] stms)
          given a block *block*, add Statement array *stms* to the end of the block, if stms is empty, do nothing
static void addStmtArrayFirst(JBlock block, JStatement[] stms)
          given a block *block*, add Statement array *stms* to the beginning of the block, if stms is empty, do nothing
static void generate(FlatNode top)
          The entry point of the code generation pass.
protected  String getExterns()
          for now, just print all the common math functions as external functions
static JStatement makeDoLoop(JStatement body, JLocalVariable var, JIntLiteral count)
          Returns a do loop that uses local variable *var* to count *count* times with the body of the loop being *body*.
static JStatement makeForLoop(JStatement body, JLocalVariable var, JExpression count)
          Returns a for loop that uses local variable *var* to count *count* times with the body of the loop being *body*.
static JVariableDefinition newIntLocal(String prefix, int uniqueID, int initVal)
          Return a new integer local variable definition with name *prefix* + *uniqueID*, that is initialized to *initVal*.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

generateTimingCode

public static final boolean generateTimingCode

MAINMETHOD

public static String MAINMETHOD
Method Detail

generate

public static void generate(FlatNode top)
The entry point of the code generation pass. This will traverse the stream graph starting at top, and generate the code for the application.

Parameters:
top - The top level node in the flat graph for the application

getExterns

protected String getExterns()
for now, just print all the common math functions as external functions


makeForLoop

public static JStatement makeForLoop(JStatement body,
                                     JLocalVariable var,
                                     JExpression count)
Returns a for loop that uses local variable *var* to count *count* times with the body of the loop being *body*. If count is non-positive, just returns an empty statement.


makeDoLoop

public static JStatement makeDoLoop(JStatement body,
                                    JLocalVariable var,
                                    JIntLiteral count)
Returns a do loop that uses local variable *var* to count *count* times with the body of the loop being *body*. If count is non-positive, just returns an empty statement.


newIntLocal

public static JVariableDefinition newIntLocal(String prefix,
                                              int uniqueID,
                                              int initVal)
Return a new integer local variable definition with name *prefix* + *uniqueID*, that is initialized to *initVal*.


addStmtArray

public static void addStmtArray(JBlock block,
                                JStatement[] stms)
given a block *block*, add Statement array *stms* to the end of the block, if stms is empty, do nothing


addStmtArrayFirst

public static void addStmtArrayFirst(JBlock block,
                                     JStatement[] stms)
given a block *block*, add Statement array *stms* to the beginning of the block, if stms is empty, do nothing