use of org.jikesrvm.compilers.opt.ir.GenericPhysicalRegisterSet in project JikesRVM by JikesRVM.
the class ActiveSet method findAvailableRegister.
/**
* @param ci interval to allocate
* @return a free physical register to allocate to the compound
* interval, {@code null} if no free physical register is found
*/
Register findAvailableRegister(CompoundInterval ci) {
if (ir.options.FREQ_FOCUS_EFFORT && ci.isInfrequent()) {
// don't bother trying to find an available register
return null;
}
Register r = ci.getRegister();
GenericRegisterRestrictions restrict = ir.stackManager.getRestrictions();
// first attempt to allocate to the preferred register
if (ir.options.REGALLOC_COALESCE_MOVES) {
Register p = getPhysicalPreference(ci);
if (p != null) {
if (LinearScan.DEBUG_COALESCE) {
System.out.println("REGISTER PREFERENCE " + ci + " " + p);
}
return p;
}
}
GenericPhysicalRegisterSet phys = ir.regpool.getPhysicalRegisterSet();
int type = GenericPhysicalRegisterSet.getPhysicalRegisterType(r);
// next attempt to allocate to a volatile
if (!restrict.allVolatilesForbidden(r)) {
for (Enumeration<Register> e = phys.enumerateVolatiles(type); e.hasMoreElements(); ) {
Register p = e.nextElement();
if (allocateToPhysical(ci, p)) {
return p;
}
}
}
// novolatiles backwards.
for (Enumeration<Register> e = phys.enumerateNonvolatilesBackwards(type); e.hasMoreElements(); ) {
Register p = e.nextElement();
if (allocateToPhysical(ci, p)) {
return p;
}
}
// no allocation succeeded.
return null;
}
use of org.jikesrvm.compilers.opt.ir.GenericPhysicalRegisterSet in project JikesRVM by JikesRVM.
the class RegisterAllocatorState method resetPhysicalRegisters.
/**
* Resets the physical register info.
*
* @param ir the IR whose info is to be reset
*/
void resetPhysicalRegisters(IR ir) {
GenericPhysicalRegisterSet phys = ir.regpool.getPhysicalRegisterSet();
for (Enumeration<Register> e = phys.enumerateAll(); e.hasMoreElements(); ) {
Register reg = e.nextElement();
reg.deallocateRegister();
// mapping from real to symbolic
reg.mapsToRegister = null;
reg.defList = null;
reg.useList = null;
setSpill(reg, 0);
}
}
use of org.jikesrvm.compilers.opt.ir.GenericPhysicalRegisterSet in project JikesRVM by JikesRVM.
the class StackManager method saveNonVolatiles.
/**
* Insert code into the prologue to save any used non-volatile
* registers.
*
* @param inst the first instruction after the prologue.
*/
private void saveNonVolatiles(Instruction inst) {
GenericPhysicalRegisterSet phys = ir.regpool.getPhysicalRegisterSet();
int nNonvolatileGPRS = ir.compiledMethod.getNumberOfNonvolatileGPRs();
// Save each non-volatile GPR used by this method.
int n = nNonvolatileGPRS - 1;
for (Enumeration<Register> e = phys.enumerateNonvolatileGPRsBackwards(); e.hasMoreElements() && n >= 0; n--) {
Register nv = e.nextElement();
int offset = getNonvolatileGPROffset(n);
Operand M = new StackLocationOperand(true, -offset, WORDSIZE);
inst.insertBefore(MIR_Move.create(IA32_MOV, M, new RegisterOperand(nv, PRIMITIVE_TYPE_FOR_WORD)));
}
}
use of org.jikesrvm.compilers.opt.ir.GenericPhysicalRegisterSet in project JikesRVM by JikesRVM.
the class StackManager method saveVolatiles.
/**
* Insert code into the prologue to save all volatile
* registers.
*
* @param inst the first instruction after the prologue.
*/
private void saveVolatiles(Instruction inst) {
GenericPhysicalRegisterSet phys = ir.regpool.getPhysicalRegisterSet();
// Save each GPR.
int i = 0;
for (Enumeration<Register> e = phys.enumerateVolatileGPRs(); e.hasMoreElements(); i++) {
Register r = e.nextElement();
int location = saveVolatileGPRLocation[i];
Operand M = new StackLocationOperand(true, -location, WORDSIZE);
inst.insertBefore(MIR_Move.create(IA32_MOV, M, new RegisterOperand(r, PRIMITIVE_TYPE_FOR_WORD)));
}
}
use of org.jikesrvm.compilers.opt.ir.GenericPhysicalRegisterSet in project JikesRVM by JikesRVM.
the class StackManager method restoreNonVolatiles.
/**
* Insert code before a return instruction to restore the nonvolatile
* registers.
*
* @param inst the return instruction
*/
private void restoreNonVolatiles(Instruction inst) {
GenericPhysicalRegisterSet phys = ir.regpool.getPhysicalRegisterSet();
int nNonvolatileGPRS = ir.compiledMethod.getNumberOfNonvolatileGPRs();
int n = nNonvolatileGPRS - 1;
for (Enumeration<Register> e = phys.enumerateNonvolatileGPRsBackwards(); e.hasMoreElements() && n >= 0; n--) {
Register nv = e.nextElement();
int offset = getNonvolatileGPROffset(n);
Operand M = new StackLocationOperand(true, -offset, WORDSIZE);
inst.insertBefore(MIR_Move.create(IA32_MOV, new RegisterOperand(nv, PRIMITIVE_TYPE_FOR_WORD), M));
}
}
Aggregations