Search in sources :

Example 51 with LIRInstruction

use of org.graalvm.compiler.lir.LIRInstruction in project graal by oracle.

the class TraceLocalMoveResolver method insertMove.

private void insertMove(Constant fromOpr, TraceInterval toInterval) {
    assert insertIdx != -1 : "must setup insert position first";
    AllocatableValue toOpr = allocator.getOperand(toInterval);
    LIRInstruction move = getAllocator().getSpillMoveFactory().createLoad(toOpr, fromOpr);
    insertionBuffer.append(insertIdx, move);
    if (debug.isLogEnabled()) {
        debug.log("insert move from value %s to %s at %d", fromOpr, toInterval, insertIdx);
    }
}
Also used : LIRInstruction(org.graalvm.compiler.lir.LIRInstruction) AllocatableValue(jdk.vm.ci.meta.AllocatableValue)

Example 52 with LIRInstruction

use of org.graalvm.compiler.lir.LIRInstruction in project graal by oracle.

the class RegisterVerifier method processOperations.

void processOperations(AbstractBlockBase<?> block, final TraceInterval[] inputState) {
    ArrayList<LIRInstruction> ops = allocator.getLIR().getLIRforBlock(block);
    DebugContext debug = allocator.getDebug();
    InstructionValueConsumer useConsumer = new InstructionValueConsumer() {

        @Override
        public void visitValue(LIRInstruction op, Value operand, OperandMode mode, EnumSet<OperandFlag> flags) {
            // we skip spill moves inserted by the spill position optimization
            if (isVariableOrRegister(operand) && allocator.isProcessed(operand) && op.id() != TraceLinearScanPhase.DOMINATOR_SPILL_MOVE_ID) {
                TraceInterval interval = intervalAt(asVariable(operand));
                if (op.id() != -1) {
                    interval = interval.getSplitChildAtOpId(op.id(), mode);
                }
                assert checkState(block, op, inputState, allocator.getOperand(interval), interval.location(), interval.splitParent());
            }
        }
    };
    InstructionValueConsumer defConsumer = (op, operand, mode, flags) -> {
        if (isVariableOrRegister(operand) && allocator.isProcessed(operand)) {
            TraceInterval interval = intervalAt(asVariable(operand));
            if (op.id() != -1) {
                interval = interval.getSplitChildAtOpId(op.id(), mode);
            }
            statePut(debug, inputState, interval.location(), interval.splitParent());
        }
    };
    // visit all instructions of the block
    for (int i = 0; i < ops.size(); i++) {
        final LIRInstruction op = ops.get(i);
        if (debug.isLogEnabled()) {
            debug.log("%s", op.toStringWithIdPrefix());
        }
        // check if input operands are correct
        op.visitEachInput(useConsumer);
        // invalidate all caller save registers at calls
        if (op.destroysCallerSavedRegisters()) {
            for (Register r : allocator.getRegisterAllocationConfig().getRegisterConfig().getCallerSaveRegisters()) {
                statePut(debug, inputState, r.asValue(), null);
            }
        }
        op.visitEachAlive(useConsumer);
        // set temp operands (some operations use temp operands also as output operands, so
        // can't set them null)
        op.visitEachTemp(defConsumer);
        // set output operands
        op.visitEachOutput(defConsumer);
    }
}
Also used : AbstractBlockBase(org.graalvm.compiler.core.common.cfg.AbstractBlockBase) OperandMode(org.graalvm.compiler.lir.LIRInstruction.OperandMode) Variable(org.graalvm.compiler.lir.Variable) TraceLinearScanPhase.isVariableOrRegister(org.graalvm.compiler.lir.alloc.trace.lsra.TraceLinearScanPhase.isVariableOrRegister) TraceLinearScan(org.graalvm.compiler.lir.alloc.trace.lsra.TraceLinearScanPhase.TraceLinearScan) LIRValueUtil.asVariable(org.graalvm.compiler.lir.LIRValueUtil.asVariable) LIRInstruction(org.graalvm.compiler.lir.LIRInstruction) Register(jdk.vm.ci.code.Register) ArrayList(java.util.ArrayList) BlockMap(org.graalvm.compiler.core.common.cfg.BlockMap) InstructionValueConsumer(org.graalvm.compiler.lir.InstructionValueConsumer) Value(jdk.vm.ci.meta.Value) OperandFlag(org.graalvm.compiler.lir.LIRInstruction.OperandFlag) DebugContext(org.graalvm.compiler.debug.DebugContext) ValueUtil.isRegister(jdk.vm.ci.code.ValueUtil.isRegister) Indent(org.graalvm.compiler.debug.Indent) GraalError(org.graalvm.compiler.debug.GraalError) ValueUtil.asRegister(jdk.vm.ci.code.ValueUtil.asRegister) EnumSet(java.util.EnumSet) InstructionValueConsumer(org.graalvm.compiler.lir.InstructionValueConsumer) TraceLinearScanPhase.isVariableOrRegister(org.graalvm.compiler.lir.alloc.trace.lsra.TraceLinearScanPhase.isVariableOrRegister) Register(jdk.vm.ci.code.Register) ValueUtil.isRegister(jdk.vm.ci.code.ValueUtil.isRegister) ValueUtil.asRegister(jdk.vm.ci.code.ValueUtil.asRegister) LIRInstruction(org.graalvm.compiler.lir.LIRInstruction) EnumSet(java.util.EnumSet) Value(jdk.vm.ci.meta.Value) DebugContext(org.graalvm.compiler.debug.DebugContext) OperandMode(org.graalvm.compiler.lir.LIRInstruction.OperandMode)

