public final class TailRecursionElimination extends CompilerPhase
NOTES:
Modifier and Type | Field and Description |
---|---|
private BranchOptimizations |
branchOpts |
private static Constructor<CompilerPhase> |
constructor
Constructor for this compiler phase
|
private static boolean |
DEBUG |
container
Constructor and Description |
---|
TailRecursionElimination() |
Modifier and Type | Method and Description |
---|---|
Constructor<CompilerPhase> |
getClassConstructor()
Get a constructor object for this compiler phase
|
String |
getName() |
(package private) boolean |
isTailRecursion(Instruction call,
IR ir)
Is the argument call instruction a tail recursive call?
|
CompilerPhase |
newExecution(IR ir)
This method is called immediately before performPhase.
|
void |
perform(IR ir)
Perform tail recursion elimination.
|
boolean |
shouldPerform(OptOptions options)
This method determines if the phase should be run, based on the
Options object it is passed.
|
(package private) Instruction |
transform(Instruction call,
Instruction prologue,
BasicBlock target,
IR ir)
Transform the tail recursive call into a loop.
|
dumpIR, dumpIR, getCompilerPhaseConstructor, getCompilerPhaseConstructor, performPhase, printingEnabled, reportAdditionalStats, setContainer, verify
private static final boolean DEBUG
private final BranchOptimizations branchOpts
private static final Constructor<CompilerPhase> constructor
public TailRecursionElimination()
public Constructor<CompilerPhase> getClassConstructor()
getClassConstructor
in class CompilerPhase
public boolean shouldPerform(OptOptions options)
CompilerPhase
shouldPerform
in class CompilerPhase
options
- the compiler options for the compilationpublic String getName()
getName
in class CompilerPhase
public CompilerPhase newExecution(IR ir)
CompilerPhase
newExecution
in class CompilerPhase
ir
- the IR that is about to be passed to performPhasepublic void perform(IR ir)
perform
in class CompilerPhase
ir
- the IR to optimizeboolean isTailRecursion(Instruction call, IR ir)
call
- the call in questionir
- the enclosing IRtrue
if call is tail recursive and
false
if it is not.Instruction transform(Instruction call, Instruction prologue, BasicBlock target, IR ir)
call
- The recursive callprologue
- The IR_Prologue instructiontarget
- The loop headir
- the containing IR