Search in sources :

Example 66 with Register

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

the class LeaveSSA method unSSAGuardsDetermineReg.

/**
 * Determine target register for guard phi operands
 *
 * @param ir the governing IR, currently in SSA form
 */
private void unSSAGuardsDetermineReg(IR ir) {
    Instruction inst = guardPhis;
    while (inst != null) {
        Register r = Phi.getResult(inst).asRegister().getRegister();
        int values = Phi.getNumberOfValues(inst);
        for (int i = 0; i < values; ++i) {
            Operand op = Phi.getValue(inst, i);
            if (op instanceof RegisterOperand) {
                guardUnion(op.asRegister().getRegister(), r);
            } else {
                if (VM.VerifyAssertions) {
                    VM._assert(op instanceof TrueGuardOperand || op instanceof UnreachableOperand);
                }
            }
        }
        inst = inst2guardPhi.get(inst);
    }
}
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) RegisterOperand(org.jikesrvm.compilers.opt.ir.operand.RegisterOperand) TrueGuardOperand(org.jikesrvm.compilers.opt.ir.operand.TrueGuardOperand) Operand(org.jikesrvm.compilers.opt.ir.operand.Operand) ConstantOperand(org.jikesrvm.compilers.opt.ir.operand.ConstantOperand) UnreachableOperand(org.jikesrvm.compilers.opt.ir.operand.UnreachableOperand) Instruction(org.jikesrvm.compilers.opt.ir.Instruction) TrueGuardOperand(org.jikesrvm.compilers.opt.ir.operand.TrueGuardOperand)

Example 67 with Register

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

the class LeaveSSA method performRename.

// substitute variables renamed in control parents
private void performRename(BasicBlock bb, DominatorTree dom, VariableStacks s) {
    if (DEBUG)
        VM.sysWriteln("performRename: " + bb);
    Enumeration<Instruction> e = bb.forwardRealInstrEnumerator();
    while (e.hasMoreElements()) {
        Instruction i = e.nextElement();
        Enumeration<Operand> ee = i.getUses();
        while (ee.hasMoreElements()) {
            Operand o = ee.nextElement();
            if (o instanceof RegisterOperand) {
                Register r1 = ((RegisterOperand) o).getRegister();
                if (r1.isValidation())
                    continue;
                Operand r2 = s.peek(r1);
                if (r2 != null) {
                    if (DEBUG) {
                        VM.sysWriteln("replace operand in " + i + "(" + r2 + " for " + o);
                    }
                    i.replaceOperand(o, r2.copy());
                }
            }
        }
    }
    // record renamings required in children
    e = bb.forwardRealInstrEnumerator();
    while (e.hasMoreElements()) {
        Instruction i = e.nextElement();
        if (globalRenameTable.contains(i)) {
            Register original = Move.getVal(i).asRegister().getRegister();
            RegisterOperand rename = Move.getResult(i);
            if (DEBUG)
                VM.sysWriteln("record rename " + rename + " for " + original);
            s.push(original, rename);
        }
    }
    // insert copies in control children
    Enumeration<TreeNode> children = dom.getChildren(bb);
    while (children.hasMoreElements()) {
        BasicBlock c = ((DominatorTreeNode) children.nextElement()).getBlock();
        performRename(c, dom, s);
    }
    // pop renamings from this block off stack
    e = bb.forwardRealInstrEnumerator();
    while (e.hasMoreElements()) {
        Instruction i = e.nextElement();
        if (globalRenameTable.contains(i)) {
            Register original = Move.getVal(i).asRegister().getRegister();
            s.pop(original);
        }
    }
}
Also used : RegisterOperand(org.jikesrvm.compilers.opt.ir.operand.RegisterOperand) Register(org.jikesrvm.compilers.opt.ir.Register) DominatorTreeNode(org.jikesrvm.compilers.opt.controlflow.DominatorTreeNode) UnreachableOperand(org.jikesrvm.compilers.opt.ir.operand.UnreachableOperand) RegisterOperand(org.jikesrvm.compilers.opt.ir.operand.RegisterOperand) TrueGuardOperand(org.jikesrvm.compilers.opt.ir.operand.TrueGuardOperand) Operand(org.jikesrvm.compilers.opt.ir.operand.Operand) ConstantOperand(org.jikesrvm.compilers.opt.ir.operand.ConstantOperand) TreeNode(org.jikesrvm.compilers.opt.util.TreeNode) DominatorTreeNode(org.jikesrvm.compilers.opt.controlflow.DominatorTreeNode) BasicBlock(org.jikesrvm.compilers.opt.ir.BasicBlock) Instruction(org.jikesrvm.compilers.opt.ir.Instruction)

