scale.backend.trips2
Class Trips2Generator

java.lang.Object
  extended by scale.backend.Generator
      extended by scale.backend.trips2.Trips2Generator
All Implemented Interfaces:
Predicate
Direct Known Subclasses:
TripsPGenerator

public class Trips2Generator
extends Generator

This class converts Scribble into TRIPS instructions.

$Id: Trips2Generator.java,v 1.386 2007-10-31 23:47:51 bmaher Exp $

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

The TRIPS memory and branch instructions use a displacement field that is relative to an address in a register or to the program counter. Because this displacement is not known until load time, the assembly program must specify how to generate the correct value at load time. We use an instance of a Displacement class to hold this information.


Field Summary
static java.lang.String[] areaNames
          ELF section names.
static int ARG_SAVE_OFFSET
          Offset to the argument save area.
static int BSS
          Un-initialized large data area.
static int DATA
          Initialized large data area.
static boolean display
          Set true to graphically display hyperblocks.
static boolean doBBID
          Tag instructions with basic block identifiers.
static boolean doBranchIds
          Set true to output analysis of hyperblock cuts.
static boolean doCutAnalysis
          Set true to output analysis of hyperblock cuts.
static boolean enableStabs
          Set true to cause stab entries to be placed in the .til file..
protected  Hyperblock hbStart
           
static int LIT4
          Initialized 4-byte data area.
static int LIT8
          Initialized 8-byte data area.
static int LITA
          Initialized address data area.
static int MAX_ARG_REGS
          Maximum number of arguments passed in registers.
static int RCONST
          Read-only constants
static int RDATA
          Read-only data.
static int SAVED_REG_SIZE
          Size of registers saved on the stack.
static int SBSS
          Un-initialized small data area.
static int SDATA
          Initialized small data area.
static boolean srcLinePerBlock
          Set true to generate one source line per block.
static int TEXT
          Instructions.
 
Fields inherited from class scale.backend.Generator
ADD, addrDisp, AND, annotateCode, ansic, ANSIC, branchPrediction, callsRoutine, cg, classTrace, codeMap, commutative, currentBeginMarker, currentRoutine, dataAreas, DEBUG, DIV, fieldAlignment, genDebugInfo, lastInstruction, lastLabel, LINENUM, lineNumbers, little, machine, MOD, MUL, naln, NALN, nextArea, nis, NIS, nph, NPH, operation, OR, predicatedOnTrue, predicateReg, readOnlyDataArea, registers, resultReg, resultRegAddressAlignment, resultRegAddressOffset, resultRegMode, resultRegSize, returnInst, scribble, SLL, SRA, SRL, stkPtrReg, SUB, successorCFGNode, trace, un, useMemory, usesAlloca, usesVaStart, XOR
 
Constructor Summary
Trips2Generator(CallGraph cg, Machine machine, int features)
           
 
Method Summary
protected  void __builtin_abs()
          Intrinsics
protected  void addRegs(int laReg, int raReg, int dest)
          Generate an add of address registers laReg and raReg.
protected  int allocStackAddress(int adrReg, Type type)
          Allocate a location on the stack for storing a value of the specified size.
protected  void analyzeHyperblocks()
          Print out a reason for each pair of hyperblocks not merged.
protected  void appendInstruction(Instruction inst)
          The difference between this routine and the one in Generator is this routine will add the predicate to an instruction if it is not already predicated.
 void assemble(Emit emit, java.lang.String source, java.util.Enumeration<java.lang.String> comments)
          Generate assembly language file.
protected  void assignBranchIds()
           
protected  void assignDeclToMemory(java.lang.String name, VariableDecl vd)
          Assign the specified variable to a location in memory using the specified name.
protected  void assignDeclToRegister(VariableDecl vd)
          Assign the specified variable to a register.
protected  void assignDeclToStack(VariableDecl vd)
          Assign the specified variable to a location in the stack frame.
protected  void assignLoadStoreIds()
          Insert nullification and assign load/store ids.
protected  void basicBlockEnd()
          Called after the last CFG node in a basic block is processed.
protected  void calcArrayElementAddress(ArrayIndexExpr aie, long offseta)
          Load the address of an array element into a register.
protected  short[] callArgs(Expr[] args, boolean retStruct)
          Assign arguments to locations (either register or memory).
protected  int convertIntRegValue(int src, int srcSize, boolean srcSigned, int dest, int destSize, boolean destSigned)
          Generate instructions to convert an integer value in an integer register to an integer value of a different size.
protected  Displacement createAddressTable(Chord[] entries, long[] indexes, int min, int max)
          Create a new read-only data area whose value is a table of displacements.
protected  Label createNewLabel()
          Create a new Label.
 int dataType(int size, boolean flt)
          Return the data type as an integer.
protected  void defineDeclInCommon(Declaration decl, Displacement disp)
          Associate information with a Declaration in COMMON.
protected  void defineDeclInMemory(Declaration decl, Displacement disp)
          Associate information with a Declaration kept in memory.
protected  void defineDeclInRegister(Declaration decl, int register, ResultMode regha)
          Associate information with a variable Declaration kept in a register.
protected  void defineDeclOnStack(Declaration decl, Displacement disp)
          Associate information with a Declaration kept on the stack.
protected  void defineRoutineInfo(RoutineDecl rd, Displacement disp)
          Associate information with a routine.
protected  Displacement defStringValue(java.lang.String v, int size)
          Return the displacement for a string.
 java.lang.String displayGraph(java.lang.String msg)
           
protected  void doBinaryOp(int which, Type ct, Expr la, Expr ra, int ir)
          Generate instructions to do a binary operation on two values.
protected  void doCompareOp(BinaryExpr c, CompareMode which)
          Generate instructions to do a comparison of two value.
protected  void dumpAssembly(Instruction first, java.lang.String phase)
          Output all instructions for debugging.
protected  void endModule()
          Called at the end of a module.
protected  void endRoutineCode(int[] regMap)
          Called at the end of code generation for a routine to generate the stackframe.
protected  void enterSSA()
          Enter SSA after register allocation.
protected  void genAcosFtn(int dest, int src, Type type)
          Generate the code for the acos() function.
protected  void genAlloca(Expr arg, int reg)
          Generate the code for the alloca() function.
protected  void genAsinFtn(int dest, int src, Type type)
          Generate the code for the asin() function.
protected  void genAtan2Ftn(int dest, int laReg, int raReg, Type rType)
          Generate the code for the Fortran ATAN2() intrinsic function.
protected  void genAtanFtn(int dest, int src, Type type)
          Generate the code for the atan() function.
protected  void genConjgFtn(int dest, int src, Type rType)
          Generate the code for the conjg() function.
protected  void genCosFtn(int dest, int src, Type type)
          Generate the code for the cos() function.
protected  void genCoshFtn(int dest, int src, Type type)
          Generate the code for the cosh() function.
protected  void genDimFtn(int dest, int laReg, int raReg, Type rType)
          Generate the code for the Fortran DIM() intrinsic function.
protected  short[] genDoubleUse(int reg1, int reg2)
          Generate the array of registers that a call to a function requires.
 void generateConditionalBranch(CompareMode which, int treg, Label lab)
          Generate a predicated branch to a single location.
 void generateProlog(ProcedureType pt)
          This method is responsible for generating instructions to move function arguments to the position assigned by the layoutParameters method.
 void generateScribble()
          Generate the machine instructions for a CFG.
 void generateUnconditionalBranch(Label lab)
          Generate an unconditional branch to the label specified.
