Search in sources :

Example 36 with IntConstantOperand

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

the class NormalizeConstants method asRegInt.

static Operand asRegInt(Operand addr, Instruction s, IR ir) {
    if (addr instanceof IntConstantOperand) {
        RegisterOperand rop = ir.regpool.makeTempInt();
        s.insertBefore(Move.create(REF_MOVE, rop, addr));
        return rop.copyD2U();
    } else if (addr instanceof ConstantOperand) {
        // must not happen
        if (VM.VerifyAssertions)
            VM._assert(VM.NOT_REACHED);
    }
    // Operand was OK as is.
    return addr;
}
Also used : LongConstantOperand(org.jikesrvm.compilers.opt.ir.operand.LongConstantOperand) DoubleConstantOperand(org.jikesrvm.compilers.opt.ir.operand.DoubleConstantOperand) CodeConstantOperand(org.jikesrvm.compilers.opt.ir.operand.CodeConstantOperand) NullConstantOperand(org.jikesrvm.compilers.opt.ir.operand.NullConstantOperand) FloatConstantOperand(org.jikesrvm.compilers.opt.ir.operand.FloatConstantOperand) TIBConstantOperand(org.jikesrvm.compilers.opt.ir.operand.TIBConstantOperand) ClassConstantOperand(org.jikesrvm.compilers.opt.ir.operand.ClassConstantOperand) IntConstantOperand(org.jikesrvm.compilers.opt.ir.operand.IntConstantOperand) AddressConstantOperand(org.jikesrvm.compilers.opt.ir.operand.AddressConstantOperand) ObjectConstantOperand(org.jikesrvm.compilers.opt.ir.operand.ObjectConstantOperand) StringConstantOperand(org.jikesrvm.compilers.opt.ir.operand.StringConstantOperand) ConstantOperand(org.jikesrvm.compilers.opt.ir.operand.ConstantOperand) IntConstantOperand(org.jikesrvm.compilers.opt.ir.operand.IntConstantOperand) RegisterOperand(org.jikesrvm.compilers.opt.ir.operand.RegisterOperand)

Example 37 with IntConstantOperand

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

the class NormalizeConstants method asRegPolymorphic.

static Operand asRegPolymorphic(Operand addr, Instruction s, IR ir) {
    if (addr instanceof IntConstantOperand) {
        RegisterOperand rop = ir.regpool.makeTempInt();
        s.insertBefore(Move.create(REF_MOVE, rop, addr));
        return rop.copyD2U();
    } else if (addr instanceof AddressConstantOperand) {
        RegisterOperand rop = ir.regpool.makeTempAddress();
        s.insertBefore(Move.create(REF_MOVE, rop, addr));
        return rop.copyD2U();
    } else if ((VM.BuildFor64Addr) && (addr instanceof LongConstantOperand)) {
        RegisterOperand rop = ir.regpool.makeTempLong();
        s.insertBefore(Move.create(REF_MOVE, rop, addr));
        return rop.copyD2U();
    }
    // Operand was OK as is.
    return addr;
}
Also used : LongConstantOperand(org.jikesrvm.compilers.opt.ir.operand.LongConstantOperand) IntConstantOperand(org.jikesrvm.compilers.opt.ir.operand.IntConstantOperand) RegisterOperand(org.jikesrvm.compilers.opt.ir.operand.RegisterOperand) AddressConstantOperand(org.jikesrvm.compilers.opt.ir.operand.AddressConstantOperand)

Example 38 with IntConstantOperand

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

the class NormalizeConstants method asImmediateOrRegLong.

static Operand asImmediateOrRegLong(Operand addr, Instruction s, IR ir, boolean signed) {
    if (VM.BuildFor64Addr && (addr instanceof LongConstantOperand)) {
        if (!canBeImmediate(((LongConstantOperand) addr).value, signed)) {
            RegisterOperand rop = ir.regpool.makeTempLong();
            s.insertBefore(Move.create(REF_MOVE, rop, addr));
            return rop.copyD2U();
        } else {
            // can be immediate --> convert to int
            return new IntConstantOperand((int) ((LongConstantOperand) addr).value);
        }
    } else if (addr instanceof ConstantOperand) {
        // must not happen
        if (VM.VerifyAssertions)
            VM._assert(VM.NOT_REACHED);
    }
    // Operand was OK as is.
    return addr;
}
Also used : LongConstantOperand(org.jikesrvm.compilers.opt.ir.operand.LongConstantOperand) LongConstantOperand(org.jikesrvm.compilers.opt.ir.operand.LongConstantOperand) DoubleConstantOperand(org.jikesrvm.compilers.opt.ir.operand.DoubleConstantOperand) CodeConstantOperand(org.jikesrvm.compilers.opt.ir.operand.CodeConstantOperand) NullConstantOperand(org.jikesrvm.compilers.opt.ir.operand.NullConstantOperand) FloatConstantOperand(org.jikesrvm.compilers.opt.ir.operand.FloatConstantOperand) TIBConstantOperand(org.jikesrvm.compilers.opt.ir.operand.TIBConstantOperand) ClassConstantOperand(org.jikesrvm.compilers.opt.ir.operand.ClassConstantOperand) IntConstantOperand(org.jikesrvm.compilers.opt.ir.operand.IntConstantOperand) AddressConstantOperand(org.jikesrvm.compilers.opt.ir.operand.AddressConstantOperand) ObjectConstantOperand(org.jikesrvm.compilers.opt.ir.operand.ObjectConstantOperand) StringConstantOperand(org.jikesrvm.compilers.opt.ir.operand.StringConstantOperand) ConstantOperand(org.jikesrvm.compilers.opt.ir.operand.ConstantOperand) RegisterOperand(org.jikesrvm.compilers.opt.ir.operand.RegisterOperand) IntConstantOperand(org.jikesrvm.compilers.opt.ir.operand.IntConstantOperand)

Example 39 with IntConstantOperand

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

the class NormalizeConstants method asImmediateOrRegPolymorphic.

static Operand asImmediateOrRegPolymorphic(Operand addr, Instruction s, IR ir, boolean signed) {
    if (addr instanceof IntConstantOperand) {
        if (!canBeImmediate(((IntConstantOperand) addr).value, signed)) {
            RegisterOperand rop = ir.regpool.makeTempInt();
            s.insertBefore(Move.create(REF_MOVE, rop, addr));
            return rop.copyD2U();
        }
    } else if (addr instanceof AddressConstantOperand) {
        if (!canBeImmediate(((AddressConstantOperand) addr).value, signed)) {
            RegisterOperand rop = ir.regpool.makeTempAddress();
            s.insertBefore(Move.create(REF_MOVE, rop, addr));
            return rop.copyD2U();
        } else {
            // can be immediate --> convert to int
            return new IntConstantOperand(((AddressConstantOperand) addr).value.toInt());
        }
    } else if (VM.BuildFor64Addr && (addr instanceof LongConstantOperand)) {
        if (!canBeImmediate(((LongConstantOperand) addr).value, signed)) {
            RegisterOperand rop = ir.regpool.makeTempLong();
            s.insertBefore(Move.create(REF_MOVE, rop, addr));
            return rop.copyD2U();
        } else {
            // can be immediate --> convert to int
            return new IntConstantOperand((int) ((LongConstantOperand) addr).value);
        }
    }
    // Operand was OK as is.
    return addr;
}
Also used : LongConstantOperand(org.jikesrvm.compilers.opt.ir.operand.LongConstantOperand) IntConstantOperand(org.jikesrvm.compilers.opt.ir.operand.IntConstantOperand) RegisterOperand(org.jikesrvm.compilers.opt.ir.operand.RegisterOperand) AddressConstantOperand(org.jikesrvm.compilers.opt.ir.operand.AddressConstantOperand)

Example 40 with IntConstantOperand

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

the class BURS_Helpers method OSR.

/**
 * special case handling OSR instructions expand long type variables to two
 * integers
 * @param burs the burs instance
 * @param s an OSRPoint instruction
 */
