public class LICM extends CompilerPhase
GCP
(global code placement).Modifier and Type | Field and Description |
---|---|
private BasicBlock[] |
block |
(package private) static int |
CL_COMPLEX |
(package private) static int |
CL_LOADS_AND_STORES |
(package private) static int |
CL_LOADS_ONLY |
(package private) static int |
CL_NONE |
(package private) static int |
CL_STORES_ONLY |
private static Constructor<CompilerPhase> |
constructor
Constructor for this compiler phase
|
private static boolean |
DEBUG
Generate debug output?
|
private DominatorTree |
dominator |
private static int |
done |
private static int |
early |
private Instruction[] |
earlyPos |
private static int |
initial |
private Map<Instruction,Integer> |
instructionNumbers |
private IR |
ir |
private static int |
late |
private HashSet<Operator> |
moved |
private BasicBlock[] |
origBlock |
private HashSet<Instruction> |
relocated |
private SSADictionary |
ssad |
private int[] |
state |
private static boolean |
VERBOSE
Generate verbose debug output?
|
container
Constructor and Description |
---|
LICM() |
Modifier and Type | Method and Description |
---|---|
private int |
_checkLoop(Instruction inst,
HeapOperand<?> hop,
int xidx) |
private int |
checkLoop(Instruction inst,
HeapOperand<Object> hop,
int xidx,
BasicBlock block) |
private BasicBlock |
commonDominator(BasicBlock a,
BasicBlock b) |
(package private) Instruction |
definingInstruction(Operand op) |
private Instruction |
dominanceSuccessor(Instruction a,
Instruction b)
return `a's successor on the path from `a' to `b' in the dominator
tree.
|
(package private) float |
frequency(BasicBlock b)
Determines how expensive it is to place an instruction in this block.
|
(package private) BasicBlock |
getBlock(Instruction inst) |
Constructor<CompilerPhase> |
getClassConstructor()
Get a constructor object for this compiler phase
|
(package private) Instruction |
getEarlyPos(Instruction inst) |
String |
getName() |
(package private) BasicBlock |
getOrigBlock(Instruction inst) |
(package private) Operand |
getResult(Instruction inst) |
(package private) int |
getState(Instruction inst)
In what state (initial, early, late, done) is this instruction
|
(package private) void |
initialize(IR ir) |
private boolean |
inVariantLocation(Instruction inst,
BasicBlock block) |
private Instruction |
maxDominatorDepth(Instruction a,
Instruction b)
Compares two instructions according to their depth in the dominator tree
and return the one with the greatest depth.
|
(package private) void |
move(Instruction inst,
BasicBlock to) |
void |
perform(IR ir)
Execute loop invariant code motion on the given IR.
|
(package private) boolean |
postDominates(BasicBlock a,
BasicBlock b,
IR ir)
does a post dominate b?
|
private boolean |
replaceUses(Instruction inst,
HeapOperand<?> replacement,
BasicBlockOperand replacementBlock,
boolean onlyPEIs) |
private void |
resetLandingPads() |
private Instruction |
scheduleEarly(Instruction inst)
Schedule this instruction as early as possible
|
(package private) Instruction |
scheduleHeapDefsEarly(HeapOperand<?>[] op,
Instruction earlyPos,
Instruction me)
Schedules an instruction as early as possible,
but behind the definitions of op[i] and behind earlyPos.
|
(package private) BasicBlock |
scheduleHeapUsesLate(Instruction inst,
BasicBlock lateBlock) |
(package private) BasicBlock |
scheduleLate(Instruction inst) |
private Instruction |
scheduleScalarDefsEarly(Enumeration<Operand> e,
Instruction earlyPos,
Instruction inst)
Schedules an instruction as early as possible,
but behind the definitions in e and behind earlyPos
|
private BasicBlock |
scheduleScalarUsesLate(Instruction inst,
BasicBlock lateBlock) |
(package private) void |
setBlock(Instruction inst,
BasicBlock b) |
(package private) void |
setEarlyPos(Instruction inst,
Instruction pos) |
(package private) void |
setOrigBlock(Instruction inst,
BasicBlock b) |
(package private) void |
setState(Instruction inst,
int s)
Set the state (initial, early, late, done) of the instruction
|
static boolean |
shouldMove(Instruction inst,
IR ir) |
boolean |
shouldPerform(OptOptions options)
This method determines if the phase should be run, based on the
Options object it is passed.
|
private boolean |
simplify(Instruction inst,
BasicBlock block) |
(package private) BasicBlock |
upto(Instruction earlyPos,
BasicBlock lateBlock,
Instruction inst)
Visits the blocks between the late and the early position along
their path in the dominator tree.
|
(package private) BasicBlock |
useBlock(Instruction use,
Operand op) |
private boolean |
useDominates(Operand op,
BasicBlock block) |
dumpIR, dumpIR, getCompilerPhaseConstructor, getCompilerPhaseConstructor, newExecution, performPhase, printingEnabled, reportAdditionalStats, setContainer, verify
private static final boolean DEBUG
private static boolean VERBOSE
private Map<Instruction,Integer> instructionNumbers
private static final Constructor<CompilerPhase> constructor
private static final int initial
private static final int early
private static final int late
private static final int done
private HashSet<Instruction> relocated
private int[] state
private BasicBlock[] block
private BasicBlock[] origBlock
private Instruction[] earlyPos
private SSADictionary ssad
private DominatorTree dominator
static final int CL_NONE
static final int CL_LOADS_ONLY
static final int CL_STORES_ONLY
static final int CL_LOADS_AND_STORES
static final int CL_COMPLEX
public LICM()
public Constructor<CompilerPhase> getClassConstructor()
getClassConstructor
in class CompilerPhase
public void perform(IR ir)
perform
in class CompilerPhase
ir
- the IR on which to apply the phasepublic String getName()
getName
in class CompilerPhase
public boolean shouldPerform(OptOptions options)
CompilerPhase
shouldPerform
in class CompilerPhase
options
- the compiler options for the compilationtrue
if SSA-based global code placement is being
performedpublic static boolean shouldMove(Instruction inst, IR ir)
inst
- the instruction that might be movedir
- the governing iRprivate Instruction scheduleEarly(Instruction inst)
inst
- the instruction to scheduleBasicBlock scheduleLate(Instruction inst)
private Instruction dominanceSuccessor(Instruction a, Instruction b)
a
- an instruction matching the constraints from the descriptionb
- another instruction matching the constraints from the descriptionprivate Instruction maxDominatorDepth(Instruction a, Instruction b)
a
- an instructionb
- another instructionprivate BasicBlock commonDominator(BasicBlock a, BasicBlock b)
private Instruction scheduleScalarDefsEarly(Enumeration<Operand> e, Instruction earlyPos, Instruction inst)
e
- the definitions that must have been occurred before the new
position of the instructionearlyPos
- the instruction that serves as a lower bound (exclusive)
for the positioninst
- the instruction to scheduleInstruction scheduleHeapDefsEarly(HeapOperand<?>[] op, Instruction earlyPos, Instruction me)
op
- the definitions that must have been occurred before the new
position of the instructionearlyPos
- the instruction that serves as a lower bound (exclusive)
for the positionme
- the instruction to scheduleBasicBlock useBlock(Instruction use, Operand op)
private BasicBlock scheduleScalarUsesLate(Instruction inst, BasicBlock lateBlock)
BasicBlock scheduleHeapUsesLate(Instruction inst, BasicBlock lateBlock)
Instruction definingInstruction(Operand op)
op
- the operand that's being definedOperand getResult(Instruction inst)
inst
- an instructionBasicBlock upto(Instruction earlyPos, BasicBlock lateBlock, Instruction inst)
earlyPos
- the early positionlateBlock
- the late positioninst
- the instruction to schedulefinal float frequency(BasicBlock b)
b
- a basic blockvoid move(Instruction inst, BasicBlock to)
boolean postDominates(BasicBlock a, BasicBlock b, IR ir)
a
- the possible post-dominatorb
- the possibly post-dominated blockir
- the IR that contains the blocksBasicBlock getBlock(Instruction inst)
void setBlock(Instruction inst, BasicBlock b)
Instruction getEarlyPos(Instruction inst)
void setEarlyPos(Instruction inst, Instruction pos)
BasicBlock getOrigBlock(Instruction inst)
void setOrigBlock(Instruction inst, BasicBlock b)
int getState(Instruction inst)
inst
- the instruction to checkvoid setState(Instruction inst, int s)
inst
- the instructions
- the statevoid initialize(IR ir)
private boolean simplify(Instruction inst, BasicBlock block)
private int _checkLoop(Instruction inst, HeapOperand<?> hop, int xidx)
private int checkLoop(Instruction inst, HeapOperand<Object> hop, int xidx, BasicBlock block)
private boolean inVariantLocation(Instruction inst, BasicBlock block)
private boolean useDominates(Operand op, BasicBlock block)
private boolean replaceUses(Instruction inst, HeapOperand<?> replacement, BasicBlockOperand replacementBlock, boolean onlyPEIs)
private void resetLandingPads()