protected  void genExpFtn(int dest, int src, Type type)
          Generate the code for the exp() function.
protected  void genFloorOfReal(int src, int srcSize, int dest, int destSize)
          Generate floor().
protected  void genFrameAddressFtn(int dest, int src, Type type)
          Generate the code for the builtin_fram_address() function.
protected  Branch genFtnCall(java.lang.String name, short[] uses, short[] defs)
          Create a call to the routine with the specified name.
protected  void genIfRegister(CompareMode which, int treg, boolean signed, Label labt, Label labf)
          Generate a branch based on the value of an expression.
protected  void genIfRelational(boolean rflag, MatchExpr predicate, Chord tc, Chord fc)
          Generate a branch based on a relational expression.
protected  void genIntToReal(int src, int srcSize, int dest, int destSize)
          Convert an integer value in an integer register to a real value in a real register.
protected  int genLoadDblImmediate(double value, int dest, int destSize)
          Generate instructions to load an immediate integer value into a register.
protected  long genLoadHighImmediate(long value, int base)
          Generate instructions to calculate a valid offset.
protected  int genLoadImmediate(long value, int dest)
          Generate instructions to load an immediate integer value into a register.
protected  void genLoadImmediate(long value, int base, int dest)
          Generate instructions to load an immediate integer value added to the value in a register into a register.
protected  void genLog10Ftn(int dest, int src, Type type)
          Generate the code for the log10() function.
protected  void genLogFtn(int dest, int src, Type type)
          Generate the code for the log() function.
protected  void genRealPart(int src, int srcSize, int dest, int destSize)
          Generate code to obtain the real part of a complex value.
protected  int genRealToInt(int src, int srcSize, int dest, int destSize, boolean destSigned)
          Convert real value in a real register to an integer value in a real register.
protected  void genRealToIntRound(int src, int srcSize, int dest, int destSize)
          Convert real value in a real register to an integer value in a real register.
protected  void genRealToReal(int src, int srcSize, int dest, int destSize)
          Convert a real value in a real register to a real value in a real register.
protected  void genRegToReg(int src, int dest)
          Generate instructions to move data from one register to another.
protected  void genReturnAddressFtn(int dest, int src, Type type)
          Generate the code for the builtin_return_address() function.
protected  void genRoundReal(int src, int srcSize, int dest, int destSize)
          Convert real value in a real register to a rounded real value in a real register.
protected  void genSignFtn(int dest, int laReg, int raReg, Type rType)
          Generate the code for the Fortran SIGN() intrinsic function.
protected  void genSinFtn(int dest, int src, Type type)
          Generate the code for the sin() function.
protected  short[] genSingleUse(int reg)
          Generate the array of registers that a call to a function requires.
protected  void genSinhFtn(int dest, int src, Type type)
          Generate the code for the sinh() function.
protected  void genSqrtFtn(int dest, int src, Type type)
          Generate the code for the sqrt() function.
protected  boolean genSwitchUsingIfs(int testReg, Chord[] cases, long[] keys, int num, long spread)
          Generate the code for a switch statement using branches for each case.
protected  void genSwitchUsingTransferVector(int testReg, Chord[] cases, long[] values, Label labd, long min, long max)
          Generate a switch using a transfer vector.
protected  void genTanFtn(int dest, int src, Type type)
          Generate the code for the tan() function.
protected  void genTanhFtn(int dest, int src, Type type)
          Generate the code for the tanh() function.
protected  void genTransformReal(int src, int srcSize, int dest, int destSize)
          Convert between single and double reals.
protected  void genTrueFalseBranch(int treg, Chord tc, Chord fc)
          Generate a branch based on the value of an expression which is guaranteed to be either 0 or 1.
protected  void genUnsignedIntToReal(int src, int srcSize, int dest, int destSize)
          Convert an unsigned integer value in an integer register to a real value in a real register.
 int getFirstArgRegister(int regType)
          Return the register used as the first argument in a function call.
 int getMaxAreaIndex()
          Return the maximum area index value.
protected  Hyperblock getReturnBlock()
          Return the return hyperblock.
 java.lang.Object getSpillLocation(int reg)
          Obtain the information needed for register spill loads and stores.
 Vector<VariableDecl> getVariables(java.lang.String func)
          Return the variables for a function.
protected  void hyperblockFormation()
          Create hyperblocks.
protected  void insertSpillLoad(int reg, java.lang.Object spillLocation, Hyperblock hb)
          Insert the instruction(s) to restore a spilled register.
 Instruction insertSpillLoad(int reg, java.lang.Object spillLocation, Instruction after)
          The insertSpillLoad(int, Object, Instruction) method should be used.
protected  void insertSpillStore(int reg, java.lang.Object spillLocation, Hyperblock hb)
          Insert the instruction(s) to save a spilled register.
 Instruction insertSpillStore(int reg, java.lang.Object spillLocation, Instruction after)
          The insertSpillStore(int, Object, Instruction) method should be used.
protected  void layoutParameters()
          Assign the routine's arguments to registers or the stack.
protected  void leaveSSA()
          Leave SSA after register allocation.
protected  void loadArrayElement(ArrayIndexExpr aie, int dest)
          Load an array element into a register.
protected  void loadFieldValue(FieldDecl fd, long fieldOffset, int adr, ResultMode adrha, int adraln, long adrrs, int dest)
          Load the value of a field to a register.
protected  void loadFromMemoryDoubleIndexing(int dest, int index1, int index2, int size, long alignment, boolean signed, boolean real)
          Generate instructions to load data from memory at the address that is the sum of the two index register values.
protected  void loadFromMemoryWithOffset(int dest, int address, Displacement offset, int size, long alignment, boolean signed, boolean real)
          Generate instructions to load data from memory at the address in a register plus an offset.
protected  void loadFromMemoryWithOffset(int dest, int address, long offset, int size, long alignment, boolean signed, boolean real)
          Generate instructions to load data from the specified data area.
protected  int loadMemoryAddress(Displacement disp)
          Load an address of a memory location into a register.
protected  void loadRegFromSymbolicLocation(int dest, int dsize, boolean isSigned, boolean isReal, Displacement disp)
          Load a register from a symbolic location in memory.
protected  int loadStackAddress(Displacement disp)
          Load an address of a stack location into a register.
protected  void mergeInstructions()
          Insert nullification and assign load/store ids.
protected  void minimizePredicates()
          Perform inter-block predicate minimization.
protected  void moveWords(int src, long srcoff, int dest, Displacement destoff, int size, int aln)
          Generate an instruction sequence to move words from one location to another.
protected  void moveWords(int src, long srcoff, int dest, long destoff, int size, int aln)
          Generate an instruction sequence to move words from one location to another.
protected  void optimizeHyperblocks(boolean removeLoads)
          Apply optimizations on predicated code.
protected  void peepholeAfterRegisterAllocation()
          Do peephole optimizations after registers are allocated.
protected  void processRoutineDecl(RoutineDecl rd, boolean topLevel)
          The RoutineDecl is assigned a tag.
protected  void processSourceLine(int line, Label lab, boolean newLine)
          The user has requested source line information be included.
 Type processType(Declaration decl)
          Insure that all types have their register types specified and all structure fields have had their offsets determined.
protected  void processTypeDecl(TypeDecl td, boolean complete)
          Called for every TypeDecl instance so that the target code generator can perform any needed processing such as making Stabs entries.