protected void OSR(BURS burs, Instruction s) {
    if (VM.VerifyAssertions) {
        opt_assert(OsrPoint.conforms(s));
    }
    // Check type info first because this needs to be done
    // for both 32-bit and 64-bit cases.
    InlinedOsrTypeInfoOperand typeInfo;
    if (VM.BuildFor32Addr) {
        // Clearing type info is ok, because instruction will be mutated and the
        // info will be reinserted
        typeInfo = OsrPoint.getClearInlinedTypeInfo(s);
    } else {
        // Instruction won't be changed so info needs to be left in
        typeInfo = OsrPoint.getInlinedTypeInfo(s);
    }
    if (VM.VerifyAssertions) {
        if (typeInfo == null) {
            VM.sysWriteln("OsrPoint " + s + " has a <null> type info:");
            VM.sysWriteln("  position :" + s.getBytecodeIndex() + "@" + s.position().method);
        }
        opt_assert(typeInfo != null);
    }
    int numparam = OsrPoint.getNumberOfElements(s);
    if (VM.BuildFor32Addr) {
        // 1. how many params
        int numlong = 0;
        for (int i = 0; i < numparam; i++) {
            Operand param = OsrPoint.getElement(s, i);
            if (param.getType().isLongType()) {
                numlong++;
            }
        }
        // 2. collect params
        Operand[] params = new Operand[numparam];
        for (int i = 0; i < numparam; i++) {
            params[i] = OsrPoint.getClearElement(s, i);
        }
        // set the number of valid params in osr type info, used
        // in LinearScan
        typeInfo.validOps = numparam;
        // 3: only makes second half register of long being used
        // creates room for long types.
        burs.append(OsrPoint.mutate(s, s.operator(), typeInfo, numparam + numlong));
        int pidx = numparam;
        for (int i = 0; i < numparam; i++) {
            Operand param = params[i];
            OsrPoint.setElement(s, i, param);
            if (param instanceof RegisterOperand) {
                RegisterOperand rparam = (RegisterOperand) param;
                // LinearScan will update the map.
                if (rparam.getType().isLongType()) {
                    OsrPoint.setElement(s, pidx++, L(burs.ir.regpool.getSecondReg(rparam.getRegister())));
                }
            } else if (param instanceof LongConstantOperand) {
                LongConstantOperand val = (LongConstantOperand) param;
                if (VM.TraceOnStackReplacement) {
                    VM.sysWriteln("caught a long const " + val);
                }
                OsrPoint.setElement(s, i, IC(val.upper32()));
                OsrPoint.setElement(s, pidx++, IC(val.lower32()));
            } else if (param instanceof IntConstantOperand) {
            } else {
                throw new OptimizingCompilerException("BURS_Helpers", "unexpected parameter type" + param);
            }
        }
        if (pidx != (numparam + numlong)) {
            VM.sysWriteln("pidx = " + pidx);
            VM.sysWriteln("numparam = " + numparam);
            VM.sysWriteln("numlong = " + numlong);
        }
        if (VM.VerifyAssertions) {
            opt_assert(pidx == (numparam + numlong));
        }
    } else {
        // set the number of valid params in osr type info, used
        // in LinearScan
        typeInfo.validOps = numparam;
        burs.append(s);
    }
}
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) 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) InlinedOsrTypeInfoOperand(org.jikesrvm.compilers.opt.ir.operand.InlinedOsrTypeInfoOperand) OptimizingCompilerException(org.jikesrvm.compilers.opt.OptimizingCompilerException) OsrPoint(org.jikesrvm.compilers.opt.ir.OsrPoint)

Aggregations

IntConstantOperand (org.jikesrvm.compilers.opt.ir.operand.IntConstantOperand)49 RegisterOperand (org.jikesrvm.compilers.opt.ir.operand.RegisterOperand)41 Operand (org.jikesrvm.compilers.opt.ir.operand.Operand)28 ConditionOperand (org.jikesrvm.compilers.opt.ir.operand.ConditionOperand)23 BranchProfileOperand (org.jikesrvm.compilers.opt.ir.operand.BranchProfileOperand)21 LongConstantOperand (org.jikesrvm.compilers.opt.ir.operand.LongConstantOperand)21 AddressConstantOperand (org.jikesrvm.compilers.opt.ir.operand.AddressConstantOperand)19 Instruction (org.jikesrvm.compilers.opt.ir.Instruction)18 LocationOperand (org.jikesrvm.compilers.opt.ir.operand.LocationOperand)17 BranchOperand (org.jikesrvm.compilers.opt.ir.operand.BranchOperand)16 TrueGuardOperand (org.jikesrvm.compilers.opt.ir.operand.TrueGuardOperand)16 DoubleConstantOperand (org.jikesrvm.compilers.opt.ir.operand.DoubleConstantOperand)15 MethodOperand (org.jikesrvm.compilers.opt.ir.operand.MethodOperand)15 NullConstantOperand (org.jikesrvm.compilers.opt.ir.operand.NullConstantOperand)15 TrapCodeOperand (org.jikesrvm.compilers.opt.ir.operand.TrapCodeOperand)14 FloatConstantOperand (org.jikesrvm.compilers.opt.ir.operand.FloatConstantOperand)13 ConstantOperand (org.jikesrvm.compilers.opt.ir.operand.ConstantOperand)12 BasicBlock (org.jikesrvm.compilers.opt.ir.BasicBlock)11 TypeReference (org.jikesrvm.classloader.TypeReference)10 TypeOperand (org.jikesrvm.compilers.opt.ir.operand.TypeOperand)9