org.jikesrvm.compilers.opt.hir2lir
Class ConvertToLowLevelIR

java.lang.Object
  extended by org.jikesrvm.compilers.opt.ir.IRTools
      extended by org.jikesrvm.compilers.opt.hir2lir.ConvertToLowLevelIR
Direct Known Subclasses:
DynamicTypeCheckExpansion

public abstract class ConvertToLowLevelIR
extends IRTools

Converts all remaining instructions with HIR-only operators into an equivalent sequence of LIR operators.


Field Summary
private static BranchOptimizations branchOpts
           
static boolean LOWER_ARRAY_ACCESS
          We have slightly different ideas of what the LIR should look like for IA32 and PowerPC.
 
Constructor Summary
ConvertToLowLevelIR()
           
 
Method Summary
private static BasicBlock _lookupswitchHelper(Instruction switchInstr, RegisterOperand reg, BasicBlock defaultBB, IR ir, BasicBlock curBlock, int low, int high, int min, int max)
          Helper function to generate the binary search tree for a lookupswitch bytecode
(package private) static Instruction callHelper(Instruction v, IR ir)
          Helper method for call expansion.
(package private) static void convert(IR ir, OptOptions options)
          Converts the given HIR to LIR.
static void doArrayLoad(Instruction s, IR ir, Operator op, int logwidth)
          Expand an array load.
static void doArrayStore(Instruction s, IR ir, Operator op, int logwidth)
          Expand an array store.
static void expandSysCallTarget(Instruction s, IR ir)
          Expand symbolic SysCall target into a chain of loads from the bootrecord to the desired target address.
static RegisterOperand getField(Instruction s, IR ir, RegisterOperand obj, RVMField field)
          Load an instance field.
(package private) static RegisterOperand getField(Instruction s, IR ir, RegisterOperand obj, RVMField field, Operand guard)
          Load an instance field.
(package private) static RegisterOperand getInstanceMethod(Instruction s, IR ir, Operand tib, RVMMethod method)
          Get an instance method from a TIB
(package private) static RegisterOperand getSpecialMethod(Instruction s, IR ir, int smid)
          support for direct call to specialized method.
static RegisterOperand getStatic(Instruction s, IR ir, RVMField field)
          Load a static field.
(package private) static Operand getTIB(Instruction s, IR ir, Operand obj, Operand guard)
          get the tib from the object pointer to by obj
(package private) static Operand getTIB(Instruction s, IR ir, RVMType type)
          get the class tib for type
(package private) static Operand getTIB(Instruction s, IR ir, TypeOperand type)
          get the class tib for type
static RegisterOperand insertBinary(Instruction s, IR ir, Operator operator, TypeReference type, Operand o1, Operand o2)
          Insert a binary instruction before s in the instruction stream.
(package private) static RegisterOperand InsertGuardedUnary(Instruction s, IR ir, Operator operator, TypeReference type, Operand o1, Operand guard)
          Insert a guarded unary instruction before s in the instruction stream.
(package private) static RegisterOperand InsertLoadOffset(Instruction s, IR ir, Operator operator, TypeReference type, Operand reg2, Offset offset)
          Insert a load off before s in the instruction stream.
(package private) static RegisterOperand InsertLoadOffset(Instruction s, IR ir, Operator operator, TypeReference type, Operand reg2, Offset offset, LocationOperand loc, Operand guard)
          Insert a load off before s in the instruction stream.
(package private) static RegisterOperand InsertLoadOffset(Instruction s, IR ir, Operator operator, TypeReference type, Operand reg2, Offset offset, Operand guard)
          Insert a load off before s in the instruction stream.
(package private) static RegisterOperand InsertLoadOffset(Instruction s, IR ir, Operator operator, TypeReference type, Operand reg2, Operand offset, LocationOperand loc, Operand guard)
          Insert a load off before s in the instruction stream.
(package private) static RegisterOperand InsertLoadOffsetJTOC(Instruction s, IR ir, Operator operator, TypeReference type, Offset offset)
          Insert a load off the JTOC before s in the instruction stream.
(package private) static RegisterOperand InsertLoadOffsetJTOC(Instruction s, IR ir, Operator operator, TypeReference type, Operand offset)
          Insert a load off the JTOC before s in the instruction stream.
(package private) static RegisterOperand InsertUnary(Instruction s, IR ir, Operator operator, TypeReference type, Operand o1)
          Insert a unary instruction before s in the instruction stream.
(package private) static Instruction lookup(Instruction switchInstr, IR ir)
          Expand a lookupswitch.
private static Instruction resolveMember(Instruction s, IR ir)
          Generate the code to resolve a member (field/method) reference.
