org.jikesrvm.compilers.opt.ssa
Class LeaveSSA

java.lang.Object
  extended by org.jikesrvm.compilers.opt.driver.CompilerPhase
      extended by org.jikesrvm.compilers.opt.ssa.LeaveSSA

public class LeaveSSA
extends CompilerPhase

This compiler phase translates out of SSA form.

See Also:
SSA, SSAOptions, LTDominators

Nested Class Summary
(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.
 
Field Summary
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  IR ir
          The IR to manipulate
private  boolean splitSomeBlock
           
 
Fields inherited from class org.jikesrvm.compilers.opt.driver.CompilerPhase
container
 
Constructor Summary
LeaveSSA()
           
 
Method Summary
 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)
          find step of union/find for guard registers during unSSA
private  Register guardUnion(Register from, Register to)
          union step of union/find for guard registers during unSSA
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)
          substitute variables renamed in control parents
(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)
           
 
Methods inherited from class org.jikesrvm.compilers.opt.driver.CompilerPhase
dumpIR, dumpIR, getCompilerPhaseConstructor, getCompilerPhaseConstructor, newExecution, performPhase, printingEnabled, reportAdditionalStats, setContainer, verify
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DEBUG

static final boolean DEBUG
verbose debugging flag

See Also:
Constant Field Values

ir

private IR ir
The IR to manipulate


branchOpts

private final BranchOptimizations branchOpts

splitSomeBlock

private boolean splitSomeBlock

globalRenameTable

private final HashSet<Instruction> globalRenameTable

globalRenamePhis

private final HashSet<Register> globalRenamePhis

constructor

private static final Constructor<CompilerPhase> constructor
Constructor for this compiler phase


guardPhis

Instruction guardPhis
Constructor Detail

LeaveSSA

public LeaveSSA()
Method Detail

shouldPerform

public final boolean shouldPerform(OptOptions options)
Is SSA form enabled for the HIR?

Overrides:
shouldPerform in class CompilerPhase
Parameters:
options - the compiler options for the compilation
Returns:
true if the phase should be performed

getClassConstructor

public Constructor<CompilerPhase> getClassConstructor()
Get a constructor object for this compiler phase

Overrides:
getClassConstructor in class CompilerPhase
Returns:
compiler phase constructor

getName

public final String getName()
Return a string name for this phase.

Specified by:
getName in class CompilerPhase
Returns:
"Leave SSA"

perform

public final void perform(IR ir)
perform the main out-of-ssa transformation

Specified by:
perform in class CompilerPhase
Parameters:
ir - the IR on which to apply the phase

performRename

private void performRename(BasicBlock bb,
                           DominatorTree dom,
                           LeaveSSA.VariableStacks s)
substitute variables renamed in control parents


usedBelowCopy

private boolean usedBelowCopy(BasicBlock bb,
                              Register r)

scheduleCopies

private void scheduleCopies(BasicBlock bb,
                            LiveAnalysis live)
Record pending copy operations needed to insert at the end of a basic block.

TODO: this procedure is getting long and ugly. Rewrite or refactor it.

Parameters:
bb - the basic block to process
live - valid liveness information for the IR

insertCopies

private void insertCopies(BasicBlock bb,
                          DominatorTree dom,
                          LiveAnalysis live)
Insert copy instructions into a basic block to safely translate out of SSA form.

Parameters:
bb - the basic block
dom - a valid dominator tree for the IR
live - valid liveness information for the IR

translateFromSSA

public void translateFromSSA(IR ir)
Main driver to translate an IR out of SSA form.

Parameters:
ir - the IR in SSA form

removeAllPhis

static void removeAllPhis(IR ir)
Remove all phi instructions from the IR.

Parameters:
ir - the governing IR

unSSAGuards

private void unSSAGuards(IR ir)
Special treatment for guard registers: Remove guard-phis by evaluating operands into same register. If this target register is not unique, unite the alternatives.


unSSAGuardsInit

private void unSSAGuardsInit(IR ir)
Initialization for removal of guard phis.


unSSAGuardsDetermineReg

private void unSSAGuardsDetermineReg(IR ir)
Determine target register for guard phi operands


unSSAGuardsFinalize

private void unSSAGuardsFinalize(IR ir)
Rename registers and delete Phis.


guardUnion

private Register guardUnion(Register from,
                            Register to)
union step of union/find for guard registers during unSSA


guardFind

private Register guardFind(Register r)
find step of union/find for guard registers during unSSA


normalizeSSA

private static void normalizeSSA(IR ir)
Avoid potential lost copy and other associated problems by Sreedhar's naive translation from TSSA to CSSA. Guards are rather trivial to un-SSA so they have already been removed from the IR. This algorithm is very wasteful of registers so needs good coalescing.

Parameters:
ir - the IR to work upon