Search in sources :

Example 31 with LongConstantOperand

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

the class BURS_Helpers method SYSCALL.

/**
 * Expansion of SYSCALL. Expand longs registers into pairs of int registers.
 *
 * @param s the instruction to expand
 * @param address the operand containing the target address
 */
protected final void SYSCALL(Instruction s, Operand address) {
    burs.ir.setHasSysCall(true);
    if (VM.BuildFor32Addr) {
        // Step 1: Find out how many parameters we're going to have.
        int numParams = Call.getNumberOfParams(s);
        int longParams = 0;
        for (int pNum = 0; pNum < numParams; pNum++) {
            if (Call.getParam(s, pNum).getType().isLongType()) {
                longParams++;
            }
        }
        // Step 2: Figure out what the result and result2 values will be.
        RegisterOperand result = Call.getResult(s);
        RegisterOperand result2 = null;
        // NOTE: C callee returns longs little endian!
        if (result != null && result.getType().isLongType()) {
            result.setType(TypeReference.Int);
            result2 = result;
            result = new RegisterOperand(regpool.getSecondReg(result.getRegister()), TypeReference.Int);
        }
        // Step 3: Mutate the Call to an MIR_Call.
        // Note MIR_Call and Call have a different number of fixed
        // arguments, so some amount of copying is required.
        Operand[] params = new Operand[numParams];
        for (int i = 0; i < numParams; i++) {
            params[i] = Call.getParam(s, i);
        }
        MIR_Call.mutate(s, IA32_SYSCALL, result, result2, address, Call.getMethod(s), numParams + longParams);
        for (int paramIdx = 0, mirCallIdx = 0; paramIdx < numParams; ) {
            Operand param = params[paramIdx++];
            if (param instanceof RegisterOperand) {
                // NOTE: longs passed little endian to C callee!
                RegisterOperand rparam = (RegisterOperand) param;
                if (rparam.getType().isLongType()) {
                    rparam.setType(TypeReference.Int);
                    MIR_Call.setParam(s, mirCallIdx++, new RegisterOperand(regpool.getSecondReg(rparam.getRegister()), TypeReference.Int));
                }
                MIR_Call.setParam(s, mirCallIdx++, param);
            } else if (param instanceof LongConstantOperand) {
                long value = ((LongConstantOperand) param).value;
                int valueHigh = (int) (value >> 32);
                int valueLow = (int) (value & 0xffffffff);
                // NOTE: longs passed little endian to C callee!
                MIR_Call.setParam(s, mirCallIdx++, IC(valueLow));
                MIR_Call.setParam(s, mirCallIdx++, IC(valueHigh));
            } else {
                MIR_Call.setParam(s, mirCallIdx++, param);
            }
        }
    } else {
        MIR_Call.mutate(s, IA32_SYSCALL, Call.getResult(s), null, address, Call.getMethod(s), Call.getNumberOfParams(s));
    }
    // emit the call instruction.
    EMIT(s);
}
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)

Example 32 with LongConstantOperand

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

the class BURS_MemOp_Helpers method augmentAddress.

protected final void augmentAddress(Operand op) {
    if (VM.VerifyAssertions)
        VM._assert(AddrStack != null, "No address to augment");
    if (op.isRegister()) {
        RegisterOperand rop = op.asRegister();
        if (AddrStack.base == null) {
            AddrStack.base = rop;
        } else if (AddrStack.index == null) {
            if (VM.VerifyAssertions)
                VM._assert(AddrStack.scale == (byte) 0);
            AddrStack.index = rop;
        } else {
            throw new OptimizingCompilerException("three base registers in address");
        }
    } else {
        if (VM.fullyBooted) {
            if (VM.BuildFor64Addr && op instanceof IntConstantOperand)
                throw new OptimizingCompilerException("augmenting int to address in 64bit code");
            if (VM.BuildFor32Addr && op instanceof LongConstantOperand)
                throw new OptimizingCompilerException("augmenting long to address in 32bit code");
        }
        long dispTemp = op instanceof LongConstantOperand ? ((LongConstantOperand) op).value : ((IntConstantOperand) op).value;
        if (VM.VerifyAssertions && VM.BuildFor32Addr)
            opt_assert(fits(dispTemp, 32));
        Offset disp = Offset.fromLong(dispTemp);
        AddrStack.displacement = AddrStack.displacement.plus(disp);
    }
}
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) OptimizingCompilerException(org.jikesrvm.compilers.opt.OptimizingCompilerException) Offset(org.vmmagic.unboxed.Offset)

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