protected  void processTypeName(TypeName tn)
          Called for every TypeName instance so that the target code generator can perform any needed processing such as making Stabs entries.
protected  void removeDeadCode()
          Eliminate dead code.
protected  void removeRedundantLoads()
          Remove redundant loads
protected  void renameRegisters()
          Rename registers to reduce the memory used during register allocation.
protected  void renameRegisters(Instruction first)
          Rename temporary registers so each block starts at 0.
 int returnRegister(int regType, boolean isCall)
          Return the register used to return the function value.
protected  void setBeginMarker(BeginMarker currentBeginMarker)
          Set the BeginMarker.
protected  void setLastInstruction(Instruction lastInstruction)
          Set the last instruction.
protected  void setLoopSizes()
          Update the scribble with the size of the unrolled loop.
protected  void setReturnBlock(Hyperblock returnBlock)
          Set the return hyperblock.
protected  int[] splitAndAllocate()
          Split blocks and register allocate.
protected  void splitHyperblocks()
          Split blocks.
protected  void startModule()
          Called at the beginning of a module.
protected  Instruction startRoutineCode()
          Called at the start of code generation for a routine.
protected  void storeBitsIntoMemory(int src, int address, long offset, int bits, int bitOffset, int alignment)
          Generate instructions to store data into the specified data area.
protected  void storeIntoMemory(int src, int address, int size, long alignment, boolean real)
          Generate instructions to store data into memory at the address specified by a register.
protected  void storeIntoMemoryWithOffset(int src, int address, Displacement offset, int size, long alignment, boolean real)
          Generate instructions to store data into memory at the address in a register plus an offset.
protected  void storeIntoMemoryWithOffset(int src, int address, long offset, int size, long alignment, boolean real)
          Generate instructions to store data into the specified data area.
protected  void storeLfae(LoadFieldAddressExpr lhs, Expr rhs)
          Store a value into a field of a structure.
protected  void storeRegToSymbolicLocation(int src, int dsize, long alignment, boolean isReal, Displacement disp)
          Store a value in a register to a symbolic location in memory.
protected  void tagBasicBlocks()
          Tag instructions with a block ID.
protected  boolean unconditionalBranchNeeded(Chord c, Chord nxt, java.lang.Object actual)
          Return true if an unconditional branch is needed.
 void visitAbsoluteValueExpr(AbsoluteValueExpr e)
           
 void visitBitComplementExpr(BitComplementExpr e)
           
 void visitCallFunctionExpr(CallFunctionExpr e)
          This method generates instructions to call a sub-function.
 void visitCompareExpr(CompareExpr e)
           
 void visitConditionalExpr(ConditionalExpr e)
           
 void visitDivisionExpr(DivisionExpr e)
           
 void visitExponentiationExpr(ExponentiationExpr e)
           
 void visitExprChord(ExprChord c)
           
 void visitMultiplicationExpr(MultiplicationExpr e)
           
 void visitNegativeExpr(NegativeExpr e)
           
 void visitNotExpr(NotExpr e)
           
 void visitRemainderExpr(RemainderExpr e)
           
 void visitReturnChord(ReturnChord c)
           
 void visitVaArgExpr(VaArgExpr e)
           
 void visitVaStartExpr(VaStartExpr e)
           
protected  void zeroFloatRegister(int dest, int destSize)
          Generate code to zero out a floating point register.
 
Methods inherited from class scale.backend.Generator
adjustImmediates, allocateData, allocateRegisters, allocateTextArea, allocateWithData, appendCallInstruction, appendLabel, associateDispWithArea, avoidedAddressCalcs, avoidedLoads, calcAddressAndOffset, calcFieldAddress, calcFieldOffsets, convertCFG, copyPropagate, createLabel, doBinaryOp, doNext, doStore, doVaCopy, findAreaDisp, findAreaDisp, findAreaDisp, findLastInstruction, generate, generateConditionalBranch, genIfRegister, genIfRegister, getBranchLabel, getBranchTarget, getCallGraph, getCurrentRoutine, getDisp, getLabel, getMachine, getName, getRegisterSet, getSAType, getSourceLanguage, getSpaceAllocation, getStackPtr, insertInstruction, insertLabel, isAssignedRegister, isFortran, isSimple, labelCfgForBackend, loadDeclValue, loadVariable, loadVariableFromCommon, loadVariableFromMemory, loadVariableFromStack, moveInstructionSequence, needValue, needValue, newLabel, peepholeAfterRegisterAllocation, peepholeBeforeRegisterAllocation, processDecls, processType, processType, processType, processVariableDecl, propagate, putAddressInRegister, putAddressInRegister, putAddressInRegisterNO, regeneratedAddresses, regeneratedLiterals, regeneratedValues, regenerateRegister, removeUnneededInstructions, resetForBasicBlock, saveGeneratedCode, shouldBeRegenerated, specifyInReg, storeLdae, storeLdve, storeLiteral, storeLvie, updateLabelIndex, valueOf, visitAdditionExpr, visitAllocateExpr, visitAndExpr, visitArrayIndexExpr, visitBeginChord, visitBinaryExpr, visitBitAndExpr, visitBitOrExpr, visitBitShiftExpr, visitBitXorExpr, visitBranchChord, visitCallExpr, visitCallMethodExpr, visitChord, visitComplexValueExpr, visitConversionExpr, visitDecisionChord, visitDualExpr, visitEndChord, visitEqualityExpr, visitExitChord, visitExpr, visitExprPhiExpr, visitGotoChord, visitGreaterEqualExpr, visitGreaterExpr, visitIfThenElseChord, visitLeaveChord, visitLessEqualExpr, visitLessExpr, visitLiteralExpr, visitLoadDeclAddressExpr, visitLoadDeclValueExpr, visitLoadExpr, visitLoadFieldAddressExpr, visitLoadFieldValueExpr, visitLoadValueIndirectExpr, visitLoopExitChord, visitLoopHeaderChord, visitLoopInitChord, visitLoopPreHeaderChord, visitLoopTailChord, visitMarkerChord, visitMaxExpr, visitMinExpr, visitNaryExpr, visitNilExpr, visitNote, visitNotEqualExpr, visitNullChord, visitOrExpr, visitPhiExpr, visitPhiExprChord, visitSequentialChord, visitSubscriptExpr, visitSubtractionExpr, visitSwitchChord, visitTernaryExpr, visitTranscendental2Expr, visitTranscendentalExpr, visitUnaryExpr, visitVaEndExpr, visitValueExpr, visitVarArgExpr, visitVectorExpr, whatIsThis
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

display

public static boolean display
Set true to graphically display hyperblocks.


doCutAnalysis

public static boolean doCutAnalysis
Set true to output analysis of hyperblock cuts.


doBranchIds

public static boolean doBranchIds
Set true to output analysis of hyperblock cuts.


doBBID

public static boolean doBBID
Tag instructions with basic block identifiers.


enableStabs

public static boolean enableStabs
Set true to cause stab entries to be placed in the .til file..


srcLinePerBlock

public static boolean srcLinePerBlock
Set true to generate one source line per block.


BSS

public static final int BSS
Un-initialized large data area.

See Also:
Constant Field Values

SBSS

public static final int SBSS
Un-initialized small data area.

See Also:
Constant Field Values

DATA

public static final int DATA
Initialized large data area.

See Also:
Constant Field Values

LIT4

public static final int LIT4
Initialized 4-byte data area.

See Also:
Constant Field Values

LIT8

public static final int LIT8
Initialized 8-byte data area.

