Search in sources :

Example 26 with Register

use of org.jikesrvm.compilers.opt.ir.Register in project JikesRVM by JikesRVM.

the class ComplexLIR2MIRExpansion method get_time_base.

private static void get_time_base(Instruction s, IR ir) {
    if (VM.BuildFor32Addr) {
        BasicBlock BB1 = s.getBasicBlock();
        BB1 = BB1.segregateInstruction(s, ir);
        Register defHigh = Nullary.getResult(s).getRegister();
        Register defLow = ir.regpool.getSecondReg(defHigh);
        Register t0 = ir.regpool.getInteger();
        Register cr = ir.regpool.getCondition();
        defLow.setSpansBasicBlock();
        defHigh.setSpansBasicBlock();
        // Try to get the base
        Register TU = ir.regpool.getPhysicalRegisterSet().asPPC().getTU();
        Register TL = ir.regpool.getPhysicalRegisterSet().asPPC().getTL();
        s.insertBefore(MIR_Move.create(PPC_MFTBU, I(defHigh), I(TU)));
        s.insertBefore(MIR_Move.create(PPC_MFTB, I(defLow), I(TL)));
        // Try again to see if it changed
        s.insertBefore(MIR_Move.create(PPC_MFTBU, I(t0), I(TU)));
        s.insertBefore(MIR_Binary.create(PPC_CMP, I(cr), I(t0), I(defHigh)));
        MIR_CondBranch.mutate(s, PPC_BCOND, I(cr), PowerPCConditionOperand.NOT_EQUAL(), BB1.makeJumpTarget(), new BranchProfileOperand());
        // fix up CFG
        BB1.insertOut(BB1);
    } else {
        // We read the 64-bit time base register atomically
        Register def = Nullary.getResult(s).getRegister();
        // See PowerPC Architecture, Book II, pp.352-353
        Register TL = ir.regpool.getPhysicalRegisterSet().asPPC().getTL();
        MIR_Move.mutate(s, PPC_MFTB, L(def), L(TL));
    }
}
Also used : Register(org.jikesrvm.compilers.opt.ir.Register) BasicBlock(org.jikesrvm.compilers.opt.ir.BasicBlock) BranchProfileOperand(org.jikesrvm.compilers.opt.ir.operand.BranchProfileOperand)

Example 27 with Register

use of org.jikesrvm.compilers.opt.ir.Register in project JikesRVM by JikesRVM.

the class LiveAnalysis method getLiveRegistersOnEntry.

/**
 * @param bb the basic block we're interested in
 * @return the set of registers that are live across a basic block, and who
 * are live before the basic block entry.
 */
HashSet<Register> getLiveRegistersOnEntry(BasicBlock bb) {
    HashSet<Register> result = new HashSet<Register>(10);
    for (Enumeration<LiveIntervalElement> e = liveIntervals.enumerateLiveIntervals(bb); e.hasMoreElements(); ) {
        LiveIntervalElement lie = e.nextElement();
        Instruction begin = lie.getBegin();
        if (begin == null)
            result.add(lie.getRegister());
    }
    return result;
}
Also used : Register(org.jikesrvm.compilers.opt.ir.Register) LiveIntervalElement(org.jikesrvm.compilers.opt.regalloc.LiveIntervalElement) Instruction(org.jikesrvm.compilers.opt.ir.Instruction) HashSet(java.util.HashSet)

Example 28 with Register

use of org.jikesrvm.compilers.opt.ir.Register in project JikesRVM by JikesRVM.

the class LiveAnalysis method getLiveRegistersOnExit.

/**
 * @param bb the basic block we're interested in
 * @return the set of registers that are live across a basic block, and who
 * are live after the basic block exit.
 */
HashSet<Register> getLiveRegistersOnExit(BasicBlock bb) {
    HashSet<Register> result = new HashSet<Register>(10);
    for (Enumeration<LiveIntervalElement> e = liveIntervals.enumerateLiveIntervals(bb); e.hasMoreElements(); ) {
        LiveIntervalElement lie = e.nextElement();
        Instruction end = lie.getEnd();
        if (end == null)
            result.add(lie.getRegister());
    }
    return result;
}
Also used : Register(org.jikesrvm.compilers.opt.ir.Register) LiveIntervalElement(org.jikesrvm.compilers.opt.regalloc.LiveIntervalElement) Instruction(org.jikesrvm.compilers.opt.ir.Instruction) HashSet(java.util.HashSet)

Example 29 with Register

use of org.jikesrvm.compilers.opt.ir.Register in project JikesRVM by JikesRVM.

the class LoadElimination method findOrCreateRegister.

/**
 * Given a value number, return the temporary register allocated
 * for that value number.  Create one if necessary.
 *
 * @param heapType a TypeReference or RVMField identifying the array SSA
 *                    heap type
 * @param valueNumber the value number
 * @param registers a mapping from value number to temporary register
 * @param pool register pool to allocate new temporaries from
 * @param type the type to store in the new register
 *
 * @return the temporary register allocated for the value number
 */
static Register findOrCreateRegister(Object heapType, int valueNumber, HashMap<UseRecord, Register> registers, GenericRegisterPool pool, TypeReference type) {
    UseRecord key = new UseRecord(heapType, valueNumber);
    Register result = registers.get(key);
    if (result == null) {
        // create a new temp and insert it in the mapping
        result = pool.makeTemp(type).getRegister();
        registers.put(key, result);
    }
    return result;
}
Also used : Register(org.jikesrvm.compilers.opt.ir.Register)

Example 30 with Register

use of org.jikesrvm.compilers.opt.ir.Register 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

Register (org.jikesrvm.compilers.opt.ir.Register)279 RegisterOperand (org.jikesrvm.compilers.opt.ir.operand.RegisterOperand)144 Instruction (org.jikesrvm.compilers.opt.ir.Instruction)106 Operand (org.jikesrvm.compilers.opt.ir.operand.Operand)82 Test (org.junit.Test)52 BasicBlock (org.jikesrvm.compilers.opt.ir.BasicBlock)50 BranchProfileOperand (org.jikesrvm.compilers.opt.ir.operand.BranchProfileOperand)45 IntConstantOperand (org.jikesrvm.compilers.opt.ir.operand.IntConstantOperand)43 GenericPhysicalRegisterSet (org.jikesrvm.compilers.opt.ir.GenericPhysicalRegisterSet)40 ConditionOperand (org.jikesrvm.compilers.opt.ir.operand.ConditionOperand)39 TrueGuardOperand (org.jikesrvm.compilers.opt.ir.operand.TrueGuardOperand)32 MemoryOperand (org.jikesrvm.compilers.opt.ir.operand.MemoryOperand)30 LocationOperand (org.jikesrvm.compilers.opt.ir.operand.LocationOperand)29 LongConstantOperand (org.jikesrvm.compilers.opt.ir.operand.LongConstantOperand)27 MethodOperand (org.jikesrvm.compilers.opt.ir.operand.MethodOperand)26 OsrPoint (org.jikesrvm.compilers.opt.ir.OsrPoint)25 ConstantOperand (org.jikesrvm.compilers.opt.ir.operand.ConstantOperand)24 IA32ConditionOperand (org.jikesrvm.compilers.opt.ir.operand.ia32.IA32ConditionOperand)23 BranchOperand (org.jikesrvm.compilers.opt.ir.operand.BranchOperand)22 StackLocationOperand (org.jikesrvm.compilers.opt.ir.operand.StackLocationOperand)22