Example 68 with Register

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

the class GenerationContextTest method assertThatLocalsForInstanceMethodWithoutParametersAreCorrect.

private void assertThatLocalsForInstanceMethodWithoutParametersAreCorrect(NormalMethod nm, GenerationContext gc) {
    assertThatNumberOfParametersIs(gc, 1);
    RegisterOperand thisOperand = getThisOperand(gc);
    assertThatRegOpHoldsClassType(thisOperand);
    assertThatRegOpHasDeclaredType(thisOperand);
    Register thisLocalReg = gc.localReg(0, nm.getDeclaringClass().getTypeRef());
    assertThatRegOpIsLocalRegOfRegister(thisOperand, thisLocalReg);
}
Also used : RegisterOperand(org.jikesrvm.compilers.opt.ir.operand.RegisterOperand) Register(org.jikesrvm.compilers.opt.ir.Register)

Example 69 with Register

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

the class GenerationContextTest method noNullCheckGuardsCanBeCreatedAfterCloseWasCalled.

@Test(expected = NullPointerException.class)
public void noNullCheckGuardsCanBeCreatedAfterCloseWasCalled() throws Exception {
    NormalMethod nm = TestingTools.getNormalMethod(MethodsForTests.class, "emptyInstanceMethodWithoutAnnotations");
    OptOptions opts = new OptOptions();
    GenerationContext gc = new GenerationContext(nm, null, null, opts, null);
    RegisterOperand thisLocal = gc.makeLocal(0, nm.getDeclaringClass().getTypeRef());
    Register thisReg = thisLocal.getRegister();
    gc.close();
    gc.makeNullCheckGuard(thisReg);
}
Also used : RegisterOperand(org.jikesrvm.compilers.opt.ir.operand.RegisterOperand) Register(org.jikesrvm.compilers.opt.ir.Register) NormalMethod(org.jikesrvm.classloader.NormalMethod) OptOptions(org.jikesrvm.compilers.opt.OptOptions) Test(org.junit.Test)

Example 70 with Register

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

the class GenerationContextTest method resyncDeletesNullCheckGuardsThatMapToUnusedRegisters.

@Test
public void resyncDeletesNullCheckGuardsThatMapToUnusedRegisters() throws Exception {
    NormalMethod nm = TestingTools.getNormalMethod(MethodsForTests.class, "emptyInstanceMethodWithoutAnnotations");
    OptOptions opts = new OptOptions();
    GenerationContext gc = new GenerationContext(nm, null, null, opts, null);
    RegisterOperand thisLocal = gc.makeLocal(0, nm.getDeclaringClass().getTypeRef());
    Register thisReg = thisLocal.getRegister();
    RegisterOperand thisNullCheckGuard = gc.makeNullCheckGuard(thisReg);
    assertNotNull(thisNullCheckGuard);
    gc.getTemps().removeRegister(thisReg);
    gc.resync();
    RegisterOperand newNullCheckGuard = gc.makeNullCheckGuard(thisReg);
    assertFalse(newNullCheckGuard.sameRegisterPropertiesAs(thisNullCheckGuard));
}
Also used : RegisterOperand(org.jikesrvm.compilers.opt.ir.operand.RegisterOperand) Register(org.jikesrvm.compilers.opt.ir.Register) NormalMethod(org.jikesrvm.classloader.NormalMethod) OptOptions(org.jikesrvm.compilers.opt.OptOptions) Test(org.junit.Test)

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