See Also:
Constant Field Values

LITA

public static final int LITA
Initialized address data area.

See Also:
Constant Field Values

RCONST

public static final int RCONST
Read-only constants

See Also:
Constant Field Values

RDATA

public static final int RDATA
Read-only data.

See Also:
Constant Field Values

SDATA

public static final int SDATA
Initialized small data area.

See Also:
Constant Field Values

TEXT

public static final int TEXT
Instructions.

See Also:
Constant Field Values

areaNames

public static final java.lang.String[] areaNames
ELF section names.


ARG_SAVE_OFFSET

public static final int ARG_SAVE_OFFSET
Offset to the argument save area.

See Also:
Constant Field Values

SAVED_REG_SIZE

public static final int SAVED_REG_SIZE
Size of registers saved on the stack.

See Also:
Constant Field Values

MAX_ARG_REGS

public static final int MAX_ARG_REGS
Maximum number of arguments passed in registers.

See Also:
Constant Field Values

hbStart

protected Hyperblock hbStart
Constructor Detail

Trips2Generator

public Trips2Generator(CallGraph cg,
                       Machine machine,
                       int features)
Parameters:
cg - is the call graph to be transformed
machine - specifies machine details
features - controls the instructions generated
Method Detail

generateScribble

public void generateScribble()
Generate the machine instructions for a CFG.

Overrides:
generateScribble in class Generator

enterSSA

protected void enterSSA()
Enter SSA after register allocation.


leaveSSA

protected void leaveSSA()
Leave SSA after register allocation.


removeDeadCode

protected void removeDeadCode()
Eliminate dead code.


optimizeHyperblocks

protected void optimizeHyperblocks(boolean removeLoads)
Apply optimizations on predicated code.


analyzeHyperblocks

protected void analyzeHyperblocks()
Print out a reason for each pair of hyperblocks not merged.


minimizePredicates

protected void minimizePredicates()
Perform inter-block predicate minimization.


splitHyperblocks

protected void splitHyperblocks()
Split blocks.


hyperblockFormation

protected void hyperblockFormation()
Create hyperblocks.


setLoopSizes

protected void setLoopSizes()
Update the scribble with the size of the unrolled loop.


tagBasicBlocks

protected void tagBasicBlocks()
Tag instructions with a block ID.


startModule

protected void startModule()
Called at the beginning of a module.

Overrides:
startModule in class Generator

endModule

protected void endModule()
Called at the end of a module.

Overrides:
endModule in class Generator

displayGraph

public java.lang.String displayGraph(java.lang.String msg)

splitAndAllocate

protected int[] splitAndAllocate()
Split blocks and register allocate.


renameRegisters

protected void renameRegisters()
Rename registers to reduce the memory used during register allocation.


renameRegisters

protected void renameRegisters(Instruction first)
Rename temporary registers so each block starts at 0.
Only call this after SSA. This routine assumes all the registers are named properly.


peepholeAfterRegisterAllocation

protected void peepholeAfterRegisterAllocation()
Do peephole optimizations after registers are allocated.


removeRedundantLoads

protected void removeRedundantLoads()
Remove redundant loads


mergeInstructions

protected void mergeInstructions()
Insert nullification and assign load/store ids.


assignLoadStoreIds

protected void assignLoadStoreIds()
Insert nullification and assign load/store ids.


assignBranchIds

protected void assignBranchIds()

dumpAssembly

protected void dumpAssembly(Instruction first,
                            java.lang.String phase)
Output all instructions for debugging.


setReturnBlock

protected void setReturnBlock(Hyperblock returnBlock)
Set the return hyperblock.


getReturnBlock

protected Hyperblock getReturnBlock()
Return the return hyperblock.


setLastInstruction

protected void setLastInstruction(Instruction lastInstruction)
Set the last instruction.


setBeginMarker

protected void setBeginMarker(BeginMarker currentBeginMarker)
Set the BeginMarker.


appendInstruction

protected void appendInstruction(Instruction inst)
The difference between this routine and the one in Generator is this routine will add the predicate to an instruction if it is not already predicated.

Overrides:
appendInstruction in class Generator

unconditionalBranchNeeded

protected boolean unconditionalBranchNeeded(Chord c,
                                            Chord nxt,
                                            java.lang.Object actual)
Return true if an unconditional branch is needed. For the Trips architecture, every block must end in a branch.

Overrides:
unconditionalBranchNeeded in class Generator
Parameters:
c - is the current node
nxt - is the successor to the current node
actual - is the actual node that will be converted to assembly next

assemble

public void assemble(Emit emit,
                     java.lang.String source,
                     java.util.Enumeration<java.lang.String> comments)
Generate assembly language file.

Specified by:
assemble in class Generator
Parameters:
emit - is the stream to use.
source - is the source file name
comments - is a list of Strings containing comments

dataType

public int dataType(int size,
                    boolean flt)
Return the data type as an integer.

Specified by:
dataType in class Generator
Parameters:
size - is the size in memory units
flt - is true for floating point values
See Also:
SpaceAllocation

defineDeclInRegister

protected void defineDeclInRegister(Declaration decl,
                                    int register,
                                    ResultMode regha)
Associate information with a variable Declaration kept in a register.

Overrides:
defineDeclInRegister in class Generator
Parameters:
decl - is the variable
register - is the register allocated for the variable
regha - specifies whether the register contains the address of the variable

defineDeclOnStack

protected void defineDeclOnStack(Declaration decl,
                                 Displacement disp)
Associate information with a Declaration kept on the stack. A unique integer value is set into the declaration label. This value can be used to retrieve the information supplied.

Overrides:
defineDeclOnStack in class Generator
Parameters:
decl - is the variable
disp - - displacement associated with declaration

defineDeclInMemory

protected void defineDeclInMemory(Declaration decl,
                                  Displacement disp)
Associate information with a Declaration kept in memory. A unique integer value is set into the declaration label. This value can be used to retrieve the information supplied.

Overrides:
defineDeclInMemory in class Generator
Parameters:
decl - is the variable
disp - - displacement associated with declaration

defineDeclInCommon

protected void defineDeclInCommon(Declaration decl,
                                  Displacement disp)
Associate information with a Declaration in COMMON. A unique integer value is set into the declaration label. This value can be used to retrieve the information supplied.

Overrides:
defineDeclInCommon in class Generator
Parameters:
decl - is the variable
disp - - displacement associated with declaration

defineRoutineInfo

protected void defineRoutineInfo(RoutineDecl rd,
                                 Displacement disp)
Associate information with a routine. A unique integer value is set into the declaration label. This value can be used to retrieve the information supplied.

Overrides:
defineRoutineInfo in class Generator
Parameters:
rd - is the routine
disp - - displacement associated with declaration

processType

public Type processType(Declaration decl)
Description copied from class: Generator
Insure that all types have their register types specified and all structure fields have had their offsets determined. The tag field of the Type is set to the register type required to hold an element of that type (or its address).

Overrides:
processType in class Generator
Returns:
the core type

assignDeclToMemory

protected void assignDeclToMemory(java.lang.String name,
                                  VariableDecl vd)
Description copied from class: Generator
Assign the specified variable to a location in memory using the specified name. The decision to place this variable in memory has already been made.

Specified by:
assignDeclToMemory in class Generator
See Also:
VariableDecl.getStorageLoc()

assignDeclToRegister

protected void assignDeclToRegister(VariableDecl vd)
Description copied from class: Generator
Assign the specified variable to a register. The decision to place this variable in a register has already been made.

