use of org.jikesrvm.compilers.opt.ir.operand.StackLocationOperand 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.operand.StackLocationOperand in project JikesRVM by JikesRVM.
the class StackManager method rewriteMoveInstruction.
/**
* Rewrites a move instruction if it has 2 memory operands.
* One of the 2 memory operands must be a stack location operand. Move
* the SP to the appropriate location and use a push or pop instruction.
*
* @param s the instruction to rewrite
*/
private void rewriteMoveInstruction(Instruction s) {
// first attempt to mutate the move into a noop
if (mutateMoveToNop(s))
return;
Operand result = MIR_Move.getResult(s);
Operand val = MIR_Move.getValue(s);
if (result instanceof StackLocationOperand) {
if (val instanceof MemoryOperand || val instanceof StackLocationOperand) {
int offset = ((StackLocationOperand) result).getOffset();
byte size = ((StackLocationOperand) result).getSize();
offset = FPOffset2SPOffset(offset) + size;
moveESPBefore(s, offset);
MIR_UnaryNoRes.mutate(s, IA32_PUSH, val);
}
} else {
if (result instanceof MemoryOperand) {
if (val instanceof StackLocationOperand) {
int offset = ((StackLocationOperand) val).getOffset();
offset = FPOffset2SPOffset(offset);
moveESPBefore(s, offset);
MIR_Nullary.mutate(s, IA32_POP, result);
}
}
}
}
use of org.jikesrvm.compilers.opt.ir.operand.StackLocationOperand 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));
}
}
use of org.jikesrvm.compilers.opt.ir.operand.StackLocationOperand in project JikesRVM by JikesRVM.
the class StackManager method restoreVolatileRegisters.
/**
* Insert code before a return instruction to restore the volatile
* and volatile registers.
*
* @param inst the return instruction
*/
private void restoreVolatileRegisters(Instruction inst) {
GenericPhysicalRegisterSet phys = ir.regpool.getPhysicalRegisterSet();
// Restore every 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, new RegisterOperand(r, PRIMITIVE_TYPE_FOR_WORD), M));
}
}
use of org.jikesrvm.compilers.opt.ir.operand.StackLocationOperand in project JikesRVM by JikesRVM.
the class StackManager method restoreFloatingPointState.
/**
* Insert code into the epilogue to restore the floating point state.
*
* @param inst the return instruction after the epilogue.
*/
private void restoreFloatingPointState(Instruction inst) {
if (SSE2_FULL) {
GenericPhysicalRegisterSet phys = ir.regpool.getPhysicalRegisterSet();
for (int i = 0; i < 8; i++) {
inst.insertBefore(MIR_Move.create(IA32_MOVQ, new RegisterOperand(phys.getFPR(i), TypeReference.Double), new StackLocationOperand(true, -fsaveLocation + (i * BYTES_IN_DOUBLE), BYTES_IN_DOUBLE)));
}
} else {
Operand M = new StackLocationOperand(true, -fsaveLocation, 4);
inst.insertBefore(MIR_FSave.create(IA32_FRSTOR, M));
}
}
Aggregations