|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object scale.backend.Generator
public abstract class Generator
This class is the base class for code generators.
$Id: Generator.java,v 1.303 2007-10-04 19:57:48 burrill Exp $
Copyright 2008 by the
Scale Compiler Group,
Department of Computer Science
University of Massachusetts,
Amherst MA. 01003, USA
All Rights Reserved.
A generator translates Scribble CFGs into a linear sequence of machine instructions.
The primary rule: Thou shall not use a register obtained from a visit() as a destination register until all other registers obtained from visit() have been used for the last time for the simple reason that they may be the same register.
The secondary rule:Thou shall not define the destination register until the very last instruction in the sequence for the simple reason that the register allocator does not know where a sequence begins and ends.
The most important methods are those dealing with the calling
conventions. The visitCallFunctionExpr
method operates the viewpoint of the caller
and generates the instructions to call a sub-function. The generateProlog
, layoutParameters
, and endRoutineCode
methods operate from the viewpoint of the callee.
Field Summary | |
---|---|
protected static int |
ADD
Add operation |
protected Displacement |
addrDisp
Last displacement generated for an address. |
protected static int |
AND
Bit and operation |
static boolean |
annotateCode
True if annotation comments are to be generated. |
protected boolean |
ansic
True if ANSI C source code specified. |
static int |
ANSIC
Specify ANSI C. |
protected double |
branchPrediction
Probability of most recent IfThenElseChord taking the true branch. |
protected boolean |
callsRoutine
True if this routine calls another routine. |
protected CallGraph |
cg
The call graph being processed. |
static boolean |
classTrace
True if traces are to be performed. |
protected HashMap<java.lang.String,SpaceAllocation> |
codeMap
Map from routine to instructions. |
protected static boolean[] |
commutative
Is the dyadic operation commutative? |
protected Marker |
currentBeginMarker
Mark the start of the routine's code. |
protected RoutineDecl |
currentRoutine
The declaration associated with this routine. |
protected SpaceAllocation[] |
dataAreas
Array of data areas - indexed by handle. |
static int |
DEBUG
Debug info should be generated. |
protected static int |
DIV
Divide operation |
protected static int[] |
fieldAlignment
Map from lower three bits of an offset to the alignment. |
protected boolean |
genDebugInfo
True if information for debuggers should be generated. |
protected Instruction |
lastInstruction
Last instruction generated. |
protected Label |
lastLabel
Last label generated. |
static int |
LINENUM
Generate source line information. |
protected boolean |
lineNumbers
True if source line number information should be placed in the assembly code. |
protected boolean |
little
True if target machine is little-endian. |
protected Machine |
machine
Machine specific information. |
protected static int |
MOD
Modulo operation |
protected static int |
MUL
Multiply operation |
protected boolean |
naln
True if we assume indirect loads are not aligned. |
static int |
NALN
Indirect loads are not aligned. |
protected int |
nextArea
Next available in dataAreas. |
protected boolean |
nis
True if instructions should not be scheduled. |
static int |
NIS
Inhibit instruction scheduling. |
protected boolean |
nph
True if the peephole optimizer should not be run. |
static int |
NPH
Inhibit peephole optimization. |
protected static java.lang.String[] |
operation
Map operation to string. |
protected static int |
OR
Bit or operation |
protected boolean |
predicatedOnTrue
Indicates if an expression predicated by predicateReg
is predicated on true or false. |
protected int |
predicateReg
Register containing the current predicate. |
protected int |
readOnlyDataArea
The data area to use to for constant data. |
protected RegisterSet |
registers
The register set definition. |
protected int |
resultReg
Register containing the last generated expression result, usually as a result of a call to visit(). |
protected int |
resultRegAddressAlignment
If resultRegMode is ResultMode.ADDRESS ,
this value is alignment of the address contained in the register
specified by resultReg . |
protected long |
resultRegAddressOffset
If resultRegMode is ResultMode.ADDRESS ,
this value is offset from the address contained in the register
specified by resultReg . |
protected ResultMode |
resultRegMode
The type of the resultReg value. |
protected long |
resultRegSize
If resultRegMode is ResultMode.STRUCT_VALUE ,
this value is size of the struct contained in the register
specified by resultReg . |
protected Instruction |
returnInst
The instruction just before the one and only return instruction. |
protected Scribble |
scribble
The CFG associated with this routine. |
protected static int |
SLL
Shift left logical operation |
protected static int |
SRA
Shift right arithmetic operation |
protected static int |
SRL
Shift right logical operation |
protected int |
stkPtrReg
The register to use to access the stack frame for the function. |
protected static int |
SUB
Subtract operation |
protected Chord |
successorCFGNode
The successor to the current CFG node. |
protected boolean |
trace
True if tracing requested. |
protected UniqueName |
un
Generate unique names for constants in memory. |
protected boolean |
useMemory
True if programmer variables should be placed in memory. |
protected boolean |
usesAlloca
True if the current routine uses __builtin_alloca() . |
protected boolean |
usesVaStart
True if the current routine uses va_start() . |
protected static int |
XOR
Bit exclusive or operation |
Constructor Summary | |
---|---|
Generator(CallGraph cg,
RegisterSet registers,
Machine machine,
int features)
This class is used to convert the Scribble CFG to machine instructions. |
Method Summary | |
---|---|
protected abstract void |
addRegs(int laReg,
int raReg,
int dest)
Generate an add of address registers laReg and
raReg . |
void |
adjustImmediates(Instruction firstInstruction)
Adjust large immediate values. |
protected int |
allocateData(java.lang.String name,
int section,
int type,
long size,
boolean readOnly,
java.lang.Object value,
int reps,
int alignment)
Return the handle of a new memory area. |
protected int[] |
allocateRegisters(Instruction first,
boolean trace)
Generate a mapping from virtual register to real register and then modify the instructions to use real registers. |
int |
allocateTextArea(java.lang.String name,
int area)
Return the handle of a new area of memory to contain instructions. |
protected int |
allocateWithData(java.lang.String name,
Type type,
long ts,
Expression init,
int area,
boolean readOnly,
int reps,
int aln)
Allocate an area for the data specified by the Clef Expression. |
protected abstract int |
allocStackAddress(int adrReg,
Type type)
Allocate a location on the stack for storing a value of the specified size. |
protected void |
appendCallInstruction(Branch call,
Label lab,
short[] uses,
short[] kills,
short[] defs,
boolean genLabel)
Append the subroutine call instruction to the end of the sequence of instructions. |
protected void |
appendInstruction(Instruction inst)
Append the instruction to the end of the sequence of instructions. |
protected void |
appendLabel(Label label)
Append the label to the end of the sequence of instructions. |
abstract void |
assemble(Emit emit,
java.lang.String source,
java.util.Enumeration<java.lang.String> comments)
Generate assembly language. |
protected abstract void |
assignDeclToMemory(java.lang.String name,
VariableDecl vd)
Assign the specified variable to a location in memory using the specified name. |
protected abstract void |
assignDeclToRegister(VariableDecl vd)
Assign the specified variable to a register. |
protected abstract void |
assignDeclToStack(VariableDecl vd)
Assign the specified variable to a location in the stack frame. |
void |
associateDispWithArea(int handle,
Displacement disp)
Associate a displacement with an area. |
static int |
avoidedAddressCalcs()
Return the number of variable address calculations that were eliminated. |
static int |
avoidedLoads()
Return the number of variable loads that were eliminated. |
protected void |
basicBlockEnd()
Called after the last CFG node in a basic block is processed. |
protected void |
calcAddressAndOffset(Expr exp,
long offset)
Load the address generated by an expression into a register. |
protected abstract void |
calcArrayElementAddress(ArrayIndexExpr aie,
long offset)
Load the address of an array element into a register. |
protected void |
calcFieldAddress(LoadFieldAddressExpr c,
long offset)
Calculate the offset and base address of a field. |
protected void |
calcFieldOffsets(AggregateType at)
Determine the offsets for fields of a struct or union. |
protected abstract short[] |
callArgs(Expr[] args,
boolean specialFirstArg)
Load the arguments into registers for a routine call. |
protected void |
convertCFG(Chord start)
Generate the instructions for the CFG node. |
protected abstract 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 void |
copyPropagate(Instruction first)
Copy-propagate register numbers from move instructions. |
Label |
createLabel()
Create a new Label and return it. |
protected Label |
createNewLabel()
Allocate a machine-specific label. |
abstract 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 abstract Displacement |
defStringValue(java.lang.String v,
int size)
Return the displacement for a string. |
protected void |
doBinaryOp(BinaryExpr c,
int which)
Generate instructions to do a binary operation on two values. |
protected abstract void |
doBinaryOp(int which,
Type ct,
Expr la,
Expr ra,
int dest)
Generate instructions to do a binary operation on two values. |
protected abstract void |
doCompareOp(BinaryExpr c,
CompareMode which)
Generate instructions to do a comparison of two values. |
protected boolean |
doNext(Chord nxt)
Make sure the specified Chord is converted next. |
protected void |
doStore(Expr lhs,
Expr rhs,
boolean vaCopy)
Generate code for a copy (i.e., assignment). |
protected void |
doVaCopy(Expr lhs,
Expr rhs)
Generate code for a va_copy(). |
protected void |
endModule()
Called at the end of a call graph (module). |
protected abstract void |
endRoutineCode(int[] regMap)
Called at the end of code generation for a routine. |
Displacement |
findAreaDisp(int section,
int type,
boolean readOnly,
long size,
double value,
int alignment)
Find an allocation of a floating point value. |
Displacement |
findAreaDisp(int section,
int type,
boolean readOnly,
long size,
long value,
int alignment)
Find an allocation of a long value. |
Displacement |
findAreaDisp(int section,
int type,
boolean readOnly,
long size,
java.lang.String value,
int alignment)
Find an allocation of a String value. |
protected void |
findLastInstruction(Instruction firstInstruction)
Find the last instruction. |
protected abstract void |
genAcosFtn(int dest,
int src,
Type type)
Generate the code for the acos() function. |
protected abstract void |
genAlloca(Expr arg,
int reg)
Generate the code for the alloca() function. |
protected abstract void |
genAsinFtn(int dest,
int src,
Type type)
Generate the code for the asin() function. |
protected abstract void |
genAtan2Ftn(int dest,
int laReg,
int raReg,
Type rType)
Generate the code for the Fortran ATAN2() intrinsic function. |
protected abstract void |
genAtanFtn(int dest,
int src,
Type type)
Generate the code for the atan() function. |
protected abstract void |
genConjgFtn(int dest,
int src,
Type type)
Generate the code for the conjg() function. |
protected abstract void |
genCosFtn(int dest,
int src,
Type type)
Generate the code for the cos() function. |
protected abstract void |
genCoshFtn(int dest,
int src,
Type type)
Generate the code for the cosh() function. |
protected abstract void |
genDimFtn(int dest,
int laReg,
int raReg,
Type rType)
Generate the code for the Fortran DIM() intrinsic
function. |
protected abstract short[] |
genDoubleUse(int reg1,
int reg2)
Generate the array of registers that a call to a function requires. |
void |
generate()
Generate the machine instructions for each routine in the call graph. |
void |
generateConditionalBranch(int which,
int treg,
Label l)
Generate a predicated branch to a single location. |
protected abstract 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. |
protected abstract void |
generateUnconditionalBranch(Label lab)
Generate an unconditional branch to the label specified. |
protected abstract void |
genExpFtn(int dest,
int src,
Type type)
Generate the code for the exp() function. |
protected abstract void |
genFloorOfReal(int src,
int srcSize,
int dest,
int destSize)
Generate instructions to compute the floor of a real vaue in a real register to a real register. |
protected abstract void |
genFrameAddressFtn(int dest,
int src,
Type type)
Generate the code for the builtin_fram_address() function. |
protected abstract 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,
Expr predicate,
Chord tc,
Chord fc)
Generate a branch based on the value of an expression compared to zero. |
protected void |
genIfRegister(CompareMode which,
int treg,
boolean signed,
Chord tc,
Chord fc)
Generate a branch based on the value of an expression compared to zero. |
protected abstract void |
genIfRegister(CompareMode which,
int treg,
boolean signed,
Label labt,
Label labf)
Generate a branch based on the value of an expression compared to zero. |
protected abstract void |
genIfRelational(boolean rflag,
MatchExpr predicate,
Chord tc,
Chord fc)
Generate a branch based on a relational expression. |
protected abstract 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 abstract int |
genLoadDblImmediate(double value,
int dest,
int destSize)
Generate instructions to load an immediate integer value into a register. |
protected abstract long |
genLoadHighImmediate(long value,
int base)
Generate instructions to calculate a valid offset. |
protected abstract int |
genLoadImmediate(long value,
int dest)
Generate instructions to load an immediate integer value into a register. |
protected abstract 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 abstract void |
genLog10Ftn(int dest,
int src,
Type type)
Generate the code for the log10() function. |
protected abstract void |
genLogFtn(int dest,
int src,
Type type)
Generate the code for the log() function. |
protected abstract 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 abstract 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 abstract 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 abstract void |
genRegToReg(int src,
int dest)
Generate instructions to move data from one register to another. |
protected abstract void |
genReturnAddressFtn(int dest,
int src,
Type type)
Generate the code for the builtin_return_address() function. |
protected abstract 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 abstract void |
genSignFtn(int dest,
int laReg,
int raReg,
Type rType)
Generate the code for the Fortran SIGN() intrinsic function. |
protected abstract void |
genSinFtn(int dest,
int src,
Type type)
Generate the code for the sin() function. |
protected abstract short[] |
genSingleUse(int reg)
Generate the array of registers that a call to a function requires. |
protected abstract void |
genSinhFtn(int dest,
int src,
Type type)
Generate the code for the sinh() function. |
protected abstract void |
genSqrtFtn(int dest,
int src,
Type type)
Generate the code for the sqrt() function. |
protected abstract 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 abstract void |
genSwitchUsingTransferVector(int testReg,
Chord[] cases,
long[] keys,
Label dflt,
long min,
long max)
Generate the code for a switch statement using
branches for each case. |
protected abstract void |
genTanFtn(int dest,
int src,
Type type)
Generate the code for the tan() function. |
protected abstract void |
genTanhFtn(int dest,
int src,
Type type)
Generate the code for the tanh() function. |
protected void |
genTrueFalseBranch(int predicate,
Chord tc,
Chord fc)
Generate a branch based on the value of an expression which is guaranteed to be either 0 or 1. |
protected abstract 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. |
protected Label |
getBranchLabel(Chord location)
Return the label for a branch location. |
protected Chord |
getBranchTarget(Chord s)
Skip nodes that don't result in generating instructions. |
CallGraph |
getCallGraph()
Return the call graph
associated with this invocation of the code generator. |
RoutineDecl |
getCurrentRoutine()
Return the current routine being processed. |
protected IntegerDisplacement |
getDisp(int value)
Generate an integer displacement. |
abstract int |
getFirstArgRegister(int regType)
Return the register used as the first argument in a function call. |
Label |
getLabel(int index)
Return the label whose index is specified. |
Machine |
getMachine()
Return the machine definition in use. |
abstract int |
getMaxAreaIndex()
Return the maximum area index value. |
java.lang.String |
getName(int handle)
Return the name associated with an area of memory. |
RegisterSet |
getRegisterSet()
Return the register set definition in use. |
int |
getSAType(Type type)
Return the SpaceAllocation type for the specified Type. |
SourceLanguage |
getSourceLanguage()
Return the source language of the original program. |
SpaceAllocation |
getSpaceAllocation(int handle)
Return the SpaceAllocation
associated with the specified handle. |
abstract java.lang.Object |
getSpillLocation(int reg)
Obtain the information needed for register spill loads and stores. |
int |
getStackPtr()
Return the register assignment of the stack pointer. |
protected Instruction |
insertInstruction(Instruction inst,
Instruction location)
Insert the instruction after the specified instruction. |
protected Instruction |
insertLabel(Label label,
Instruction location)
Insert the label after the specified instruction. |
abstract Instruction |
insertSpillLoad(int reg,
java.lang.Object spillLocation,
Instruction after)
Insert the instruction(s) to restore a spilled register. |
abstract Instruction |
insertSpillStore(int reg,
java.lang.Object spillLocation,
Instruction after)
Insert the instruction(s) to save a spilled register. |
protected boolean |
isAssignedRegister(int reg)
Return true if the register is assigned to a variable. |
boolean |
isFortran()
Return true if the source language is Fortran. |
boolean |
isSimple(Expr arg)
Return true if the expression will not result in a call to a routine. |
protected void |
labelCfgForBackend()
Label the basic blocks. |
protected abstract void |
layoutParameters()
Determine the layout of routine parameters for the call. |
protected abstract void |
loadArrayElement(ArrayIndexExpr aie,
int dest)
Load an array element into a register. |
protected void |
loadDeclValue(Declaration decl,
Type vt,
boolean isPredicated)
Load the value of a declaration into a register. |
protected abstract 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 abstract 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 abstract 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 abstract void |
loadFromMemoryWithOffset(int dest,
int address,
long 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 abstract int |
loadMemoryAddress(Displacement disp)
Load an address of a memory location into a register. |
protected abstract void |
loadRegFromSymbolicLocation(int dest,
int dsize,
boolean isSigned,
boolean isReal,
Displacement disp)
Load a register from a symbolic location in memory. |
protected abstract int |
loadStackAddress(Displacement disp)
Load an address of a stack location into a register. |
protected void |
loadVariable(VariableDecl vd,
Type vt,
boolean isPredicated)
Load the value of a variable into a register. |
protected void |
loadVariableFromCommon(int adr,
Type vt,
long offset)
Load the value of a variable in COMMON into a register. |
protected void |
loadVariableFromMemory(Displacement vdisp,
Type vt)
Load the value of a variable in memory into a register. |
protected void |
loadVariableFromStack(Displacement vdisp,
Type vt)
Load the value of a variable on the stack into a register. |
protected void |
moveInstructionSequence(Instruction prior,
Instruction last,
Instruction after)
Move a sequence of instructions to another position. |
protected abstract 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 abstract 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 |
needValue(Expr exp)
Process the expression and if the result is an address value, add any offset required to the base address. |
protected void |
needValue(int src,
long srcoff,
ResultMode srcha)
If the register contains an address value, add any offset required to the base address. |
int |
newLabel()
Create a new Label and return its index. |
protected void |
peepholeAfterRegisterAllocation(Instruction first)
Do peephole optimizations after registers are allocated. |
protected void |
peepholeBeforeRegisterAllocation(Instruction first)
Do peephole optimizations before registers are allocated. |
protected void |
processDecls()
Process the declarations of this CFG. |
protected abstract void |
processRoutineDecl(RoutineDecl rd,
boolean topLevel)
The RoutineDecl is assigned a tag. |
protected abstract void |
processSourceLine(int line,
Label label,
boolean newLine)
The user has requested source line information be included. |
protected Type |
processType(Declaration decl)
Insure that all types have their register types specified and all structure fields have had their offsets determined. |
protected Type |
processType(Expr expr)
Insure that all types have their register types specified and all structure fields have had their offsets determined. |
protected Type |
processType(Expression expr)
Insure that all types have their register types specified and all structure fields have had their offsets determined. |
protected Type |
processType(Type type)
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 td)
Called for every TypeName
instance so that the target code generator can perform any needed
processing such as making Stabs entries. |
protected void |
processVariableDecl(VariableDecl vd,
boolean topLevel)
The VariableDecl is assigned a tag. |
protected void |
propagate(Instruction inst,
int newReg,
int oldReg)
Perform copy propagation for the specified registers within the basic block that begins with the specified instruction. |
protected void |
putAddressInRegister(Declaration decl,
boolean isPredicated)
Load the address of a declaration into a register. |
protected void |
putAddressInRegister(Expr expr)
Place the address of the argument in a register. |
protected void |
putAddressInRegisterNO(Declaration decl,
boolean isPredicated)
Load the address of a declaration into a register and place any offset into resultRegAddressOffset . |
static int |
regeneratedAddresses()
Return the number of spill loads that were avoided because of regenerating the address value. |
static int |
regeneratedLiterals()
Return the number of spills were avoided because of regenerating the literal value. |
static int |
regeneratedValues()
Return the number of spills were avoided because of regenerating the value. |
protected Instruction |
regenerateRegister(int reg,
Instruction after)
Regenerate a register value instead of performing a spill load. |
boolean |
removeUnneededInstructions(Instruction first)
Remove instructions that do not change the machine state. |
protected void |
resetForBasicBlock()
This method is called at the end of each basic block and at the start before any CFG nodes are processed. |
abstract int |
returnRegister(int regType,
boolean isCall)
Return the register used to return the function value. |
protected void |
saveGeneratedCode(Instruction first)
Save the generated code in a TEXT section using the name of the current routine. |
protected boolean |
shouldBeRegenerated(int reg)
Return true if the value in the register can be easily regenerated. |
protected void |
specifyInReg(Declaration decl,
int reg,
ResultMode regha)
Specify that the value of a variable kept in memory is now in a register. |
protected void |
startModule()
Called at the beginning of a call graph (module). |
protected abstract Instruction |
startRoutineCode()
Called at the start of code generation for a routine. |
protected abstract 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 abstract 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 abstract void |
storeIntoMemoryWithOffset(int src,
int address,
long 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 |
storeLdae(LoadDeclAddressExpr lhs,
Expr rhs)
Store a value into a variable. |
protected void |
storeLdve(LoadDeclValueExpr lhs,
Expr rhs)
Store a value into the location specied by an address in a variable. |
protected abstract void |
storeLfae(LoadFieldAddressExpr lhs,
Expr rhs)
Store a value into a field of a structure. |
protected void |
storeLiteral(LiteralExpr le,
Expr rhs)
Store a value into the location specied by a literal value. |
protected void |
storeLvie(LoadValueIndirectExpr lhs,
Expr rhs)
Store a value into the location specied by the value of an expression. |
protected abstract 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 boolean |
unconditionalBranchNeeded(Chord c,
Chord nxt,
java.lang.Object actual)
Return true if an unconditional branch is needed. |
void |
updateLabelIndex(Label label)
Update the unique identifier for a label. |
protected long |
valueOf(SizeofLiteral il)
Return the value of the SizeofLiteral. |
void |
visitAdditionExpr(AdditionExpr e)
|
void |
visitAllocateExpr(AllocateExpr e)
|
void |
visitAndExpr(AndExpr e)
|
void |
visitArrayIndexExpr(ArrayIndexExpr e)
|
void |
visitBeginChord(BeginChord c)
|
void |
visitBinaryExpr(BinaryExpr e)
|
void |
visitBitAndExpr(BitAndExpr e)
|
void |
visitBitOrExpr(BitOrExpr e)
|
void |
visitBitShiftExpr(BitShiftExpr e)
|
void |
visitBitXorExpr(BitXorExpr e)
|
void |
visitBranchChord(BranchChord c)
|
void |
visitCallExpr(CallExpr e)
|
void |
visitCallMethodExpr(CallMethodExpr e)
|
void |
visitChord(Chord c)
|
void |
visitComplexValueExpr(ComplexValueExpr e)
|
void |
visitConditionalExpr(ConditionalExpr e)
|
void |
visitConversionExpr(ConversionExpr e)
|
void |
visitDecisionChord(DecisionChord c)
|
void |
visitDualExpr(DualExpr e)
|
void |
visitEndChord(EndChord c)
|
void |
visitEqualityExpr(EqualityExpr e)
|
void |
visitExitChord(ExitChord c)
|
void |
visitExpr(Expr e)
|
void |
visitExprChord(ExprChord c)
|
void |
visitExprPhiExpr(ExprPhiExpr e)
|
void |
visitGotoChord(GotoChord c)
|
void |
visitGreaterEqualExpr(GreaterEqualExpr e)
|
void |
visitGreaterExpr(GreaterExpr e)
|
void |
visitIfThenElseChord(IfThenElseChord c)
|
void |
visitLeaveChord(LeaveChord c)
|
void |
visitLessEqualExpr(LessEqualExpr e)
|
void |
visitLessExpr(LessExpr e)
|
void |
visitLiteralExpr(LiteralExpr e)
|
void |
visitLoadDeclAddressExpr(LoadDeclAddressExpr e)
|
void |
visitLoadDeclValueExpr(LoadDeclValueExpr e)
|
void |
visitLoadExpr(LoadExpr e)
|
void |
visitLoadFieldAddressExpr(LoadFieldAddressExpr e)
|
void |
visitLoadFieldValueExpr(LoadFieldValueExpr e)
|
void |
visitLoadValueIndirectExpr(LoadValueIndirectExpr lvie)
|
void |
visitLoopExitChord(LoopExitChord c)
|
void |
visitLoopHeaderChord(LoopHeaderChord c)
|
void |
visitLoopInitChord(LoopInitChord c)
|
void |
visitLoopPreHeaderChord(LoopPreHeaderChord c)
|
void |
visitLoopTailChord(LoopTailChord c)
|
void |
visitMarkerChord(MarkerChord c)
|
void |
visitMaxExpr(MaxExpr e)
|
void |
visitMinExpr(MinExpr e)
|
void |
visitNaryExpr(NaryExpr e)
|
void |
visitNilExpr(NilExpr e)
|
void |
visitNote(Note n)
|
void |
visitNotEqualExpr(NotEqualExpr e)
|
void |
visitNullChord(NullChord c)
|
void |
visitOrExpr(OrExpr e)
|
void |
visitPhiExpr(PhiExpr e)
|
void |
visitPhiExprChord(PhiExprChord c)
|
void |
visitSequentialChord(SequentialChord c)
|
void |
visitSubscriptExpr(SubscriptExpr e)
|
void |
visitSubtractionExpr(SubtractionExpr e)
|
void |
visitSwitchChord(SwitchChord c)
|
void |
visitTernaryExpr(TernaryExpr e)
|
void |
visitTranscendental2Expr(Transcendental2Expr e)
|
void |
visitTranscendentalExpr(TranscendentalExpr e)
|
void |
visitUnaryExpr(UnaryExpr e)
|
void |
visitVaEndExpr(VaEndExpr e)
|
void |
visitValueExpr(ValueExpr e)
|
void |
visitVarArgExpr(VarArgExpr e)
|
void |
visitVaStartExpr(VaStartExpr e)
|
void |
visitVectorExpr(VectorExpr e)
|
protected void |
whatIsThis(Note n)
Generate an error. |
protected abstract 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 |
Methods inherited from interface scale.score.Predicate |
---|
visitAbsoluteValueExpr, visitBitComplementExpr, visitCallFunctionExpr, visitCompareExpr, visitDivisionExpr, visitExponentiationExpr, visitMultiplicationExpr, visitNegativeExpr, visitNotExpr, visitRemainderExpr, visitReturnChord, visitVaArgExpr |
Field Detail |
---|
public static final int DEBUG
public static final int NALN
public static final int NIS
public static final int NPH
public static final int ANSIC
public static final int LINENUM
public static boolean classTrace
public static boolean annotateCode
protected static final int ADD
commutative
,
Constant Field Valuesprotected static final int SUB
commutative
,
Constant Field Valuesprotected static final int MUL
commutative
,
Constant Field Valuesprotected static final int DIV
commutative
,
Constant Field Valuesprotected static final int AND
commutative
,
Constant Field Valuesprotected static final int OR
commutative
,
Constant Field Valuesprotected static final int XOR
commutative
,
Constant Field Valuesprotected static final int SRA
commutative
,
Constant Field Valuesprotected static final int SRL
commutative
,
Constant Field Valuesprotected static final int SLL
commutative
,
Constant Field Valuesprotected static final int MOD
commutative
,
Constant Field Valuesprotected static final boolean[] commutative
protected static final java.lang.String[] operation
protected static final int[] fieldAlignment
protected boolean trace
protected boolean little
protected boolean useMemory
protected boolean genDebugInfo
protected boolean naln
protected boolean nis
protected boolean nph
protected boolean ansic
protected boolean lineNumbers
protected boolean usesAlloca
__builtin_alloca()
.
protected boolean usesVaStart
va_start()
.
protected boolean callsRoutine
protected Chord successorCFGNode
null
if the last CFG node generated a branch.
protected RoutineDecl currentRoutine
protected Scribble scribble
protected Displacement addrDisp
protected Marker currentBeginMarker
protected CallGraph cg
protected Instruction lastInstruction
protected Label lastLabel
protected Instruction returnInst
protected RegisterSet registers
protected SpaceAllocation[] dataAreas
protected int nextArea
protected HashMap<java.lang.String,SpaceAllocation> codeMap
protected Machine machine
protected UniqueName un
protected int stkPtrReg
protected int readOnlyDataArea
protected ResultMode resultRegMode
resultReg
value.
ResultMode
protected int resultReg
It is very important that the register returned as a result of a visit NEVER be used as the destination of any instruction; It may be the register containing a variable. And, if a source register must be used in multiple instructions, the destination register must not be used for intermediate values.
protected int resultRegAddressAlignment
resultRegMode
is ResultMode.ADDRESS
,
this value is alignment of the address contained in the register
specified by resultReg
. The value 8 is used to
specify the normal alignment for variables and the value 1 is
used if the alignment is not known. Typical values are 8 and 4.
Note - this alignment does not account for the value in
resultRegAddressOffset
.
protected long resultRegAddressOffset
resultRegMode
is ResultMode.ADDRESS
,
this value is offset from the address contained in the register
specified by resultReg
.
resultRegMode
protected long resultRegSize
resultRegMode
is ResultMode.STRUCT_VALUE
,
this value is size of the struct contained in the register
specified by resultReg
.
resultRegMode
protected int predicateReg
predicateReg
is -1, there is no predicate set.
protected boolean predicatedOnTrue
predicateReg
is predicated on true or false.
protected double branchPrediction
Constructor Detail |
---|
public Generator(CallGraph cg, RegisterSet registers, Machine machine, int features)
cg
- is the call graph to be usedregisters
- is the register set definition to be usedmachine
- specifies the target architecturefeatures
- contains various flags that control the backendMethod Detail |
---|
public static int avoidedLoads()
public static int avoidedAddressCalcs()
public static int regeneratedAddresses()
public static int regeneratedValues()
public static int regeneratedLiterals()
public Machine getMachine()
public RoutineDecl getCurrentRoutine()
public RegisterSet getRegisterSet()
public int getStackPtr()
public final boolean isFortran()
public void generate()
protected void processTypeDecl(TypeDecl td, boolean complete)
TypeDecl
instance so that the target code generator can perform any needed
processing such as making Stabs entries.
protected void processTypeName(TypeName td)
TypeName
instance so that the target code generator can perform any needed
processing such as making Stabs entries.
protected void startModule()
protected void endModule()
protected void labelCfgForBackend()
protected void findLastInstruction(Instruction firstInstruction)
public void generateScribble()
public void adjustImmediates(Instruction firstInstruction)
protected void saveGeneratedCode(Instruction first)
protected void processDecls()
protected void defineDeclInRegister(Declaration decl, int register, ResultMode regha)
decl
- is the variableregister
- is the register allocated for the variableregha
- is mode of the registerprotected void defineDeclOnStack(Declaration decl, Displacement disp)
decl
- is the variabledisp
- - displacement associated with declarationprotected void defineDeclInMemory(Declaration decl, Displacement disp)
decl
- is the variabledisp
- - displacement associated with declarationprotected void defineDeclInCommon(Declaration decl, Displacement disp)
decl
- is the variabledisp
- - displacement associated with declarationprotected void defineRoutineInfo(RoutineDecl rd, Displacement disp)
rd
- is the routinedisp
- - displacement associated with declarationprotected void calcFieldOffsets(AggregateType at)
protected int[] allocateRegisters(Instruction first, boolean trace)
protected boolean doNext(Chord nxt)
protected void copyPropagate(Instruction first)
protected void propagate(Instruction inst, int newReg, int oldReg)
protected void resetForBasicBlock()
protected void convertCFG(Chord start)
protected boolean unconditionalBranchNeeded(Chord c, Chord nxt, java.lang.Object actual)
c
- is the current nodenxt
- is the successor to the current nodeactual
- is the actual node that will be converted to
assembly nextprotected void basicBlockEnd()
protected final Chord getBranchTarget(Chord s)
public boolean removeUnneededInstructions(Instruction first)
protected void peepholeBeforeRegisterAllocation(Instruction first)
protected void peepholeAfterRegisterAllocation(Instruction first)
protected void processVariableDecl(VariableDecl vd, boolean topLevel)
For register-assigned variable, the virtual register is specified. For stack-assigned variables, the stack offset is assigned. (The stack offset will be adjusted later.) For memory-assigned variables, a data area is created.
vd
- is the declarationtopLevel
- is true if this declaration is defined outside of
a routineprotected abstract void assignDeclToMemory(java.lang.String name, VariableDecl vd)
VariableDecl.getStorageLoc()
protected abstract void assignDeclToRegister(VariableDecl vd)
VariableDecl.getStorageLoc()
protected abstract void assignDeclToStack(VariableDecl vd)
VariableDecl.getStorageLoc()
protected abstract void processRoutineDecl(RoutineDecl rd, boolean topLevel)
rd
- is the declarationtopLevel
- is true if this declaration is defined outside of a routinepublic abstract java.lang.Object getSpillLocation(int reg)
reg
- specifies which virtual register will be spilledpublic abstract Instruction insertSpillLoad(int reg, java.lang.Object spillLocation, Instruction after)
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
getSpillLocation(int)
public abstract Instruction insertSpillStore(int reg, java.lang.Object spillLocation, Instruction after)
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
getSpillLocation(int)
public abstract int returnRegister(int regType, boolean isCall)
regType
- specifies the type of valueisCall
- is true if the calling routine is askingpublic abstract int getFirstArgRegister(int regType)
regType
- specifies the type of argument valueprotected boolean shouldBeRegenerated(int reg)
protected Instruction regenerateRegister(int reg, Instruction after)
public void generateConditionalBranch(int which, int treg, Label l)
which
- specifies the branch test (EQ, NE, LT, ...)treg
- specifies the condition to testl
- is the label to branch to.public abstract void assemble(Emit emit, java.lang.String source, java.util.Enumeration<java.lang.String> comments)
emit
- is the stream to use.source
- is the source file namecomments
- is a list of Strings containing commentsprotected abstract void generateUnconditionalBranch(Label lab)
protected abstract void processSourceLine(int line, Label label, boolean newLine)
line
- is the current line numberlabel
- is the last label encountered or null
newLine
- is true if a new source line with no labelprotected abstract Instruction startRoutineCode()
protected abstract void endRoutineCode(int[] regMap)
protected abstract void layoutParameters()
The generateProlog
method generates instructions to move the
arguments to the location determined by this method.
protected abstract void generateProlog(ProcedureType pt)
layoutParameters
method.
protected abstract void storeLfae(LoadFieldAddressExpr lhs, Expr rhs)
lhs
- specifies the field of the structurerhs
- specifies the valueprotected void loadVariableFromStack(Displacement vdisp, Type vt)
resultReg
.
vdisp
- is the variable displacementvt
- specifies the type of the valueprotected void loadVariableFromCommon(int adr, Type vt, long offset)
resultReg
.
adr
- specifies the base addressvt
- specifies the type of the valueoffset
- is the offset of the variable from the base of commonprotected void loadVariableFromMemory(Displacement vdisp, Type vt)
resultReg
.
vdisp
- is the variable displacementvt
- specifies the type of the valueprotected abstract void loadRegFromSymbolicLocation(int dest, int dsize, boolean isSigned, boolean isReal, Displacement disp)
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 abstract void loadFromMemoryWithOffset(int dest, int address, long offset, int size, long alignment, boolean signed, boolean real)
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 a realprotected abstract void loadFromMemoryWithOffset(int dest, int address, Displacement offset, int size, long alignment, boolean signed, boolean real)
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 a realprotected abstract void loadFromMemoryDoubleIndexing(int dest, int index1, int index2, int size, long alignment, boolean signed, boolean real)
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 abstract void loadArrayElement(ArrayIndexExpr aie, int dest)
aie
- specifies the array elementdest
- specifies the registerprotected abstract void storeIntoMemoryWithOffset(int src, int address, long offset, int size, long alignment, boolean real)
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 realprotected abstract void storeIntoMemoryWithOffset(int src, int address, Displacement offset, int size, long alignment, boolean real)
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 realprotected abstract void storeRegToSymbolicLocation(int src, int dsize, long alignment, boolean isReal, Displacement disp)
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 abstract void storeIntoMemory(int src, int address, int size, long alignment, boolean real)
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 putAddressInRegister(Declaration decl, boolean isPredicated)
resultReg
. The
resultRegAddressOffset
value is always 0. The
resultRegMode
value is always
ResultMode.NORMAL_VALUE
.
decl
- specifies the declarationisPredicated
- is true if this sequence of instructions will
be predicatedprotected void putAddressInRegisterNO(Declaration decl, boolean isPredicated)
resultRegAddressOffset
. The register is
specified in resultReg
. The
resultRegMode
value is always
ResultMode.NORMAL_VALUE
.
decl
- specifies the declarationisPredicated
- is true if this sequence of instructions will
be predicatedprotected void specifyInReg(Declaration decl, int reg, ResultMode regha)
protected boolean isAssignedRegister(int reg)
protected void calcAddressAndOffset(Expr exp, long offset)
resultRegAddressOffset
and the address is in
resultReg
.
exp
- specifies the expressionoffset
- is the offset from the addressprotected abstract void calcArrayElementAddress(ArrayIndexExpr aie, long offset)
resultRegAddressOffset
.
The address is specified in resultReg
.
aie
- specifies the array elementxpressionoffset
- is the offset from the addressprotected void putAddressInRegister(Expr expr)
resultRegAddressOffset
value is always 0.
The resultRegMode
value is always false
.
Return the register containing the address in resultReg
.
protected abstract int allocStackAddress(int adrReg, Type type)
adrReg
- specifies the register to receive the addresstype
- is the type of the value
protected abstract Displacement defStringValue(java.lang.String v, int size)
v
- is the stringsize
- is the length of the stringprotected abstract int loadMemoryAddress(Displacement disp)
disp
- specifies the address (should be a SymbolDisplacement
or offset of one)
protected abstract int loadStackAddress(Displacement disp)
disp
- specifies the address (should be a SymbolDisplacement
or offset of one)
protected abstract int genLoadImmediate(long value, int dest)
value
- is the value to loaddest
- is the register conatining the result
protected abstract long genLoadHighImmediate(long value, int base)
value
- is the value to add to the base addressbase
- is the base address
protected abstract int genLoadDblImmediate(double value, int dest, int destSize)
value
- is the value to loaddest
- is the register conatining the resultdestSize
- is the size of the value
public abstract int dataType(int size, boolean flt)
size
- is the size in memory unitsflt
- is true for floating point valuesSpaceAllocation
protected abstract void genRegToReg(int src, int dest)
src
- specifies the source registerdest
- specifies the destination registerprotected abstract void addRegs(int laReg, int raReg, int dest)
laReg
and
raReg
.
protected abstract void moveWords(int src, long srcoff, int dest, long destoff, int size, int aln)
src
- specifies the register containing the source addresssrcoff
- specifies the offset from the addressdest
- specifies the register containing the destination
addressdestoff
- specifies the offset from the addresssize
- specifes the number of bytes to movealn
- is the alignment that can be assumed for both the
source and destination addressesprotected abstract void moveWords(int src, long srcoff, int dest, Displacement destoff, int size, int aln)
src
- specifies the register containing the source addresssrcoff
- specifies the offset from the addressdest
- specifies the register containing the destination addressdestoff
- specifies the offset from the addresssize
- specifes the number of bytes to movealn
- is the alignment that can be assumed for both the
source and destination addressesprotected abstract void genIfRegister(CompareMode which, int treg, boolean signed, Label labt, Label labf)
which
- specifies the branch test (EQ, NE, LT, ...)treg
- specifies the register containing the valuesigned
- is true if the value is signedlabt
- specifies the path if the test failslabf
- specifies the path if the test succeedsprotected abstract void genLoadImmediate(long value, int base, int dest)
value
- is the value to loadbase
- is the base register (e.g., AlphaRegisterSet.I0_REG)dest
- is the register conatining the resultprotected abstract void genIfRelational(boolean rflag, MatchExpr predicate, Chord tc, Chord fc)
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 abstract Branch genFtnCall(java.lang.String name, short[] uses, short[] defs)
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
protected abstract short[] callArgs(Expr[] args, boolean specialFirstArg)
args
- is the set of argumentsspecialFirstArg
- is true if the first argument register is reserved
protected void doBinaryOp(BinaryExpr c, int which)
c
- is the binary expressionwhich
- specifies the binary operation (ADD, SUB, ...)protected abstract void doBinaryOp(int which, Type ct, Expr la, Expr ra, int dest)
which
- specifies the binary operation (ADD, SUB, ...)ct
- is the result typela
- is the left argumentra
- is the right argumentdest
- is the destination registerprotected abstract void doCompareOp(BinaryExpr c, CompareMode which)
c
- is the compare expressionwhich
- specifies the compare (EQ, NE, ...)public abstract int getMaxAreaIndex()
protected final IntegerDisplacement getDisp(int value)
value
- specifies the value of the displacement
protected Type processType(Type type)
protected Type processType(Declaration decl)
protected Type processType(Expr expr)
protected Type processType(Expression expr)
protected void appendInstruction(Instruction inst)
protected void appendCallInstruction(Branch call, Label lab, short[] uses, short[] kills, short[] defs, boolean genLabel)
call
- is the call instructionlab
- is the label of the call return pointuses
- specifies what registers are used by the callkills
- specifies what registers are killed by the calldefs
- specifies what registers are defined by the callgenLabel
- if the return label should be appendedprotected void appendLabel(Label label)
protected Instruction insertInstruction(Instruction inst, Instruction location)
protected Instruction insertLabel(Label label, Instruction location)
public void updateLabelIndex(Label label)
protected void moveInstructionSequence(Instruction prior, Instruction last, Instruction after)
prior
- is the instruction prior to the first instruction in
the sequencelast
- is the last instruction in the sequenceafter
- is the instruction to insert the sequence afterprotected Label createNewLabel()
public final Label createLabel()
public final int newLabel()
public final Label getLabel(int index)
protected final Label getBranchLabel(Chord location)
public final SpaceAllocation getSpaceAllocation(int handle)
SpaceAllocation
associated with the specified handle.
public final Displacement findAreaDisp(int section, int type, boolean readOnly, long size, double value, int alignment)
section
- specifies the section in which the loader should
place the areatype
- specifies the type of datareadOnly
- is true if the area is read-onlysize
- is the number of addressable units requiredvalue
- is the initial data value for the areaalignment
- specifies the address alignment required
SpaceAllocation
public final Displacement findAreaDisp(int section, int type, boolean readOnly, long size, long value, int alignment)
section
- specifies the section in which the loader should
place the areatype
- specifies the type of datareadOnly
- is true if the area is read-onlysize
- is the number of addressable units requiredvalue
- is the initial data value for the areaalignment
- specifies the address alignment required
SpaceAllocation
public final Displacement findAreaDisp(int section, int type, boolean readOnly, long size, java.lang.String value, int alignment)
section
- specifies the section in which the loader should
place the areatype
- specifies the type of datareadOnly
- is true if the area is read-onlysize
- is the number of addressable units requiredvalue
- is the initial data value for the areaalignment
- specifies the address alignment required
SpaceAllocation
public final void associateDispWithArea(int handle, Displacement disp)
protected long valueOf(SizeofLiteral il)
protected final int allocateWithData(java.lang.String name, Type type, long ts, Expression init, int area, boolean readOnly, int reps, int aln)
name
- is the name of the datatype
- is the type of the variablets
- is the size of the area to allocateinit
- is the initial valuearea
- is the data area to usereadOnly
- is true if the data should be read-onlyreps
- is the number os times to repeat the data to fill the areaaln
- is the required alignment for the data
public int getSAType(Type type)
protected final int allocateData(java.lang.String name, int section, int type, long size, boolean readOnly, java.lang.Object value, int reps, int alignment)
name
- is the name of the area (variable, routine, etc) or
nullsection
- specifies the section in which the loader should
place the areatype
- specifies the type of datasize
- is the number of addressable units requiredreadOnly
- is true if the area is read-onlyvalue
- is the initial data value for the areareps
- is the number of times the value must be replicatedalignment
- specifies the address alignment requiredSpaceAllocation
public final int allocateTextArea(java.lang.String name, int area)
public final java.lang.String getName(int handle)
public final SourceLanguage getSourceLanguage()
public final CallGraph getCallGraph()
call graph
associated with this invocation of the code generator.
protected void whatIsThis(Note n)
protected final void needValue(Expr exp)
resultReg
, et al.
protected final void needValue(int src, long srcoff, ResultMode srcha)
resultReg
, et al.
protected void loadVariable(VariableDecl vd, Type vt, boolean isPredicated)
resultReg
. If the value can not be loaded into a
register, return the 2's complement of the register containing
the address of the data.
vd
- specifies the variablevt
- specifies the type of the valuepublic boolean isSimple(Expr arg)
public void visitLoadDeclAddressExpr(LoadDeclAddressExpr e)
visitLoadDeclAddressExpr
in interface Predicate
protected void loadDeclValue(Declaration decl, Type vt, boolean isPredicated)
public void visitLoadValueIndirectExpr(LoadValueIndirectExpr lvie)
visitLoadValueIndirectExpr
in interface Predicate
public void visitLoadDeclValueExpr(LoadDeclValueExpr e)
visitLoadDeclValueExpr
in interface Predicate
public void visitLoadFieldAddressExpr(LoadFieldAddressExpr e)
visitLoadFieldAddressExpr
in interface Predicate
public void visitLoadFieldValueExpr(LoadFieldValueExpr e)
visitLoadFieldValueExpr
in interface Predicate
protected abstract void loadFieldValue(FieldDecl fd, long fieldOffset, int adr, ResultMode adrha, int adraln, long adrrs, int dest)
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 calcFieldAddress(LoadFieldAddressExpr c, long offset)
resultReg
member. Return the offset from the
address in resultRegAddressOffset
. The address is
specified in resultReg
.
offset
- is the initial offset (normally 0)public void visitArrayIndexExpr(ArrayIndexExpr e)
visitArrayIndexExpr
in interface Predicate
public void visitBeginChord(BeginChord c)
visitBeginChord
in interface Predicate
public void visitExitChord(ExitChord c)
visitExitChord
in interface Predicate
protected abstract short[] genSingleUse(int reg)
protected abstract short[] genDoubleUse(int reg1, int reg2)
public void visitExprChord(ExprChord c)
visitExprChord
in interface Predicate
protected void doStore(Expr lhs, Expr rhs, boolean vaCopy)
protected void doVaCopy(Expr lhs, Expr rhs)
public void visitIfThenElseChord(IfThenElseChord c)
visitIfThenElseChord
in interface Predicate
public void visitSwitchChord(SwitchChord c)
visitSwitchChord
in interface Predicate
protected abstract boolean genSwitchUsingIfs(int testReg, Chord[] cases, long[] keys, int num, long spread)
switch
statement using
branches for each case.
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 abstract void genSwitchUsingTransferVector(int testReg, Chord[] cases, long[] keys, Label dflt, long min, long max)
switch
statement using
branches for each case.
testReg
- is the register holding the selected key valuecases
- is the list of CFG nodes for the switch caseskeys
- is the list of case valuesdflt
- is the label for the default casemin
- is the smallest case valuemax
- is the largest case valueprotected void genTrueFalseBranch(int predicate, Chord tc, Chord fc)
predicate
- specifies the register to testtc
- specifies the path if the test succeedsfc
- specifies the path if the test failsprotected void genIfRegister(CompareMode which, Expr predicate, Chord tc, Chord fc)
which
- specifies the branch test (EQ, NE, LT, ...)predicate
- specifies the condition to testtc
- specifies the path if the test succeedsfc
- specifies the path if the test failsprotected void genIfRegister(CompareMode which, int treg, boolean signed, Chord tc, Chord fc)
which
- specifies the branch test (EQ, NE, LT, ...)treg
- specifies the condition (register value) to testsigned
- is true if the value is signedtc
- specifies the path if the test succeedsfc
- specifies the path if the test failspublic void visitAdditionExpr(AdditionExpr e)
visitAdditionExpr
in interface Predicate
public void visitAndExpr(AndExpr e)
visitAndExpr
in interface Predicate
public void visitBitAndExpr(BitAndExpr e)
visitBitAndExpr
in interface Predicate
public void visitBitOrExpr(BitOrExpr e)
visitBitOrExpr
in interface Predicate
public void visitBitXorExpr(BitXorExpr e)
visitBitXorExpr
in interface Predicate
public void visitOrExpr(OrExpr e)
visitOrExpr
in interface Predicate
public void visitSubtractionExpr(SubtractionExpr e)
visitSubtractionExpr
in interface Predicate
public void visitBitShiftExpr(BitShiftExpr e)
visitBitShiftExpr
in interface Predicate
protected abstract void genAtan2Ftn(int dest, int laReg, int raReg, Type rType)
protected abstract void genSignFtn(int dest, int laReg, int raReg, Type rType)
protected abstract void genDimFtn(int dest, int laReg, int raReg, Type rType)
DIM()
intrinsic
function.
protected abstract void genSqrtFtn(int dest, int src, Type type)
sqrt()
function.
protected abstract void genAlloca(Expr arg, int reg)
alloca()
function.
protected abstract void genExpFtn(int dest, int src, Type type)
exp()
function.
protected abstract void genLogFtn(int dest, int src, Type type)
log()
function.
protected abstract void genLog10Ftn(int dest, int src, Type type)
log10()
function.
protected abstract void genSinFtn(int dest, int src, Type type)
sin()
function.
protected abstract void genCosFtn(int dest, int src, Type type)
cos()
function.
protected abstract void genTanFtn(int dest, int src, Type type)
tan()
function.
protected abstract void genAsinFtn(int dest, int src, Type type)
asin()
function.
protected abstract void genAcosFtn(int dest, int src, Type type)
acos()
function.
protected abstract void genAtanFtn(int dest, int src, Type type)
atan()
function.
protected abstract void genSinhFtn(int dest, int src, Type type)
sinh()
function.
protected abstract void genCoshFtn(int dest, int src, Type type)
cosh()
function.
protected abstract void genTanhFtn(int dest, int src, Type type)
tanh()
function.
protected abstract void genConjgFtn(int dest, int src, Type type)
conjg()
function.
protected abstract void genReturnAddressFtn(int dest, int src, Type type)
builtin_return_address()
function.
protected abstract void genFrameAddressFtn(int dest, int src, Type type)
builtin_fram_address()
function.
public void visitTranscendentalExpr(TranscendentalExpr e)
visitTranscendentalExpr
in interface Predicate
public void visitTranscendental2Expr(Transcendental2Expr e)
visitTranscendental2Expr
in interface Predicate
public void visitCallMethodExpr(CallMethodExpr e)
visitCallMethodExpr
in interface Predicate
public void visitComplexValueExpr(ComplexValueExpr e)
visitComplexValueExpr
in interface Predicate
protected abstract int convertIntRegValue(int src, int srcSize, boolean srcSigned, int dest, int destSize, boolean destSigned)
The semantics are that the register passed in as
dest
is the register the caller wants used. But,
the register returned as the value of the method is the actual
register used which may or may not be dest
. For
example, the register passed in as the source may not need to be
modified. Thus, a move can be avoided if src
is
used instead of the specified destination. In some cases the
source may be a register that is a hard-wired zero such as $31 on
the alpha or %g0 on the sparc. The caller may still need to do a
genRegToReg if it must have the result in the specified register.
Note that genRegToReg
generates no move if the
source and destination registers are the same.
src
- is the register containing the source valuesrcSize
- is the source value sizesrcSigned
- is true if the source value is signeddest
- is the suggested register to contain the resultdestSize
- is the size of the result valuedestSigned
- is true if the result value is signed
protected abstract int genRealToInt(int src, int srcSize, int dest, int destSize, boolean destSigned)
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 abstract void genRealToReal(int src, int srcSize, int dest, int destSize)
protected abstract void genIntToReal(int src, int srcSize, int dest, int destSize)
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 abstract void genUnsignedIntToReal(int src, int srcSize, int dest, int destSize)
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 abstract void genRealToIntRound(int src, int srcSize, int dest, int destSize)
protected abstract void genRoundReal(int src, int srcSize, int dest, int destSize)
protected abstract void genFloorOfReal(int src, int srcSize, int dest, int destSize)
protected abstract void zeroFloatRegister(int dest, int destSize)
public void visitConversionExpr(ConversionExpr e)
visitConversionExpr
in interface Predicate
public void visitDualExpr(DualExpr e)
visitDualExpr
in interface Predicate
public void visitEqualityExpr(EqualityExpr e)
visitEqualityExpr
in interface Predicate
public void visitGreaterEqualExpr(GreaterEqualExpr e)
visitGreaterEqualExpr
in interface Predicate
public void visitGreaterExpr(GreaterExpr e)
visitGreaterExpr
in interface Predicate
public void visitLessEqualExpr(LessEqualExpr e)
visitLessEqualExpr
in interface Predicate
public void visitLessExpr(LessExpr e)
visitLessExpr
in interface Predicate
public void visitNotEqualExpr(NotEqualExpr e)
visitNotEqualExpr
in interface Predicate
public void visitLiteralExpr(LiteralExpr e)
visitLiteralExpr
in interface Predicate
public void visitNilExpr(NilExpr e)
visitNilExpr
in interface Predicate
protected void storeLiteral(LiteralExpr le, Expr rhs)
le
- specifies the literalrhs
- specifies the valueprotected void storeLdve(LoadDeclValueExpr lhs, Expr rhs)
lhs
- specifies the variablerhs
- specifies the valueprotected void storeLvie(LoadValueIndirectExpr lhs, Expr rhs)
lhs
- specifies the expressionrhs
- specifies the valueprotected void storeLdae(LoadDeclAddressExpr lhs, Expr rhs)
lhs
- specifies the variablerhs
- specifies the valuepublic void visitVaStartExpr(VaStartExpr e)
visitVaStartExpr
in interface Predicate
public void visitAllocateExpr(AllocateExpr e)
visitAllocateExpr
in interface Predicate
public void visitBinaryExpr(BinaryExpr e)
public void visitBranchChord(BranchChord c)
public void visitCallExpr(CallExpr e)
public void visitChord(Chord c)
public void visitDecisionChord(DecisionChord c)
public void visitExpr(Expr e)
public void visitExprPhiExpr(ExprPhiExpr e)
visitExprPhiExpr
in interface Predicate
public void visitLoadExpr(LoadExpr e)
public void visitMaxExpr(MaxExpr e)
visitMaxExpr
in interface Predicate
public void visitMinExpr(MinExpr e)
visitMinExpr
in interface Predicate
public void visitNaryExpr(NaryExpr e)
public void visitNote(Note n)
public void visitMarkerChord(MarkerChord c)
visitMarkerChord
in interface Predicate
public void visitGotoChord(GotoChord c)
visitGotoChord
in interface Predicate
public void visitLoopExitChord(LoopExitChord c)
visitLoopExitChord
in interface Predicate
public void visitLoopHeaderChord(LoopHeaderChord c)
visitLoopHeaderChord
in interface Predicate
public void visitLoopPreHeaderChord(LoopPreHeaderChord c)
visitLoopPreHeaderChord
in interface Predicate
public void visitLoopTailChord(LoopTailChord c)
visitLoopTailChord
in interface Predicate
public void visitLoopInitChord(LoopInitChord c)
visitLoopInitChord
in interface Predicate
public void visitNullChord(NullChord c)
visitNullChord
in interface Predicate
public void visitPhiExpr(PhiExpr e)
visitPhiExpr
in interface Predicate
public void visitPhiExprChord(PhiExprChord c)
visitPhiExprChord
in interface Predicate
public void visitSequentialChord(SequentialChord c)
public void visitEndChord(EndChord c)
visitEndChord
in interface Predicate
public void visitLeaveChord(LeaveChord c)
public void visitSubscriptExpr(SubscriptExpr e)
visitSubscriptExpr
in interface Predicate
public void visitTernaryExpr(TernaryExpr e)
public void visitUnaryExpr(UnaryExpr e)
public void visitValueExpr(ValueExpr e)
public void visitVarArgExpr(VarArgExpr e)
public void visitVaEndExpr(VaEndExpr e)
visitVaEndExpr
in interface Predicate
public void visitVectorExpr(VectorExpr e)
visitVectorExpr
in interface Predicate
public void visitConditionalExpr(ConditionalExpr e)
visitConditionalExpr
in interface Predicate
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |