Search in sources :

Example 6 with LiveIntervalElement

use of org.jikesrvm.compilers.opt.regalloc.LiveIntervalElement in project JikesRVM by JikesRVM.

the class LiveIntervalEnumeration method nextElement.

@Override
public LiveIntervalElement nextElement() {
    LiveIntervalElement result = currentElement;
    currentElement = currentElement.getNext();
    return result;
}
Also used : LiveIntervalElement(org.jikesrvm.compilers.opt.regalloc.LiveIntervalElement)

Example 7 with LiveIntervalElement

use of org.jikesrvm.compilers.opt.regalloc.LiveIntervalElement in project JikesRVM by JikesRVM.

the class RegisterRestrictions method addArchRestrictions.

@Override
public void addArchRestrictions(BasicBlock bb, ArrayList<LiveIntervalElement> symbolics) {
    // the code in MIRSplitRanges.
    for (Enumeration<Instruction> ie = bb.forwardInstrEnumerator(); ie.hasMoreElements(); ) {
        Instruction s = ie.nextElement();
        if (s.isPEI() && s.operator() != IR_PROLOGUE) {
            if (bb.hasApplicableExceptionalOut(s) || !SCRATCH_IN_PEI) {
                for (Enumeration<Operand> e = s.getOperands(); e.hasMoreElements(); ) {
                    Operand op = e.nextElement();
                    if (op != null && op.isRegister()) {
                        noteMustNotSpill(op.asRegister().getRegister());
                        handle8BitRestrictions(s);
                    }
                }
            }
        }
        // handle special cases
        switch(s.getOpcode()) {
            case MIR_LOWTABLESWITCH_opcode:
                {
                    RegisterOperand op = MIR_LowTableSwitch.getMethodStart(s);
                    noteMustNotSpill(op.getRegister());
                    op = MIR_LowTableSwitch.getIndex(s);
                    noteMustNotSpill(op.getRegister());
                }
                break;
            case IA32_MOVZX__B_opcode:
            case IA32_MOVSX__B_opcode:
            case IA32_MOVZXQ__B_opcode:
            case IA32_MOVSXQ__B_opcode:
                {
                    if (MIR_Unary.getVal(s).isRegister()) {
                        RegisterOperand val = MIR_Unary.getVal(s).asRegister();
                        restrictTo8Bits(val.getRegister());
                    }
                }
                break;
            case IA32_SET__B_opcode:
                {
                    if (MIR_Set.getResult(s).isRegister()) {
                        RegisterOperand op = MIR_Set.getResult(s).asRegister();
                        restrictTo8Bits(op.getRegister());
                    }
                }
                break;
            default:
                handle8BitRestrictions(s);
                break;
        }
    }
    for (Enumeration<Instruction> ie = bb.forwardInstrEnumerator(); ie.hasMoreElements(); ) {
        Instruction s = ie.nextElement();
        if (s.operator() == IA32_FNINIT) {
            // No floating point register survives across an FNINIT
            for (LiveIntervalElement symb : symbolics) {
                if (symb.getRegister().isFloatingPoint()) {
                    if (contains(symb, regAllocState.getDFN(s))) {
                        addRestrictions(symb.getRegister(), phys.asIA32().getFPRs());
                    }
                }
            }
        } else if (s.operator() == IA32_FCLEAR) {
            // Only some FPRs survive across an FCLEAR
            for (LiveIntervalElement symb : symbolics) {
                if (symb.getRegister().isFloatingPoint()) {
                    if (contains(symb, regAllocState.getDFN(s))) {
                        int nSave = MIR_UnaryNoRes.getVal(s).asIntConstant().value;
                        for (int i = nSave; i < NUM_FPRS; i++) {
                            addRestriction(symb.getRegister(), phys.getFPR(i));
                        }
                    }
                }
            }
        }
    }
}
Also used : RegisterOperand(org.jikesrvm.compilers.opt.ir.operand.RegisterOperand) RegisterOperand(org.jikesrvm.compilers.opt.ir.operand.RegisterOperand) Operand(org.jikesrvm.compilers.opt.ir.operand.Operand) BURSManagedFPROperand(org.jikesrvm.compilers.opt.ir.operand.ia32.BURSManagedFPROperand) MemoryOperand(org.jikesrvm.compilers.opt.ir.operand.MemoryOperand) LiveIntervalElement(org.jikesrvm.compilers.opt.regalloc.LiveIntervalElement) Instruction(org.jikesrvm.compilers.opt.ir.Instruction)