(package private) static Instruction tableswitch(Instruction s, IR ir)
          Expand a tableswitch.
 
Methods inherited from class org.jikesrvm.compilers.opt.ir.IRTools
A, AC, AC, CPOS, CR, D, DC, defDoublesAsUse, definedIn, F, FC, getCondMoveOp, getDefaultOperand, getLoadOp, getLoadOp, getMoveOp, getStoreOp, getStoreOp, I, IC, insertInstructionsAfter, L, LC, makeBlockOnEdge, mayBeVolatileFieldLoad, moveInstruction, moveIntoRegister, moveIntoRegister, nonPEIGC, TG, usedIn, useDoublesAsDef
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

LOWER_ARRAY_ACCESS

public static final boolean LOWER_ARRAY_ACCESS
We have slightly different ideas of what the LIR should look like for IA32 and PowerPC. The main difference is that for IA32 instead of bending over backwards in BURS to rediscover array loads, (where we can use base + index*scale addressing modes), we'll leave array loads in the LIR.

See Also:
Constant Field Values

branchOpts

private static BranchOptimizations branchOpts
Constructor Detail

ConvertToLowLevelIR

public ConvertToLowLevelIR()
Method Detail

convert

static void convert(IR ir,
                    OptOptions options)
Converts the given HIR to LIR.

Parameters:
ir - IR to convert

tableswitch

static Instruction tableswitch(Instruction s,
                               IR ir)
Expand a tableswitch.

Parameters:
s - the instruction to expand
ir - the containing IR
Returns:
the last Instruction in the generated LIR sequence.

lookup

static Instruction lookup(Instruction switchInstr,
                          IR ir)
Expand a lookupswitch.

Parameters:
switchInstr - The instruction to expand
ir - The containing IR
Returns:
the next Instruction after the generated LIR sequence.

_lookupswitchHelper

private static BasicBlock _lookupswitchHelper(Instruction switchInstr,
                                              RegisterOperand reg,
                                              BasicBlock defaultBB,
                                              IR ir,
                                              BasicBlock curBlock,
                                              int low,
                                              int high,
                                              int min,
                                              int max)
Helper function to generate the binary search tree for a lookupswitch bytecode

Parameters:
switchInstr - the lookupswitch instruction
defaultBB - the basic block of the default case
ir - the ir object
curBlock - the basic block to insert instructions into
reg - the RegisterOperand that contains the valued being switched on
low - the low index of cases (operands of switchInstr)
high - the high index of cases (operands of switchInstr)
min -
max -
Returns:
the last basic block created

doArrayLoad

public static void doArrayLoad(Instruction s,
                               IR ir,
                               Operator op,
                               int logwidth)
Expand an array load.

Parameters:
s - the instruction to expand
ir - the containing IR
op - the load operator to use
logwidth - the log base 2 of the element type's size

doArrayStore

public static void doArrayStore(Instruction s,
                                IR ir,
                                Operator op,
                                int logwidth)
Expand an array store.

Parameters:
s - the instruction to expand
ir - the containing IR
op - the store operator to use
logwidth - the log base 2 of the element type's size

callHelper

static Instruction callHelper(Instruction v,
                              IR ir)
Helper method for call expansion.

Parameters:
v - the call instruction
ir - the containing IR
Returns:
the last expanded instruction

resolveMember

private static Instruction resolveMember(Instruction s,
                                         IR ir)
Generate the code to resolve a member (field/method) reference.

Parameters:
s - the RESOLVE_MEMBER instruction to expand
ir - the containing ir object
Returns:
the last expanded instruction

insertBinary

public static RegisterOperand insertBinary(Instruction s,
                                           IR ir,
                                           Operator operator,
                                           TypeReference type,
                                           Operand o1,
                                           Operand o2)
Insert a binary instruction before s in the instruction stream.

Parameters:
s - the instruction to insert before
ir - the containing IR
operator - the operator to insert
type - the type of the result
o1 - the first operand
o2 - the second operand
Returns:
the result operand of the inserted instruction

InsertUnary

static RegisterOperand InsertUnary(Instruction s,
                                   IR ir,
                                   Operator operator,
                                   TypeReference type,
                                   Operand o1)
Insert a unary instruction before s in the instruction stream.

Parameters:
s - the instruction to insert before
ir - the containing IR
operator - the operator to insert
type - the type of the result
o1 - the operand
Returns:
the result operand of the inserted instruction

InsertGuardedUnary

static RegisterOperand InsertGuardedUnary(Instruction s,
                                          IR ir,
                                          Operator operator,
                                          TypeReference type,
                                          Operand o1,
                                          Operand guard)
Insert a guarded unary instruction before s in the instruction stream.

