Search in sources :

Example 11 with GenericPhysicalRegisterSet

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;
}
Also used : GenericPhysicalRegisterSet(org.jikesrvm.compilers.opt.ir.GenericPhysicalRegisterSet) Register(org.jikesrvm.compilers.opt.ir.Register)

Example 12 with GenericPhysicalRegisterSet

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);
    }
}
Also used : GenericPhysicalRegisterSet(org.jikesrvm.compilers.opt.ir.GenericPhysicalRegisterSet) Register(org.jikesrvm.compilers.opt.ir.Register)

Example 13 with GenericPhysicalRegisterSet

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)));
    }
}
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 14 with GenericPhysicalRegisterSet

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)));
    }
}
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 15 with GenericPhysicalRegisterSet

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

Aggregations

GenericPhysicalRegisterSet (org.jikesrvm.compilers.opt.ir.GenericPhysicalRegisterSet)25 Register (org.jikesrvm.compilers.opt.ir.Register)21 RegisterOperand (org.jikesrvm.compilers.opt.ir.operand.RegisterOperand)12 Operand (org.jikesrvm.compilers.opt.ir.operand.Operand)10 MemoryOperand (org.jikesrvm.compilers.opt.ir.operand.MemoryOperand)8 StackLocationOperand (org.jikesrvm.compilers.opt.ir.operand.StackLocationOperand)8 IA32ConditionOperand (org.jikesrvm.compilers.opt.ir.operand.ia32.IA32ConditionOperand)8 TrapCodeOperand (org.jikesrvm.compilers.opt.ir.operand.TrapCodeOperand)6 Instruction (org.jikesrvm.compilers.opt.ir.Instruction)3 BasicBlock (org.jikesrvm.compilers.opt.ir.BasicBlock)2 BranchProfileOperand (org.jikesrvm.compilers.opt.ir.operand.BranchProfileOperand)2 LocationOperand (org.jikesrvm.compilers.opt.ir.operand.LocationOperand)2 MethodOperand (org.jikesrvm.compilers.opt.ir.operand.MethodOperand)2 HashSet (java.util.HashSet)1 TypeReference (org.jikesrvm.classloader.TypeReference)1 ControlFlowGraph (org.jikesrvm.compilers.opt.ir.ControlFlowGraph)1 GCIRMapElement (org.jikesrvm.compilers.opt.ir.GCIRMapElement)1 RegSpillListElement (org.jikesrvm.compilers.opt.ir.RegSpillListElement)1 DoubleConstantOperand (org.jikesrvm.compilers.opt.ir.operand.DoubleConstantOperand)1 FloatConstantOperand (org.jikesrvm.compilers.opt.ir.operand.FloatConstantOperand)1