Search in sources :

Example 6 with LongConstantOperand

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

the class ClassLoaderProxy method getLongFromConstantPool.

public static LongConstantOperand getLongFromConstantPool(RVMClass klass, int index) {
    Offset offset = klass.getLiteralOffset(index);
    long val = Statics.getSlotContentsAsLong(offset);
    return new LongConstantOperand(val);
}
Also used : LongConstantOperand(org.jikesrvm.compilers.opt.ir.operand.LongConstantOperand) Offset(org.vmmagic.unboxed.Offset)

Example 7 with LongConstantOperand

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

the class MinimalBURS method buildTree.

// //////////////////////////////
// Implementation
// //////////////////////////////
/**
 * Build a BURS Tree for each Instruction.
 * Complete BURS trees by adding leaf nodes as needed, and
 * creating tree edges by calling insertChild1() or insertChild2()
 * This step is also where we introduce intermediate tree nodes for
 * any LIR instruction that has > 2 "real" operands e.g., a CALL.
 *
 * @param s The instruction for which a tree must be built
 * @return the root of the newly constructed tree
 */
private AbstractBURS_TreeNode buildTree(Instruction s) {
    AbstractBURS_TreeNode root = AbstractBURS_TreeNode.create(new DepGraphNode(s));
    AbstractBURS_TreeNode cur = root;
    for (Enumeration<Operand> uses = s.getUses(); uses.hasMoreElements(); ) {
        Operand op = uses.nextElement();
        if (op == null)
            continue;
        // Set child = AbstractBURS_TreeNode for operand op
        AbstractBURS_TreeNode child;
        if (op instanceof RegisterOperand) {
            if (op.asRegister().getRegister().isValidation())
                continue;
            child = Register;
        } else if (op instanceof IntConstantOperand) {
            child = new BURS_IntConstantTreeNode(((IntConstantOperand) op).value);
        } else if (op instanceof LongConstantOperand) {
            child = LongConstant;
        } else if (op instanceof AddressConstantOperand) {
            child = AddressConstant;
        } else if (op instanceof BranchOperand && s.isCall()) {
            child = BranchTarget;
        } else if (op instanceof InlinedOsrTypeInfoOperand && s.isYieldPoint()) {
            child = NullTreeNode;
        } else {
            continue;
        }
        // Attach child as child of cur_parent in correct position
        if (cur.child1 == null) {
            cur.child1 = child;
        } else if (cur.child2 == null) {
            cur.child2 = child;
        } else {
            // Create auxiliary node so as to represent
            // a instruction with arity > 2 in a binary tree.
            AbstractBURS_TreeNode child1 = cur.child2;
            AbstractBURS_TreeNode aux = AbstractBURS_TreeNode.create(OTHER_OPERAND_opcode);
            cur.child2 = aux;
            cur = aux;
            cur.child1 = child1;
            cur.child2 = child;
        }
    }
    // patch for calls & return
    switch(s.getOpcode()) {
        case CALL_opcode:
        case SYSCALL_opcode:
        case YIELDPOINT_OSR_opcode:
            if (cur.child2 == null) {
                cur.child2 = NullTreeNode;
            }
        // fall through
        case RETURN_opcode:
            if (cur.child1 == null) {
                cur.child1 = NullTreeNode;
            }
    }
    return root;
}
Also used : LongConstantOperand(org.jikesrvm.compilers.opt.ir.operand.LongConstantOperand) RegisterOperand(org.jikesrvm.compilers.opt.ir.operand.RegisterOperand) IntConstantOperand(org.jikesrvm.compilers.opt.ir.operand.IntConstantOperand) AddressConstantOperand(org.jikesrvm.compilers.opt.ir.operand.AddressConstantOperand) Operand(org.jikesrvm.compilers.opt.ir.operand.Operand) IntConstantOperand(org.jikesrvm.compilers.opt.ir.operand.IntConstantOperand) InlinedOsrTypeInfoOperand(org.jikesrvm.compilers.opt.ir.operand.InlinedOsrTypeInfoOperand) LongConstantOperand(org.jikesrvm.compilers.opt.ir.operand.LongConstantOperand) BranchOperand(org.jikesrvm.compilers.opt.ir.operand.BranchOperand) RegisterOperand(org.jikesrvm.compilers.opt.ir.operand.RegisterOperand) AddressConstantOperand(org.jikesrvm.compilers.opt.ir.operand.AddressConstantOperand) DepGraphNode(org.jikesrvm.compilers.opt.depgraph.DepGraphNode) InlinedOsrTypeInfoOperand(org.jikesrvm.compilers.opt.ir.operand.InlinedOsrTypeInfoOperand) BranchOperand(org.jikesrvm.compilers.opt.ir.operand.BranchOperand)

Example 8 with LongConstantOperand

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

the class BURS_Helpers method ATTEMPT_LONG.

/**
 * This routine expands an ATTEMPT instruction into an atomic
 * compare exchange. The atomic compare and exchange will place at
 * mo the value of newValue if the value of mo is oldValue. The
 * result register is set to 0/1 depending on whether the valye was
 * replaced or not.
 *
 * @param result the register operand that is set to 0/1 as a result
 * of the attempt
 * @param mo       the address at which to attempt the exchange
 * @param oldValue the old value to check for at the address mo
 * @param newValue the new value to place at the address mo
 */
protected final void ATTEMPT_LONG(RegisterOperand result, MemoryOperand mo, Operand oldValue, Operand newValue) {
    if (VM.BuildFor32Addr) {
        // Set up EDX:EAX with the old value
        if (oldValue.isRegister()) {
            Register oldValue_hval = oldValue.asRegister().getRegister();
            Register oldValue_lval = regpool.getSecondReg(oldValue_hval);
            EMIT(MIR_Move.create(IA32_MOV, new RegisterOperand(getEDX(), TypeReference.Int), new RegisterOperand(oldValue_hval, TypeReference.Int)));
            EMIT(MIR_Move.create(IA32_MOV, new RegisterOperand(getEAX(), TypeReference.Int), new RegisterOperand(oldValue_lval, TypeReference.Int)));
        } else {
            if (VM.VerifyAssertions)
                opt_assert(oldValue.isLongConstant());
            LongConstantOperand val = oldValue.asLongConstant();
            EMIT(MIR_Move.create(IA32_MOV, new RegisterOperand(getEDX(), TypeReference.Int), IC(val.upper32())));
            EMIT(MIR_Move.create(IA32_MOV, new RegisterOperand(getEAX(), TypeReference.Int), IC(val.lower32())));
        }
        // Set up ECX:EBX with the new value
        if (newValue.isRegister()) {
            Register newValue_hval = newValue.asRegister().getRegister();
            Register newValue_lval = regpool.getSecondReg(newValue_hval);
            EMIT(MIR_Move.create(IA32_MOV, new RegisterOperand(getECX(), TypeReference.Int), new RegisterOperand(newValue_hval, TypeReference.Int)));
            EMIT(MIR_Move.create(IA32_MOV, new RegisterOperand(getEBX(), TypeReference.Int), new RegisterOperand(newValue_lval, TypeReference.Int)));
        } else {
            if (VM.VerifyAssertions)
                opt_assert(newValue.isLongConstant());
            LongConstantOperand val = newValue.asLongConstant();
            EMIT(MIR_Move.create(IA32_MOV, new RegisterOperand(getECX(), TypeReference.Int), IC(val.upper32())));
            EMIT(MIR_Move.create(IA32_MOV, new RegisterOperand(getEBX(), TypeReference.Int), IC(val.lower32())));
        }
        EMIT(MIR_CompareExchange8B.create(IA32_LOCK_CMPXCHG8B, new RegisterOperand(getEDX(), TypeReference.Int), new RegisterOperand(getEAX(), TypeReference.Int), mo, new RegisterOperand(getECX(), TypeReference.Int), new RegisterOperand(getEBX(), TypeReference.Int)));
        RegisterOperand temp = regpool.makeTemp(result);
        EMIT(MIR_Set.create(IA32_SET__B, temp, IA32ConditionOperand.EQ()));
        // need to zero-extend the result of the set
        EMIT(MIR_Unary.create(IA32_MOVZX__B, result, temp.copy()));
    } else {
        RegisterOperand temp = regpool.makeTempLong();
        RegisterOperand temp2 = regpool.makeTemp(result);
        EMIT(MIR_Move.create(IA32_MOV, temp, newValue));
        EMIT(MIR_Move.create(IA32_MOV, new RegisterOperand(getEAX(), TypeReference.Long), oldValue));
        EMIT(MIR_CompareExchange.create(IA32_LOCK_CMPXCHG, new RegisterOperand(getEAX(), TypeReference.Long), mo, temp.copyRO()));
        EMIT(MIR_Set.create(IA32_SET__B, temp2, IA32ConditionOperand.EQ()));
        // need to zero-extend the result of the set
        EMIT(MIR_Unary.create(IA32_MOVZX__B, result, temp2.copy()));
    }
}
Also used : LongConstantOperand(org.jikesrvm.compilers.opt.ir.operand.LongConstantOperand) RegisterOperand(org.jikesrvm.compilers.opt.ir.operand.RegisterOperand) Register(org.jikesrvm.compilers.opt.ir.Register)

Example 9 with LongConstantOperand

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

the class BURS_Helpers method LONG_CMP.

/**
 * Expansion of LONG_CMP: compare to values and set result to -1, 0, 1 for &lt;, =, &gt;,
 * respectively
 *
 * @param s the compare instruction
 * @param res the result/first operand
 * @param val1 the first value
 * @param val2 the second value
 */
protected final void LONG_CMP(Instruction s, RegisterOperand res, Operand val1, Operand val2) {
    if (VM.BuildFor32Addr) {
        RegisterOperand one = regpool.makeTempInt();
        RegisterOperand lone = regpool.makeTempInt();
        Operand two, ltwo;
        if (val1 instanceof RegisterOperand) {
            Register val1_reg = val1.asRegister().getRegister();
            EMIT(CPOS(s, MIR_Move.create(IA32_MOV, one, new RegisterOperand(val1_reg, TypeReference.Int))));
            EMIT(CPOS(s, MIR_Move.create(IA32_MOV, lone, new RegisterOperand(regpool.getSecondReg(val1_reg), TypeReference.Int))));
        } else {
            LongConstantOperand tmp = (LongConstantOperand) val1;
            EMIT(CPOS(s, MIR_Move.create(IA32_MOV, one, IC(tmp.upper32()))));
            EMIT(CPOS(s, MIR_Move.create(IA32_MOV, lone, IC(tmp.lower32()))));
        }
        if (val2 instanceof RegisterOperand) {
            two = val2;
            ltwo = L(burs.ir.regpool.getSecondReg(val2.asRegister().getRegister()));
        } else {
            LongConstantOperand tmp = (LongConstantOperand) val2;
            two = IC(tmp.upper32());
            ltwo = IC(tmp.lower32());
        }
        EMIT(CPOS(s, MIR_Compare.create(IA32_CMP, lone.copyRO(), ltwo)));
        EMIT(CPOS(s, MIR_BinaryAcc.create(IA32_SBB, one.copyRO(), two)));
        EMIT(CPOS(s, MIR_Set.create(IA32_SET__B, res, // res =
        IA32ConditionOperand.LT())));
        // (val1 < val2) ? 1 :0
        EMIT(CPOS(s, MIR_BinaryAcc.create(IA32_OR, one.copyRO(), lone.copyRO())));
        EMIT(CPOS(s, MIR_Set.create(IA32_SET__B, lone.copyRO(), // lone = (val1 != val2) ? 1 : 0
        IA32ConditionOperand.NE())));
        // res = (val1 <
        EMIT(CPOS(s, MIR_UnaryAcc.create(IA32_NEG, res.copyRO())));
        // val2) ? -1 :0
        EMIT(CPOS(s, MIR_BinaryAcc.create(IA32_OR, res.copyRO(), lone.copyRO())));
        EMIT(MIR_Unary.mutate(s, IA32_MOVSX__B, res.copyRO(), res.copyRO()));
    } else {
        RegisterOperand one = regpool.makeTempLong();
        RegisterOperand two = regpool.makeTempLong();
        EMIT(CPOS(s, MIR_Move.create(IA32_MOV, one, val1)));
        EMIT(CPOS(s, MIR_Move.create(IA32_MOV, two, val2)));
        EMIT(CPOS(s, MIR_BinaryAcc.create(IA32_SUB, one, two)));
        EMIT(CPOS(s, MIR_Set.create(IA32_SET__B, res, IA32ConditionOperand.NE())));
        EMIT(CPOS(s, MIR_BinaryAcc.create(IA32_SAR, one.copyRO(), LC(64))));
        EMIT(CPOS(s, MIR_BinaryAcc.create(IA32_OR, res.copyRO(), one.copyRO())));
    }
}
Also used : LongConstantOperand(org.jikesrvm.compilers.opt.ir.operand.LongConstantOperand) RegisterOperand(org.jikesrvm.compilers.opt.ir.operand.RegisterOperand) Register(org.jikesrvm.compilers.opt.ir.Register) LongConstantOperand(org.jikesrvm.compilers.opt.ir.operand.LongConstantOperand) DoubleConstantOperand(org.jikesrvm.compilers.opt.ir.operand.DoubleConstantOperand) RegisterOperand(org.jikesrvm.compilers.opt.ir.operand.RegisterOperand) IA32ConditionOperand(org.jikesrvm.compilers.opt.ir.operand.ia32.IA32ConditionOperand) FloatConstantOperand(org.jikesrvm.compilers.opt.ir.operand.FloatConstantOperand) StackLocationOperand(org.jikesrvm.compilers.opt.ir.operand.StackLocationOperand) LocationOperand(org.jikesrvm.compilers.opt.ir.operand.LocationOperand) MemoryOperand(org.jikesrvm.compilers.opt.ir.operand.MemoryOperand) IntConstantOperand(org.jikesrvm.compilers.opt.ir.operand.IntConstantOperand) MethodOperand(org.jikesrvm.compilers.opt.ir.operand.MethodOperand) TrueGuardOperand(org.jikesrvm.compilers.opt.ir.operand.TrueGuardOperand) ConditionOperand(org.jikesrvm.compilers.opt.ir.operand.ConditionOperand) Operand(org.jikesrvm.compilers.opt.ir.operand.Operand) BranchProfileOperand(org.jikesrvm.compilers.opt.ir.operand.BranchProfileOperand) InlinedOsrTypeInfoOperand(org.jikesrvm.compilers.opt.ir.operand.InlinedOsrTypeInfoOperand) TrapCodeOperand(org.jikesrvm.compilers.opt.ir.operand.TrapCodeOperand) BURSManagedFPROperand(org.jikesrvm.compilers.opt.ir.operand.ia32.BURSManagedFPROperand) BranchOperand(org.jikesrvm.compilers.opt.ir.operand.BranchOperand) ConstantOperand(org.jikesrvm.compilers.opt.ir.operand.ConstantOperand)

Example 10 with LongConstantOperand

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

the class BURS_Helpers method SSE2_GPR2FPR_64.

/**
 * Emits code to move 64 bits from GPRs to SSE2 FPRs
 *
 * @param s instruction to modify for the move
 */
protected final void SSE2_GPR2FPR_64(Instruction s) {
    int offset = -burs.ir.stackManager.allocateSpaceForConversion();
    StackLocationOperand sl = new StackLocationOperand(true, offset, QW);
    Operand val = Unary.getClearVal(s);
    if (VM.BuildFor32Addr) {
        StackLocationOperand sl1 = new StackLocationOperand(true, offset + 4, DW);
        StackLocationOperand sl2 = new StackLocationOperand(true, offset, DW);
        Operand i1, i2;
        if (val instanceof RegisterOperand) {
            RegisterOperand rval = (RegisterOperand) val;
            i1 = val;
            i2 = new RegisterOperand(regpool.getSecondReg(rval.getRegister()), TypeReference.Int);
        } else {
            LongConstantOperand rhs = (LongConstantOperand) val;
            i1 = IC(rhs.upper32());
            i2 = IC(rhs.lower32());
        }
        EMIT(CPOS(s, MIR_Move.create(IA32_MOV, sl1, i1)));
        EMIT(CPOS(s, MIR_Move.create(IA32_MOV, sl2, i2)));
        EMIT(MIR_Move.mutate(s, IA32_MOVSD, Unary.getResult(s), sl));
    } else {
        EMIT(CPOS(s, MIR_Move.create(IA32_MOV, sl, val)));
        EMIT(MIR_Move.mutate(s, IA32_MOVSD, Unary.getResult(s), sl.copy()));
    }
}
Also used : LongConstantOperand(org.jikesrvm.compilers.opt.ir.operand.LongConstantOperand) RegisterOperand(org.jikesrvm.compilers.opt.ir.operand.RegisterOperand) LongConstantOperand(org.jikesrvm.compilers.opt.ir.operand.LongConstantOperand) DoubleConstantOperand(org.jikesrvm.compilers.opt.ir.operand.DoubleConstantOperand) RegisterOperand(org.jikesrvm.compilers.opt.ir.operand.RegisterOperand) IA32ConditionOperand(org.jikesrvm.compilers.opt.ir.operand.ia32.IA32ConditionOperand) FloatConstantOperand(org.jikesrvm.compilers.opt.ir.operand.FloatConstantOperand) StackLocationOperand(org.jikesrvm.compilers.opt.ir.operand.StackLocationOperand) LocationOperand(org.jikesrvm.compilers.opt.ir.operand.LocationOperand) MemoryOperand(org.jikesrvm.compilers.opt.ir.operand.MemoryOperand) IntConstantOperand(org.jikesrvm.compilers.opt.ir.operand.IntConstantOperand) MethodOperand(org.jikesrvm.compilers.opt.ir.operand.MethodOperand) TrueGuardOperand(org.jikesrvm.compilers.opt.ir.operand.TrueGuardOperand) ConditionOperand(org.jikesrvm.compilers.opt.ir.operand.ConditionOperand) Operand(org.jikesrvm.compilers.opt.ir.operand.Operand) BranchProfileOperand(org.jikesrvm.compilers.opt.ir.operand.BranchProfileOperand) InlinedOsrTypeInfoOperand(org.jikesrvm.compilers.opt.ir.operand.InlinedOsrTypeInfoOperand) TrapCodeOperand(org.jikesrvm.compilers.opt.ir.operand.TrapCodeOperand) BURSManagedFPROperand(org.jikesrvm.compilers.opt.ir.operand.ia32.BURSManagedFPROperand) BranchOperand(org.jikesrvm.compilers.opt.ir.operand.BranchOperand) ConstantOperand(org.jikesrvm.compilers.opt.ir.operand.ConstantOperand) OsrPoint(org.jikesrvm.compilers.opt.ir.OsrPoint) StackLocationOperand(org.jikesrvm.compilers.opt.ir.operand.StackLocationOperand)

Aggregations

LongConstantOperand (org.jikesrvm.compilers.opt.ir.operand.LongConstantOperand)32 RegisterOperand (org.jikesrvm.compilers.opt.ir.operand.RegisterOperand)29 IntConstantOperand (org.jikesrvm.compilers.opt.ir.operand.IntConstantOperand)27 DoubleConstantOperand (org.jikesrvm.compilers.opt.ir.operand.DoubleConstantOperand)19 FloatConstantOperand (org.jikesrvm.compilers.opt.ir.operand.FloatConstantOperand)19 Operand (org.jikesrvm.compilers.opt.ir.operand.Operand)18 ConstantOperand (org.jikesrvm.compilers.opt.ir.operand.ConstantOperand)16 ConditionOperand (org.jikesrvm.compilers.opt.ir.operand.ConditionOperand)15 BranchOperand (org.jikesrvm.compilers.opt.ir.operand.BranchOperand)14 LocationOperand (org.jikesrvm.compilers.opt.ir.operand.LocationOperand)14 AddressConstantOperand (org.jikesrvm.compilers.opt.ir.operand.AddressConstantOperand)13 TrapCodeOperand (org.jikesrvm.compilers.opt.ir.operand.TrapCodeOperand)13 BranchProfileOperand (org.jikesrvm.compilers.opt.ir.operand.BranchProfileOperand)12 TrueGuardOperand (org.jikesrvm.compilers.opt.ir.operand.TrueGuardOperand)12 IA32ConditionOperand (org.jikesrvm.compilers.opt.ir.operand.ia32.IA32ConditionOperand)12 InlinedOsrTypeInfoOperand (org.jikesrvm.compilers.opt.ir.operand.InlinedOsrTypeInfoOperand)11 MemoryOperand (org.jikesrvm.compilers.opt.ir.operand.MemoryOperand)11 MethodOperand (org.jikesrvm.compilers.opt.ir.operand.MethodOperand)11 StackLocationOperand (org.jikesrvm.compilers.opt.ir.operand.StackLocationOperand)11 OsrPoint (org.jikesrvm.compilers.opt.ir.OsrPoint)9