Specified by:
assignDeclToRegister in class Generator
See Also:
VariableDecl.getStorageLoc()

assignDeclToStack

protected void assignDeclToStack(VariableDecl vd)
Description copied from class: Generator
Assign the specified variable to a location in the stack frame. The decision to place this variable on the stack has already been made.

Specified by:
assignDeclToStack in class Generator
See Also:
VariableDecl.getStorageLoc()

processRoutineDecl

protected void processRoutineDecl(RoutineDecl rd,
                                  boolean topLevel)
The RoutineDecl is assigned a tag. The tag can be used to retrieve information about the declaration. For a RoutineDecl, the information is a Displacement, the data area for the routine and the label to be used for BSR calls to the routine.

Specified by:
processRoutineDecl in class Generator
Parameters:
rd - is the declaration
topLevel - is true if this declaration is defined outside of a routine

processTypeDecl

protected void processTypeDecl(TypeDecl td,
                               boolean complete)
Description copied from class: Generator
Called for every TypeDecl instance so that the target code generator can perform any needed processing such as making Stabs entries.

Overrides:
processTypeDecl in class Generator

processTypeName

protected void processTypeName(TypeName tn)
Description copied from class: Generator
Called for every TypeName instance so that the target code generator can perform any needed processing such as making Stabs entries.

Overrides:
processTypeName in class Generator

layoutParameters

protected void layoutParameters()
Assign the routine's arguments to registers or the stack. Callee side.

Specified by:
layoutParameters in class Generator

returnRegister

public final int returnRegister(int regType,
                                boolean isCall)
Return the register used to return the function value.

Specified by:
returnRegister in class Generator
Parameters:
regType - specifies the type of value
isCall - is true if the calling routine is asking

getFirstArgRegister

public final int getFirstArgRegister(int regType)
Return the register used as the first argument in a function call.

Specified by:
getFirstArgRegister in class Generator
Parameters:
regType - specifies the type of argument value

defStringValue

protected Displacement defStringValue(java.lang.String v,
                                      int size)
Return the displacement for a string.

Specified by:
defStringValue in class Generator
Parameters:
v - is the string
size - is the length of the string

createAddressTable

protected Displacement createAddressTable(Chord[] entries,
                                          long[] indexes,
                                          int min,
                                          int max)
Create a new read-only data area whose value is a table of displacements.


createNewLabel

protected Label createNewLabel()
Create a new Label.

Overrides:
createNewLabel in class Generator

genRegToReg

protected void genRegToReg(int src,
                           int dest)
Generate instructions to move data from one register to another.

Specified by:
genRegToReg in class Generator
Parameters:
src - specifies the source register
dest - specifies the destination register

addRegs

protected void addRegs(int laReg,
                       int raReg,
                       int dest)
Generate an add of address registers laReg and raReg.

Specified by:
addRegs in class Generator

loadMemoryAddress

protected int loadMemoryAddress(Displacement disp)
Load an address of a memory location into a register.

Specified by:
loadMemoryAddress in class Generator
Parameters:
disp - specifies the address (should be a SymbolDisplacement or offset of one)
Returns:
the register that is set with the address

loadStackAddress

protected int loadStackAddress(Displacement disp)
Load an address of a stack location into a register.

Specified by:
loadStackAddress in class Generator
Parameters:
disp - specifies the address (should be a SymbolDisplacement or offset of one)
Returns:
the register that is set with the address

genLoadImmediate

protected void genLoadImmediate(long value,
                                int base,
                                int dest)
Generate instructions to load an immediate integer value added to the value in a register into a register.

Specified by:
genLoadImmediate in class Generator
Parameters:
value - is the value to load
base - is the base register
dest - is the register conatining the result

genLoadHighImmediate

protected long genLoadHighImmediate(long value,
                                    int base)
Generate instructions to calculate a valid offset. The *resultReg* register is set to the register containing the address to be used and the remaining offset is returned.

Specified by:
genLoadHighImmediate in class Generator
Parameters:
value - is the value to add to the base address
base - is the base address
Returns:
the lower 16 bits of the constant

genLoadImmediate

protected int genLoadImmediate(long value,
                               int dest)
Generate instructions to load an immediate integer value into a register.

Specified by:
genLoadImmediate in class Generator
Parameters:
value - is the value to load
dest - is the register conatining the result
Returns:
the register containing the value

genLoadDblImmediate

protected int genLoadDblImmediate(double value,
                                  int dest,
                                  int destSize)
Generate instructions to load an immediate integer value into a register. The destination register type is ignored so that single values can be loaded into PAIRREG registers. Note, we know that any value referenced from memory is aligned because it is created by this routine.

Specified by:
genLoadDblImmediate in class Generator
Parameters:
value - is the value to load
dest - is the register conatining the result
destSize - is the size of the value
Returns:
the register containing the value

basicBlockEnd

protected void basicBlockEnd()
Called after the last CFG node in a basic block is processed.

Overrides:
basicBlockEnd in class Generator

allocStackAddress

protected int allocStackAddress(int adrReg,
                                Type type)
Allocate a location on the stack for storing a value of the specified size. Put the address of the location in the register.

Specified by:
allocStackAddress in class Generator
Parameters:
adrReg - specifies the register to receive the address
type - is the type of the value
Returns:
the size of the value to be stored

loadFromMemoryWithOffset

protected void loadFromMemoryWithOffset(int dest,
                                        int address,
                                        Displacement offset,
                                        int size,
                                        long alignment,
                                        boolean signed,
                                        boolean real)
Generate instructions to load data from memory at the address in a register plus an offset. The offset must not be symbolic.

Specified by:
loadFromMemoryWithOffset in class Generator
Parameters:
dest - is the destination register
address - is the register containing the address of the data
offset - is the offset from the address
size - specifies the size of the data to be loaded
alignment - is the alignment of the data (usually 1, 2, 4, or 8)
signed - is true if the data is to be sign extended
real - is true if the data is known to be real - this argument is not used in this architecture and will be ignored

loadFromMemoryWithOffset

protected void loadFromMemoryWithOffset(int dest,
                                        int address,
                                        long offset,
                                        int size,
                                        long alignment,
                                        boolean signed,
                                        boolean real)
Generate instructions to load data from the specified data area.

Specified by:
loadFromMemoryWithOffset in class Generator
Parameters:
dest - is the destination register
address - is the register containing the address of the data
offset - specifies the offset from the address register value
size - specifies the size of the data to be loaded
alignment - is the alignment of the data (usually 1, 2, 4, or 8)
signed - is true if the data is to be sign extended
real - is true if the data is known to be real

loadFromMemoryDoubleIndexing

protected void loadFromMemoryDoubleIndexing(int dest,
                                            int index1,
                                            int index2,
                                            int size,
                                            long alignment,
                                            boolean signed,
                                            boolean real)
Generate instructions to load data from memory at the address that is the sum of the two index register values.

Specified by:
loadFromMemoryDoubleIndexing in class Generator
Parameters:
dest - is the destination register
index1 - is the register containing the first index
index2 - is the register containing the second index
size - specifies the size of the data to be loaded
alignment - is the alignment of the data (usually 1, 2, 4, or 8)
signed - is true if the data is to be sign extended
real - is true if the data is known to be a real

storeIntoMemoryWithOffset

protected void storeIntoMemoryWithOffset(int src,
                                         int address,
                                         long offset,
                                         int size,
                                         long alignment,
                                         boolean real)
Generate instructions to store data into the specified data area.

