scale.score
Class Scribble2C

java.lang.Object
  extended by scale.score.Scribble2C
All Implemented Interfaces:
Predicate

public final class Scribble2C
extends java.lang.Object
implements Predicate

A class to generate C code from a Scribble CFG.

$Id: Scribble2C.java,v 1.5 2007-10-04 19:58:19 burrill Exp $

Copyright 2008 by the Scale Compiler Group,
Department of Computer Science
University of Massachusetts,
Amherst MA. 01003, USA
All Rights Reserved.


Constructor Summary
Scribble2C(Machine machine)
          Construct an object to generate C code from a scribble tree.
 
Method Summary
static void genCFromCallGraph(CallGraph cg, Emit emit)
          Generate C source code from a collection of routines.
 void generateC(Scribble scribble, Emit emit, boolean debug)
          Generate C code from the specified CFG.
static void genGlobalDecls(CallGraph cg, Emit emit)
          Generate global declarations
static void genIncludes(SourceLanguage lang, Emit emit)
          Generate the include files needed for the generated C code.
 void visitAbsoluteValueExpr(AbsoluteValueExpr e)
           
 void visitAdditionExpr(AdditionExpr ae)
           
 void visitAllocateExpr(AllocateExpr e)
           
 void visitAndExpr(AndExpr e)
           
 void visitArrayIndexExpr(ArrayIndexExpr aie)
           
 void visitBeginChord(BeginChord c)
           
 void visitBitAndExpr(BitAndExpr e)
           
 void visitBitComplementExpr(BitComplementExpr e)
           
 void visitBitOrExpr(BitOrExpr e)
           
 void visitBitShiftExpr(BitShiftExpr e)
           
 void visitBitXorExpr(BitXorExpr e)
           
 void visitCallFunctionExpr(CallFunctionExpr e)
           
 void visitCallMethodExpr(CallMethodExpr e)
           
 void visitCompareExpr(CompareExpr e)
           
 void visitComplexValueExpr(ComplexValueExpr e)
           
 void visitConditionalExpr(ConditionalExpr ce)
           
 void visitConversionExpr(ConversionExpr e)
           
 void visitDivisionExpr(DivisionExpr e)
           
 void visitDualExpr(DualExpr e)
           
 void visitEndChord(EndChord c)
           
 void visitEqualityExpr(EqualityExpr e)
           
 void visitExitChord(ExitChord c)
           
 void visitExponentiationExpr(ExponentiationExpr e)
           
 void visitExprChord(ExprChord c)
           
 void visitExprPhiExpr(ExprPhiExpr e)
           
 void visitGotoChord(GotoChord c)
           
 void visitGreaterEqualExpr(GreaterEqualExpr e)
           
 void visitGreaterExpr(GreaterExpr e)
           
 void visitIfThenElseChord(IfThenElseChord c)
           
 void visitLessEqualExpr(LessEqualExpr e)
           
 void visitLessExpr(LessExpr e)
           
 void visitLiteralExpr(LiteralExpr e)
           
 void visitLoadDeclAddressExpr(LoadDeclAddressExpr e)
           
 void visitLoadDeclValueExpr(LoadDeclValueExpr e)
           
 void visitLoadFieldAddressExpr(LoadFieldAddressExpr e)
           
 void visitLoadFieldValueExpr(LoadFieldValueExpr e)
           
 void visitLoadValueIndirectExpr(LoadValueIndirectExpr e)
           
 void visitLoopExitChord(LoopExitChord c)
           
 void visitLoopHeaderChord(LoopHeaderChord c)
           
 void visitLoopInitChord(LoopInitChord c)
           
 void visitLoopPreHeaderChord(LoopPreHeaderChord c)
           
 void visitLoopTailChord(LoopTailChord c)
           
 void visitMarkerChord(MarkerChord c)
           
 void visitMaxExpr(MaxExpr e)
           
 void visitMinExpr(MinExpr e)
           
 void visitMultiplicationExpr(MultiplicationExpr e)
           
 void visitNegativeExpr(NegativeExpr e)
           
 void visitNilExpr(NilExpr e)
           
 void visitNotEqualExpr(NotEqualExpr e)
           
 void visitNotExpr(NotExpr e)
           
 void visitNullChord(NullChord c)
           
 void visitOrExpr(OrExpr e)
           
 void visitPhiExpr(PhiExpr e)
           
 void visitPhiExprChord(PhiExprChord c)
           
 void visitRemainderExpr(RemainderExpr e)
           
 void visitReturnChord(ReturnChord c)
           
 void visitSubscriptExpr(SubscriptExpr e)
           
 void visitSubtractionExpr(SubtractionExpr se)
           
 void visitSwitchChord(SwitchChord c)
           
 void visitTranscendental2Expr(Transcendental2Expr e)
           
 void visitTranscendentalExpr(TranscendentalExpr e)
           
 void visitVaArgExpr(VaArgExpr e)
           
 void visitVaEndExpr(VaEndExpr e)
           
 void visitVaStartExpr(VaStartExpr e)
           
 void visitVectorExpr(VectorExpr e)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Scribble2C

