org.jikesrvm.compilers.opt.ssa
Class GlobalCSE

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

public final class GlobalCSE
extends CompilerPhase

This class provides global common sub expression elimination.


Field Summary
private  HashMap<Integer,Instruction> avail
          Available expressions.
private static Constructor<CompilerPhase> constructor
          Constructor for this compiler phase
private  DominatorTree dominator
          Cache of dominator tree that should be computed prior to this phase
private  IR ir
          Cache of IR being processed by this phase
private  GlobalValueNumberState valueNumbers
          Cache of the value numbers from the IR
 boolean verbose
          Output debug messages
 
Fields inherited from class org.jikesrvm.compilers.opt.driver.CompilerPhase
container
 
Constructor Summary
GlobalCSE()
          Constructor
 
Method Summary
 Constructor<CompilerPhase> getClassConstructor()
          Get a constructor object for this compiler phase
 String getName()
          Returns the name of the phase
private  RegisterOperand getResult(Instruction inst)
          Get the result operand of the instruction
private  void globalCSE(BasicBlock b)
          Recursively descend over all blocks dominated by b.
 void perform(IR ir)
          Perform the GlobalCSE compiler phase
private  boolean shouldCSE(Instruction inst)
          should this instruction be cse'd ?
 boolean shouldPerform(OptOptions options)
          Redefine shouldPerform so that none of the subphases will occur unless we pass through this test.
 
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

verbose

public boolean verbose
Output debug messages


ir

private IR ir
Cache of IR being processed by this phase


valueNumbers

private GlobalValueNumberState valueNumbers
Cache of the value numbers from the IR


dominator

private DominatorTree dominator
Cache of dominator tree that should be computed prior to this phase


avail

private final HashMap<Integer,Instruction> avail
Available expressions. From Muchnick, "an expression expis said to be available at the entry to a basic block if along every control-flow path from the entry block to this block there is an evaluation of exp that is not subsequently killed by having one or more of its operands assigned a new value." Our available expressions are a mapping from a value number to the first instruction to define it as we traverse the dominator tree.


constructor

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

Constructor Detail

GlobalCSE

public GlobalCSE()
Constructor

Method Detail

shouldPerform

public boolean shouldPerform(OptOptions options)
Redefine shouldPerform so that none of the subphases will occur unless we pass through this test.

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 String getName()
Returns the name of the phase

Specified by:
getName in class CompilerPhase
Returns:
a String which is the name of the phase.

perform

public void perform(IR ir)
Perform the GlobalCSE compiler phase

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

globalCSE

private void globalCSE(BasicBlock b)
Recursively descend over all blocks dominated by b. For each instruction in the block, if it defines a GVN then record it in the available expressions. If the GVN already exists in the available expressions then eliminate the instruction and change all uses of the result of the instruction to be uses of the first instruction to define the result of this expression.

Parameters:
b - the current block to process

getResult

private RegisterOperand getResult(Instruction inst)
Get the result operand of the instruction

Parameters:
inst -

shouldCSE

private boolean shouldCSE(Instruction inst)
should this instruction be cse'd ?

Parameters:
inst -