Search in sources :

Example 1 with DominatorTree

use of org.jikesrvm.compilers.opt.controlflow.DominatorTree in project JikesRVM by JikesRVM.

the class LoopVersioning method perform.

/**
 * @param _ir the IR to process
 */
@Override
public void perform(IR _ir) {
    ir = _ir;
    // Create SSA
    ir.desiredSSAOptions = desiredSSAOptions;
    if (!inSSAphase) {
        enterSSA.perform(ir);
    }
    if (DEBUG) {
        SSA.printInstructions(ir);
    }
    // Perform loop annotation
    if (!ir.hasReachableExceptionHandlers()) {
        // Build LST tree and dominator info
        domPhase.perform(ir);
        DefUse.computeDU(ir);
        // Build annotated version
        ir.HIRInfo.loopStructureTree = new AnnotatedLSTGraph(ir, ir.HIRInfo.loopStructureTree);
    }
    if (VERIFY) {
        ir.verify(getName(), true);
    }
    // Check loop annotation has been performed
    if (!(ir.HIRInfo.loopStructureTree instanceof AnnotatedLSTGraph)) {
        report("Optimisation of " + ir.getMethod() + " failed as LST wasn't annotated\n");
    } else {
        loopRegisterSet = new HashSet<Register>();
        if (DEBUG) {
            VM.sysWriteln(ir.getMethod().toString());
            VM.sysWriteln(ir.HIRInfo.loopStructureTree.toString());
            SSA.printInstructions(ir);
        }
        while (findLoopToOptimise((AnnotatedLSTNode) ir.HIRInfo.loopStructureTree.getRoot())) {
            if (DEBUG) {
                VM.sysWriteln("Successful optimisation of " + ir.getMethod());
                SSA.printInstructions(ir);
                VM.sysWriteln(ir.cfg.toString());
            }
            // Get IR into shape for next pass
            DefUse.computeDU(ir);
            LTDominators.perform(ir, true, true);
            ir.HIRInfo.dominatorTree = new DominatorTree(ir, true);
            LSTGraph.perform(ir);
            AnnotatedLSTGraph.perform(ir);
            if (VERIFY) {
                ir.verify(getName(), true);
            }
            if (DEBUG) {
                VM.sysWriteln("after an optimization pass");
                VM.sysWriteln(ir.HIRInfo.loopStructureTree.toString());
                SSA.printInstructions(ir);
                VM.sysWriteln("Finish optimize: " + ir.getMethod().toString());
            }
        }
        // No longer in use
        loopRegisterSet = null;
    }
    if (!inSSAphase) {
        // Leave SSA
        leaveSSA.perform(ir);
    }
    if (VERIFY) {
        ir.verify(getName(), true);
    }
}
Also used : AnnotatedLSTGraph(org.jikesrvm.compilers.opt.controlflow.AnnotatedLSTGraph) DominatorTree(org.jikesrvm.compilers.opt.controlflow.DominatorTree) Register(org.jikesrvm.compilers.opt.ir.Register)

Example 2 with DominatorTree

use of org.jikesrvm.compilers.opt.controlflow.DominatorTree in project JikesRVM by JikesRVM.

the class LeaveSSA method translateFromSSA.

/**
 * Main driver to translate an IR out of SSA form.
 *
 * @param ir the IR in SSA form
 */
public void translateFromSSA(IR ir) {
    // 0. Deal with guards (validation registers)
    unSSAGuards(ir);
    // 1. re-compute dominator tree in case of control flow changes
    LTDominators.perform(ir, true, true);
    DominatorTree dom = new DominatorTree(ir, true);
    // 1.5 Perform Sreedhar's naive translation from TSSA to CSSA
    // if (ir.options.UNROLL_LOG == 0) normalizeSSA(ir);
    // 2. compute liveness
    LiveAnalysis live = new // don't create GC maps
    LiveAnalysis(// don't create GC maps
    false, // skip (final) local propagation step
    true, // don't store information at handlers
    false, // don't skip guards
    false);
    live.perform(ir);
    // 3. initialization
    VariableStacks s = new VariableStacks();
    // 4. convert phi nodes into copies
    BasicBlock b = ((DominatorTreeNode) dom.getRoot()).getBlock();
    insertCopies(b, dom, live);
    // 5. If necessary, recompute dominators to account for new control flow.
    if (splitSomeBlock) {
        LTDominators.perform(ir, true, true);
        dom = new DominatorTree(ir, true);
    }
    // 6. compensate for copies required by simultaneous liveness
    performRename(b, dom, s);
    // 7. phis are now redundant
    removeAllPhis(ir);
}
Also used : DominatorTree(org.jikesrvm.compilers.opt.controlflow.DominatorTree) DominatorTreeNode(org.jikesrvm.compilers.opt.controlflow.DominatorTreeNode) LiveAnalysis(org.jikesrvm.compilers.opt.liveness.LiveAnalysis) BasicBlock(org.jikesrvm.compilers.opt.ir.BasicBlock)

Aggregations

DominatorTree (org.jikesrvm.compilers.opt.controlflow.DominatorTree)2 AnnotatedLSTGraph (org.jikesrvm.compilers.opt.controlflow.AnnotatedLSTGraph)1 DominatorTreeNode (org.jikesrvm.compilers.opt.controlflow.DominatorTreeNode)1 BasicBlock (org.jikesrvm.compilers.opt.ir.BasicBlock)1 Register (org.jikesrvm.compilers.opt.ir.Register)1 LiveAnalysis (org.jikesrvm.compilers.opt.liveness.LiveAnalysis)1