Search in sources :

Example 1 with AnnotatedLSTGraph

use of org.jikesrvm.compilers.opt.controlflow.AnnotatedLSTGraph 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)

Aggregations

AnnotatedLSTGraph (org.jikesrvm.compilers.opt.controlflow.AnnotatedLSTGraph)1 DominatorTree (org.jikesrvm.compilers.opt.controlflow.DominatorTree)1 Register (org.jikesrvm.compilers.opt.ir.Register)1