Specified by:
storeIntoMemoryWithOffset in class Generator
Parameters:
src - is the source register
address - is the register containing the address of the data in memory
offset - specifies the offset from the address register value
size - specifies the size of the data to be loaded
alignment - is the alignment of the data (usually 1, 2, 4, or 8)
real - is true if the data is known to be real

storeIntoMemoryWithOffset

protected void storeIntoMemoryWithOffset(int src,
                                         int address,
                                         Displacement offset,
                                         int size,
                                         long alignment,
                                         boolean real)
Generate instructions to store data into memory at the address in a register plus an offset. The offset must not be symbolic.

Specified by:
storeIntoMemoryWithOffset in class Generator
Parameters:
src - is the register containing the value to be stored
address - is the register containing the address of the data
offset - is the offset from the address
size - specifies the size of the data to be loaded
alignment - is the alignment of the data (usually 1, 2, 4, or 8)
real - is true if the data is known to be real - this argument is not used in this architecture and will be ignored

storeIntoMemory

protected void storeIntoMemory(int src,
                               int address,
                               int size,
                               long alignment,
                               boolean real)
Generate instructions to store data into memory at the address specified by a register.

Specified by:
storeIntoMemory in class Generator
Parameters:
src - is the source register
address - is the register containing the address of the data in memory
size - specifies the size of the data to be loaded
alignment - is the alignment of the data (usually 1, 2, 4, or 8)
real - is true if the data is known to be real

storeBitsIntoMemory

protected void storeBitsIntoMemory(int src,
                                   int address,
                                   long offset,
                                   int bits,
                                   int bitOffset,
                                   int alignment)
Generate instructions to store data into the specified data area.

Parameters:
src - is the source register
address - is the register containing the address of the data in memory
offset - specifies the offset from the address register value
bits - specifies the size of the data in bits to be loaded - must be 32 or less
bitOffset - specifies the offset in bits to the data
alignment - specifies the alignment of the address

moveWords

protected void moveWords(int src,
                         long srcoff,
                         int dest,
                         Displacement destoff,
                         int size,
                         int aln)
Generate an instruction sequence to move words from one location to another.

Specified by:
moveWords in class Generator
Parameters:
src - specifies the register containing the source address
srcoff - specifies the offset from the source address
dest - specifies the register containing the destination address
destoff - specifies the offset from the destination address
size - specifes the number of bytes to move
aln - is the alignment that can be assumed for both the source and destination addresses

moveWords

protected void moveWords(int src,
                         long srcoff,
                         int dest,
                         long destoff,
                         int size,
                         int aln)
Generate an instruction sequence to move words from one location to another.

Specified by:
moveWords in class Generator
Parameters:
src - specifies the register containing the source address
srcoff - specifies the offset from the source address
dest - specifies the register containing the destination address
destoff - specifies the offset from the destination address
size - specifes the number of bytes to move
aln - is the alignment that can be assumed for both the source and destination addresses

loadRegFromSymbolicLocation

protected void loadRegFromSymbolicLocation(int dest,
                                           int dsize,
                                           boolean isSigned,
                                           boolean isReal,
                                           Displacement disp)
Load a register from a symbolic location in memory.

Specified by:
loadRegFromSymbolicLocation in class Generator
Parameters:
dest - is the register
dsize - is the size of the value in addressable memory units
isSigned - is true if the value in the register is signed
isReal - is true if the value in the register is a floating point value
disp - specifies the location

doBinaryOp

protected void doBinaryOp(int which,
                          Type ct,
                          Expr la,
                          Expr ra,
                          int ir)
Generate instructions to do a binary operation on two values.

Specified by:
doBinaryOp in class Generator
Parameters:
which - specifies the binary operation (ADD, SUB, ...)
ct - is the result type
la - is the left argument
ra - is the right argument
ir - is the destination register

doCompareOp

protected void doCompareOp(BinaryExpr c,
                           CompareMode which)
Generate instructions to do a comparison of two value.

Specified by:
doCompareOp in class Generator
Parameters:
c - is the compare expression
which - specifies the compare (EQ, NE, ...)

startRoutineCode

protected Instruction startRoutineCode()
Called at the start of code generation for a routine.

Specified by:
startRoutineCode in class Generator

processSourceLine

protected void processSourceLine(int line,
                                 Label lab,
                                 boolean newLine)
Description copied from class: Generator
The user has requested source line information be included.

Specified by:
processSourceLine in class Generator
Parameters:
line - is the current line number
lab - is the last label encountered or null
newLine - is true if a new source line with no label

generateConditionalBranch

public void generateConditionalBranch(CompareMode which,
                                      int treg,
                                      Label lab)
Generate a predicated branch to a single location. This is only relevant when hyperblocks are enabled.

Parameters:
which - specifies the branch test (EQ, NE, LT, ...)
treg - specifies the condition to test
lab - is the label to branch to.

generateUnconditionalBranch

public void generateUnconditionalBranch(Label lab)
Generate an unconditional branch to the label specified.

Specified by:
generateUnconditionalBranch in class Generator

getSpillLocation

public java.lang.Object getSpillLocation(int reg)
Obtain the information needed for register spill loads and stores. The Object returned will probably specify a memory location. It will be passed to getSpillLoad() and getSpillStore().

Specified by:
getSpillLocation in class Generator
Parameters:
reg - specifies which virtual register will be spilled

insertSpillLoad

public Instruction insertSpillLoad(int reg,
                                   java.lang.Object spillLocation,
                                   Instruction after)
The insertSpillLoad(int, Object, Instruction) method should be used.

Specified by:
insertSpillLoad in class Generator
Parameters:
reg - specifies which virtual register will be loaded
spillLocation - specifies the offset on the stack to the spill location
after - specifies the instruction to insert the load after
Returns:
the last instruction inserted
See Also:
insertSpillStore(int, Object, Hyperblock)

insertSpillLoad

protected void insertSpillLoad(int reg,
                               java.lang.Object spillLocation,
                               Hyperblock hb)
Insert the instruction(s) to restore a spilled register. At this point, we are using a one-to-one mapping between real registers and virtual registers, so only a single instruction is required.

Parameters:
reg - specifies which virtual register will be loaded
spillLocation - specifies the offset on the stack to the spill location
hb -
See Also:
getSpillLocation(int)

insertSpillStore

public Instruction insertSpillStore(int reg,
                                    java.lang.Object spillLocation,
                                    Instruction after)
The insertSpillStore(int, Object, Instruction) method should be used.

Specified by:
insertSpillStore in class Generator
Parameters:
reg - specifies which virtual register will be stored
spillLocation - specifies the offset on the stack to the spill location
after - specifies the instruction to insert the store after
Returns:
the last instruction inserted
See Also:
insertSpillStore(int, Object, Hyperblock)

insertSpillStore

protected void insertSpillStore(int reg,
                                java.lang.Object spillLocation,
                                Hyperblock hb)
Insert the instruction(s) to save a spilled register.

Parameters:
reg - specifies which virtual register will be stored
spillLocation - specifies the offset on the stack to the spill location
hb -
See Also:
getSpillLocation(int)

endRoutineCode

protected void endRoutineCode(int[] regMap)
Called at the end of code generation for a routine to generate the stackframe. This method is responsible for inserting any prolog or epilog instructions required. It may also adjust stack offsets.

For a called routine, the stack looks like:
Trips call stack
Note - all locations are accessed using offsets from the SP register.

Specified by:
endRoutineCode in class Generator

