public final class MIRBranchOptimizations extends BranchOptimizationDriver
container| Constructor and Description |
|---|
MIRBranchOptimizations(int level) |
| Modifier and Type | Method and Description |
|---|---|
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?
|
private static boolean |
isMIR_Branch(Instruction x) |
private static boolean |
isMIR_CondBranch(Instruction x) |
private static boolean |
isMIR_CondBranch2(Instruction x) |
private static BranchOperand |
MIR_Branch_getTarget(Instruction x) |
private static void |
MIR_Branch_setTarget(Instruction x,
BranchOperand y) |
private static void |
MIR_CondBranch_setTarget(Instruction x,
BranchOperand y) |
private static BranchOperand |
MIR_CondBranch2_getTarget1(Instruction x) |
private static BranchOperand |
MIR_CondBranch2_getTarget2(Instruction x) |
private static void |
MIR_CondBranch2_setTarget1(Instruction x,
BranchOperand y) |
private static void |
MIR_CondBranch2_setTarget2(Instruction x,
BranchOperand y) |
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.
|
applyPeepholeBranchOpts, firstLabelFollowing, firstRealInstructionFollowing, getName, maximizeBasicBlocks, newExecution, perform, perform, printingEnabled, removeUnreachableCode, shouldPerformdumpIR, dumpIR, getClassConstructor, getCompilerPhaseConstructor, getCompilerPhaseConstructor, performPhase, reportAdditionalStats, setContainer, verifypublic MIRBranchOptimizations(int level)
level - the minimum optimization level at which the branch
optimizations should be performed.private static boolean isMIR_Branch(Instruction x)
private static boolean isMIR_CondBranch(Instruction x)
private static boolean isMIR_CondBranch2(Instruction x)
private static BranchOperand MIR_Branch_getTarget(Instruction x)
private static void MIR_Branch_setTarget(Instruction x, BranchOperand y)
private static void MIR_CondBranch_setTarget(Instruction x, BranchOperand y)
private static BranchOperand MIR_CondBranch2_getTarget1(Instruction x)
private static BranchOperand MIR_CondBranch2_getTarget2(Instruction x)
private static void MIR_CondBranch2_setTarget1(Instruction x, BranchOperand y)
private static void MIR_CondBranch2_setTarget2(Instruction x, BranchOperand y)
protected boolean optimizeBranchInstruction(IR ir, Instruction s, BasicBlock bb)
optimizeBranchInstruction in class BranchOptimizationDriverir - the containing IRs - the branch instruction to optimizebb - the containing basic blocktrue 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 gtrue 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 iftrue 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 iftrue 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
branchprivate void flipConditionalBranch(Instruction cb)
Precondition isFlipCandidate(cb)
cb - the conditional branch instruction