Search in sources :

Example 21 with LIRInstruction

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

the class LocationMarker method processBlock.

@SuppressWarnings("try")
private void processBlock(AbstractBlockBase<?> block, UniqueWorkList worklist) {
    if (updateOutBlock(block)) {
        DebugContext debug = lir.getDebug();
        try (Indent indent = debug.logAndIndent("handle block %s", block)) {
            currentSet = liveOutMap.get(block).copy();
            ArrayList<LIRInstruction> instructions = lir.getLIRforBlock(block);
            for (int i = instructions.size() - 1; i >= 0; i--) {
                LIRInstruction inst = instructions.get(i);
                processInstructionBottomUp(inst);
            }
            liveInMap.put(block, currentSet);
            currentSet = null;
            for (AbstractBlockBase<?> b : block.getPredecessors()) {
                worklist.add(b);
            }
        }
    }
}
Also used : Indent(org.graalvm.compiler.debug.Indent) LIRInstruction(org.graalvm.compiler.lir.LIRInstruction) DebugContext(org.graalvm.compiler.debug.DebugContext)

Example 22 with LIRInstruction

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

the class FixPointIntervalBuilder method processBlock.

@SuppressWarnings("try")
private void processBlock(AbstractBlockBase<?> block, Deque<AbstractBlockBase<?>> worklist) {
    DebugContext debug = lir.getDebug();
    if (updateOutBlock(block)) {
        try (Indent indent = debug.logAndIndent("handle block %s", block)) {
            ArrayList<LIRInstruction> instructions = lir.getLIRforBlock(block);
            // get out set and mark intervals
            BitSet outSet = liveOutMap.get(block);
            markOutInterval(outSet, getBlockEnd(instructions));
            printLiveSet("liveOut", outSet);
            // process instructions
            BlockClosure closure = new BlockClosure((BitSet) outSet.clone());
            for (int i = instructions.size() - 1; i >= 0; i--) {
                LIRInstruction inst = instructions.get(i);
                closure.processInstructionBottomUp(inst);
            }
            // add predecessors to work list
            for (AbstractBlockBase<?> b : block.getPredecessors()) {
                worklist.add(b);
            }
            // set in set and mark intervals
            BitSet inSet = closure.getCurrentSet();
            liveInMap.put(block, inSet);
            markInInterval(inSet, getBlockBegin(instructions));
            printLiveSet("liveIn", inSet);
        }
    }
}
Also used : Indent(org.graalvm.compiler.debug.Indent) LIRInstruction(org.graalvm.compiler.lir.LIRInstruction) BitSet(java.util.BitSet) DebugContext(org.graalvm.compiler.debug.DebugContext)

Example 23 with LIRInstruction

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

the class SimpleStackSlotAllocator method updateLIR.

@SuppressWarnings("try")
protected void updateLIR(LIRGenerationResult res, StackSlot[] mapping) {
    DebugContext debug = res.getLIR().getDebug();
    try (DebugContext.Scope scope = debug.scope("StackSlotMappingLIR")) {
        ValueProcedure updateProc = (value, mode, flags) -> {
            if (isVirtualStackSlot(value)) {
                StackSlot stackSlot = mapping[asVirtualStackSlot(value).getId()];
                debug.log("map %s -> %s", value, stackSlot);
                return stackSlot;
            }
            return value;
        };
        for (AbstractBlockBase<?> block : res.getLIR().getControlFlowGraph().getBlocks()) {
            try (Indent indent0 = debug.logAndIndent("block: %s", block)) {
                for (LIRInstruction inst : res.getLIR().getLIRforBlock(block)) {
                    try (Indent indent1 = debug.logAndIndent("Inst: %d: %s", inst.id(), inst)) {
                        inst.forEachAlive(updateProc);
                        inst.forEachInput(updateProc);
                        inst.forEachOutput(updateProc);
                        inst.forEachTemp(updateProc);
                        inst.forEachState(updateProc);
                    }
                }
            }
        }
    }
}
Also used : ValueProcedure(org.graalvm.compiler.lir.ValueProcedure) AbstractBlockBase(org.graalvm.compiler.core.common.cfg.AbstractBlockBase) FrameMapBuilderTool(org.graalvm.compiler.lir.framemap.FrameMapBuilderTool) AllocationPhase(org.graalvm.compiler.lir.phases.AllocationPhase) LIRInstruction(org.graalvm.compiler.lir.LIRInstruction) StackSlotAllocatorUtil.allocatedSlots(org.graalvm.compiler.lir.stackslotalloc.StackSlotAllocatorUtil.allocatedSlots) VirtualStackSlotRange(org.graalvm.compiler.lir.framemap.VirtualStackSlotRange) LIRGenerationResult(org.graalvm.compiler.lir.gen.LIRGenerationResult) TargetDescription(jdk.vm.ci.code.TargetDescription) LIRValueUtil.asVirtualStackSlot(org.graalvm.compiler.lir.LIRValueUtil.asVirtualStackSlot) SimpleVirtualStackSlot(org.graalvm.compiler.lir.framemap.SimpleVirtualStackSlot) DebugContext(org.graalvm.compiler.debug.DebugContext) StackSlotAllocatorUtil.virtualFramesize(org.graalvm.compiler.lir.stackslotalloc.StackSlotAllocatorUtil.virtualFramesize) Indent(org.graalvm.compiler.debug.Indent) GraalError(org.graalvm.compiler.debug.GraalError) StackSlot(jdk.vm.ci.code.StackSlot) LIRValueUtil.isVirtualStackSlot(org.graalvm.compiler.lir.LIRValueUtil.isVirtualStackSlot) ValueProcedure(org.graalvm.compiler.lir.ValueProcedure) StackSlotAllocatorUtil.allocatedFramesize(org.graalvm.compiler.lir.stackslotalloc.StackSlotAllocatorUtil.allocatedFramesize) VirtualStackSlot(org.graalvm.compiler.lir.VirtualStackSlot) Indent(org.graalvm.compiler.debug.Indent) LIRInstruction(org.graalvm.compiler.lir.LIRInstruction) LIRValueUtil.asVirtualStackSlot(org.graalvm.compiler.lir.LIRValueUtil.asVirtualStackSlot) SimpleVirtualStackSlot(org.graalvm.compiler.lir.framemap.SimpleVirtualStackSlot) StackSlot(jdk.vm.ci.code.StackSlot) LIRValueUtil.isVirtualStackSlot(org.graalvm.compiler.lir.LIRValueUtil.isVirtualStackSlot) VirtualStackSlot(org.graalvm.compiler.lir.VirtualStackSlot) DebugContext(org.graalvm.compiler.debug.DebugContext)

Example 24 with LIRInstruction

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

the class LIRGenerator method append.

@Override
public <I extends LIRInstruction> I append(I op) {
    LIR lir = res.getLIR();
    if (printIrWithLir) {
        TTY.println(op.toStringWithIdPrefix());
        TTY.println();
    }
    assert LIRVerifier.verify(op);
    ArrayList<LIRInstruction> lirForBlock = lir.getLIRforBlock(getCurrentBlock());
    op.setPosition(currentPosition);
    lirForBlock.add(op);
    return op;
}
Also used : LIR(org.graalvm.compiler.lir.LIR) LIRInstruction(org.graalvm.compiler.lir.LIRInstruction)

Example 25 with LIRInstruction

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

the class PhiResolver method emitMove.

private void emitMove(Value dest, Value src) {
    assert isLegal(src);
    assert isLegal(dest);
    LIRInstruction move = moveFactory.createMove((AllocatableValue) dest, src);
    buffer.append(insertBefore, move);
}
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