Search in sources :

Example 1 with ValueProcedure

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

the class TrivialTraceAllocator method handlePhiOut.

private static void handlePhiOut(LIRInstruction jump, int[] varIn, Value[] locIn) {
    // handle outgoing phi values
    ValueProcedure outputConsumer = new ValueProcedure() {

        @Override
        public Value doValue(Value value, OperandMode mode, EnumSet<OperandFlag> flags) {
            if (isVariable(value)) {
                // since incoming variables are sorted, we can do a binary search
                return locIn[Arrays.binarySearch(varIn, asVariable(value).index)];
            }
            return value;
        }
    };
    // Jumps have only alive values (outgoing phi values)
    jump.forEachAlive(outputConsumer);
}
Also used : ValueProcedure(org.graalvm.compiler.lir.ValueProcedure) EnumSet(java.util.EnumSet) Value(jdk.vm.ci.meta.Value) OperandMode(org.graalvm.compiler.lir.LIRInstruction.OperandMode)

Example 2 with ValueProcedure

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

the class UseEntry method replaceValue.

private static void replaceValue(LIRInstruction op, Value oldValue, Value newValue) {
    ValueProcedure proc = (value, mode, flags) -> value.identityEquals(oldValue) ? newValue : value;
    op.forEachAlive(proc);
    op.forEachInput(proc);
    op.forEachOutput(proc);
    op.forEachTemp(proc);
    op.forEachState(proc);
}
Also used : ValueProcedure(org.graalvm.compiler.lir.ValueProcedure) AbstractBlockBase(org.graalvm.compiler.core.common.cfg.AbstractBlockBase) Value(jdk.vm.ci.meta.Value) ValueProcedure(org.graalvm.compiler.lir.ValueProcedure) LIRInstruction(org.graalvm.compiler.lir.LIRInstruction)

Example 3 with ValueProcedure

use of org.graalvm.compiler.lir.ValueProcedure 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)

Aggregations

ValueProcedure (org.graalvm.compiler.lir.ValueProcedure)3 Value (jdk.vm.ci.meta.Value)2 AbstractBlockBase (org.graalvm.compiler.core.common.cfg.AbstractBlockBase)2 LIRInstruction (org.graalvm.compiler.lir.LIRInstruction)2 EnumSet (java.util.EnumSet)1 StackSlot (jdk.vm.ci.code.StackSlot)1 TargetDescription (jdk.vm.ci.code.TargetDescription)1 DebugContext (org.graalvm.compiler.debug.DebugContext)1 GraalError (org.graalvm.compiler.debug.GraalError)1 Indent (org.graalvm.compiler.debug.Indent)1 OperandMode (org.graalvm.compiler.lir.LIRInstruction.OperandMode)1 LIRValueUtil.asVirtualStackSlot (org.graalvm.compiler.lir.LIRValueUtil.asVirtualStackSlot)1 LIRValueUtil.isVirtualStackSlot (org.graalvm.compiler.lir.LIRValueUtil.isVirtualStackSlot)1 VirtualStackSlot (org.graalvm.compiler.lir.VirtualStackSlot)1 FrameMapBuilderTool (org.graalvm.compiler.lir.framemap.FrameMapBuilderTool)1 SimpleVirtualStackSlot (org.graalvm.compiler.lir.framemap.SimpleVirtualStackSlot)1 VirtualStackSlotRange (org.graalvm.compiler.lir.framemap.VirtualStackSlotRange)1 LIRGenerationResult (org.graalvm.compiler.lir.gen.LIRGenerationResult)1 AllocationPhase (org.graalvm.compiler.lir.phases.AllocationPhase)1 StackSlotAllocatorUtil.allocatedFramesize (org.graalvm.compiler.lir.stackslotalloc.StackSlotAllocatorUtil.allocatedFramesize)1