Search in sources :

Example 6 with Operator

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

the class ComplexLIR2MIRExpansion method boolean_cmp.

private static void boolean_cmp(Instruction s, IR ir, boolean cmp32Bit) {
    // undo the optimization because it cannot efficiently be generated
    Register res = BooleanCmp.getClearResult(s).getRegister();
    RegisterOperand one = (RegisterOperand) BooleanCmp.getClearVal1(s);
    Operand two = BooleanCmp.getClearVal2(s);
    ConditionOperand cond = BooleanCmp.getClearCond(s);
    res.setSpansBasicBlock();
    BasicBlock BB1 = s.getBasicBlock();
    BasicBlock BB4 = BB1.splitNodeAt(s, ir);
    s = s.remove();
    BasicBlock BB2 = BB1.createSubBlock(0, ir);
    BasicBlock BB3 = BB1.createSubBlock(0, ir);
    RegisterOperand t = ir.regpool.makeTempInt();
    t.getRegister().setCondition();
    Operator op;
    if (VM.BuildFor64Addr && !cmp32Bit) {
        if (two instanceof IntConstantOperand) {
            op = cond.isUNSIGNED() ? PPC64_CMPLI : PPC64_CMPI;
        } else {
            op = cond.isUNSIGNED() ? PPC64_CMPL : PPC64_CMP;
        }
    } else if (two instanceof IntConstantOperand) {
        op = cond.isUNSIGNED() ? PPC_CMPLI : PPC_CMPI;
    } else {
        op = cond.isUNSIGNED() ? PPC_CMPL : PPC_CMP;
    }
    BB1.appendInstruction(MIR_Binary.create(op, t, one, two));
    BB1.appendInstruction(MIR_CondBranch.create(PPC_BCOND, t.copyD2U(), PowerPCConditionOperand.get(cond), BB3.makeJumpTarget(), new BranchProfileOperand()));
    BB2.appendInstruction(MIR_Unary.create(PPC_LDI, I(res), IC(0)));
    BB2.appendInstruction(MIR_Branch.create(PPC_B, BB4.makeJumpTarget()));
    BB3.appendInstruction(MIR_Unary.create(PPC_LDI, I(res), IC(1)));
    // fix CFG
    BB1.insertOut(BB2);
    BB1.insertOut(BB3);
    BB2.insertOut(BB4);
    BB3.insertOut(BB4);
    ir.cfg.linkInCodeOrder(BB1, BB2);
    ir.cfg.linkInCodeOrder(BB2, BB3);
    ir.cfg.linkInCodeOrder(BB3, BB4);
}
Also used : Operator(org.jikesrvm.compilers.opt.ir.Operator) RegisterOperand(org.jikesrvm.compilers.opt.ir.operand.RegisterOperand) IntConstantOperand(org.jikesrvm.compilers.opt.ir.operand.IntConstantOperand) Register(org.jikesrvm.compilers.opt.ir.Register) BranchProfileOperand(org.jikesrvm.compilers.opt.ir.operand.BranchProfileOperand) PowerPCConditionOperand(org.jikesrvm.compilers.opt.ir.operand.ppc.PowerPCConditionOperand) RegisterOperand(org.jikesrvm.compilers.opt.ir.operand.RegisterOperand) LocationOperand(org.jikesrvm.compilers.opt.ir.operand.LocationOperand) ConditionOperand(org.jikesrvm.compilers.opt.ir.operand.ConditionOperand) Operand(org.jikesrvm.compilers.opt.ir.operand.Operand) IntConstantOperand(org.jikesrvm.compilers.opt.ir.operand.IntConstantOperand) BasicBlock(org.jikesrvm.compilers.opt.ir.BasicBlock) 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)

Example 7 with Operator

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

the class PiNodes method cleanUp.

/**
 * Change all PI nodes to INT_MOVE instructions
 * <p> Side effect: invalidates SSA state
 *
 * @param ir the governing IR
 */
static void cleanUp(IR ir) {
    for (Enumeration<Instruction> e = ir.forwardInstrEnumerator(); e.hasMoreElements(); ) {
        Instruction s = e.nextElement();
        if (s.operator() == PI) {
            RegisterOperand result = GuardedUnary.getResult(s);
            Operator mv = IRTools.getMoveOp(result.getType());
            Operand val = GuardedUnary.getVal(s);
            Move.mutate(s, mv, result, val);
        }
    }
    // invalidate SSA state
    ir.actualSSAOptions = null;
}
Also used : Operator(org.jikesrvm.compilers.opt.ir.Operator) RegisterOperand(org.jikesrvm.compilers.opt.ir.operand.RegisterOperand) Operand(org.jikesrvm.compilers.opt.ir.operand.Operand) RegisterOperand(org.jikesrvm.compilers.opt.ir.operand.RegisterOperand) Instruction(org.jikesrvm.compilers.opt.ir.Instruction)

Example 8 with Operator

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

the class StackManager method insertSpillBefore.

@Override
public void insertSpillBefore(Instruction s, Register r, Register type, int location) {
    Operator move = getMoveOperator(type);
    byte size = getSizeOfType(type);
    RegisterOperand rOp;
    if (type.isFloat()) {
        rOp = F(r);
    } else if (type.isDouble()) {
        rOp = D(r);
    } else {
        if (VM.BuildFor64Addr && type.isInteger()) {
            rOp = new RegisterOperand(r, TypeReference.Int);
        } else {
            rOp = new RegisterOperand(r, PRIMITIVE_TYPE_FOR_WORD);
        }
    }
    StackLocationOperand spillLoc = new StackLocationOperand(true, -location, size);
    Instruction spillOp = MIR_Move.create(move, spillLoc, rOp);
    if (VERBOSE_DEBUG) {
        System.out.println("INSERT_SPILL_BEFORE: " + "Inserting " + spillOp + " before " + s);
    }
    s.insertBefore(spillOp);
}
Also used : Operator(org.jikesrvm.compilers.opt.ir.Operator) RegisterOperand(org.jikesrvm.compilers.opt.ir.operand.RegisterOperand) Instruction(org.jikesrvm.compilers.opt.ir.Instruction) StackLocationOperand(org.jikesrvm.compilers.opt.ir.operand.StackLocationOperand)

Example 9 with Operator

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

the class BURS_Helpers method CMP.

/**
 * emit basic code to handle an INT_IFCMP when no folding
 * of the compare into some other computation is possible.
 */
protected final void CMP(Instruction s, RegisterOperand val1, Operand val2, ConditionOperand cond, boolean immediate) {
    RegisterOperand cr = regpool.makeTempCondition();
    Operator op;
    if (immediate) {
        op = cond.isUNSIGNED() ? PPC_CMPLI : PPC_CMPI;
    } else {
        op = cond.isUNSIGNED() ? PPC_CMPL : PPC_CMP;
    }
    EMIT(MIR_Binary.create(op, cr, val1, val2));
    EMIT(MIR_CondBranch.mutate(s, PPC_BCOND, cr.copyD2U(), new PowerPCConditionOperand(cond), IfCmp.getTarget(s), IfCmp.getBranchProfile(s)));
}
Also used : Operator(org.jikesrvm.compilers.opt.ir.Operator) RegisterOperand(org.jikesrvm.compilers.opt.ir.operand.RegisterOperand) PowerPCConditionOperand(org.jikesrvm.compilers.opt.ir.operand.ppc.PowerPCConditionOperand)

Example 10 with Operator

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

the class Simple method typePropagation.

/**
 * Perform flow-insensitive type propagation using register list
 * information. Note: register list MUST be initialized BEFORE
 * calling this routine.
 *
 * <p> Kept separate from copyPropagation loop to enable clients
 * more flexibility.
 *
 * @param ir the IR in question
 */
static void typePropagation(IR ir) {
    // Use register list to enumerate register objects (FAST)
    Register elemNext;
    for (Register reg = ir.regpool.getFirstSymbolicRegister(); reg != null; reg = elemNext) {
        elemNext = reg.getNext();
        // Type propagation not possible if reg has no uses
        if (reg.useList == null) {
            continue;
        }
        // Type propagation not possible if reg has no defs
        if (reg.defList == null) {
            continue;
        }
        // Do not attempt type propagation if reg has multiple defs
        if (!reg.isSSA()) {
            continue;
        }
        // Now reg has exactly one definition
        RegisterOperand lhs = reg.defList;
        Instruction instr = lhs.instruction;
        Operator op = instr.operator();
        // Type propagation not possible if lhs is not in a move instr
        if (!op.isMove()) {
            continue;
        }
        Operand rhsOp = Move.getVal(instr);
        // Do not attempt type propagation if RHS is not a register
        if (!(rhsOp instanceof RegisterOperand)) {
            continue;
        }
        RegisterOperand rhs = (RegisterOperand) rhsOp;
        // Propagate the type in the def
        lhs.copyTypeFrom(rhs);
        // Now propagate lhs into all uses; substitute rhs.type for lhs.type
        for (RegisterOperand use = reg.useList; use != null; use = use.getNext()) {
            // because use.type has more detailed information
            if (ClassLoaderProxy.includesType(rhs.getType(), use.getType()) == YES) {
                continue;
            }
            // don't undo the effects!
            if (rhs.getType().isPrimitiveType() && !use.getType().isPrimitiveType()) {
                continue;
            }
            use.copyTypeFrom(rhs);
        }
    }
}
Also used : Operator(org.jikesrvm.compilers.opt.ir.Operator) RegisterOperand(org.jikesrvm.compilers.opt.ir.operand.RegisterOperand) Register(org.jikesrvm.compilers.opt.ir.Register) RegisterOperand(org.jikesrvm.compilers.opt.ir.operand.RegisterOperand) TrueGuardOperand(org.jikesrvm.compilers.opt.ir.operand.TrueGuardOperand) Operand(org.jikesrvm.compilers.opt.ir.operand.Operand) TrapCodeOperand(org.jikesrvm.compilers.opt.ir.operand.TrapCodeOperand) IntConstantOperand(org.jikesrvm.compilers.opt.ir.operand.IntConstantOperand) Instruction(org.jikesrvm.compilers.opt.ir.Instruction)

Aggregations

Operator (org.jikesrvm.compilers.opt.ir.Operator)28 RegisterOperand (org.jikesrvm.compilers.opt.ir.operand.RegisterOperand)25 Instruction (org.jikesrvm.compilers.opt.ir.Instruction)17 Operand (org.jikesrvm.compilers.opt.ir.operand.Operand)15 IntConstantOperand (org.jikesrvm.compilers.opt.ir.operand.IntConstantOperand)12 TrapCodeOperand (org.jikesrvm.compilers.opt.ir.operand.TrapCodeOperand)9 Register (org.jikesrvm.compilers.opt.ir.Register)8 ConditionOperand (org.jikesrvm.compilers.opt.ir.operand.ConditionOperand)8 TrueGuardOperand (org.jikesrvm.compilers.opt.ir.operand.TrueGuardOperand)8 BranchProfileOperand (org.jikesrvm.compilers.opt.ir.operand.BranchProfileOperand)7 ConstantOperand (org.jikesrvm.compilers.opt.ir.operand.ConstantOperand)7 LongConstantOperand (org.jikesrvm.compilers.opt.ir.operand.LongConstantOperand)7 PowerPCConditionOperand (org.jikesrvm.compilers.opt.ir.operand.ppc.PowerPCConditionOperand)7 BranchOperand (org.jikesrvm.compilers.opt.ir.operand.BranchOperand)6 LocationOperand (org.jikesrvm.compilers.opt.ir.operand.LocationOperand)6 AddressConstantOperand (org.jikesrvm.compilers.opt.ir.operand.AddressConstantOperand)5 MethodOperand (org.jikesrvm.compilers.opt.ir.operand.MethodOperand)5 TypeReference (org.jikesrvm.classloader.TypeReference)4 OptimizingCompilerException (org.jikesrvm.compilers.opt.OptimizingCompilerException)4 BasicBlock (org.jikesrvm.compilers.opt.ir.BasicBlock)4