|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object scale.backend.Generator scale.backend.sparc.SparcGenerator
public class SparcGenerator
This class converts Scribble into Sparc instructions.
$Id: SparcGenerator.java,v 1.214 2007-10-04 19:57:57 burrill Exp $
Copyright 2008 by the
Scale Compiler Group,
Department of Computer Science
University of Massachusetts,
Amherst MA. 01003, USA
All Rights Reserved.
Provides generated code for the following ISAs:
Field Summary | |
---|---|
static int |
ARG_SAVE_OFFSET
Offset to the argument save area. |
static int |
BSS
Un-initialized large data area. |
static int |
CANRESTORE
|
static int |
CANSAVE
|
static byte[] |
ccFlgTab
Map from CC code to CC flag. |
static java.lang.String[] |
ccTab
Map from CC code to string. |
static int |
CLEANWIN
|
static int |
COMMENT
Comment section. |
static int |
CWP
|
static int |
DATA
Initialized data area. |
static int |
DATA1
Initialized large data area. |
static int |
DEBUG
Debugging information. |
static int |
FCC0
Specifies the FCC0 condition code. |
static int |
FCC0Flg
|
static int |
FCC1
Specifies the FCC1 condition code. |
static int |
FCC1Flg
|
static int |
FCC2
Specifies the FCC2 condition code. |
static int |
FCC2Flg
|
static int |
FCC3
Specifies the FCC3 condition code. |
static int |
FCC3Flg
|
static int |
FINI
Finalization code |
static int |
FQ
|
static int |
FT_HH
|
static int |
FT_HI
|
static int |
FT_HM
|
static int |
FT_LO
|
static int |
FT_NONE
|
static java.lang.String[] |
ftns
|
static int |
ICC
Specifies the ICC condition code. |
static int |
ICCFlg
|
static int |
INIT
Initialization code |
static int |
LINE
Line number information. |
static int |
MAX_IMM13
|
static int |
MIN_IMM13
|
static int |
NOTE
Note information. |
static int |
OTHERWIN
|
static int |
PIL
|
static java.lang.String[] |
pRegs
|
static int |
PSTATE
|
static int |
RODATA
Initialized read-only data area. |
static int |
RODATA1
Initialized read-only large data area. |
static int |
SR_ASI
|
static int |
SR_ASR
|
static int |
SR_CCR
|
static int |
SR_FPRS
|
static int |
SR_PC
|
static int |
SR_STICK
|
static int |
SR_Y
State Registers |
static java.lang.String[] |
sRegs
|
static int |
TBA
|
static int |
TEXT
Instructions. |
static int |
TICK
|
static int |
TL
|
static int |
TNPC
|
static int |
TPC
Privileged Registers |
static int |
TSTATE
|
static int |
TT
|
static int |
VER
|
static int |
WSTATE
|
static int |
XCC
Specifies the XCC condition code. |
static int |
XCCFlg
|
static int |
YFlg
|
Fields inherited from class scale.backend.Generator |
---|
ADD, addrDisp, AND, annotateCode, ansic, ANSIC, branchPrediction, callsRoutine, cg, classTrace, codeMap, commutative, currentBeginMarker, currentRoutine, dataAreas, 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 | |
---|---|
SparcGenerator(CallGraph cg,
Machine machine,
int features)
|
Method Summary | |
---|---|
protected void |
addRegs(int laReg,
int raReg,
int dest)
Generate an add of address registers laRegraReg . |
protected int |
allocStackAddress(int adrReg,
Type type)
Allocate a location on the stack for storing a value of the specified size. |
void |
assemble(Emit emit,
java.lang.String source,
java.util.Enumeration<java.lang.String> comments)
Generate assembly language file. |
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 |
calcArrayElementAddress(ArrayIndexExpr aie,
long offseta)
Load the address of an array element into a register. |
protected short[] |
callArgs(Expr[] rtArgs,
boolean specialFirstArg)
Load the arguments into registers for a routine call. |
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 short[] |
createRoutineDefs(boolean isReal,
int bs)
Create a DefRegisters marker to specify the registers used to return the value of the routine. |
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. |
static java.lang.String |
displayDisp(Displacement disp,
int ftn)
Generate a String representation that can be used by the assembly code generater. |
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 |
endModule()
Called at the end of a module. |
protected void |
endRoutineCode(int[] regMap)
Called at the end of code generation for a routine. |
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 type)
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 |
generateProlog(ProcedureType pt)
This method is responsible for generating instructions to move function arguments to the position assigned by the layoutParameters method. |
void |
generateReturn(short[] uses)
Generate a function return. |
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 instructions to compute the floor of a real vaue in a real register to a real register. |
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 compared to zero. |
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 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 integer 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[] keys,
Label labd,
long min,
long max)
Generate the code for a switch statement using
branches for each case. |
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 |
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. |
java.lang.Object |
getSpillLocation(int reg)
Obtain the information needed for register spill loads and stores. |
Instruction |
insertSpillLoad(int reg,
java.lang.Object spillLocation,
Instruction after)
Insert the instruction(s) to restore a spilled register. |
Instruction |
insertSpillStore(int reg,
java.lang.Object spillLocation,
Instruction after)
Insert the instruction(s) to save a spilled register. |
protected void |
layoutParameters()
Assign the routine's arguments to registers or the stack. |
protected void |
loadArrayElement(ArrayIndexExpr aie,
int dest)
Load an array element into a register. |
protected void |
loadBitsFromMemory(int dest,
int address,
Displacement disp,
int dftn,
int bits,
int bitOffset,
int alignment,
boolean signed)
Generate instructions to load data from the specified data area. |
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 address,
int offset,
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 memory at the address in a register plus an offset. |
protected void |
loadFromMemoryX(int dest,
int address,
Displacement disp,
int dftn,
int size,
long alignment,
boolean signed)
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 |
move04(int src,
int dest)
Generate instructions to move a 4-byte (or less) value from one register to another. |
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 |
peepholeAfterRegisterAllocation(Instruction first)
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. |
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. |
int |
returnRegister(int regType,
boolean isCall)
Return the register used to return the function value. |
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,
Displacement disp,
int dftn,
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 memory at the address in a register plus an offset. |
protected void |
storeIntoMemoryX(int src,
int address,
int offset,
int size,
long alignment)
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. |
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 |
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 final int BSS
public static final int DATA
public static final int DATA1
public static final int RODATA
public static final int RODATA1
public static final int TEXT
public static final int COMMENT
public static final int DEBUG
public static final int FINI
public static final int INIT
public static final int LINE
public static final int NOTE
public static final int FCC0Flg
public static final int FCC1Flg
public static final int FCC2Flg
public static final int FCC3Flg
public static final int ICCFlg
public static final int XCCFlg
public static final int YFlg
public static final int FCC0
public static final int FCC1
public static final int FCC2
public static final int FCC3
public static final int ICC
public static final int XCC
public static final java.lang.String[] ccTab
public static final byte[] ccFlgTab
public static final int TPC
public static final int TNPC
public static final int TSTATE
public static final int TT
public static final int TICK
public static final int TBA
public static final int PSTATE
public static final int TL
public static final int PIL
public static final int CWP
public static final int CANSAVE
public static final int CANRESTORE
public static final int CLEANWIN
public static final int OTHERWIN
public static final int WSTATE
public static final int FQ
public static final int VER
public static final java.lang.String[] pRegs
public static final int SR_Y
public static final int SR_CCR
public static final int SR_ASI
public static final int SR_STICK
public static final int SR_PC
public static final int SR_FPRS
public static final int SR_ASR
public static final java.lang.String[] sRegs
public static final int FT_NONE
public static final int FT_HI
public static final int FT_LO
public static final int FT_HH
public static final int FT_HM
public static final java.lang.String[] ftns
public static final int MAX_IMM13
public static final int MIN_IMM13
public static final int ARG_SAVE_OFFSET
Constructor Detail |
---|
public SparcGenerator(CallGraph cg, Machine machine, int features)
cg
- is the call graph to be transformedmachine
- specifies machine detailsfeatures
- controls the instructions generated (not used)Method Detail |
---|
public void generateScribble()
generateScribble
in class Generator
protected void startModule()
startModule
in class Generator
protected void endModule()
endModule
in class Generator
protected void endRoutineCode(int[] regMap)
endRoutineCode
in class Generator
public static java.lang.String displayDisp(Displacement disp, int ftn)
protected void peepholeAfterRegisterAllocation(Instruction first)
peepholeAfterRegisterAllocation
in class Generator
public 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
- is mode of the registerprotected 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 declarationprotected 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 int loadMemoryAddress(Displacement disp)
loadMemoryAddress
in class Generator
disp
- specifies the address (should be a SymbolDisplacement
or offset of one)
protected int genLoadImmediate(long value, int dest)
genLoadImmediate
in class Generator
value
- is the value to loaddest
- is the register containing 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 int loadStackAddress(Displacement disp)
loadStackAddress
in class Generator
disp
- specifies the address (should be a SymbolDisplacement
or offset of one)
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 loadFromMemoryX(int dest, int address, Displacement disp, int dftn, int size, long alignment, boolean signed)
dest
- is the destination registeraddress
- is the register containing the address of the datadisp
- 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 extendedprotected void loadFromMemoryDoubleIndexing(int dest, int address, int offset, int size, long alignment, boolean signed, boolean real)
loadFromMemoryDoubleIndexing
in class Generator
dest
- is the destination registeraddress
- is the register containing the first indexoffset
- 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 real - this
argument is not used in this architecture and will be ignoredprotected void storeIntoMemoryX(int src, int address, int offset, int size, long alignment)
src
- is the source registeraddress
- is the register containing the address of the data
in memoryoffset
- is the register containing the offsetalignment
- is the alignment of the data (usually 1, 2, 4, or 8)protected void loadBitsFromMemory(int dest, int address, Displacement disp, int dftn, int bits, int bitOffset, int alignment, boolean signed)
dest
- is the destination registeraddress
- is the register containing the address of the datadisp
- specifies the offset from the address register valuedftn
- - FT_NONE, FT_LObits
- specifies the size of the data to be loaded in bits -
must be 32 or lessbitOffset
- specifies the offset to the field in bitsalignment
- specifies the alignment of the addresssigned
- is true if the data is to be sign extendedprotected void storeBitsIntoMemory(int src, int address, Displacement disp, int dftn, int bits, int bitOffset, int alignment)
src
- is the source registeraddress
- is the register containing the address of the data
in memorydisp
- specifies the offset from the address register valuedftn
- - FT_NONE, FT_LObits
- 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 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
- is the offset value - usually zerosize
- 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, 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 storeIntoMemoryWithOffset(int src, int address, long 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 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 real - this
argument is not used in this architecture and will be ignoredprotected 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 Displacement defStringValue(java.lang.String v, int size)
Generator
defStringValue
in class Generator
v
- is the stringsize
- is the length of the stringprotected Instruction startRoutineCode()
startRoutineCode
in class Generator
protected void move04(int src, int dest)
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)
laRegraReg
.
addRegs
in class Generator
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 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 short[] createRoutineDefs(boolean isReal, int bs)
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
protected void genFloorOfReal(int src, int srcSize, int dest, int destSize)
genFloorOfReal
in class Generator
protected void genRoundReal(int src, int srcSize, int dest, int destSize)
genRoundReal
in class Generator
protected void genRealToIntRound(int src, int srcSize, int dest, int destSize)
genRealToIntRound
in class Generator
protected void zeroFloatRegister(int dest, int destSize)
zeroFloatRegister
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 generateUnconditionalBranch(Label lab)
generateUnconditionalBranch
in class Generator
protected 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 move.aln
- 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 move.aln
- is the alignment that can be assumed for both the
source and destination addressespublic java.lang.Object getSpillLocation(int reg)
getSpillLocation
in class Generator
reg
- specifies which virtual register will be spilledprotected short[] callArgs(Expr[] rtArgs, boolean specialFirstArg)
callArgs
in class Generator
rtArgs
- is the set of argumentsspecialFirstArg
- is true if the first argument register is reserved
public void visitBitComplementExpr(BitComplementExpr e)
public void visitExponentiationExpr(ExponentiationExpr e)
public void visitDivisionExpr(DivisionExpr e)
public void visitRemainderExpr(RemainderExpr e)
public void generateReturn(short[] uses)
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 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 failspublic void visitNotExpr(NotExpr e)
protected 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)
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 type)
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
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[] keys, Label labd, long min, long max)
Generator
switch
statement using
branches for each case.
genSwitchUsingTransferVector
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 valueslabd
- is the label for the default casemin
- is the smallest case valuemax
- is the largest case valuepublic int getMaxAreaIndex()
Generator
getMaxAreaIndex
in class Generator
public 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 short[] genSingleUse(int reg)
Generator
genSingleUse
in class Generator
protected short[] genDoubleUse(int reg1, int reg2)
Generator
genDoubleUse
in class Generator
protected void layoutParameters()
layoutParameters
in class Generator
protected void doCompareOp(BinaryExpr c, CompareMode which)
doCompareOp
in class Generator
c
- is the compare expressionwhich
- specifies the compare (EQ, NE, ...)protected void genLoadImmediate(long value, int base, int dest)
genLoadImmediate
in class Generator
value
- is the value to loadbase
- is the base register (e.g., SparcRegisterSet.G0_REG)dest
- 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
public 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
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
getSpillLocation(int)
public void visitAbsoluteValueExpr(AbsoluteValueExpr e)
public void generateProlog(ProcedureType pt)
layoutParameters
method.
generateProlog
in class Generator
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 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 succeedspublic void visitNegativeExpr(NegativeExpr e)
public void visitConditionalExpr(ConditionalExpr e)
visitConditionalExpr
in interface Predicate
visitConditionalExpr
in class Generator
public void visitReturnChord(ReturnChord c)
public void visitVaStartExpr(VaStartExpr e)
visitVaStartExpr
in interface Predicate
visitVaStartExpr
in class Generator
public void visitVaArgExpr(VaArgExpr e)
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |