Search in sources :

Example 21 with BranchProfileOperand

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

the class BURS_Helpers method DOUBLE_IFCMP.

protected final void DOUBLE_IFCMP(Instruction s, RegisterOperand left, Operand right) {
    // Create compare
    RegisterOperand cr = regpool.makeTempCondition();
    EMIT(MIR_Binary.create(PPC_FCMPU, cr, left, right));
    // Branch depends on condition
    ConditionOperand c = IfCmp.getCond(s);
    BranchOperand target = IfCmp.getClearTarget(s);
    if (!c.branchIfUnordered()) {
        // If branch doesn't branch when unordered then we need just one
        // branch destination
        EMIT(MIR_CondBranch.create(PPC_BCOND, cr.copyD2U(), new PowerPCConditionOperand(c), target, IfCmp.getClearBranchProfile(s)));
    } else {
        if ((c.value != ConditionOperand.NOT_EQUAL) || (!left.similar(right))) {
            // Propagate branch probabilities as follows: assume the
            // probability of unordered (first condition) is zero, and
            // propagate the original probability to the second condition.
            EMIT(MIR_CondBranch2.create(PPC_BCOND2, cr.copyD2U(), PowerPCConditionOperand.UNORDERED(), target, new BranchProfileOperand(0f), new PowerPCConditionOperand(c), (BranchOperand) target.copy(), IfCmp.getClearBranchProfile(s)));
        } else {
            // If branch is effectively a NaN test we just need 1 branch
            EMIT(MIR_CondBranch.create(PPC_BCOND, cr.copyD2U(), new PowerPCConditionOperand(c), target, IfCmp.getClearBranchProfile(s)));
        }
    }
}
Also used : RegisterOperand(org.jikesrvm.compilers.opt.ir.operand.RegisterOperand) PowerPCConditionOperand(org.jikesrvm.compilers.opt.ir.operand.ppc.PowerPCConditionOperand) BranchProfileOperand(org.jikesrvm.compilers.opt.ir.operand.BranchProfileOperand) PowerPCConditionOperand(org.jikesrvm.compilers.opt.ir.operand.ppc.PowerPCConditionOperand) ConditionOperand(org.jikesrvm.compilers.opt.ir.operand.ConditionOperand) BranchOperand(org.jikesrvm.compilers.opt.ir.operand.BranchOperand)

Example 22 with BranchProfileOperand

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

the class ComplexLIR2MIRExpansion method long_ifcmp.

private static void long_ifcmp(Instruction s, IR ir) {
    if (VM.VerifyAssertions)
        VM._assert(!IfCmp.getCond(s).isUNSIGNED());
    BasicBlock BB1 = s.getBasicBlock();
    BasicBlock BB3 = BB1.splitNodeAt(s, ir);
    BasicBlock BB2 = BB1.createSubBlock(0, ir);
    BB1.insertOut(BB2);
    BB1.insertOut(BB3);
    BB2.insertOut(BB3);
    ir.cfg.linkInCodeOrder(BB1, BB2);
    ir.cfg.linkInCodeOrder(BB2, BB3);
    // s is in BB1, we'll mutate it and insert in BB3 below.
    s.remove();
    RegisterOperand cr = ir.regpool.makeTempCondition();
    RegisterOperand val1 = (RegisterOperand) IfCmp.getClearVal1(s);
    RegisterOperand val2 = (RegisterOperand) IfCmp.getClearVal2(s);
    RegisterOperand lval1 = L(ir.regpool.getSecondReg(val1.getRegister()));
    RegisterOperand lval2 = L(ir.regpool.getSecondReg(val2.getRegister()));
    PowerPCConditionOperand cond = new PowerPCConditionOperand(IfCmp.getCond(s));
    BB1.appendInstruction(MIR_Binary.create(PPC_CMP, cr, val1, val2));
    BB1.appendInstruction(MIR_CondBranch.create(PPC_BCOND, cr.copyD2U(), PowerPCConditionOperand.NOT_EQUAL(), BB3.makeJumpTarget(), new BranchProfileOperand()));
    BB2.appendInstruction(MIR_Binary.create(PPC_CMPL, cr.copyD2D(), lval1, lval2));
    BB3.prependInstruction(MIR_CondBranch.mutate(s, PPC_BCOND, cr.copyD2U(), cond, IfCmp.getTarget(s), IfCmp.getBranchProfile(s)));
}
Also used : RegisterOperand(org.jikesrvm.compilers.opt.ir.operand.RegisterOperand) PowerPCConditionOperand(org.jikesrvm.compilers.opt.ir.operand.ppc.PowerPCConditionOperand) BasicBlock(org.jikesrvm.compilers.opt.ir.BasicBlock) BranchProfileOperand(org.jikesrvm.compilers.opt.ir.operand.BranchProfileOperand)

Example 23 with BranchProfileOperand

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

the class ComplexLIR2MIRExpansion method long_shr.

private static void long_shr(Instruction s, IR ir) {
    BasicBlock BB1 = s.getBasicBlock();
    BasicBlock BB2 = BB1.createSubBlock(0, ir);
    BasicBlock BB3 = BB1.splitNodeAt(s, ir);
    Register defHigh = Binary.getResult(s).getRegister();
    Register defLow = ir.regpool.getSecondReg(defHigh);
    RegisterOperand left = (RegisterOperand) Binary.getVal1(s);
    Register leftHigh = left.getRegister();
    Register leftLow = ir.regpool.getSecondReg(leftHigh);
    RegisterOperand shiftOp = (RegisterOperand) Binary.getVal2(s);
    Register shift = shiftOp.getRegister();
    Register t31 = ir.regpool.getInteger();
    Register t0 = ir.regpool.getInteger();
    Register cr = ir.regpool.getCondition();
    defLow.setSpansBasicBlock();
    defHigh.setSpansBasicBlock();
    s.insertBefore(MIR_Binary.create(PPC_SUBFIC, I(t31), I(shift), IC(32)));
    s.insertBefore(MIR_Binary.create(PPC_SRW, I(defLow), I(leftLow), I(shift)));
    s.insertBefore(MIR_Binary.create(PPC_SLW, I(t0), I(leftHigh), I(t31)));
    s.insertBefore(MIR_Binary.create(PPC_OR, I(defLow), I(defLow), I(t0)));
    s.insertBefore(MIR_Binary.create(PPC_ADDI, I(t31), I(shift), IC(-32)));
    s.insertBefore(MIR_Binary.create(PPC_SRAW, I(t0), I(leftHigh), I(t31)));
    s.insertBefore(MIR_Binary.create(PPC_SRAW, I(defHigh), I(leftHigh), I(shift)));
    s.insertBefore(MIR_Binary.create(PPC_CMPI, I(cr), I(t31), IC(0)));
    MIR_CondBranch.mutate(s, PPC_BCOND, I(cr), PowerPCConditionOperand.LESS_EQUAL(), BB3.makeJumpTarget(), new BranchProfileOperand());
    // insert the branch and second compare
    BB2.appendInstruction(MIR_Move.create(PPC_MOVE, I(defLow), I(t0)));
    // fix up CFG
    BB1.insertOut(BB2);
    BB1.insertOut(BB3);
    BB2.insertOut(BB3);
    ir.cfg.linkInCodeOrder(BB1, BB2);
    ir.cfg.linkInCodeOrder(BB2, BB3);
}
Also used : RegisterOperand(org.jikesrvm.compilers.opt.ir.operand.RegisterOperand) Register(org.jikesrvm.compilers.opt.ir.Register) BasicBlock(org.jikesrvm.compilers.opt.ir.BasicBlock) BranchProfileOperand(org.jikesrvm.compilers.opt.ir.operand.BranchProfileOperand)

Example 24 with BranchProfileOperand

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

the class ComplexLIR2MIRExpansion method threeValueLongCmp_32.

private static void threeValueLongCmp_32(Instruction s, IR ir) {
    Register res = Binary.getClearResult(s).getRegister();
    RegisterOperand one = (RegisterOperand) Binary.getClearVal1(s);
    RegisterOperand two = (RegisterOperand) Binary.getClearVal2(s);
    RegisterOperand lone = L(ir.regpool.getSecondReg(one.getRegister()));
    RegisterOperand ltwo = L(ir.regpool.getSecondReg(two.getRegister()));
    res.setSpansBasicBlock();
    BasicBlock BB1 = s.getBasicBlock();
    BasicBlock BB6 = BB1.splitNodeAt(s, ir);
    s = s.remove();
    BasicBlock BB2 = BB1.createSubBlock(0, ir);
    BasicBlock BB3 = BB1.createSubBlock(0, ir);
    BasicBlock BB4 = BB1.createSubBlock(0, ir);
    BasicBlock BB5 = BB1.createSubBlock(0, ir);
    RegisterOperand t = ir.regpool.makeTempInt();
    t.getRegister().setCondition();
    BB1.appendInstruction(MIR_Binary.create(PPC_CMP, t, one, two));
    BB1.appendInstruction(MIR_CondBranch2.create(PPC_BCOND2, t.copyD2U(), PowerPCConditionOperand.LESS(), BB4.makeJumpTarget(), new BranchProfileOperand(0.49f), PowerPCConditionOperand.GREATER(), BB5.makeJumpTarget(), new BranchProfileOperand(0.49f)));
    BB2.appendInstruction(MIR_Binary.create(PPC_CMPL, t.copyD2D(), lone, ltwo));
    BB2.appendInstruction(MIR_CondBranch2.create(PPC_BCOND2, t.copyD2U(), PowerPCConditionOperand.LESS(), BB4.makeJumpTarget(), new BranchProfileOperand(0.49f), PowerPCConditionOperand.GREATER(), BB5.makeJumpTarget(), new BranchProfileOperand(0.49f)));
    BB3.appendInstruction(MIR_Unary.create(PPC_LDI, I(res), IC(0)));
    BB3.appendInstruction(MIR_Branch.create(PPC_B, BB6.makeJumpTarget()));
    BB4.appendInstruction(MIR_Unary.create(PPC_LDI, I(res), IC(-1)));
    BB4.appendInstruction(MIR_Branch.create(PPC_B, BB6.makeJumpTarget()));
    BB5.appendInstruction(MIR_Unary.create(PPC_LDI, I(res), IC(1)));
    // fix CFG
    BB1.insertOut(BB2);
    BB1.insertOut(BB4);
    BB1.insertOut(BB5);
    BB2.insertOut(BB3);
    BB2.insertOut(BB4);
    BB2.insertOut(BB5);
    BB3.insertOut(BB6);
    BB4.insertOut(BB6);
    BB5.insertOut(BB6);
    ir.cfg.linkInCodeOrder(BB1, BB2);
    ir.cfg.linkInCodeOrder(BB2, BB3);
    ir.cfg.linkInCodeOrder(BB3, BB4);
    ir.cfg.linkInCodeOrder(BB4, BB5);
    ir.cfg.linkInCodeOrder(BB5, BB6);
}
Also used : RegisterOperand(org.jikesrvm.compilers.opt.ir.operand.RegisterOperand) Register(org.jikesrvm.compilers.opt.ir.Register) BasicBlock(org.jikesrvm.compilers.opt.ir.BasicBlock) BranchProfileOperand(org.jikesrvm.compilers.opt.ir.operand.BranchProfileOperand)

Example 25 with BranchProfileOperand

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

the class ComplexLIR2MIRExpansion method double_2long.

private static void double_2long(Instruction s, IR ir) {
    if (VM.VerifyAssertions)
        VM._assert(VM.BuildFor64Addr);
    Register res = Unary.getResult(s).getRegister();
    Register src = ((RegisterOperand) Unary.getVal(s)).getRegister();
    Register FP = ir.regpool.getPhysicalRegisterSet().getFP();
    int p = ir.stackManager.allocateSpaceForConversion();
    Register temp = ir.regpool.getDouble();
    BasicBlock BB1 = s.getBasicBlock();
    BasicBlock BB3 = BB1.splitNodeAt(s, ir);
    BasicBlock BB2 = BB1.createSubBlock(0, ir);
    RegisterOperand cond = ir.regpool.makeTempCondition();
    BB1.appendInstruction(MIR_Binary.create(PPC_FCMPU, cond, D(src), D(src)));
    BB1.appendInstruction(MIR_Unary.create(PPC_LDI, L(res), IC(0)));
    BB1.appendInstruction(MIR_CondBranch.create(PPC_BCOND, cond.copyD2U(), PowerPCConditionOperand.UNORDERED(), BB3.makeJumpTarget(), new BranchProfileOperand()));
    BB2.appendInstruction(MIR_Unary.create(PPC64_FCTIDZ, D(temp), D(src)));
    BB2.appendInstruction(MIR_Store.create(PPC_STFD, D(temp), A(FP), IC(p)));
    BB2.appendInstruction(MIR_Load.create(PPC64_LD, L(res), A(FP), IC(p)));
    // fix up CFG
    BB1.insertOut(BB2);
    BB1.insertOut(BB3);
    BB2.insertOut(BB3);
    ir.cfg.linkInCodeOrder(BB1, BB2);
    ir.cfg.linkInCodeOrder(BB2, BB3);
    s.remove();
}
Also used : RegisterOperand(org.jikesrvm.compilers.opt.ir.operand.RegisterOperand) Register(org.jikesrvm.compilers.opt.ir.Register) BasicBlock(org.jikesrvm.compilers.opt.ir.BasicBlock) BranchProfileOperand(org.jikesrvm.compilers.opt.ir.operand.BranchProfileOperand)

Aggregations

BranchProfileOperand (org.jikesrvm.compilers.opt.ir.operand.BranchProfileOperand)33 RegisterOperand (org.jikesrvm.compilers.opt.ir.operand.RegisterOperand)29 BasicBlock (org.jikesrvm.compilers.opt.ir.BasicBlock)24 IntConstantOperand (org.jikesrvm.compilers.opt.ir.operand.IntConstantOperand)18 ConditionOperand (org.jikesrvm.compilers.opt.ir.operand.ConditionOperand)17 Operand (org.jikesrvm.compilers.opt.ir.operand.Operand)15 LocationOperand (org.jikesrvm.compilers.opt.ir.operand.LocationOperand)12 Instruction (org.jikesrvm.compilers.opt.ir.Instruction)11 Register (org.jikesrvm.compilers.opt.ir.Register)10 BranchOperand (org.jikesrvm.compilers.opt.ir.operand.BranchOperand)9 MethodOperand (org.jikesrvm.compilers.opt.ir.operand.MethodOperand)9 TrapCodeOperand (org.jikesrvm.compilers.opt.ir.operand.TrapCodeOperand)8 TrueGuardOperand (org.jikesrvm.compilers.opt.ir.operand.TrueGuardOperand)8 NullConstantOperand (org.jikesrvm.compilers.opt.ir.operand.NullConstantOperand)7 PowerPCConditionOperand (org.jikesrvm.compilers.opt.ir.operand.ppc.PowerPCConditionOperand)5 RVMClass (org.jikesrvm.classloader.RVMClass)4 RVMMethod (org.jikesrvm.classloader.RVMMethod)4 RVMType (org.jikesrvm.classloader.RVMType)4 TypeReference (org.jikesrvm.classloader.TypeReference)4 AddressConstantOperand (org.jikesrvm.compilers.opt.ir.operand.AddressConstantOperand)4