Example 53 with LIRInstruction

use of org.graalvm.compiler.lir.LIRInstruction in project graal by oracle.

the class PhiResolver method create.

public static PhiResolver create(LIRGeneratorTool gen) {
    AbstractBlockBase<?> block = gen.getCurrentBlock();
    assert block != null;
    ArrayList<LIRInstruction> instructions = gen.getResult().getLIR().getLIRforBlock(block);
    return new PhiResolver(gen, new LIRInsertionBuffer(), instructions, instructions.size());
}
Also used : LIRInsertionBuffer(org.graalvm.compiler.lir.LIRInsertionBuffer) LIRInstruction(org.graalvm.compiler.lir.LIRInstruction)

Example 54 with LIRInstruction

use of org.graalvm.compiler.lir.LIRInstruction in project graal by oracle.

the class FrameMapBuilderImpl method verifyStackSlotAllocation.

private static void verifyStackSlotAllocation(LIRGenerationResult res) {
    LIR lir = res.getLIR();
    InstructionValueConsumer verifySlots = (LIRInstruction op, Value value, OperandMode mode, EnumSet<OperandFlag> flags) -> {
        assert !isVirtualStackSlot(value) : String.format("Instruction %s contains a virtual stack slot %s", op, value);
    };
    for (AbstractBlockBase<?> block : lir.getControlFlowGraph().getBlocks()) {
        lir.getLIRforBlock(block).forEach(op -> {
            op.visitEachInput(verifySlots);
            op.visitEachAlive(verifySlots);
            op.visitEachState(verifySlots);
            op.visitEachTemp(verifySlots);
            op.visitEachOutput(verifySlots);
        });
    }
}
Also used : LIR(org.graalvm.compiler.lir.LIR) InstructionValueConsumer(org.graalvm.compiler.lir.InstructionValueConsumer) LIRInstruction(org.graalvm.compiler.lir.LIRInstruction) Value(jdk.vm.ci.meta.Value) OperandFlag(org.graalvm.compiler.lir.LIRInstruction.OperandFlag) OperandMode(org.graalvm.compiler.lir.LIRInstruction.OperandMode)

Example 55 with LIRInstruction

use of org.graalvm.compiler.lir.LIRInstruction in project graal by oracle.

the class SSAVerifier method verifyBlock.

private boolean verifyBlock(AbstractBlockBase<?> block) {
    currentBlock = block;
    assert !visited.get(block.getId()) : "Block already visited: " + block;
    visited.set(block.getId());
    for (LIRInstruction op : lir.getLIRforBlock(block)) {
        op.visitEachAlive(this::useConsumer);
        op.visitEachState(this::useConsumer);
        op.visitEachInput(this::useConsumer);
        op.visitEachTemp(this::defConsumer);
        op.visitEachOutput(this::defConsumer);
    }
    currentBlock = null;
    return true;
}
Also used : LIRInstruction(org.graalvm.compiler.lir.LIRInstruction)

Aggregations

LIRInstruction (org.graalvm.compiler.lir.LIRInstruction)55 DebugContext (org.graalvm.compiler.debug.DebugContext)25 Indent (org.graalvm.compiler.debug.Indent)19 AllocatableValue (jdk.vm.ci.meta.AllocatableValue)15 Value (jdk.vm.ci.meta.Value)15 OperandMode (org.graalvm.compiler.lir.LIRInstruction.OperandMode)10 EnumSet (java.util.EnumSet)8 Register (jdk.vm.ci.code.Register)8 AbstractBlockBase (org.graalvm.compiler.core.common.cfg.AbstractBlockBase)8 OperandFlag (org.graalvm.compiler.lir.LIRInstruction.OperandFlag)7 BitSet (java.util.BitSet)6 GraalError (org.graalvm.compiler.debug.GraalError)6 InstructionValueConsumer (org.graalvm.compiler.lir.InstructionValueConsumer)6 LIR (org.graalvm.compiler.lir.LIR)6 LIRInsertionBuffer (org.graalvm.compiler.lir.LIRInsertionBuffer)6 ValueConsumer (org.graalvm.compiler.lir.ValueConsumer)6 ArrayList (java.util.ArrayList)5 ValueUtil.asRegister (jdk.vm.ci.code.ValueUtil.asRegister)5 ValueUtil.isRegister (jdk.vm.ci.code.ValueUtil.isRegister)5 LoadConstantOp (org.graalvm.compiler.lir.StandardOp.LoadConstantOp)5