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);
}
}
Aggregations