public Scribble2C(Machine machine)
Construct an object to generate C code from a scribble tree. This object is serially re-usable.

Parameters:
machine - specifies the target architecture
Method Detail

generateC

public void generateC(Scribble scribble,
                      Emit emit,
                      boolean debug)
Generate C code from the specified CFG.

Parameters:
scribble - the Scribble graph (which represents a single routine).
emit - the Emit class instance for generating the output
debug - is true to select generation of additional comments

genCFromCallGraph

public static void genCFromCallGraph(CallGraph cg,
                                     Emit emit)
Generate C source code from a collection of routines.

Parameters:
cg - specifies the collection of routines
emit - is the Emit object ued to output the code

genIncludes

public static void genIncludes(SourceLanguage lang,
                               Emit emit)
Generate the include files needed for the generated C code.

Parameters:
lang - specifies the original source language
emit - is the Emit object ued to output the code

genGlobalDecls

public static void genGlobalDecls(CallGraph cg,
                                  Emit emit)
Generate global declarations

Parameters:
cg - specifies the collection of routines
emit - is the Emit object ued to output the code

visitNullChord

public void visitNullChord(NullChord c)
Specified by:
visitNullChord in interface Predicate

visitLoopPreHeaderChord

public void visitLoopPreHeaderChord(LoopPreHeaderChord c)
Specified by:
visitLoopPreHeaderChord in interface Predicate

visitLoopHeaderChord

public void visitLoopHeaderChord(LoopHeaderChord c)
Specified by:
visitLoopHeaderChord in interface Predicate

visitLoopTailChord

public void visitLoopTailChord(LoopTailChord c)
Specified by:
visitLoopTailChord in interface Predicate

visitLoopInitChord

public void visitLoopInitChord(LoopInitChord c)
Specified by:
visitLoopInitChord in interface Predicate

visitLoopExitChord

public void visitLoopExitChord(LoopExitChord c)
Specified by:
visitLoopExitChord in interface Predicate

visitExprChord

public void visitExprChord(ExprChord c)
Specified by:
visitExprChord in interface Predicate

visitPhiExprChord

public void visitPhiExprChord(PhiExprChord c)
Specified by:
visitPhiExprChord in interface Predicate

visitBeginChord

public void visitBeginChord(BeginChord c)
Specified by:
visitBeginChord in interface Predicate

visitEndChord

public void visitEndChord(EndChord c)
Specified by:
visitEndChord in interface Predicate

visitSwitchChord

public void visitSwitchChord(SwitchChord c)
Specified by:
visitSwitchChord in interface Predicate

visitIfThenElseChord

public void visitIfThenElseChord(IfThenElseChord c)
Specified by:
visitIfThenElseChord in interface Predicate

visitMarkerChord

public void visitMarkerChord(MarkerChord c)
Specified by:
visitMarkerChord in interface Predicate

visitGotoChord

public void visitGotoChord(GotoChord c)
Specified by:
visitGotoChord in interface Predicate

visitReturnChord

public void visitReturnChord(ReturnChord c)
Specified by:
visitReturnChord in interface Predicate

visitExitChord

public void visitExitChord(ExitChord c)
Specified by:
visitExitChord in interface Predicate

visitDualExpr

public void visitDualExpr(DualExpr e)
Specified by:
visitDualExpr in interface Predicate

visitLiteralExpr

public void visitLiteralExpr(LiteralExpr e)
Specified by:
visitLiteralExpr in interface Predicate

visitNilExpr

public void visitNilExpr(NilExpr e)
Specified by:
visitNilExpr in interface Predicate

visitVaStartExpr

public void visitVaStartExpr(VaStartExpr e)
Specified by:
visitVaStartExpr in interface Predicate

visitVaEndExpr

public void visitVaEndExpr(VaEndExpr e)
Specified by:
visitVaEndExpr in interface Predicate

visitVaArgExpr

public void visitVaArgExpr(VaArgExpr e)
Specified by:
visitVaArgExpr in interface Predicate

visitAbsoluteValueExpr

public void visitAbsoluteValueExpr(AbsoluteValueExpr e)
Specified by:
visitAbsoluteValueExpr in interface Predicate

visitBitComplementExpr

public void visitBitComplementExpr(BitComplementExpr e)
Specified by:
visitBitComplementExpr in interface Predicate

visitNegativeExpr

public void visitNegativeExpr(NegativeExpr e)
Specified by:
visitNegativeExpr in interface Predicate

visitTranscendentalExpr

public void visitTranscendentalExpr(TranscendentalExpr e)
Specified by:
visitTranscendentalExpr in interface Predicate

visitTranscendental2Expr

public void visitTranscendental2Expr(Transcendental2Expr e)
Specified by:
visitTranscendental2Expr in interface Predicate

visitNotExpr

public void visitNotExpr(NotExpr e)
Specified by:
visitNotExpr in interface Predicate

visitAllocateExpr

public void visitAllocateExpr(AllocateExpr e)
Specified by:
visitAllocateExpr in interface Predicate

visitAdditionExpr

public void visitAdditionExpr(AdditionExpr ae)
Specified by:
visitAdditionExpr in interface Predicate

