Search in sources :

Example 16 with StackLocationOperand

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)));
    }
}
Also used : GenericPhysicalRegisterSet(org.jikesrvm.compilers.opt.ir.GenericPhysicalRegisterSet) RegisterOperand(org.jikesrvm.compilers.opt.ir.operand.RegisterOperand) Register(org.jikesrvm.compilers.opt.ir.Register) RegisterOperand(org.jikesrvm.compilers.opt.ir.operand.RegisterOperand) Operand(org.jikesrvm.compilers.opt.ir.operand.Operand) IA32ConditionOperand(org.jikesrvm.compilers.opt.ir.operand.ia32.IA32ConditionOperand) StackLocationOperand(org.jikesrvm.compilers.opt.ir.operand.StackLocationOperand) TrapCodeOperand(org.jikesrvm.compilers.opt.ir.operand.TrapCodeOperand) MemoryOperand(org.jikesrvm.compilers.opt.ir.operand.MemoryOperand) StackLocationOperand(org.jikesrvm.compilers.opt.ir.operand.StackLocationOperand)

Example 17 with StackLocationOperand

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);
            }
        }
    }
}
Also used : RegisterOperand(org.jikesrvm.compilers.opt.ir.operand.RegisterOperand) Operand(org.jikesrvm.compilers.opt.ir.operand.Operand) IA32ConditionOperand(org.jikesrvm.compilers.opt.ir.operand.ia32.IA32ConditionOperand) StackLocationOperand(org.jikesrvm.compilers.opt.ir.operand.StackLocationOperand) TrapCodeOperand(org.jikesrvm.compilers.opt.ir.operand.TrapCodeOperand) MemoryOperand(org.jikesrvm.compilers.opt.ir.operand.MemoryOperand) MemoryOperand(org.jikesrvm.compilers.opt.ir.operand.MemoryOperand) StackLocationOperand(org.jikesrvm.compilers.opt.ir.operand.StackLocationOperand)

Example 18 with StackLocationOperand

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));
    }
}
Also used : GenericPhysicalRegisterSet(org.jikesrvm.compilers.opt.ir.GenericPhysicalRegisterSet) RegisterOperand(org.jikesrvm.compilers.opt.ir.operand.RegisterOperand) Register(org.jikesrvm.compilers.opt.ir.Register) RegisterOperand(org.jikesrvm.compilers.opt.ir.operand.RegisterOperand) Operand(org.jikesrvm.compilers.opt.ir.operand.Operand) IA32ConditionOperand(org.jikesrvm.compilers.opt.ir.operand.ia32.IA32ConditionOperand) StackLocationOperand(org.jikesrvm.compilers.opt.ir.operand.StackLocationOperand) TrapCodeOperand(org.jikesrvm.compilers.opt.ir.operand.TrapCodeOperand) MemoryOperand(org.jikesrvm.compilers.opt.ir.operand.MemoryOperand) StackLocationOperand(org.jikesrvm.compilers.opt.ir.operand.StackLocationOperand)

Example 19 with StackLocationOperand

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));
    }
}
Also used : GenericPhysicalRegisterSet(org.jikesrvm.compilers.opt.ir.GenericPhysicalRegisterSet) RegisterOperand(org.jikesrvm.compilers.opt.ir.operand.RegisterOperand) Register(org.jikesrvm.compilers.opt.ir.Register) RegisterOperand(org.jikesrvm.compilers.opt.ir.operand.RegisterOperand) Operand(org.jikesrvm.compilers.opt.ir.operand.Operand) IA32ConditionOperand(org.jikesrvm.compilers.opt.ir.operand.ia32.IA32ConditionOperand) StackLocationOperand(org.jikesrvm.compilers.opt.ir.operand.StackLocationOperand) TrapCodeOperand(org.jikesrvm.compilers.opt.ir.operand.TrapCodeOperand) MemoryOperand(org.jikesrvm.compilers.opt.ir.operand.MemoryOperand) StackLocationOperand(org.jikesrvm.compilers.opt.ir.operand.StackLocationOperand)

Example 20 with StackLocationOperand

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));
    }
}
Also used : GenericPhysicalRegisterSet(org.jikesrvm.compilers.opt.ir.GenericPhysicalRegisterSet) RegisterOperand(org.jikesrvm.compilers.opt.ir.operand.RegisterOperand) RegisterOperand(org.jikesrvm.compilers.opt.ir.operand.RegisterOperand) Operand(org.jikesrvm.compilers.opt.ir.operand.Operand) IA32ConditionOperand(org.jikesrvm.compilers.opt.ir.operand.ia32.IA32ConditionOperand) StackLocationOperand(org.jikesrvm.compilers.opt.ir.operand.StackLocationOperand) TrapCodeOperand(org.jikesrvm.compilers.opt.ir.operand.TrapCodeOperand) MemoryOperand(org.jikesrvm.compilers.opt.ir.operand.MemoryOperand) StackLocationOperand(org.jikesrvm.compilers.opt.ir.operand.StackLocationOperand)

Aggregations

StackLocationOperand (org.jikesrvm.compilers.opt.ir.operand.StackLocationOperand)28 RegisterOperand (org.jikesrvm.compilers.opt.ir.operand.RegisterOperand)26 MemoryOperand (org.jikesrvm.compilers.opt.ir.operand.MemoryOperand)22 Operand (org.jikesrvm.compilers.opt.ir.operand.Operand)20 IA32ConditionOperand (org.jikesrvm.compilers.opt.ir.operand.ia32.IA32ConditionOperand)20 TrapCodeOperand (org.jikesrvm.compilers.opt.ir.operand.TrapCodeOperand)15 LocationOperand (org.jikesrvm.compilers.opt.ir.operand.LocationOperand)13 GenericPhysicalRegisterSet (org.jikesrvm.compilers.opt.ir.GenericPhysicalRegisterSet)12 BranchProfileOperand (org.jikesrvm.compilers.opt.ir.operand.BranchProfileOperand)11 MethodOperand (org.jikesrvm.compilers.opt.ir.operand.MethodOperand)11 Register (org.jikesrvm.compilers.opt.ir.Register)10 OsrPoint (org.jikesrvm.compilers.opt.ir.OsrPoint)9 LongConstantOperand (org.jikesrvm.compilers.opt.ir.operand.LongConstantOperand)8 IntConstantOperand (org.jikesrvm.compilers.opt.ir.operand.IntConstantOperand)7 Instruction (org.jikesrvm.compilers.opt.ir.Instruction)6 BranchOperand (org.jikesrvm.compilers.opt.ir.operand.BranchOperand)6 ConditionOperand (org.jikesrvm.compilers.opt.ir.operand.ConditionOperand)6 ConstantOperand (org.jikesrvm.compilers.opt.ir.operand.ConstantOperand)6 DoubleConstantOperand (org.jikesrvm.compilers.opt.ir.operand.DoubleConstantOperand)6 FloatConstantOperand (org.jikesrvm.compilers.opt.ir.operand.FloatConstantOperand)6