public abstract class IRTools extends Object
Constructor and Description |
---|
IRTools() |
Modifier and Type | Method and Description |
---|---|
static RegisterOperand |
A(Register reg)
Create an integer register operand for a given register.
|
static AddressConstantOperand |
AC(Address value)
Create an address constant operand with a given value.
|
static AddressConstantOperand |
AC(Offset value) |
static Instruction |
CPOS(Instruction src,
Instruction dst)
Copy the position information from the source instruction to
the destination instruction, returning the source instruction.
|
static RegisterOperand |
CR(Register reg)
Create a condition register operand for a given register.
|
static RegisterOperand |
D(Register reg)
Create a double register operand for a given register.
|
static DoubleConstantOperand |
DC(double value)
Create a long constant operand with a given value.
|
static boolean |
defDoublesAsUse(Operand d,
Instruction s)
Is the operand d, which is a def in instruction s, also a use
in instruction s?
|
static boolean |
definedIn(Register r,
Instruction s) |
static RegisterOperand |
F(Register reg)
Create a float register operand for a given register.
|
static FloatConstantOperand |
FC(float value)
Create a long constant operand with a given value.
|
static Operator |
getCondMoveOp(TypeReference type)
Returns the correct operator for a conditional move with the given data
type.
|
static Operand |
getDefaultOperand(TypeReference type)
Returns a constant operand with a default value for a given type
|
static Operator |
getLoadOp(FieldReference field,
boolean isStatic)
Returns the correct operator for loading from the given field
|
static Operator |
getLoadOp(TypeReference type,
boolean isStatic)
Returns the correct operator for loading a value of the given type
|
static Operator |
getMoveOp(TypeReference type)
Returns the correct operator for moving the given data type.
|
static Operator |
getStoreOp(FieldReference field,
boolean isStatic)
Returns the correct operator for storing to the given field.
|
static Operator |
getStoreOp(TypeReference type,
boolean isStatic)
Returns the correct operator for storing a value of the given type
|
static RegisterOperand |
I(Register reg)
Create an integer register operand for a given register.
|
static IntConstantOperand |
IC(int value)
Create an integer constant operand with a given value.
|
static void |
insertInstructionsAfter(Instruction after,
BasicBlock temp)
Inserts the instructions in the given basic block after the given
instruction.
|
static RegisterOperand |
L(Register reg)
Create a long register operand for a given register.
|
static LongConstantOperand |
LC(long value)
Create a long constant operand with a given value.
|
static BasicBlock |
makeBlockOnEdge(BasicBlock in,
BasicBlock out,
IR ir)
Make an empty basic block on an edge in the control flow graph,
and fix up the control flow graph and IR instructions accordingly.
|
static boolean |
mayBeVolatileFieldLoad(Instruction s)
Might this instruction be a load from a field that is declared
to be volatile?
|
static void |
moveInstruction(Instruction from,
Instruction to)
Moves the 'from' instruction to immediately before the 'to' instruction.
|
static RegisterOperand |
moveIntoRegister(GenericRegisterPool pool,
Instruction s,
Operand op)
Generates an instruction to move the given operand into a register, and
inserts it before the given instruction.
|
static RegisterOperand |
moveIntoRegister(TypeReference type,
Operator move_op,
GenericRegisterPool pool,
Instruction s,
Operand op)
Generates an instruction to move the given operand into a register, and
inserts it before the given instruction.
|
static Instruction |
nonPEIGC(Instruction instr)
Mark the parameter as nonGC and nonPEI and return it.
|
static Operand |
offsetOperand(Offset o)
Generates appropriately sized constant operand for a given Offset.
|
static TrueGuardOperand |
TG()
Create a new TrueGuardOperand.
|
static boolean |
usedIn(Register r,
Instruction s) |
static boolean |
useDoublesAsDef(Operand u,
Instruction s)
Is the operand u, which is a use in instruction s, also a def
in instruction s?
|
public IRTools()
public static RegisterOperand A(Register reg)
... Load.create(INT_LOAD, I(r2), A(r1), IC(4)) ...
reg
- the given registerpublic static RegisterOperand I(Register reg)
... Load.create(INT_LOAD, I(r2), A(r1), IC(4)) ...
reg
- the given registerpublic static RegisterOperand F(Register reg)
... Load.create(FLOAT_LOAD, F(r2), A(r1), IC(4)) ...
reg
- the given registerpublic static RegisterOperand D(Register reg)
... Load.create(DOUBLE_LOAD, D(r2), A(r1), IC(4)) ...
reg
- the given registerpublic static RegisterOperand L(Register reg)
... Binary.create(LONG_LOAD, L(r2), A(r1), IC(4)) ...
reg
- the given registerpublic static RegisterOperand CR(Register reg)
... Binary.create(INT_CMP, CR(c2), I(r1), IC(4)) ...
reg
- the given registerpublic static AddressConstantOperand AC(Address value)
...<op>.create(...., AC(Address.zero()) ...
value
- The address constantpublic static AddressConstantOperand AC(Offset value)
public static IntConstantOperand IC(int value)
...<op>.create(...., IC(0) ...
value
- The int constantpublic static LongConstantOperand LC(long value)
...<op>.create(...., LC(0L) ...
value
- the long valuepublic static FloatConstantOperand FC(float value)
...<op>.create(...., FC(0L) ...
value
- the float valuepublic static DoubleConstantOperand DC(double value)
...<op>.create(...., DC(0L) ...
value
- the double valuepublic static TrueGuardOperand TG()
...<op>.create(...., TG() ...
public static Operand offsetOperand(Offset o)
o
- an offsetIntConstantOperand
(32-bit)
or LongConstantOperand
(64-bit)public static Instruction CPOS(Instruction src, Instruction dst)
instr.insertBack(CPOS(instr, Load.create(...)));
src
- the instruction to copy position information fromdst
- the instruction to copy position information topublic static Operand getDefaultOperand(TypeReference type)
type
- desired typepublic static Operator getMoveOp(TypeReference type)
type
- desired type to movepublic static Operator getCondMoveOp(TypeReference type)
type
- desired type to movepublic static Operator getLoadOp(FieldReference field, boolean isStatic)
field
- field to load fromisStatic
- is the field staticpublic static Operator getLoadOp(TypeReference type, boolean isStatic)
type
- type of value to loadisStatic
- is the field staticpublic static Operator getStoreOp(FieldReference field, boolean isStatic)
field
- The field we're asking aboutisStatic
- is the field staticpublic static Operator getStoreOp(TypeReference type, boolean isStatic)
type
- desired type to storeisStatic
- is the field staticpublic static RegisterOperand moveIntoRegister(GenericRegisterPool pool, Instruction s, Operand op)
pool
- register pool to allocate froms
- instruction to insert beforeop
- operand to copy to a registerpublic static RegisterOperand moveIntoRegister(TypeReference type, Operator move_op, GenericRegisterPool pool, Instruction s, Operand op)
type
- type to movemove_op
- move operator to usepool
- register pool to allocate froms
- instruction to insert beforeop
- operand to copy to a registerpublic static void moveInstruction(Instruction from, Instruction to)
from
- instruction to moveto
- instruction after where you want it movedpublic static void insertInstructionsAfter(Instruction after, BasicBlock temp)
after
- instruction after where you want it insertedtemp
- basic block which contains the instructions to be inserted.public static BasicBlock makeBlockOnEdge(BasicBlock in, BasicBlock out, IR ir)
in -> bb -> out.Precondition : There is an edge in the control flow graph from * in -> out.
in
- the source of the control flow edgeout
- the sink of the control flow edgeir
- the governing IRpublic static boolean useDoublesAsDef(Operand u, Instruction s)
TODO!!: This implementation is slow. Think about adding some IR support for this functionality; possibly add methods like enumeratePureDefs(), enumerateImpureUses(), etc ..., and restructure the caller to avoid having to call this function. Not going to put effort into this now, as the whole scratch register architecture has a questionable future.
u
- the operand that's a uses
- the instruction that u is a use intrue
if the operand is both a use and a defpublic static boolean defDoublesAsUse(Operand d, Instruction s)
TODO!!: This implementation is slow. Think about adding some IR support for this functionality; possibly add methods like enumeratePureDefs(), enumerateImpureUses(), etc ..., and restructure the caller to avoid having to call this function. Not going to put effort into this now, as the whole scratch register architecture has a questionable future.
d
- the operand that's a defs
- the instruction that d is a def intrue
if the operand is both a use and a defpublic static boolean definedIn(Register r, Instruction s)
public static boolean usedIn(Register r, Instruction s)
public static Instruction nonPEIGC(Instruction instr)
instr.insertBack(notPEIGC(Load.create(...)));
instr
- the given instructionpublic static boolean mayBeVolatileFieldLoad(Instruction s)
s
- the insruction to checktrue
if the instruction might be a load
from a volatile field or false
if it
cannot be a load from a volatile field