Example 8 with LiveIntervalElement

use of org.jikesrvm.compilers.opt.regalloc.LiveIntervalElement in project JikesRVM by JikesRVM.

the class LiveAnalysis method addToRegisterMap.

private void addToRegisterMap(Register r, LiveIntervalElement i) {
    int regNumber = r.getNumber();
    ArrayList<LiveIntervalElement> set = registerMap[regNumber];
    if (set == null) {
        set = new ArrayList<LiveIntervalElement>(3);
        registerMap[regNumber] = set;
    }
    set.add(i);
}
Also used : LiveIntervalElement(org.jikesrvm.compilers.opt.regalloc.LiveIntervalElement) OsrPoint(org.jikesrvm.compilers.opt.ir.OsrPoint)

Example 9 with LiveIntervalElement

use of org.jikesrvm.compilers.opt.regalloc.LiveIntervalElement in project JikesRVM by JikesRVM.

the class LiveAnalysis method computeRegisterMap.

/**
 * Sets up a mapping from each register to the set of live intervals for
 * the register.
 * <p>
 * Side effect: map each live interval element to its basic block.
 *
 * @param ir the governing IR
 */
@SuppressWarnings("unchecked")
private void computeRegisterMap(IR ir) {
    registerMap = new ArrayList[ir.regpool.getNumberOfSymbolicRegisters()];
    for (Enumeration<BasicBlock> e = ir.getBasicBlocks(); e.hasMoreElements(); ) {
        BasicBlock bb = e.nextElement();
        for (Enumeration<LiveIntervalElement> i = liveIntervals.enumerateLiveIntervals(bb); i.hasMoreElements(); ) {
            LiveIntervalElement lie = i.nextElement();
            lie.setBasicBlock(bb);
            if (lie.getRegister().isSymbolic()) {
                addToRegisterMap(lie.getRegister(), lie);
            }
        }
    }
}
Also used : ExceptionHandlerBasicBlock(org.jikesrvm.compilers.opt.ir.ExceptionHandlerBasicBlock) BasicBlock(org.jikesrvm.compilers.opt.ir.BasicBlock) LiveIntervalElement(org.jikesrvm.compilers.opt.regalloc.LiveIntervalElement)

Example 10 with LiveIntervalElement

use of org.jikesrvm.compilers.opt.regalloc.LiveIntervalElement in project JikesRVM by JikesRVM.

the class LiveInterval method createEndLiveRange.

/**
 * This method checks if an existing unresolved live interval node, i.e.,
 * one that has an end instruction, but no beginning instruction, is present
 * for the register and basic block passed.  If one does not exist, it
 * creates a node with the end instruction being <code>inst</code>.  If one
 * already exists no action is taken.
 *
 * @param reg   The register
 * @param block The basic block
 * @param inst  The end instruction to use, if we have to create a neode.
 */
public void createEndLiveRange(Register reg, BasicBlock block, Instruction inst) {
    if (DEBUG) {
        System.out.println("Marking Register " + reg + "'s live range as ENDing at instruction\n   " + inst + " in block #" + block.getNumber());
        printLiveIntervalList(block);
    }
    if (!containsUnresolvedElement(block, reg)) {
        LiveIntervalElement elem = new LiveIntervalElement(reg, null, inst);
        prependLiveIntervalElement(block, elem);
    }
}
Also used : LiveIntervalElement(org.jikesrvm.compilers.opt.regalloc.LiveIntervalElement)

Aggregations

LiveIntervalElement (org.jikesrvm.compilers.opt.regalloc.LiveIntervalElement)11 Instruction (org.jikesrvm.compilers.opt.ir.Instruction)3 HashSet (java.util.HashSet)2 Register (org.jikesrvm.compilers.opt.ir.Register)2 BasicBlock (org.jikesrvm.compilers.opt.ir.BasicBlock)1 ExceptionHandlerBasicBlock (org.jikesrvm.compilers.opt.ir.ExceptionHandlerBasicBlock)1 OsrPoint (org.jikesrvm.compilers.opt.ir.OsrPoint)1 MemoryOperand (org.jikesrvm.compilers.opt.ir.operand.MemoryOperand)1 Operand (org.jikesrvm.compilers.opt.ir.operand.Operand)1 RegisterOperand (org.jikesrvm.compilers.opt.ir.operand.RegisterOperand)1 BURSManagedFPROperand (org.jikesrvm.compilers.opt.ir.operand.ia32.BURSManagedFPROperand)1