public class LeaveSSA extends CompilerPhase
SSA
,
SSAOptions
,
LTDominators
Modifier and Type | Class and Description |
---|---|
(package private) static class |
LeaveSSA.Copy
An instance of this class represents a pending copy instruction
to be inserted.
|
(package private) static class |
LeaveSSA.VariableStacks
This class provides an abstraction over stacks of names
for registers.
|
Modifier and Type | Field and Description |
---|---|
private HashMap<Register,Register> |
associatedRegisters |
private BranchOptimizations |
branchOpts |
private static Constructor<CompilerPhase> |
constructor
Constructor for this compiler phase
|
(package private) static boolean |
DEBUG
verbose debugging flag
|
private HashSet<Register> |
globalRenamePhis |
private HashSet<Instruction> |
globalRenameTable |
(package private) Instruction |
guardPhis |
private HashMap<Register,Integer> |
guardRegUnion |
private HashMap<Instruction,Instruction> |
inst2guardPhi |
private IR |
ir
The IR to manipulate
|
private boolean |
splitSomeBlock |
container
Constructor and Description |
---|
LeaveSSA() |
Modifier and Type | Method and Description |
---|---|
Constructor<CompilerPhase> |
getClassConstructor()
Get a constructor object for this compiler phase
|
String |
getName()
Return a string name for this phase.
|
private Register |
guardFind(Register r) |
private Register |
guardUnion(Register from,
Register to) |
private void |
insertCopies(BasicBlock bb,
DominatorTree dom,
LiveAnalysis live)
Insert copy instructions into a basic block to safely translate out
of SSA form.
|
private static void |
normalizeSSA(IR ir)
Avoid potential lost copy and other associated problems by
Sreedhar's naive translation from TSSA to CSSA.
|
void |
perform(IR ir)
perform the main out-of-ssa transformation
|
private void |
performRename(BasicBlock bb,
DominatorTree dom,
LeaveSSA.VariableStacks s) |
(package private) static void |
removeAllPhis(IR ir)
Remove all phi instructions from the IR.
|
private void |
scheduleCopies(BasicBlock bb,
LiveAnalysis live)
Record pending copy operations needed to insert at the end of a basic
block.
|
boolean |
shouldPerform(OptOptions options)
Is SSA form enabled for the HIR?
|
void |
translateFromSSA(IR ir)
Main driver to translate an IR out of SSA form.
|
private void |
unSSAGuards(IR ir)
Special treatment for guard registers:
Remove guard-phis by evaluating operands into same register.
|
private void |
unSSAGuardsDetermineReg(IR ir)
Determine target register for guard phi operands
|
private void |
unSSAGuardsFinalize(IR ir)
Rename registers and delete Phis.
|
private void |
unSSAGuardsInit(IR ir)
Initialization for removal of guard phis.
|
private boolean |
usedBelowCopy(BasicBlock bb,
Register r) |
dumpIR, dumpIR, getCompilerPhaseConstructor, getCompilerPhaseConstructor, newExecution, performPhase, printingEnabled, reportAdditionalStats, setContainer, verify
static final boolean DEBUG
private final BranchOptimizations branchOpts
private boolean splitSomeBlock
private final HashSet<Instruction> globalRenameTable
private final HashSet<Register> globalRenamePhis
private static final Constructor<CompilerPhase> constructor
Instruction guardPhis
private HashMap<Instruction,Instruction> inst2guardPhi
private HashMap<Register,Integer> guardRegUnion
private HashMap<Register,Register> associatedRegisters
public LeaveSSA()
public final boolean shouldPerform(OptOptions options)
shouldPerform
in class CompilerPhase
options
- the compiler options for the compilationpublic Constructor<CompilerPhase> getClassConstructor()
getClassConstructor
in class CompilerPhase
public final String getName()
getName
in class CompilerPhase
public final void perform(IR ir)
perform
in class CompilerPhase
ir
- the IR on which to apply the phaseprivate void performRename(BasicBlock bb, DominatorTree dom, LeaveSSA.VariableStacks s)
private boolean usedBelowCopy(BasicBlock bb, Register r)
private void scheduleCopies(BasicBlock bb, LiveAnalysis live)
TODO: this procedure is getting long and ugly. Rewrite or refactor it.
bb
- the basic block to processlive
- valid liveness information for the IRprivate void insertCopies(BasicBlock bb, DominatorTree dom, LiveAnalysis live)
bb
- the basic blockdom
- a valid dominator tree for the IRlive
- valid liveness information for the IRpublic void translateFromSSA(IR ir)
ir
- the IR in SSA formstatic void removeAllPhis(IR ir)
ir
- the governing IRprivate void unSSAGuards(IR ir)
ir
- the governing IR, currently in SSA formprivate void unSSAGuardsInit(IR ir)
ir
- the governing IR, currently in SSA formprivate void unSSAGuardsDetermineReg(IR ir)
ir
- the governing IR, currently in SSA formprivate void unSSAGuardsFinalize(IR ir)
ir
- the governing IR, currently in SSA formprivate Register guardUnion(Register from, Register to)
private static void normalizeSSA(IR ir)
ir
- the IR to work upon