visitAndExpr

public void visitAndExpr(AndExpr e)
Specified by:
visitAndExpr in interface Predicate

visitBitAndExpr

public void visitBitAndExpr(BitAndExpr e)
Specified by:
visitBitAndExpr in interface Predicate

visitBitOrExpr

public void visitBitOrExpr(BitOrExpr e)
Specified by:
visitBitOrExpr in interface Predicate

visitBitShiftExpr

public void visitBitShiftExpr(BitShiftExpr e)
Specified by:
visitBitShiftExpr in interface Predicate

visitBitXorExpr

public void visitBitXorExpr(BitXorExpr e)
Specified by:
visitBitXorExpr in interface Predicate

visitDivisionExpr

public void visitDivisionExpr(DivisionExpr e)
Specified by:
visitDivisionExpr in interface Predicate

visitCompareExpr

public void visitCompareExpr(CompareExpr e)
Specified by:
visitCompareExpr in interface Predicate

visitEqualityExpr

public void visitEqualityExpr(EqualityExpr e)
Specified by:
visitEqualityExpr in interface Predicate

visitGreaterEqualExpr

public void visitGreaterEqualExpr(GreaterEqualExpr e)
Specified by:
visitGreaterEqualExpr in interface Predicate

visitGreaterExpr

public void visitGreaterExpr(GreaterExpr e)
Specified by:
visitGreaterExpr in interface Predicate

visitLessEqualExpr

public void visitLessEqualExpr(LessEqualExpr e)
Specified by:
visitLessEqualExpr in interface Predicate

visitLessExpr

public void visitLessExpr(LessExpr e)
Specified by:
visitLessExpr in interface Predicate

visitExponentiationExpr

public void visitExponentiationExpr(ExponentiationExpr e)
Specified by:
visitExponentiationExpr in interface Predicate

visitMultiplicationExpr

public void visitMultiplicationExpr(MultiplicationExpr e)
Specified by:
visitMultiplicationExpr in interface Predicate

visitNotEqualExpr

public void visitNotEqualExpr(NotEqualExpr e)
Specified by:
visitNotEqualExpr in interface Predicate

visitOrExpr

public void visitOrExpr(OrExpr e)
Specified by:
visitOrExpr in interface Predicate

visitRemainderExpr

public void visitRemainderExpr(RemainderExpr e)
Specified by:
visitRemainderExpr in interface Predicate

visitSubtractionExpr

public void visitSubtractionExpr(SubtractionExpr se)
Specified by:
visitSubtractionExpr in interface Predicate

visitLoadFieldValueExpr

public void visitLoadFieldValueExpr(LoadFieldValueExpr e)
Specified by:
visitLoadFieldValueExpr in interface Predicate

visitLoadFieldAddressExpr

public void visitLoadFieldAddressExpr(LoadFieldAddressExpr e)
Specified by:
visitLoadFieldAddressExpr in interface Predicate

visitConditionalExpr

public void visitConditionalExpr(ConditionalExpr ce)
Specified by:
visitConditionalExpr in interface Predicate

visitConversionExpr

public void visitConversionExpr(ConversionExpr e)
Specified by:
visitConversionExpr in interface Predicate

visitComplexValueExpr

public void visitComplexValueExpr(ComplexValueExpr e)
Specified by:
visitComplexValueExpr in interface Predicate

visitCallFunctionExpr

public void visitCallFunctionExpr(CallFunctionExpr e)
Specified by:
visitCallFunctionExpr in interface Predicate

visitCallMethodExpr

public void visitCallMethodExpr(CallMethodExpr e)
Specified by:
visitCallMethodExpr in interface Predicate

visitLoadDeclAddressExpr

public void visitLoadDeclAddressExpr(LoadDeclAddressExpr e)
Specified by:
visitLoadDeclAddressExpr in interface Predicate

visitLoadDeclValueExpr

public void visitLoadDeclValueExpr(LoadDeclValueExpr e)
Specified by:
visitLoadDeclValueExpr in interface Predicate

visitLoadValueIndirectExpr

public void visitLoadValueIndirectExpr(LoadValueIndirectExpr e)
Specified by:
visitLoadValueIndirectExpr in interface Predicate

visitArrayIndexExpr

public void visitArrayIndexExpr(ArrayIndexExpr aie)
Specified by:
visitArrayIndexExpr in interface Predicate

visitSubscriptExpr

public void visitSubscriptExpr(SubscriptExpr e)
Specified by:
visitSubscriptExpr in interface Predicate

visitPhiExpr

public void visitPhiExpr(PhiExpr e)
Specified by:
visitPhiExpr in interface Predicate

visitExprPhiExpr

public void visitExprPhiExpr(ExprPhiExpr e)
Specified by:
visitExprPhiExpr in interface Predicate

visitVectorExpr

public void visitVectorExpr(VectorExpr e)
Specified by:
visitVectorExpr in interface Predicate

visitMaxExpr

public void visitMaxExpr(MaxExpr e)
Specified by:
visitMaxExpr in interface Predicate

visitMinExpr

public void visitMinExpr(MinExpr e)
Specified by:
visitMinExpr in interface Predicate