Search in sources :

Example 1 with LIR

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

the class HotSpotZapRegistersPhase method run.

@Override
protected void run(TargetDescription target, LIRGenerationResult lirGenRes, PostAllocationOptimizationContext context) {
    Stub stub = ((HotSpotLIRGenerationResult) lirGenRes).getStub();
    boolean zapRegisters = stub != null && !stub.preservesRegisters();
    boolean zapStack = false;
    for (AllocatableValue arg : lirGenRes.getCallingConvention().getArguments()) {
        if (isStackSlot(arg)) {
            zapStack = true;
            break;
        }
    }
    if (zapRegisters || zapStack) {
        LIR lir = lirGenRes.getLIR();
        processLIR(context.diagnosticLirGenTool, (HotSpotLIRGenerationResult) lirGenRes, lir, zapRegisters, zapStack);
    }
}
Also used : LIR(org.graalvm.compiler.lir.LIR) HotSpotLIRGenerationResult(org.graalvm.compiler.hotspot.HotSpotLIRGenerationResult) Stub(org.graalvm.compiler.hotspot.stubs.Stub) AllocatableValue(jdk.vm.ci.meta.AllocatableValue)

Example 2 with LIR

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

the class TraceGlobalMoveResolutionPhase method resolve.

public static void resolve(TargetDescription target, LIRGenerationResult lirGenRes, TraceAllocationContext context) {
    LIR lir = lirGenRes.getLIR();
    DebugContext debug = lir.getDebug();
    debug.dump(DebugContext.VERBOSE_LEVEL, lir, "Before TraceGlobalMoveResultion");
    MoveFactory spillMoveFactory = context.spillMoveFactory;
    resolveGlobalDataFlow(context.resultTraces, lirGenRes, spillMoveFactory, target.arch, context.livenessInfo, context.registerAllocationConfig);
}
Also used : LIR(org.graalvm.compiler.lir.LIR) DebugContext(org.graalvm.compiler.debug.DebugContext) MoveFactory(org.graalvm.compiler.lir.gen.LIRGeneratorTool.MoveFactory)

Example 3 with LIR

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

the class TraceRegisterAllocationPhase method run.

@Override
@SuppressWarnings("try")
protected void run(TargetDescription target, LIRGenerationResult lirGenRes, AllocationContext context) {
    MoveFactory spillMoveFactory = context.spillMoveFactory;
    RegisterAllocationConfig registerAllocationConfig = context.registerAllocationConfig;
    LIR lir = lirGenRes.getLIR();
    DebugContext debug = lir.getDebug();
    TraceBuilderResult resultTraces = context.contextLookup(TraceBuilderResult.class);
    GlobalLivenessInfo livenessInfo = context.contextLookup(GlobalLivenessInfo.class);
    assert livenessInfo != null;
    TraceAllocationContext traceContext = new TraceAllocationContext(spillMoveFactory, registerAllocationConfig, resultTraces, livenessInfo);
    AllocatableValue[] cachedStackSlots = Options.TraceRACacheStackSlots.getValue(lir.getOptions()) ? new AllocatableValue[lir.numVariables()] : null;
    // currently this is not supported
    boolean neverSpillConstant = false;
    final TraceRegisterAllocationPolicy plan = DefaultTraceRegisterAllocationPolicy.allocationPolicy(target, lirGenRes, spillMoveFactory, registerAllocationConfig, cachedStackSlots, resultTraces, neverSpillConstant, livenessInfo, lir.getOptions());
    try (DebugContext.Scope s0 = debug.scope("AllocateTraces", resultTraces, livenessInfo)) {
        for (Trace trace : resultTraces.getTraces()) {
            tracesCounter.increment(debug);
            TraceAllocationPhase<TraceAllocationContext> allocator = plan.selectStrategy(trace);
            try (Indent i = debug.logAndIndent("Allocating Trace%d: %s (%s)", trace.getId(), trace, allocator);
                DebugContext.Scope s = debug.scope("AllocateTrace", trace)) {
                allocator.apply(target, lirGenRes, trace, traceContext);
            }
        }
    } catch (Throwable e) {
        throw debug.handle(e);
    }
    TraceGlobalMoveResolutionPhase.resolve(target, lirGenRes, traceContext);
    deconstructSSAForm(lir);
}
Also used : Indent(org.graalvm.compiler.debug.Indent) DebugContext(org.graalvm.compiler.debug.DebugContext) TraceAllocationContext(org.graalvm.compiler.lir.alloc.trace.TraceAllocationPhase.TraceAllocationContext) AllocatableValue(jdk.vm.ci.meta.AllocatableValue) Trace(org.graalvm.compiler.core.common.alloc.Trace) LIR(org.graalvm.compiler.lir.LIR) RegisterAllocationConfig(org.graalvm.compiler.core.common.alloc.RegisterAllocationConfig) TraceBuilderResult(org.graalvm.compiler.core.common.alloc.TraceBuilderResult) MoveFactory(org.graalvm.compiler.lir.gen.LIRGeneratorTool.MoveFactory)

Example 4 with LIR

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

the class BottomUpAllocator method resolveFindInsertPos.

