org.jikesrvm.compilers.opt
Class LocalCSE

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

public class LocalCSE
extends CompilerPhase

Perform local common-subexpression elimination for a factored basic block.

Algorithm: Muchnick pp.379-385


Nested Class Summary
private static class LocalCSE.AvailableExpression
          A tuple to record an Available Expression
protected static class LocalCSE.AvExCache
          Implements a cache of Available Expressions
 
Field Summary
private static Constructor<CompilerPhase> constructor
          Constructor for this compiler phase
private  boolean isHIR
           
 
Fields inherited from class org.jikesrvm.compilers.opt.driver.CompilerPhase
container
 
Constructor Summary
LocalCSE(boolean isHIR)
          Constructor
 
Method Summary
private  void checkHelper(IR ir, LocalCSE.AvExCache cache, Instruction inst)
          Process a check instruction
private  void expressionHelper(IR ir, LocalCSE.AvExCache cache, Instruction inst)
          Process a unary or binary expression.
 Constructor<CompilerPhase> getClassConstructor()
          Get a constructor object for this compiler phase
private static Operator getMoveOp(RegisterOperand r)
           
 String getName()
           
private  boolean isCheck(Instruction inst)
          Is the given instruction a check instruction?
private  boolean isExpression(Instruction inst)
          Does the instruction compute some expression?
static boolean isLoadInstruction(Instruction s)
          Is a given instruction a CSE-able load?
static boolean isStoreInstruction(Instruction s)
          Is a given instruction a CSE-able store?
private static boolean isSynchronizing(Instruction inst)
          Is this a synchronizing instruction?
private  boolean isTypeCheck(Instruction inst)
           
private  void loadHelper(IR ir, LocalCSE.AvExCache cache, Instruction inst)
          Process a load instruction
private  void optimizeBasicBlockHIR(IR ir, BasicBlock bb)
          Perform Local CSE for a basic block in HIR.
private  void optimizeBasicBlockLIR(IR ir, BasicBlock bb)
          Perform Local CSE for a basic block in LIR.
 void perform(IR ir)
          Perform Local CSE for a method.
 void reportAdditionalStats()
          Called when printing a measure compilation report to enable a phase to report additional phase-specific statistics.
 boolean shouldPerform(OptOptions options)
          This method determines if the phase should be run, based on the Options object it is passed.
private  void storeHelper(LocalCSE.AvExCache cache, Instruction inst)
          Process a store instruction
private static void typeCheckHelper(IR ir, LocalCSE.AvExCache cache, Instruction inst)
          Process a type check instruction
 
Methods inherited from class org.jikesrvm.compilers.opt.driver.CompilerPhase
dumpIR, dumpIR, getCompilerPhaseConstructor, getCompilerPhaseConstructor, newExecution, performPhase, printingEnabled, setContainer, verify
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

isHIR

private final boolean isHIR

constructor

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

Constructor Detail

LocalCSE

public LocalCSE(boolean isHIR)
Constructor

Method Detail

getClassConstructor

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

Overrides:
getClassConstructor in class CompilerPhase
Returns:
compiler phase constructor

reportAdditionalStats

public final void reportAdditionalStats()
Description copied from class: CompilerPhase
Called when printing a measure compilation report to enable a phase to report additional phase-specific statistics.

Overrides:
reportAdditionalStats in class CompilerPhase

shouldPerform

public final boolean shouldPerform(OptOptions options)
Description copied from class: CompilerPhase
This method determines if the phase should be run, based on the Options object it is passed. By default, phases are always performed. Subclasses should override this method if they only want to be performed conditionally.

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

getName

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

perform

public final void perform(IR ir)
Perform Local CSE for a method.

Specified by:
perform in class CompilerPhase
Parameters:
ir - the IR to optimize

optimizeBasicBlockHIR

private void optimizeBasicBlockHIR(IR ir,
                                   BasicBlock bb)
Perform Local CSE for a basic block in HIR.

Parameters:
ir - the method's ir
bb - the basic block

optimizeBasicBlockLIR

private void optimizeBasicBlockLIR(IR ir,
                                   BasicBlock bb)
Perform Local CSE for a basic block in LIR.

Parameters:
ir - the method's ir
bb - the basic block

isLoadInstruction

public static boolean isLoadInstruction(Instruction s)
Is a given instruction a CSE-able load?


isStoreInstruction

public static boolean isStoreInstruction(Instruction s)
Is a given instruction a CSE-able store?


isExpression

private boolean isExpression(Instruction inst)
Does the instruction compute some expression?

Parameters:
inst - the instruction in question
Returns:
true or false, as appropriate

isCheck

private boolean isCheck(Instruction inst)
Is the given instruction a check instruction?

Parameters:
inst - the instruction in question
Returns:
true or false, as appropriate

isTypeCheck

private boolean isTypeCheck(Instruction inst)

loadHelper

private void loadHelper(IR ir,
                        LocalCSE.AvExCache cache,
                        Instruction inst)
Process a load instruction

Parameters:
ir - the containing IR object.
cache - the cache of available expressions
inst - the instruction begin processed

storeHelper

private void storeHelper(LocalCSE.AvExCache cache,
                         Instruction inst)
Process a store instruction

Parameters:
cache - the cache of available expressions
inst - the instruction begin processed

expressionHelper

private void expressionHelper(IR ir,
                              LocalCSE.AvExCache cache,
                              Instruction inst)
Process a unary or binary expression.

Parameters:
ir - the containing IR object
cache - the cache of available expressions
inst - the instruction begin processed

checkHelper

private void checkHelper(IR ir,
                         LocalCSE.AvExCache cache,
                         Instruction inst)
Process a check instruction

Parameters:
cache - the cache of available expressions
inst - the instruction begin processed

typeCheckHelper

private static void typeCheckHelper(IR ir,
                                    LocalCSE.AvExCache cache,
                                    Instruction inst)
Process a type check instruction

Parameters:
ir - Unused
cache - The cache of available expressions.
inst - The instruction being processed

getMoveOp

private static Operator getMoveOp(RegisterOperand r)

isSynchronizing

private static boolean isSynchronizing(Instruction inst)
Is this a synchronizing instruction?

Parameters:
inst - the instruction in question