Search in sources :

Example 11 with LiveIntervalElement

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

the class LiveInterval method setStartLiveRange.

/**
 * This method finds the LiveInterval node for the register and basic block
 * passed.  It then sets the begin instruction to the instruction passed
 * and moves the node to the proper place on the list block list.
 * (The block list is sorted by "begin" instruction.
 *
 * @param reg   the register of interest
 * @param inst  the "begin" instruction
 * @param block the basic block of interest
 */
public void setStartLiveRange(Register reg, Instruction inst, BasicBlock block) {
    if (DEBUG) {
        System.out.println("Marking Register " + reg + "'s live range as STARTing at instruction\n   " + inst + " in block #" + block.getNumber());
    }
    LiveIntervalElement prev = null;
    LiveIntervalElement elem = getFirstLiveIntervalElement(block);
    while (elem != null) {
        if (elem.getRegister() == reg && elem.getBegin() == null) {
            break;
        }
        prev = elem;
        elem = elem.getNext();
    }
    if (elem != null) {
        elem.setBegin(inst);
        // be the most recent.  Thus, we move "elem" to the front of the list.
        if (prev != null) {
            // remove elem from current position
            prev.setNext(elem.getNext());
            // add it to the begining
            prependLiveIntervalElement(block, elem);
        }
    // if prev == null, the element is already first in the list!
    } else {
        // if we didn't find it, it means we have a def that is not later
        // used, i.e., a dead assignment.  This may exist because the
        // instruction has side effects such as a function call or a PEI
        // In this case, we create a LiveIntervalElement node with begining
        // and ending instruction "inst"
        LiveIntervalElement newElem = new LiveIntervalElement(reg, inst, inst);
        prependLiveIntervalElement(block, newElem);
    }
    if (DEBUG) {
        System.out.println("after add");
        printLiveIntervalList(block);
    }
}
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