|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object scale.backend.Generator scale.backend.trips2.Trips2Generator
public class Trips2Generator
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 java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static boolean display
public static boolean doCutAnalysis
public static boolean doBranchIds
public static boolean doBBID
public static boolean enableStabs
public static boolean srcLinePerBlock
public static final int BSS
public static final int SBSS
public static final int DATA
public static final int LIT4
public static final int LIT8
public static final int LITA
public static final int RCONST
public static final int RDATA
public static final int SDATA
public static final int TEXT
public static final java.lang.String[] areaNames
public static final int ARG_SAVE_OFFSET
public static final int SAVED_REG_SIZE
public static final int MAX_ARG_REGS
protected Hyperblock hbStart
Constructor Detail |
---|
public Trips2Generator(CallGraph cg, Machine machine, int features)
cg
- is the call graph to be transformedmachine
- specifies machine detailsfeatures
- controls the instructions generatedMethod Detail |
---|
public void generateScribble()
generateScribble
in class Generator
protected void enterSSA()
protected void leaveSSA()
protected void removeDeadCode()
protected void optimizeHyperblocks(boolean removeLoads)
protected void analyzeHyperblocks()
protected void minimizePredicates()
protected void splitHyperblocks()
protected void hyperblockFormation()
protected void setLoopSizes()
protected void tagBasicBlocks()
protected void startModule()
startModule
in class Generator
protected void endModule()
endModule
in class Generator
public java.lang.String displayGraph(java.lang.String msg)
protected int[] splitAndAllocate()
protected void renameRegisters()
protected void renameRegisters(Instruction first)
protected void peepholeAfterRegisterAllocation()
protected void removeRedundantLoads()
protected void mergeInstructions()
protected void assignLoadStoreIds()
protected void assignBranchIds()
protected void dumpAssembly(Instruction first, java.lang.String phase)
protected void setReturnBlock(Hyperblock returnBlock)
protected Hyperblock getReturnBlock()
protected void setLastInstruction(Instruction lastInstruction)
protected void setBeginMarker(BeginMarker currentBeginMarker)
protected void appendInstruction(Instruction inst)
appendInstruction
in class Generator
protected boolean unconditionalBranchNeeded(Chord c, Chord nxt, java.lang.Object actual)
unconditionalBranchNeeded
in class Generator
c
- is the current nodenxt
- is the successor to the current nodeactual
- is the actual node that will be converted to
assembly nextpublic void assemble(Emit emit, java.lang.String source, java.util.Enumeration<java.lang.String> comments)
assemble
in class Generator
emit
- is the stream to use.source
- is the source file namecomments
- is a list of Strings containing commentspublic int dataType(int size, boolean flt)
dataType
in class Generator
size
- is the size in memory unitsflt
- is true for floating point valuesSpaceAllocation
protected void defineDeclInRegister(Declaration decl, int register, ResultMode regha)
defineDeclInRegister
in class Generator
decl
- is the variableregister
- is the register allocated for the variableregha
- specifies whether the register contains the address
of the variableprotected void defineDeclOnStack(Declaration decl, Displacement disp)
defineDeclOnStack
in class Generator
decl
- is the variabledisp
- - displacement associated with declarationprotected void defineDeclInMemory(Declaration decl, Displacement disp)
defineDeclInMemory
in class Generator
decl
- is the variabledisp
- - displacement associated with declarationprotected void defineDeclInCommon(Declaration decl, Displacement disp)
defineDeclInCommon
in class Generator
decl
- is the variabledisp
- - displacement associated with declarationprotected void defineRoutineInfo(RoutineDecl rd, Displacement disp)
defineRoutineInfo
in class Generator
rd
- is the routinedisp
- - displacement associated with declarationpublic Type processType(Declaration decl)
Generator
processType
in class Generator
protected void assignDeclToMemory(java.lang.String name, VariableDecl vd)
Generator
assignDeclToMemory
in class Generator
VariableDecl.getStorageLoc()
protected void assignDeclToRegister(VariableDecl vd)
Generator
assignDeclToRegister
in class Generator
VariableDecl.getStorageLoc()
protected void assignDeclToStack(VariableDecl vd)
Generator
assignDeclToStack
in class Generator
VariableDecl.getStorageLoc()
protected void processRoutineDecl(RoutineDecl rd, boolean topLevel)
processRoutineDecl
in class Generator
rd
- is the declarationtopLevel
- is true if this declaration is defined outside of a routineprotected void processTypeDecl(TypeDecl td, boolean complete)
Generator
TypeDecl
instance so that the target code generator can perform any needed
processing such as making Stabs entries.
processTypeDecl
in class Generator
protected void processTypeName(TypeName tn)
Generator
TypeName
instance so that the target code generator can perform any needed
processing such as making Stabs entries.
processTypeName
in class Generator
protected void layoutParameters()
layoutParameters
in class Generator
public final int returnRegister(int regType, boolean isCall)
returnRegister
in class Generator
regType
- specifies the type of valueisCall
- is true if the calling routine is askingpublic final int getFirstArgRegister(int regType)
getFirstArgRegister
in class Generator
regType
- specifies the type of argument valueprotected Displacement defStringValue(java.lang.String v, int size)
defStringValue
in class Generator
v
- is the stringsize
- is the length of the stringprotected Displacement createAddressTable(Chord[] entries, long[] indexes, int min, int max)
protected Label createNewLabel()
createNewLabel
in class Generator
protected void genRegToReg(int src, int dest)
genRegToReg
in class Generator
src
- specifies the source registerdest
- specifies the destination registerprotected void addRegs(int laReg, int raReg, int dest)
laReg
and
raReg
.
addRegs
in class Generator
protected int loadMemoryAddress(Displacement disp)
loadMemoryAddress
in class Generator
disp
- specifies the address (should be a SymbolDisplacement
or offset of one)
protected int loadStackAddress(Displacement disp)
loadStackAddress
in class Generator
disp
- specifies the address (should be a SymbolDisplacement
or offset of one)
protected void genLoadImmediate(long value, int base, int dest)
genLoadImmediate
in class Generator
value
- is the value to loadbase
- is the base registerdest
- is the register conatining the resultprotected long genLoadHighImmediate(long value, int base)
genLoadHighImmediate
in class Generator
value
- is the value to add to the base addressbase
- is the base address
protected int genLoadImmediate(long value, int dest)
genLoadImmediate
in class Generator
value
- is the value to loaddest
- is the register conatining the result
protected int genLoadDblImmediate(double value, int dest, int destSize)
genLoadDblImmediate
in class Generator
value
- is the value to loaddest
- is the register conatining the resultdestSize
- is the size of the value
protected void basicBlockEnd()
basicBlockEnd
in class Generator
protected int allocStackAddress(int adrReg, Type type)
allocStackAddress
in class Generator
adrReg
- specifies the register to receive the addresstype
- is the type of the value
protected void loadFromMemoryWithOffset(int dest, int address, Displacement offset, int size, long alignment, boolean signed, boolean real)
loadFromMemoryWithOffset
in class Generator
dest
- is the destination registeraddress
- is the register containing the address of the dataoffset
- is the offset from the addresssize
- specifies the size of the data to be loadedalignment
- is the alignment of the data (usually 1, 2, 4, or 8)signed
- is true if the data is to be sign extendedreal
- is true if the data is known to be real - this
argument is not used in this architecture and will be ignoredprotected void loadFromMemoryWithOffset(int dest, int address, long offset, int size, long alignment, boolean signed, boolean real)
loadFromMemoryWithOffset
in class Generator
dest
- is the destination registeraddress
- is the register containing the address of the dataoffset
- specifies the offset from the address register valuesize
- specifies the size of the data to be loadedalignment
- is the alignment of the data (usually 1, 2, 4, or 8)signed
- is true if the data is to be sign extendedreal
- is true if the data is known to be realprotected void loadFromMemoryDoubleIndexing(int dest, int index1, int index2, int size, long alignment, boolean signed, boolean real)
loadFromMemoryDoubleIndexing
in class Generator
dest
- is the destination registerindex1
- is the register containing the first indexindex2
- is the register containing the second indexsize
- specifies the size of the data to be loadedalignment
- is the alignment of the data (usually 1, 2, 4, or 8)signed
- is true if the data is to be sign extendedreal
- is true if the data is known to be a realprotected void storeIntoMemoryWithOffset(int src, int address, long offset, int size, long alignment, boolean real)
storeIntoMemoryWithOffset
in class Generator
src
- is the source registeraddress
- is the register containing the address of the data
in memoryoffset
- specifies the offset from the address register valuesize
- specifies the size of the data to be loadedalignment
- is the alignment of the data (usually 1, 2, 4, or 8)real
- is true if the data is known to be realprotected void storeIntoMemoryWithOffset(int src, int address, Displacement offset, int size, long alignment, boolean real)
storeIntoMemoryWithOffset
in class Generator
src
- is the register containing the value to be storedaddress
- is the register containing the address of the dataoffset
- is the offset from the addresssize
- specifies the size of the data to be loadedalignment
- 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 ignoredprotected void storeIntoMemory(int src, int address, int size, long alignment, boolean real)
storeIntoMemory
in class Generator
src
- is the source registeraddress
- is the register containing the address of the data in memorysize
- specifies the size of the data to be loadedalignment
- is the alignment of the data (usually 1, 2, 4, or 8)real
- is true if the data is known to be realprotected void storeBitsIntoMemory(int src, int address, long offset, int bits, int bitOffset, int alignment)
src
- is the source registeraddress
- is the register containing the address of the data
in memoryoffset
- specifies the offset from the address register valuebits
- specifies the size of the data in bits to be loaded -
must be 32 or lessbitOffset
- specifies the offset in bits to the dataalignment
- specifies the alignment of the addressprotected void moveWords(int src, long srcoff, int dest, Displacement destoff, int size, int aln)
moveWords
in class Generator
src
- specifies the register containing the source addresssrcoff
- specifies the offset from the source addressdest
- specifies the register containing the destination addressdestoff
- specifies the offset from the destination addresssize
- specifes the number of bytes to movealn
- is the alignment that can be assumed for both the
source and destination addressesprotected void moveWords(int src, long srcoff, int dest, long destoff, int size, int aln)
moveWords
in class Generator
src
- specifies the register containing the source addresssrcoff
- specifies the offset from the source addressdest
- specifies the register containing the destination addressdestoff
- specifies the offset from the destination addresssize
- specifes the number of bytes to movealn
- is the alignment that can be assumed for both the
source and destination addressesprotected void loadRegFromSymbolicLocation(int dest, int dsize, boolean isSigned, boolean isReal, Displacement disp)
loadRegFromSymbolicLocation
in class Generator
dest
- is the registerdsize
- is the size of the value in addressable memory unitsisSigned
- is true if the value in the register is signedisReal
- is true if the value in the register is a floating
point valuedisp
- specifies the locationprotected void doBinaryOp(int which, Type ct, Expr la, Expr ra, int ir)
doBinaryOp
in class Generator
which
- specifies the binary operation (ADD, SUB, ...)ct
- is the result typela
- is the left argumentra
- is the right argumentir
- is the destination registerprotected void doCompareOp(BinaryExpr c, CompareMode which)
doCompareOp
in class Generator
c
- is the compare expressionwhich
- specifies the compare (EQ, NE, ...)protected Instruction startRoutineCode()
startRoutineCode
in class Generator
protected void processSourceLine(int line, Label lab, boolean newLine)
Generator
processSourceLine
in class Generator
line
- is the current line numberlab
- is the last label encountered or null
newLine
- is true if a new source line with no labelpublic void generateConditionalBranch(CompareMode which, int treg, Label lab)
which
- specifies the branch test (EQ, NE, LT, ...)treg
- specifies the condition to testlab
- is the label to branch to.public void generateUnconditionalBranch(Label lab)
generateUnconditionalBranch
in class Generator
public java.lang.Object getSpillLocation(int reg)
getSpillLocation
in class Generator
reg
- specifies which virtual register will be spilledpublic Instruction insertSpillLoad(int reg, java.lang.Object spillLocation, Instruction after)
insertSpillLoad
in class Generator
reg
- specifies which virtual register will be loadedspillLocation
- specifies the offset on the stack to the spill locationafter
- specifies the instruction to insert the load after
insertSpillStore(int, Object, Hyperblock)
protected void insertSpillLoad(int reg, java.lang.Object spillLocation, Hyperblock hb)
reg
- specifies which virtual register will be loadedspillLocation
- specifies the offset on the stack to the spill locationhb
- getSpillLocation(int)
public Instruction insertSpillStore(int reg, java.lang.Object spillLocation, Instruction after)
insertSpillStore
in class Generator
reg
- specifies which virtual register will be storedspillLocation
- specifies the offset on the stack to the spill locationafter
- specifies the instruction to insert the store after
insertSpillStore(int, Object, Hyperblock)
protected void insertSpillStore(int reg, java.lang.Object spillLocation, Hyperblock hb)
reg
- specifies which virtual register will be storedspillLocation
- specifies the offset on the stack to the
spill locationhb
- getSpillLocation(int)
protected void endRoutineCode(int[] regMap)
For a called routine, the stack looks like:
Note - all locations are accessed using offsets from the
SP register.
endRoutineCode
in class Generator
protected Branch genFtnCall(java.lang.String name, short[] uses, short[] defs)
Generator
genFtnCall
in class Generator
name
- is the name of the functionuses
- is the set of registers used by the calldefs
- is the set of registers defined by the call or null
public void visitAbsoluteValueExpr(AbsoluteValueExpr e)
public void generateProlog(ProcedureType pt)
layoutParameters
method.
generateProlog
in class Generator
public void visitBitComplementExpr(BitComplementExpr e)
protected short[] callArgs(Expr[] args, boolean retStruct)
callArgs
in class Generator
args
- is the set of argumentsretStruct
- is true if the routine returns a struct
public void visitCallFunctionExpr(CallFunctionExpr e)
public void visitCompareExpr(CompareExpr e)
protected int convertIntRegValue(int src, int srcSize, boolean srcSigned, int dest, int destSize, boolean destSigned)
convertIntRegValue
in class Generator
src
- is the register containing the source valuesrcSize
- is the source value sizesrcSigned
- is true if the source value is signeddest
- is the register containing the resultdestSize
- is the size of the result valuedestSigned
- is true if the result value is signed
protected void zeroFloatRegister(int dest, int destSize)
zeroFloatRegister
in class Generator
protected void genRealPart(int src, int srcSize, int dest, int destSize)
protected int genRealToInt(int src, int srcSize, int dest, int destSize, boolean destSigned)
genRealToInt
in class Generator
src
- is the register containing the source valuesrcSize
- is the source value sizedest
- is the register containing the resultdestSize
- is the size of the result valuedestSigned
- is true if the result value is signed
protected void genRealToReal(int src, int srcSize, int dest, int destSize)
genRealToReal
in class Generator
protected void genTransformReal(int src, int srcSize, int dest, int destSize)
protected void genRealToIntRound(int src, int srcSize, int dest, int destSize)
genRealToIntRound
in class Generator
protected void genRoundReal(int src, int srcSize, int dest, int destSize)
genRoundReal
in class Generator
protected void genIntToReal(int src, int srcSize, int dest, int destSize)
genIntToReal
in class Generator
src
- is the register containing the source integer valuesrcSize
- is the size of the integer valuedest
- is the register that will conatin the result real
valuedestSize
- is the size of the real valueprotected void genUnsignedIntToReal(int src, int srcSize, int dest, int destSize)
genUnsignedIntToReal
in class Generator
src
- is the register containing the source integer valuesrcSize
- is the size of the integer valuedest
- is the register that will conatin the result real valuedestSize
- is the size of the real valueprotected void genFloorOfReal(int src, int srcSize, int dest, int destSize)
genFloorOfReal
in class Generator
public void visitExponentiationExpr(ExponentiationExpr e)
public void visitDivisionExpr(DivisionExpr e)
public void visitRemainderExpr(RemainderExpr e)
protected short[] genSingleUse(int reg)
Generator
genSingleUse
in class Generator
protected short[] genDoubleUse(int reg1, int reg2)
Generator
genDoubleUse
in class Generator
protected void loadFieldValue(FieldDecl fd, long fieldOffset, int adr, ResultMode adrha, int adraln, long adrrs, int dest)
loadFieldValue
in class Generator
fd
- defines the fieldfieldOffset
- is the offset from the specified addressadr
- is the register holding the addressadrha
- specifies the type of addressadraln
- specifies the alignment of the addressadrrs
- specifies the size of the structure if it is in a registerdest
- specifies the register to hold the field valueprotected void genTrueFalseBranch(int treg, Chord tc, Chord fc)
genTrueFalseBranch
in class Generator
treg
- specifies the register to testtc
- specifies the path if the test succeedsfc
- specifies the path if the test failsprotected void genIfRegister(CompareMode which, int treg, boolean signed, Label labt, Label labf)
genIfRegister
in class Generator
which
- specifies the branch test (EQ, NE, LT, ...)treg
- specifies the condition (register value) to testsigned
- is true if the value is signedlabt
- specifies the path if the test failslabf
- specifies the path if the test succeedsprotected void genIfRelational(boolean rflag, MatchExpr predicate, Chord tc, Chord fc)
genIfRelational
in class Generator
rflag
- true if the test condition should be reversedpredicate
- specifies the relational expressiontc
- specifies the path if the test succeedsfc
- specifies the path if the test failsprotected void loadArrayElement(ArrayIndexExpr aie, int dest)
loadArrayElement
in class Generator
aie
- specifies the array elementdest
- specifies the registerprotected void calcArrayElementAddress(ArrayIndexExpr aie, long offseta)
resultRegAddressOffset
.
The address is specified in resultReg
.
calcArrayElementAddress
in class Generator
aie
- specifies the array elementxpressionoffseta
- is the offset from the addresspublic void visitMultiplicationExpr(MultiplicationExpr e)
public void visitNegativeExpr(NegativeExpr e)
protected void genAlloca(Expr arg, int reg)
Generator
alloca()
function.
genAlloca
in class Generator
protected void genSqrtFtn(int dest, int src, Type type)
Generator
sqrt()
function.
genSqrtFtn
in class Generator
protected void genExpFtn(int dest, int src, Type type)
Generator
exp()
function.
genExpFtn
in class Generator
protected void genLogFtn(int dest, int src, Type type)
Generator
log()
function.
genLogFtn
in class Generator
protected void genLog10Ftn(int dest, int src, Type type)
Generator
log10()
function.
genLog10Ftn
in class Generator
protected void genSinFtn(int dest, int src, Type type)
Generator
sin()
function.
genSinFtn
in class Generator
protected void genCosFtn(int dest, int src, Type type)
Generator
cos()
function.
genCosFtn
in class Generator
protected void genTanFtn(int dest, int src, Type type)
Generator
tan()
function.
genTanFtn
in class Generator
protected void genAsinFtn(int dest, int src, Type type)
Generator
asin()
function.
genAsinFtn
in class Generator
protected void genAcosFtn(int dest, int src, Type type)
Generator
acos()
function.
genAcosFtn
in class Generator
protected void genAtanFtn(int dest, int src, Type type)
Generator
atan()
function.
genAtanFtn
in class Generator
protected void genSinhFtn(int dest, int src, Type type)
Generator
sinh()
function.
genSinhFtn
in class Generator
protected void genCoshFtn(int dest, int src, Type type)
Generator
cosh()
function.
genCoshFtn
in class Generator
protected void genTanhFtn(int dest, int src, Type type)
Generator
tanh()
function.
genTanhFtn
in class Generator
protected void genConjgFtn(int dest, int src, Type rType)
Generator
conjg()
function.
genConjgFtn
in class Generator
protected void genReturnAddressFtn(int dest, int src, Type type)
Generator
builtin_return_address()
function.
genReturnAddressFtn
in class Generator
protected void genFrameAddressFtn(int dest, int src, Type type)
Generator
builtin_fram_address()
function.
genFrameAddressFtn
in class Generator
protected void genSignFtn(int dest, int laReg, int raReg, Type rType)
Generator
genSignFtn
in class Generator
protected void genAtan2Ftn(int dest, int laReg, int raReg, Type rType)
Generator
genAtan2Ftn
in class Generator
protected void genDimFtn(int dest, int laReg, int raReg, Type rType)
Generator
DIM()
intrinsic
function.
genDimFtn
in class Generator
public void visitNotExpr(NotExpr e)
public void visitReturnChord(ReturnChord c)
protected void storeRegToSymbolicLocation(int src, int dsize, long alignment, boolean isReal, Displacement disp)
storeRegToSymbolicLocation
in class Generator
src
- is the valuedsize
- is the size of the value in addressable memory unitsalignment
- 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 valuedisp
- specifies the locationprotected void storeLfae(LoadFieldAddressExpr lhs, Expr rhs)
storeLfae
in class Generator
lhs
- specifies the field of the structurerhs
- specifies the valueprotected boolean genSwitchUsingIfs(int testReg, Chord[] cases, long[] keys, int num, long spread)
Generator
switch
statement using
branches for each case.
genSwitchUsingIfs
in class Generator
testReg
- is the register holding the selected key valuecases
- is the list of CFG nodes for the switch caseskeys
- is the list of case valuesnum
- is the number of casesspread
- is a measure of the density of the cases values
protected void genSwitchUsingTransferVector(int testReg, Chord[] cases, long[] values, Label labd, long min, long max)
genSwitchUsingTransferVector
in class Generator
testReg
- is the register holding the selected key valuecases
- is the list of CFG nodes for the switch casesvalues
- is the list of case valueslabd
- is the label for the default casemin
- is the smallest case valuemax
- is the largest case valuepublic void visitVaStartExpr(VaStartExpr e)
visitVaStartExpr
in interface Predicate
visitVaStartExpr
in class Generator
public void visitVaArgExpr(VaArgExpr e)
public void visitConditionalExpr(ConditionalExpr e)
visitConditionalExpr
in interface Predicate
visitConditionalExpr
in class Generator
public void visitExprChord(ExprChord c)
visitExprChord
in interface Predicate
visitExprChord
in class Generator
public int getMaxAreaIndex()
Generator
getMaxAreaIndex
in class Generator
public Vector<VariableDecl> getVariables(java.lang.String func)
protected void __builtin_abs()
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |