Search in sources :

Example 61 with Register

use of org.jikesrvm.compilers.opt.ir.Register in project JikesRVM by JikesRVM.

the class EnterSSA method computeNonLocals.

/**
 * Pass through the IR and calculate which registers are not
 * local to a basic block.  Store the result in the <code> nonLocalRegisters
 * </code> field.
 */
@SuppressWarnings("unused")
private void computeNonLocals() {
    nonLocalRegisters = new HashSet<Register>(20);
    Enumeration<BasicBlock> blocks = ir.getBasicBlocks();
    while (blocks.hasMoreElements()) {
        HashSet<Register> killed = new HashSet<Register>(5);
        BasicBlock block = blocks.nextElement();
        Enumeration<Instruction> instrs = block.forwardRealInstrEnumerator();
        while (instrs.hasMoreElements()) {
            Instruction instr = instrs.nextElement();
            Enumeration<Operand> uses = instr.getUses();
            while (uses.hasMoreElements()) {
                Operand op = uses.nextElement();
                if (op instanceof RegisterOperand) {
                    if (!killed.contains(op.asRegister().getRegister())) {
                        nonLocalRegisters.add(op.asRegister().getRegister());
                    }
                }
            }
            Enumeration<Operand> defs = instr.getDefs();
            while (defs.hasMoreElements()) {
                Operand op = defs.nextElement();
                if (op instanceof RegisterOperand) {
                    killed.add(op.asRegister().getRegister());
                }
            }
        }
    }
}
Also used : RegisterOperand(org.jikesrvm.compilers.opt.ir.operand.RegisterOperand) Register(org.jikesrvm.compilers.opt.ir.Register) UnreachableOperand(org.jikesrvm.compilers.opt.ir.operand.UnreachableOperand) BasicBlockOperand(org.jikesrvm.compilers.opt.ir.operand.BasicBlockOperand) RegisterOperand(org.jikesrvm.compilers.opt.ir.operand.RegisterOperand) Operand(org.jikesrvm.compilers.opt.ir.operand.Operand) HeapOperand(org.jikesrvm.compilers.opt.ir.operand.HeapOperand) BasicBlock(org.jikesrvm.compilers.opt.ir.BasicBlock) Instruction(org.jikesrvm.compilers.opt.ir.Instruction) HashSet(java.util.HashSet)

Example 62 with Register

use of org.jikesrvm.compilers.opt.ir.Register in project JikesRVM by JikesRVM.

the class ValueGraph method processPi.

/**
 * Update the value graph to account for a given PI instruction.
 *
 * <p><b>PRECONDITION:</b> <code> s.operator == PI </code>
 *
 * @param s the instruction in question
 */
private void processPi(Instruction s) {
    Register result = GuardedUnary.getResult(s).getRegister();
    ValueGraphVertex v = findOrCreateVertex(result);
    Operand val = GuardedUnary.getVal(s);
    // bypass Move instructions that define the right-hand side
    val = bypassMoves(val);
    v.copyVertex(findOrCreateVertex(val));
}
Also used : Register(org.jikesrvm.compilers.opt.ir.Register) MethodOperand(org.jikesrvm.compilers.opt.ir.operand.MethodOperand) UnreachableOperand(org.jikesrvm.compilers.opt.ir.operand.UnreachableOperand) LongConstantOperand(org.jikesrvm.compilers.opt.ir.operand.LongConstantOperand) DoubleConstantOperand(org.jikesrvm.compilers.opt.ir.operand.DoubleConstantOperand) TypeOperand(org.jikesrvm.compilers.opt.ir.operand.TypeOperand) RegisterOperand(org.jikesrvm.compilers.opt.ir.operand.RegisterOperand) TrueGuardOperand(org.jikesrvm.compilers.opt.ir.operand.TrueGuardOperand) ConditionOperand(org.jikesrvm.compilers.opt.ir.operand.ConditionOperand) Operand(org.jikesrvm.compilers.opt.ir.operand.Operand) ObjectConstantOperand(org.jikesrvm.compilers.opt.ir.operand.ObjectConstantOperand) FloatConstantOperand(org.jikesrvm.compilers.opt.ir.operand.FloatConstantOperand) TIBConstantOperand(org.jikesrvm.compilers.opt.ir.operand.TIBConstantOperand) IntConstantOperand(org.jikesrvm.compilers.opt.ir.operand.IntConstantOperand) ConstantOperand(org.jikesrvm.compilers.opt.ir.operand.ConstantOperand)

Example 63 with Register

use of org.jikesrvm.compilers.opt.ir.Register in project JikesRVM by JikesRVM.

the class ValueGraph method bypassMoves.

/**
 * Bypass MOVE instructions that def an operand: return the first def
 * in the chain that is not the result of a MOVE instruction.
 * <p>
 * Note: treat PI instructions like MOVES
 *
 * @param op the RegisterOperand
 * @return the first def in the chain that is not the result of
 *  move if it can be found, the original operand otherwise
 */
private Operand bypassMoves(Operand op) {
    if (!op.isRegister())
        return op;
    Register r = op.asRegister().getRegister();
    Instruction def = r.getFirstDef();
    if (def == null) {
        return op;
    }
    if (r.isPhysical()) {
        return op;
    }
    if (Move.conforms(def)) {
        // infinite mutual recursion.
        return op;
    } else if (def.operator() == PI) {
        return bypassMoves(GuardedUnary.getVal(def));
    } else {
        return op;
    }
}
Also used : Register(org.jikesrvm.compilers.opt.ir.Register) Instruction(org.jikesrvm.compilers.opt.ir.Instruction)

Example 64 with Register

use of org.jikesrvm.compilers.opt.ir.Register in project JikesRVM by JikesRVM.

the class ValueGraph method processPrologue.

/**
 * Update the value graph to account for an IR_PROLOGUE instruction
 *
 * <p><b>PRECONDITION:</b> <code> Prologue.conforms(s); </code>
 *
 * @param s the instruction in question
 */
private void processPrologue(Instruction s) {
    int numArgs = 0;
    for (Enumeration<Operand> e = s.getDefs(); e.hasMoreElements(); numArgs++) {
        Register formal = ((RegisterOperand) e.nextElement()).getRegister();
        ValueGraphVertex v = findOrCreateVertex(formal);
        v.setLabel(new ValueGraphParamLabel(numArgs), 0);
    }
}
Also used : RegisterOperand(org.jikesrvm.compilers.opt.ir.operand.RegisterOperand) Register(org.jikesrvm.compilers.opt.ir.Register) MethodOperand(org.jikesrvm.compilers.opt.ir.operand.MethodOperand) UnreachableOperand(org.jikesrvm.compilers.opt.ir.operand.UnreachableOperand) LongConstantOperand(org.jikesrvm.compilers.opt.ir.operand.LongConstantOperand) DoubleConstantOperand(org.jikesrvm.compilers.opt.ir.operand.DoubleConstantOperand) TypeOperand(org.jikesrvm.compilers.opt.ir.operand.TypeOperand) RegisterOperand(org.jikesrvm.compilers.opt.ir.operand.RegisterOperand) TrueGuardOperand(org.jikesrvm.compilers.opt.ir.operand.TrueGuardOperand) ConditionOperand(org.jikesrvm.compilers.opt.ir.operand.ConditionOperand) Operand(org.jikesrvm.compilers.opt.ir.operand.Operand) ObjectConstantOperand(org.jikesrvm.compilers.opt.ir.operand.ObjectConstantOperand) FloatConstantOperand(org.jikesrvm.compilers.opt.ir.operand.FloatConstantOperand) TIBConstantOperand(org.jikesrvm.compilers.opt.ir.operand.TIBConstantOperand) IntConstantOperand(org.jikesrvm.compilers.opt.ir.operand.IntConstantOperand) ConstantOperand(org.jikesrvm.compilers.opt.ir.operand.ConstantOperand)

Example 65 with Register

use of org.jikesrvm.compilers.opt.ir.Register in project JikesRVM by JikesRVM.

the class LeaveSSA method unSSAGuardsFinalize.

/**
 * Rename registers and delete Phis.
 *
 * @param ir the governing IR, currently in SSA form
 */
private void unSSAGuardsFinalize(IR ir) {
    DefUse.computeDU(ir);
    for (Register r = ir.regpool.getFirstSymbolicRegister(); r != null; r = r.getNext()) {
        if (!r.isValidation())
            continue;
        Register nreg = guardFind(r);
        Enumeration<RegisterOperand> uses = DefUse.uses(r);
        while (uses.hasMoreElements()) {
            RegisterOperand use = uses.nextElement();
            use.setRegister(nreg);
        }
        Enumeration<RegisterOperand> defs = DefUse.defs(r);
        while (defs.hasMoreElements()) {
            RegisterOperand def = defs.nextElement();
            def.setRegister(nreg);
        }
    }
    Instruction inst = guardPhis;
    while (inst != null) {
        inst.remove();
        inst = inst2guardPhi.get(inst);
    }
}
Also used : RegisterOperand(org.jikesrvm.compilers.opt.ir.operand.RegisterOperand) Register(org.jikesrvm.compilers.opt.ir.Register) Instruction(org.jikesrvm.compilers.opt.ir.Instruction)

Aggregations

Register (org.jikesrvm.compilers.opt.ir.Register)279 RegisterOperand (org.jikesrvm.compilers.opt.ir.operand.RegisterOperand)144 Instruction (org.jikesrvm.compilers.opt.ir.Instruction)106 Operand (org.jikesrvm.compilers.opt.ir.operand.Operand)82 Test (org.junit.Test)52 BasicBlock (org.jikesrvm.compilers.opt.ir.BasicBlock)50 BranchProfileOperand (org.jikesrvm.compilers.opt.ir.operand.BranchProfileOperand)45 IntConstantOperand (org.jikesrvm.compilers.opt.ir.operand.IntConstantOperand)43 GenericPhysicalRegisterSet (org.jikesrvm.compilers.opt.ir.GenericPhysicalRegisterSet)40 ConditionOperand (org.jikesrvm.compilers.opt.ir.operand.ConditionOperand)39 TrueGuardOperand (org.jikesrvm.compilers.opt.ir.operand.TrueGuardOperand)32 MemoryOperand (org.jikesrvm.compilers.opt.ir.operand.MemoryOperand)30 LocationOperand (org.jikesrvm.compilers.opt.ir.operand.LocationOperand)29 LongConstantOperand (org.jikesrvm.compilers.opt.ir.operand.LongConstantOperand)27 MethodOperand (org.jikesrvm.compilers.opt.ir.operand.MethodOperand)26 OsrPoint (org.jikesrvm.compilers.opt.ir.OsrPoint)25 ConstantOperand (org.jikesrvm.compilers.opt.ir.operand.ConstantOperand)24 IA32ConditionOperand (org.jikesrvm.compilers.opt.ir.operand.ia32.IA32ConditionOperand)23 BranchOperand (org.jikesrvm.compilers.opt.ir.operand.BranchOperand)22 StackLocationOperand (org.jikesrvm.compilers.opt.ir.operand.StackLocationOperand)22