private void resolveFindInsertPos(AbstractBlockBase<?> fromBlock, AbstractBlockBase<?> toBlock) {
    LIR lir = lirGenRes.getLIR();
    if (fromBlock.getSuccessorCount() <= 1) {
        if (debug.isLogEnabled()) {
            debug.log("inserting moves at end of fromBlock B%d", fromBlock.getId());
        }
        ArrayList<LIRInstruction> instructions = lir.getLIRforBlock(fromBlock);
        LIRInstruction instr = instructions.get(instructions.size() - 1);
        if (instr instanceof StandardOp.JumpOp) {
            // insert moves before branch
            moveResolver.setInsertPosition(instructions, instructions.size() - 1);
        } else {
            moveResolver.setInsertPosition(instructions, instructions.size());
        }
    } else {
        if (debug.isLogEnabled()) {
            debug.log("inserting moves at beginning of toBlock B%d", toBlock.getId());
        }
        if (Assertions.detailedAssertionsEnabled(getLIR().getOptions())) {
            assert lir.getLIRforBlock(fromBlock).get(0) instanceof StandardOp.LabelOp : "block does not start with a label";
            /*
                 * Because the number of predecessor edges matches the number of successor edges,
                 * blocks which are reached by switch statements may have be more than one
                 * predecessor but it will be guaranteed that all predecessors will be the same.
                 */
            for (AbstractBlockBase<?> predecessor : toBlock.getPredecessors()) {
                assert fromBlock == predecessor : "all critical edges must be broken";
            }
        }
        moveResolver.setInsertPosition(lir.getLIRforBlock(toBlock), 1);
    }
}
Also used : LabelOp(org.graalvm.compiler.lir.StandardOp.LabelOp) LIR(org.graalvm.compiler.lir.LIR) JumpOp(org.graalvm.compiler.lir.StandardOp.JumpOp) LIRInstruction(org.graalvm.compiler.lir.LIRInstruction)

Example 5 with LIR

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

the class SubstrateAMD64Backend method newCompilationResultBuilder.

@Override
public CompilationResultBuilder newCompilationResultBuilder(LIRGenerationResult lirGenResult, FrameMap frameMap, CompilationResult compilationResult, CompilationResultBuilderFactory factory) {
    Assembler masm = createAssembler(frameMap);
    SharedMethod method = ((SubstrateLIRGenerationResult) lirGenResult).getMethod();
    Deoptimizer.StubType stubType = method.getDeoptStubType();
    DataBuilder dataBuilder = new SubstrateDataBuilder();
    FrameContext frameContext;
    if (stubType == Deoptimizer.StubType.EntryStub) {
        frameContext = new DeoptEntryStubContext();
    } else if (stubType == Deoptimizer.StubType.ExitStub) {
        frameContext = new DeoptExitStubContext();
    } else {
        frameContext = new SubstrateAMD64FrameContext();
    }
    LIR lir = lirGenResult.getLIR();
    OptionValues options = lir.getOptions();
    DebugContext debug = lir.getDebug();
    CompilationResultBuilder tasm = factory.createBuilder(getCodeCache(), getForeignCalls(), lirGenResult.getFrameMap(), masm, dataBuilder, frameContext, options, debug, compilationResult);
    tasm.setTotalFrameSize(lirGenResult.getFrameMap().totalFrameSize());
    return tasm;
}
Also used : OptionValues(org.graalvm.compiler.options.OptionValues) FrameContext(org.graalvm.compiler.lir.asm.FrameContext) DebugContext(org.graalvm.compiler.debug.DebugContext) Deoptimizer(com.oracle.svm.core.deopt.Deoptimizer) CompilationResultBuilder(org.graalvm.compiler.lir.asm.CompilationResultBuilder) LIR(org.graalvm.compiler.lir.LIR) SubstrateDataBuilder(com.oracle.svm.core.graal.code.SubstrateDataBuilder) DataBuilder(org.graalvm.compiler.lir.asm.DataBuilder) SharedMethod(com.oracle.svm.core.meta.SharedMethod) AMD64MacroAssembler(org.graalvm.compiler.asm.amd64.AMD64MacroAssembler) Assembler(org.graalvm.compiler.asm.Assembler) SubstrateDataBuilder(com.oracle.svm.core.graal.code.SubstrateDataBuilder)

Aggregations

LIR (org.graalvm.compiler.lir.LIR)22 DebugContext (org.graalvm.compiler.debug.DebugContext)11 LIRInstruction (org.graalvm.compiler.lir.LIRInstruction)6 Assembler (org.graalvm.compiler.asm.Assembler)4 Trace (org.graalvm.compiler.core.common.alloc.Trace)4 HotSpotLIRGenerationResult (org.graalvm.compiler.hotspot.HotSpotLIRGenerationResult)4 Stub (org.graalvm.compiler.hotspot.stubs.Stub)4 CompilationResultBuilder (org.graalvm.compiler.lir.asm.CompilationResultBuilder)4 DataBuilder (org.graalvm.compiler.lir.asm.DataBuilder)4 OptionValues (org.graalvm.compiler.options.OptionValues)4 Register (jdk.vm.ci.code.Register)3 StackSlot (jdk.vm.ci.code.StackSlot)3 ValueUtil.asRegister (jdk.vm.ci.code.ValueUtil.asRegister)3 AllocatableValue (jdk.vm.ci.meta.AllocatableValue)3 TraceBuilderResult (org.graalvm.compiler.core.common.alloc.TraceBuilderResult)3 AbstractBlockBase (org.graalvm.compiler.core.common.cfg.AbstractBlockBase)3 HotSpotDataBuilder (org.graalvm.compiler.hotspot.HotSpotDataBuilder)3 AMD64MacroAssembler (org.graalvm.compiler.asm.amd64.AMD64MacroAssembler)2 Indent (org.graalvm.compiler.debug.Indent)2 FrameMapBuilder (org.graalvm.compiler.lir.framemap.FrameMapBuilder)2