public abstract class CompilerPhase extends Object
By default, a new instance of the phase is created each time shouldPerform is called. This instance is discarded as soon as shouldPerform completes. Therefore, it is allowable (and is suggested when necessary) for subclasses to use their instance fields to hold per-compilation state. To be more concrete, the pattern of use is:
newExecution(ir).performPhase(ir).
Modifier and Type | Field and Description |
---|---|
protected OptimizationPlanAtomicElement |
container
The plan element that contains this phase.
|
private Object[] |
initargs
Arguments to constructor that copies this phase
|
Constructor and Description |
---|
CompilerPhase()
Constructor
|
CompilerPhase(Object[] initargs)
Constructor
|
Modifier and Type | Method and Description |
---|---|
static void |
dumpIR(IR ir,
String tag)
Prints the IR, optionally including the CFG
|
static void |
dumpIR(IR ir,
String tag,
boolean forceCFG)
Prints the IR, optionally including the CFG
|
Constructor<CompilerPhase> |
getClassConstructor()
Get a constructor object for this compiler phase
|
protected static Constructor<CompilerPhase> |
getCompilerPhaseConstructor(Class<? extends CompilerPhase> klass)
Given the name of a compiler phase return the default (no
argument) constructor for it.
|
protected static Constructor<CompilerPhase> |
getCompilerPhaseConstructor(Class<? extends CompilerPhase> phaseType,
Class<?>[] initTypes)
Given the name of a compiler phase return the default (no
argument) constructor for it.
|
abstract String |
getName() |
CompilerPhase |
newExecution(IR ir)
This method is called immediately before performPhase.
|
abstract void |
perform(IR ir)
This is the method that actually does the work of the phase.
|
void |
performPhase(IR ir)
Runs a phase by calling perform on the supplied IR surrounded by
printing/messaging/debugging glue.
|
boolean |
printingEnabled(OptOptions options,
boolean before)
Returns true if the phase wants the IR dumped before and/or after it runs.
|
void |
reportAdditionalStats()
Called when printing a measure compilation report to enable a phase
to report additional phase-specific statistics.
|
void |
setContainer(OptimizationPlanAtomicElement atomEl) |
boolean |
shouldPerform(OptOptions options)
This method determines if the phase should be run, based on the
Options object it is passed.
|
void |
verify(IR ir)
Verify the IR.
|
protected OptimizationPlanAtomicElement container
public CompilerPhase()
public CompilerPhase(Object[] initargs)
initargs
- arguments used when constructing copies of this phasepublic abstract void perform(IR ir)
ir
- the IR on which to apply the phasepublic boolean shouldPerform(OptOptions options)
options
- the compiler options for the compilationpublic boolean printingEnabled(OptOptions options, boolean before)
options
- the compiler options for the compilationbefore
- true when invoked before perform, false otherwise.public void reportAdditionalStats()
public CompilerPhase newExecution(IR ir)
ir
- the IR that is about to be passed to performPhasepublic Constructor<CompilerPhase> getClassConstructor()
protected static Constructor<CompilerPhase> getCompilerPhaseConstructor(Class<? extends CompilerPhase> klass)
klass
- the compiler phase to constructprotected static Constructor<CompilerPhase> getCompilerPhaseConstructor(Class<? extends CompilerPhase> phaseType, Class<?>[] initTypes)
phaseType
- the class for the compiler phaseinitTypes
- the argument types for the constructorpublic final void setContainer(OptimizationPlanAtomicElement atomEl)
public final void performPhase(IR ir)
ir
- the IR object on which to do the work of the phase.public static void dumpIR(IR ir, String tag)
ir
- the IR to printtag
- a String to use in the start/end message of the IR dumppublic static void dumpIR(IR ir, String tag, boolean forceCFG)
ir
- the IR to printforceCFG
- should the CFG be printed, independent of the value of ir.options.PRINT_CFG?tag
- a String to use in the start/end message of the IR dump