|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.jikesrvm.compilers.opt.driver.CompilerPhase org.jikesrvm.compilers.opt.controlflow.BranchOptimizationDriver org.jikesrvm.compilers.opt.controlflow.MIRBranchOptimizations
public final class MIRBranchOptimizations
Perform simple peephole optimizations for MIR branches.
Field Summary |
---|
Fields inherited from class org.jikesrvm.compilers.opt.driver.CompilerPhase |
---|
container |
Constructor Summary | |
---|---|
MIRBranchOptimizations(int level)
|
Method Summary | |
---|---|
private void |
flipConditionalBranch(Instruction cb)
Flip a conditional branch and remove the trailing goto. |
private boolean |
isFlipCandidate(Instruction cb,
Instruction target)
Is a conditional branch a candidate to be flipped? |
protected boolean |
optimizeBranchInstruction(IR ir,
Instruction s,
BasicBlock bb)
This method actually does the work of attempting to peephole optimize a branch instruction. |
private boolean |
processCondBranch(IR ir,
Instruction cb,
BasicBlock bb)
Perform optimizations for a conditional branch. |
private boolean |
processGoto(IR ir,
Instruction g,
BasicBlock bb)
Perform optimizations for an unconditonal branch. |
private boolean |
processTwoTargetConditionalBranch(IR ir,
Instruction cb,
BasicBlock bb)
Perform optimizations for a two way conditional branch. |
Methods inherited from class org.jikesrvm.compilers.opt.controlflow.BranchOptimizationDriver |
---|
applyPeepholeBranchOpts, firstLabelFollowing, firstRealInstructionFollowing, getName, maximizeBasicBlocks, newExecution, perform, perform, printingEnabled, removeUnreachableCode, shouldPerform |
Methods inherited from class org.jikesrvm.compilers.opt.driver.CompilerPhase |
---|
dumpIR, dumpIR, getClassConstructor, getCompilerPhaseConstructor, getCompilerPhaseConstructor, performPhase, reportAdditionalStats, setContainer, verify |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public MIRBranchOptimizations(int level)
level
- the minimum optimization level at which the branch
optimizations should be performed.Method Detail |
---|
protected boolean optimizeBranchInstruction(IR ir, Instruction s, BasicBlock bb)
optimizeBranchInstruction
in class BranchOptimizationDriver
ir
- the containing IRs
- the branch instruction to optimizebb
- the containing basic block
true
if an optimization was applied, false
otherwiseprivate boolean processGoto(IR ir, Instruction g, BasicBlock bb)
Patterns:
1) GOTO A replaced by GOTO B A: GOTO B 2) GOTO next instruction eliminated 3) GOTO A replaced by GOTO B A: LABEL BBEND B:Precondition: MIR_Branch.conforms(g)
ir
- governing IRg
- the instruction to optimizebb
- the basic block holding g
true
if made a transformationprivate boolean processCondBranch(IR ir, Instruction cb, BasicBlock bb)
1) IF .. GOTO A replaced by IF .. GOTO B ... A: GOTO B 2) conditional branch to next instruction eliminated 3) IF (condition) GOTO A replaced by IF (!condition) GOTO B GOTO B A: ... A: ... 4) IF .. GOTO A replaced by IF .. GOTO B A: LABEL BBEND B: 5) fallthrough to a goto: replicate goto to enable other optimizations.
Precondition: MIR_CondBranch.conforms(cb)
ir
- the governing IRcb
- the instruction to optimizebb
- the basic block holding if
true
iff made a transformationprivate boolean processTwoTargetConditionalBranch(IR ir, Instruction cb, BasicBlock bb)
1) IF .. GOTO A replaced by IF .. GOTO B ... A: GOTO B 2) conditional branch to next instruction eliminated 3) IF .. GOTO A replaced by IF .. GOTO B A: LABEL BBEND B: 4) fallthrough to a goto: replicate goto to enable other optimizations.
Precondition: MIR_CondBranch2.conforms(cb)
ir
- the governing IRcb
- the instruction to optimizebb
- the basic block holding if
true
iff made a transformationprivate boolean isFlipCandidate(Instruction cb, Instruction target)
Precondition: MIR_CondBranch.conforms(cb)
cb
- the conditional branch instructiontarget
- the target instruction (real instruction) of the conditional
branch
private void flipConditionalBranch(Instruction cb)
Precondition isFlipCandidate(cb)
cb
- the conditional branch instruction
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |