Search in sources :

Example 1 with AddressConstantOperand

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

the class InstrumentationSamplingFramework method appendLoad.

/**
 * Append a load of the global counter to the given basic block.
 *
 * WARNING: Tested for LIR only!
 *
 * @param bb The block to append the load to
 * @param ir The IR
 */
private void appendLoad(BasicBlock bb, IR ir) {
    if (DEBUG)
        VM.sysWriteln("Adding load to " + bb);
    Instruction load = null;
    if (ir.options.ADAPTIVE_PROCESSOR_SPECIFIC_COUNTER) {
        if (ir.isHIR()) {
            VM.sysFail("Not implemented yet.");
        } else {
            // Phase is being used in LIR
            if (VM.VerifyAssertions)
                VM._assert(ir.isLIR());
            // Insert the load instruction.
            load = Load.create(INT_LOAD, cbsReg.copyRO(), ir.regpool.makeTROp(), IRTools.AC(AosEntrypoints.threadCBSField.getOffset()), new LocationOperand(AosEntrypoints.threadCBSField));
            bb.appendInstruction(load);
        }
    } else {
        // Use global counter
        if (ir.isHIR()) {
            Operand offsetOp = new AddressConstantOperand(AosEntrypoints.globalCBSField.getOffset());
            load = GetStatic.create(GETSTATIC, cbsReg.copyRO(), offsetOp, new LocationOperand(AosEntrypoints.globalCBSField));
            bb.appendInstruction(load);
        } else {
            // LIR
            Instruction dummy = Load.create(INT_LOAD, null, null, null, null);
            bb.appendInstruction(dummy);
            load = Load.create(INT_LOAD, cbsReg.copyRO(), ir.regpool.makeJTOCOp(), IRTools.AC(AosEntrypoints.globalCBSField.getOffset()), new LocationOperand(AosEntrypoints.globalCBSField));
            dummy.insertBefore(load);
            dummy.remove();
        }
    }
}
Also used : LocationOperand(org.jikesrvm.compilers.opt.ir.operand.LocationOperand) AddressConstantOperand(org.jikesrvm.compilers.opt.ir.operand.AddressConstantOperand) BranchProfileOperand(org.jikesrvm.compilers.opt.ir.operand.BranchProfileOperand) BranchOperand(org.jikesrvm.compilers.opt.ir.operand.BranchOperand) 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) AddressConstantOperand(org.jikesrvm.compilers.opt.ir.operand.AddressConstantOperand) Instruction(org.jikesrvm.compilers.opt.ir.Instruction)

Example 2 with AddressConstantOperand

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

the class InstrumentationSamplingFramework method prependCounterReset.

/**
 * Prepend the code to reset the global counter to the given basic
 * block.
 *
 * Warning:  Tested in LIR only!
 *
 * @param bb The block to append the load to
 * @param ir The IR
 */
private void prependCounterReset(BasicBlock bb, IR ir) {
    Instruction load = null;
    Instruction store = null;
    if (ir.isHIR()) {
        // Not tested
        Operand offsetOp = new AddressConstantOperand(AosEntrypoints.cbsResetValueField.getOffset());
        load = GetStatic.create(GETSTATIC, cbsReg.copyRO(), offsetOp, new LocationOperand(AosEntrypoints.cbsResetValueField));
        store = PutStatic.create(PUTSTATIC, cbsReg.copyRO(), new AddressConstantOperand(AosEntrypoints.globalCBSField.getOffset()), new LocationOperand(AosEntrypoints.globalCBSField));
        bb.prependInstruction(store);
        bb.prependInstruction(load);
    } else {
        // LIR
        if (VM.VerifyAssertions)
            VM._assert(ir.isLIR());
        Instruction dummy = Load.create(INT_LOAD, null, null, null, null);
        bb.prependInstruction(dummy);
        // Load the reset value
        load = Load.create(INT_LOAD, cbsReg.copyRO(), ir.regpool.makeJTOCOp(), IRTools.AC(AosEntrypoints.cbsResetValueField.getOffset()), new LocationOperand(AosEntrypoints.cbsResetValueField));
        dummy.insertBefore(load);
        // Store it in the counter register
        if (ir.options.ADAPTIVE_PROCESSOR_SPECIFIC_COUNTER) {
            store = Store.create(INT_STORE, cbsReg.copyRO(), ir.regpool.makeTROp(), IRTools.AC(AosEntrypoints.threadCBSField.getOffset()), new LocationOperand(AosEntrypoints.threadCBSField));
        } else {
            // Use global counter
            store = Store.create(INT_STORE, cbsReg.copyRO(), ir.regpool.makeJTOCOp(), IRTools.AC(AosEntrypoints.globalCBSField.getOffset()), new LocationOperand(AosEntrypoints.globalCBSField));
        }
        dummy.insertBefore(store);
        dummy.remove();
    }
}
Also used : LocationOperand(org.jikesrvm.compilers.opt.ir.operand.LocationOperand) AddressConstantOperand(org.jikesrvm.compilers.opt.ir.operand.AddressConstantOperand) BranchProfileOperand(org.jikesrvm.compilers.opt.ir.operand.BranchProfileOperand) BranchOperand(org.jikesrvm.compilers.opt.ir.operand.BranchOperand) 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) AddressConstantOperand(org.jikesrvm.compilers.opt.ir.operand.AddressConstantOperand) Instruction(org.jikesrvm.compilers.opt.ir.Instruction)