genFtnCall

protected Branch genFtnCall(java.lang.String name,
                            short[] uses,
                            short[] defs)
Description copied from class: Generator
Create a call to the routine with the specified name. This is used to call things like the divide subroutine.

Specified by:
genFtnCall in class Generator
Parameters:
name - is the name of the function
uses - is the set of registers used by the call
defs - is the set of registers defined by the call or null
Returns:
the branch instruction generated

visitAbsoluteValueExpr

public void visitAbsoluteValueExpr(AbsoluteValueExpr e)

generateProlog

public void generateProlog(ProcedureType pt)
This method is responsible for generating instructions to move function arguments to the position assigned by the layoutParameters method.

Specified by:
generateProlog in class Generator

visitBitComplementExpr

public void visitBitComplementExpr(BitComplementExpr e)

callArgs

protected short[] callArgs(Expr[] args,
                           boolean retStruct)
Assign arguments to locations (either register or memory). Only the first MAX_ARG_REGS arguments are passed in registers, the remaining arguments are passed on the stack. There can be a hidden first argument for large returns.

Specified by:
callArgs in class Generator
Parameters:
args - is the set of arguments
retStruct - is true if the routine returns a struct
Returns:
the registers used by the call

visitCallFunctionExpr

public void visitCallFunctionExpr(CallFunctionExpr e)
This method generates instructions to call a sub-function. It places arguments in the appropriate registers or on the stack as required.


visitCompareExpr

public void visitCompareExpr(CompareExpr e)

convertIntRegValue

protected int convertIntRegValue(int src,
                                 int srcSize,
                                 boolean srcSigned,
                                 int dest,
                                 int destSize,
                                 boolean destSigned)
Generate instructions to convert an integer value in an integer register to an integer value of a different size. The source and destination may be the same register. This logic assumes that the value in the source register conforms to the specified type.

Specified by:
convertIntRegValue in class Generator
Parameters:
src - is the register containing the source value
srcSize - is the source value size
srcSigned - is true if the source value is signed
dest - is the register containing the result
destSize - is the size of the result value
destSigned - is true if the result value is signed
Returns:
the register containing the converted value

zeroFloatRegister

protected void zeroFloatRegister(int dest,
                                 int destSize)
Generate code to zero out a floating point register.

Specified by:
zeroFloatRegister in class Generator

genRealPart

protected void genRealPart(int src,
                           int srcSize,
                           int dest,
                           int destSize)
Generate code to obtain the real part of a complex value.


genRealToInt

protected int genRealToInt(int src,
                           int srcSize,
                           int dest,
                           int destSize,
                           boolean destSigned)
Convert real value in a real register to an integer value in a real register. The result is rounded down.

Specified by:
genRealToInt in class Generator
Parameters:
src - is the register containing the source value
srcSize - is the source value size
dest - is the register containing the result
destSize - is the size of the result value
destSigned - is true if the result value is signed
Returns:
the register containing the converted value

genRealToReal

protected void genRealToReal(int src,
                             int srcSize,
                             int dest,
                             int destSize)
Convert a real value in a real register to a real value in a real register.

Specified by:
genRealToReal in class Generator

genTransformReal

protected void genTransformReal(int src,
                                int srcSize,
                                int dest,
                                int destSize)
Convert between single and double reals. Only used on loads and stores to memory.


genRealToIntRound

protected void genRealToIntRound(int src,
                                 int srcSize,
                                 int dest,
                                 int destSize)
Convert real value in a real register to an integer value in a real register. The result is rounded to the nearest integer.

Specified by:
genRealToIntRound in class Generator

genRoundReal

protected void genRoundReal(int src,
                            int srcSize,
                            int dest,
                            int destSize)
Convert real value in a real register to a rounded real value in a real register. The result is rounded to the nearest integer.

Specified by:
genRoundReal in class Generator

genIntToReal

protected void genIntToReal(int src,
                            int srcSize,
                            int dest,
                            int destSize)
Convert an integer value in an integer register to a real value in a real register.

Specified by:
genIntToReal in class Generator
Parameters:
src - is the register containing the source integer value
srcSize - is the size of the integer value
dest - is the register that will conatin the result real value
destSize - is the size of the real value

genUnsignedIntToReal

protected void genUnsignedIntToReal(int src,
                                    int srcSize,
                                    int dest,
                                    int destSize)
Convert an unsigned integer value in an integer register to a real value in a real register.

Specified by:
genUnsignedIntToReal in class Generator
Parameters:
src - is the register containing the source integer value
srcSize - is the size of the integer value
dest - is the register that will conatin the result real value
destSize - is the size of the real value

genFloorOfReal

protected void genFloorOfReal(int src,
                              int srcSize,
                              int dest,
                              int destSize)
Generate floor().

Specified by:
genFloorOfReal in class Generator

visitExponentiationExpr

public void visitExponentiationExpr(ExponentiationExpr e)

visitDivisionExpr

public void visitDivisionExpr(DivisionExpr e)

visitRemainderExpr

public void visitRemainderExpr(RemainderExpr e)

genSingleUse

protected short[] genSingleUse(int reg)
Description copied from class: Generator
Generate the array of registers that a call to a function requires. The specified register is the argument register. Other registers required by the calling convention are added to the array.

Specified by:
genSingleUse in class Generator

genDoubleUse

protected short[] genDoubleUse(int reg1,
                               int reg2)
Description copied from class: Generator
Generate the array of registers that a call to a function requires. The specified registers are the two argument registers. Other registers required by the calling convention are added to the array.

Specified by:
genDoubleUse in class Generator

loadFieldValue

protected void loadFieldValue(FieldDecl fd,
                              long fieldOffset,
                              int adr,
                              ResultMode adrha,
                              int adraln,
                              long adrrs,
                              int dest)
Load the value of a field to a register.

Specified by:
loadFieldValue in class Generator
Parameters:
fd - defines the field
fieldOffset - is the offset from the specified address
adr - is the register holding the address
adrha - specifies the type of address
adraln - specifies the alignment of the address
adrrs - specifies the size of the structure if it is in a register
dest - specifies the register to hold the field value

genTrueFalseBranch

protected void genTrueFalseBranch(int treg,
                                  Chord tc,
                                  Chord fc)
Generate a branch based on the value of an expression which is guaranteed to be either 0 or 1.

Overrides:
genTrueFalseBranch in class Generator
Parameters:
treg - specifies the register to test
tc - specifies the path if the test succeeds
fc - specifies the path if the test fails

genIfRegister

protected void genIfRegister(CompareMode which,
                             int treg,
                             boolean signed,
                             Label labt,
                             Label labf)
Generate a branch based on the value of an expression. The value may be floating point or integer but it is never a value pair.

Specified by:
genIfRegister in class Generator
Parameters:
which - specifies the branch test (EQ, NE, LT, ...)
treg - specifies the condition (register value) to test
signed - is true if the value is signed
labt - specifies the path if the test fails
labf - specifies the path if the test succeeds

genIfRelational

protected void genIfRelational(boolean rflag,
                               MatchExpr predicate,
                               Chord tc,
                               Chord fc)
Generate a branch based on a relational expression.

Specified by:
genIfRelational in class Generator
Parameters:
rflag - true if the test condition should be reversed
predicate - specifies the relational expression
tc - specifies the path if the test succeeds
fc - specifies the path if the test fails

loadArrayElement

protected void loadArrayElement(ArrayIndexExpr aie,
                                int dest)
Load an array element into a register.