Parameters:
s - the instruction to insert before
ir - the containing IR
operator - the operator to insert
type - the type of the result
o1 - the operand
guard - the guard operand
Returns:
the result operand of the inserted instruction

InsertLoadOffsetJTOC

static RegisterOperand InsertLoadOffsetJTOC(Instruction s,
                                            IR ir,
                                            Operator operator,
                                            TypeReference type,
                                            Offset offset)
Insert a load off the JTOC before s in the instruction stream.

Parameters:
s - the instruction to insert before
ir - the containing IR
operator - the operator to insert
type - the type of the result
offset - the offset to load at
Returns:
the result operand of the inserted instruction

InsertLoadOffsetJTOC

static RegisterOperand InsertLoadOffsetJTOC(Instruction s,
                                            IR ir,
                                            Operator operator,
                                            TypeReference type,
                                            Operand offset)
Insert a load off the JTOC before s in the instruction stream.

Parameters:
s - the instruction to insert before
ir - the containing IR
operator - the operator to insert
type - the type of the result
offset - the offset to load at
Returns:
the result operand of the inserted instruction

InsertLoadOffset

static RegisterOperand InsertLoadOffset(Instruction s,
                                        IR ir,
                                        Operator operator,
                                        TypeReference type,
                                        Operand reg2,
                                        Offset offset)
Insert a load off before s in the instruction stream.

Parameters:
s - the instruction to insert before
ir - the containing IR
operator - the operator to insert
type - the type of the result
reg2 - the base to load from
offset - the offset to load at
Returns:
the result operand of the inserted instruction

InsertLoadOffset

static RegisterOperand InsertLoadOffset(Instruction s,
                                        IR ir,
                                        Operator operator,
                                        TypeReference type,
                                        Operand reg2,
                                        Offset offset,
                                        Operand guard)
Insert a load off before s in the instruction stream.

Parameters:
s - the instruction to insert before
ir - the containing IR
operator - the operator to insert
type - the type of the result
reg2 - the base to load from
offset - the offset to load at
guard - the guard operand
Returns:
the result operand of the inserted instruction

InsertLoadOffset

static RegisterOperand InsertLoadOffset(Instruction s,
                                        IR ir,
                                        Operator operator,
                                        TypeReference type,
                                        Operand reg2,
                                        Offset offset,
                                        LocationOperand loc,
                                        Operand guard)
Insert a load off before s in the instruction stream.

Parameters:
s - the instruction to insert before
ir - the containing IR
operator - the operator to insert
type - the type of the result
reg2 - the base to load from
offset - the offset to load at
loc - the location operand
guard - the guard operand
Returns:
the result operand of the inserted instruction

InsertLoadOffset

static RegisterOperand InsertLoadOffset(Instruction s,
                                        IR ir,
                                        Operator operator,
                                        TypeReference type,
                                        Operand reg2,
                                        Operand offset,
                                        LocationOperand loc,
                                        Operand guard)
Insert a load off before s in the instruction stream.

Parameters:
s - the instruction to insert before
ir - the containing IR
operator - the operator to insert
type - the type of the result
reg2 - the base to load from
offset - the offset to load at
loc - the location operand
guard - the guard operand
Returns:
the result operand of the inserted instruction

getTIB

static Operand getTIB(Instruction s,
                      IR ir,
                      Operand obj,
                      Operand guard)
get the tib from the object pointer to by obj


getTIB

static Operand getTIB(Instruction s,
                      IR ir,
                      RVMType type)
get the class tib for type


getTIB

static Operand getTIB(Instruction s,
                      IR ir,
                      TypeOperand type)
get the class tib for type


getInstanceMethod

static RegisterOperand getInstanceMethod(Instruction s,
                                         IR ir,
                                         Operand tib,
                                         RVMMethod method)
Get an instance method from a TIB


getField

public static RegisterOperand getField(Instruction s,
                                       IR ir,
                                       RegisterOperand obj,
                                       RVMField field)
Load an instance field.

Parameters:
s -
ir -
obj -
field -

getField

static RegisterOperand getField(Instruction s,
                                IR ir,
                                RegisterOperand obj,
                                RVMField field,
                                Operand guard)
Load an instance field.

Parameters:
s -
ir -
obj -
field -
guard -

getSpecialMethod

static RegisterOperand getSpecialMethod(Instruction s,
                                        IR ir,
                                        int smid)
support for direct call to specialized method.


expandSysCallTarget

public static void expandSysCallTarget(Instruction s,
                                       IR ir)
Expand symbolic SysCall target into a chain of loads from the bootrecord to the desired target address.


getStatic

public static RegisterOperand getStatic(Instruction s,
                                        IR ir,
                                        RVMField field)
Load a static field.

Parameters:
s -
ir -
field -