Example 3 with AddressConstantOperand

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

the class InstrumentationSamplingFramework method prependStore.

/**
 * Append a store of the global counter to the given basic block.
 *
 * WARNING: Tested in LIR only!
 *
 * @param bb The block to append the load to
 * @param ir The IR
 */
private void prependStore(BasicBlock bb, IR ir) {
    if (DEBUG)
        VM.sysWriteln("Adding store to " + bb);
    Instruction store = null;
    if (ir.options.ADAPTIVE_PROCESSOR_SPECIFIC_COUNTER) {
        store = Store.create(INT_STORE, cbsReg.copyRO(), ir.regpool.makeTROp(), IRTools.AC(AosEntrypoints.threadCBSField.getOffset()), new LocationOperand(AosEntrypoints.threadCBSField));
        bb.prependInstruction(store);
    } else {
        if (ir.isHIR()) {
            store = PutStatic.create(PUTSTATIC, cbsReg.copyRO(), new AddressConstantOperand(AosEntrypoints.globalCBSField.getOffset()), new LocationOperand(AosEntrypoints.globalCBSField));
            bb.prependInstruction(store);
        } else {
            Instruction dummy = Load.create(INT_LOAD, null, null, null, null);
            bb.prependInstruction(dummy);
            store = Store.create(INT_STORE, cbsReg.copyRO(), ir.regpool.makeJTOCOp(), IRTools.AC(AosEntrypoints.globalCBSField.getOffset()), new LocationOperand(AosEntrypoints.globalCBSField));
            dummy.insertBefore(store);
            dummy.remove();
        }
    }
}
Also used : LocationOperand(org.jikesrvm.compilers.opt.ir.operand.LocationOperand) AddressConstantOperand(org.jikesrvm.compilers.opt.ir.operand.AddressConstantOperand) Instruction(org.jikesrvm.compilers.opt.ir.Instruction)

Example 4 with AddressConstantOperand

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

the class NormalizeConstants method asRegOffset.

static Operand asRegOffset(Operand addr, Instruction s, IR ir) {
    if (addr instanceof AddressConstantOperand) {
        RegisterOperand rop = ir.regpool.makeTempOffset();
        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) RegisterOperand(org.jikesrvm.compilers.opt.ir.operand.RegisterOperand) AddressConstantOperand(org.jikesrvm.compilers.opt.ir.operand.AddressConstantOperand)

Example 5 with AddressConstantOperand

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

the class NormalizeConstants method asImmediateOrRegOffset.

static Operand asImmediateOrRegOffset(Operand addr, Instruction s, IR ir, boolean signed) {
    if (addr instanceof AddressConstantOperand) {
        if (!canBeImmediate(((AddressConstantOperand) addr).value, signed)) {
            RegisterOperand rop = ir.regpool.makeTempOffset();
            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 (addr instanceof ConstantOperand) {
        // must not happen, because is 64-bit unsafe
        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) RegisterOperand(org.jikesrvm.compilers.opt.ir.operand.RegisterOperand) IntConstantOperand(org.jikesrvm.compilers.opt.ir.operand.IntConstantOperand) AddressConstantOperand(org.jikesrvm.compilers.opt.ir.operand.AddressConstantOperand)

Aggregations

AddressConstantOperand (org.jikesrvm.compilers.opt.ir.operand.AddressConstantOperand)18 IntConstantOperand (org.jikesrvm.compilers.opt.ir.operand.IntConstantOperand)15 RegisterOperand (org.jikesrvm.compilers.opt.ir.operand.RegisterOperand)15 LongConstantOperand (org.jikesrvm.compilers.opt.ir.operand.LongConstantOperand)13 Operand (org.jikesrvm.compilers.opt.ir.operand.Operand)10 Instruction (org.jikesrvm.compilers.opt.ir.Instruction)9 DoubleConstantOperand (org.jikesrvm.compilers.opt.ir.operand.DoubleConstantOperand)8 FloatConstantOperand (org.jikesrvm.compilers.opt.ir.operand.FloatConstantOperand)8 NullConstantOperand (org.jikesrvm.compilers.opt.ir.operand.NullConstantOperand)8 LocationOperand (org.jikesrvm.compilers.opt.ir.operand.LocationOperand)7 BranchOperand (org.jikesrvm.compilers.opt.ir.operand.BranchOperand)6 ClassConstantOperand (org.jikesrvm.compilers.opt.ir.operand.ClassConstantOperand)6 ObjectConstantOperand (org.jikesrvm.compilers.opt.ir.operand.ObjectConstantOperand)6 TypeReference (org.jikesrvm.classloader.TypeReference)5 BranchProfileOperand (org.jikesrvm.compilers.opt.ir.operand.BranchProfileOperand)5 ConstantOperand (org.jikesrvm.compilers.opt.ir.operand.ConstantOperand)5 StringConstantOperand (org.jikesrvm.compilers.opt.ir.operand.StringConstantOperand)5 CodeConstantOperand (org.jikesrvm.compilers.opt.ir.operand.CodeConstantOperand)4 ConditionOperand (org.jikesrvm.compilers.opt.ir.operand.ConditionOperand)4 TIBConstantOperand (org.jikesrvm.compilers.opt.ir.operand.TIBConstantOperand)4