Specified by:
loadArrayElement in class Generator
Parameters:
aie - specifies the array element
dest - specifies the register

calcArrayElementAddress

protected void calcArrayElementAddress(ArrayIndexExpr aie,
                                       long offseta)
Load the address of an array element into a register. Return the offset from the address in resultRegAddressOffset. The address is specified in resultReg.

Specified by:
calcArrayElementAddress in class Generator
Parameters:
aie - specifies the array elementxpression
offseta - is the offset from the address

visitMultiplicationExpr

public void visitMultiplicationExpr(MultiplicationExpr e)

visitNegativeExpr

public void visitNegativeExpr(NegativeExpr e)

genAlloca

protected void genAlloca(Expr arg,
                         int reg)
Description copied from class: Generator
Generate the code for the alloca() function.

Specified by:
genAlloca in class Generator

genSqrtFtn

protected void genSqrtFtn(int dest,
                          int src,
                          Type type)
Description copied from class: Generator
Generate the code for the sqrt() function.

Specified by:
genSqrtFtn in class Generator

genExpFtn

protected void genExpFtn(int dest,
                         int src,
                         Type type)
Description copied from class: Generator
Generate the code for the exp() function.

Specified by:
genExpFtn in class Generator

genLogFtn

protected void genLogFtn(int dest,
                         int src,
                         Type type)
Description copied from class: Generator
Generate the code for the log() function.

Specified by:
genLogFtn in class Generator

genLog10Ftn

protected void genLog10Ftn(int dest,
                           int src,
                           Type type)
Description copied from class: Generator
Generate the code for the log10() function.

Specified by:
genLog10Ftn in class Generator

genSinFtn

protected void genSinFtn(int dest,
                         int src,
                         Type type)
Description copied from class: Generator
Generate the code for the sin() function.

Specified by:
genSinFtn in class Generator

genCosFtn

protected void genCosFtn(int dest,
                         int src,
                         Type type)
Description copied from class: Generator
Generate the code for the cos() function.

Specified by:
genCosFtn in class Generator

genTanFtn

protected void genTanFtn(int dest,
                         int src,
                         Type type)
Description copied from class: Generator
Generate the code for the tan() function.

Specified by:
genTanFtn in class Generator

genAsinFtn

protected void genAsinFtn(int dest,
                          int src,
                          Type type)
Description copied from class: Generator
Generate the code for the asin() function.

Specified by:
genAsinFtn in class Generator

genAcosFtn

protected void genAcosFtn(int dest,
                          int src,
                          Type type)
Description copied from class: Generator
Generate the code for the acos() function.

Specified by:
genAcosFtn in class Generator

genAtanFtn

protected void genAtanFtn(int dest,
                          int src,
                          Type type)
Description copied from class: Generator
Generate the code for the atan() function.

Specified by:
genAtanFtn in class Generator

genSinhFtn

protected void genSinhFtn(int dest,
                          int src,
                          Type type)
Description copied from class: Generator
Generate the code for the sinh() function.

Specified by:
genSinhFtn in class Generator

genCoshFtn

protected void genCoshFtn(int dest,
                          int src,
                          Type type)
Description copied from class: Generator
Generate the code for the cosh() function.

Specified by:
genCoshFtn in class Generator

genTanhFtn

protected void genTanhFtn(int dest,
                          int src,
                          Type type)
Description copied from class: Generator
Generate the code for the tanh() function.

Specified by:
genTanhFtn in class Generator

genConjgFtn

protected void genConjgFtn(int dest,
                           int src,
                           Type rType)
Description copied from class: Generator
Generate the code for the conjg() function.

Specified by:
genConjgFtn in class Generator

genReturnAddressFtn

protected void genReturnAddressFtn(int dest,
                                   int src,
                                   Type type)
Description copied from class: Generator
Generate the code for the builtin_return_address() function.

Specified by:
genReturnAddressFtn in class Generator

genFrameAddressFtn

protected void genFrameAddressFtn(int dest,
                                  int src,
                                  Type type)
Description copied from class: Generator
Generate the code for the builtin_fram_address() function.

Specified by:
genFrameAddressFtn in class Generator

genSignFtn

protected void genSignFtn(int dest,
                          int laReg,
                          int raReg,
                          Type rType)
Description copied from class: Generator
Generate the code for the Fortran SIGN() intrinsic function.

Specified by:
genSignFtn in class Generator

genAtan2Ftn

protected void genAtan2Ftn(int dest,
                           int laReg,
                           int raReg,
                           Type rType)
Description copied from class: Generator
Generate the code for the Fortran ATAN2() intrinsic function.

Specified by:
genAtan2Ftn in class Generator

genDimFtn

protected void genDimFtn(int dest,
                         int laReg,
                         int raReg,
                         Type rType)
Description copied from class: Generator
Generate the code for the Fortran DIM() intrinsic function.

Specified by:
genDimFtn in class Generator

visitNotExpr

public void visitNotExpr(NotExpr e)

visitReturnChord

public void visitReturnChord(ReturnChord c)

storeRegToSymbolicLocation

protected void storeRegToSymbolicLocation(int src,
                                          int dsize,
                                          long alignment,
                                          boolean isReal,
                                          Displacement disp)
Store a value in a register to a symbolic location in memory.

Specified by:
storeRegToSymbolicLocation in class Generator
Parameters:
src - is the value
dsize - is the size of the value in addressable memory units
alignment - is the alignment of the data (usually 1, 2, 4, or 8)
isReal - is true if the value in the register is a floating point value
disp - specifies the location

storeLfae

protected void storeLfae(LoadFieldAddressExpr lhs,
                         Expr rhs)
Store a value into a field of a structure.

Specified by:
storeLfae in class Generator
Parameters:
lhs - specifies the field of the structure
rhs - specifies the value

genSwitchUsingIfs

protected boolean genSwitchUsingIfs(int testReg,
                                    Chord[] cases,
                                    long[] keys,
                                    int num,
                                    long spread)
Description copied from class: Generator
Generate the code for a switch statement using branches for each case.

Specified by:
genSwitchUsingIfs in class Generator
Parameters:
testReg - is the register holding the selected key value
cases - is the list of CFG nodes for the switch cases
keys - is the list of case values
num - is the number of cases
spread - is a measure of the density of the cases values
Returns:
true if code for the switch statement was generated

genSwitchUsingTransferVector

protected void genSwitchUsingTransferVector(int testReg,
                                            Chord[] cases,
                                            long[] values,
                                            Label labd,
                                            long min,
                                            long max)
Generate a switch using a transfer vector.

Specified by:
genSwitchUsingTransferVector in class Generator
Parameters:
testReg - is the register holding the selected key value
cases - is the list of CFG nodes for the switch cases
values - is the list of case values
labd - is the label for the default case
min - is the smallest case value
max - is the largest case value

visitVaStartExpr

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

visitVaArgExpr

public void visitVaArgExpr(VaArgExpr e)

visitConditionalExpr

public void visitConditionalExpr(ConditionalExpr e)
Specified by:
visitConditionalExpr in interface Predicate
Overrides:
visitConditionalExpr in class Generator

visitExprChord

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

getMaxAreaIndex

public int getMaxAreaIndex()
Description copied from class: Generator
Return the maximum area index value.

Specified by:
getMaxAreaIndex in class Generator

getVariables

public Vector<VariableDecl> getVariables(java.lang.String func)
Return the variables for a function.


__builtin_abs

protected void __builtin_abs()
Intrinsics