public final class Simple extends CompilerPhase
Except for the "CompilerPhase" methods, all fields and methods in this class are declared static.
Modifier and Type | Field and Description |
---|---|
private BranchOptimizations |
branchOpts |
private static Constructor<CompilerPhase> |
constructor
Constructor for this compiler phase
|
private boolean |
foldBranches
Fold conditional branches with constant operands?
|
private boolean |
foldChecks
Attempt to eliminate bounds and cast checks?
|
private int |
level
At what optimization level should this phase be run?
|
private boolean |
sortRegisters
Sort registers used by commutative operators
|
private boolean |
typeProp
Perform type propagation?
|
container
Constructor and Description |
---|
Simple(int level,
boolean typeProp,
boolean foldChecks,
boolean foldBranches,
boolean sortRegisters)
The constructor is used to specify what pieces of Simple will
be enabled for this instance.
|
Modifier and Type | Method and Description |
---|---|
(package private) static void |
arrayPropagation(IR ir)
Perform flow-insensitive propagation to eliminate bounds checks
and arraylength for arrays with static lengths.
|
static void |
copyPropagation(IR ir)
Perform flow-insensitive copy and constant propagation using
register list information.
|
(package private) static void |
eliminateDeadInstructions(IR ir)
Simple conservative dead code elimination.
|
static void |
eliminateDeadInstructions(IR ir,
boolean preserveImplicitSSA)
Simple conservative dead code elimination.
|
(package private) static Operand |
equivalentValforPHI(Instruction phi)
Try to find an operand that is equivalent to the result of a
given phi instruction.
|
(package private) void |
foldConstants(IR ir)
Perform constant folding.
|
Constructor<CompilerPhase> |
getClassConstructor()
Get a constructor object for this compiler phase
|
String |
getName() |
void |
perform(IR ir)
Main driver for the simple optimizations
|
boolean |
printingEnabled(OptOptions options,
boolean before)
Returns true if the phase wants the IR dumped before and/or after it runs.
|
boolean |
shouldPerform(OptOptions options)
This method determines if the phase should be run, based on the
Options object it is passed.
|
(package private) void |
simplifyConstantBranches(IR ir)
Simplify branches whose operands are constants.
|
private static void |
sortCommutativeRegisterUses(IR ir)
Sort commutative use operands so that those defined most are on the lhs
|
(package private) static void |
typePropagation(IR ir)
Perform flow-insensitive type propagation using register list
information.
|
dumpIR, dumpIR, getCompilerPhaseConstructor, getCompilerPhaseConstructor, newExecution, performPhase, reportAdditionalStats, setContainer, verify
private final BranchOptimizations branchOpts
private final int level
private final boolean typeProp
private final boolean foldChecks
private final boolean foldBranches
private final boolean sortRegisters
private static final Constructor<CompilerPhase> constructor
public Simple(int level, boolean typeProp, boolean foldChecks, boolean foldBranches, boolean sortRegisters)
level
- at what optimization level should the phase be enabled?typeProp
- should type propagation be peformed?foldChecks
- should we attempt to eliminate boundscheck?foldBranches
- should we attempt to constant fold conditionalsortRegisters
- should we sort use operands?
branches?public boolean shouldPerform(OptOptions options)
CompilerPhase
shouldPerform
in class CompilerPhase
options
- the compiler options for the compilationpublic String getName()
getName
in class CompilerPhase
public boolean printingEnabled(OptOptions options, boolean before)
CompilerPhase
printingEnabled
in class CompilerPhase
options
- the compiler options for the compilationbefore
- true when invoked before perform, false otherwise.public Constructor<CompilerPhase> getClassConstructor()
getClassConstructor
in class CompilerPhase
public void perform(IR ir)
perform
in class CompilerPhase
ir
- the IR to optimizeprivate static void sortCommutativeRegisterUses(IR ir)
ir
- the IR to work onpublic static void copyPropagation(IR ir)
ir
- the IR in questionstatic Operand equivalentValforPHI(Instruction phi)
phi
- the instruction to be simplifiedstatic void typePropagation(IR ir)
Kept separate from copyPropagation loop to enable clients more flexibility.
ir
- the IR in questionstatic void arrayPropagation(IR ir)
Note: this function incrementally maintains the register list.
ir
- the IR in questionstatic void eliminateDeadInstructions(IR ir)
Note: this function incrementally maintains the register list.
ir
- the IR to optimizepublic static void eliminateDeadInstructions(IR ir, boolean preserveImplicitSSA)
Note: this function incrementally maintains the register list.
ir
- IR to optimizepreserveImplicitSSA
- if this is true, do not eliminate dead
instructions that have implicit operands for heap array SSA formvoid foldConstants(IR ir)
ir
- the IR to optimizevoid simplifyConstantBranches(IR ir)
NOTE: This pass ensures that the register list is still valid after it is done.
ir
- the IR to optimize