Search in sources :

Example 6 with LIR

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

the class LIRGenerationPhase method emitBlock.

private static void emitBlock(NodeLIRBuilderTool nodeLirGen, LIRGenerationResult lirGenRes, Block b, StructuredGraph graph, BlockMap<List<Node>> blockMap) {
    assert !isProcessed(lirGenRes, b) : "Block already processed " + b;
    assert verifyPredecessors(lirGenRes, b);
    nodeLirGen.doBlock(b, graph, blockMap);
    LIR lir = lirGenRes.getLIR();
    DebugContext debug = lir.getDebug();
    instructionCounter.add(debug, lir.getLIRforBlock(b).size());
}
Also used : LIR(org.graalvm.compiler.lir.LIR) DebugContext(org.graalvm.compiler.debug.DebugContext)

Example 7 with LIR

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

the class GraalCompiler method emitLIR0.

@SuppressWarnings("try")
private static LIRGenerationResult emitLIR0(Backend backend, StructuredGraph graph, Object stub, RegisterConfig registerConfig, LIRSuites lirSuites, String[] allocationRestrictedTo) {
    DebugContext debug = graph.getDebug();
    try (DebugContext.Scope ds = debug.scope("EmitLIR");
        DebugCloseable a = EmitLIR.start(debug)) {
        assert !graph.hasValueProxies();
        ScheduleResult schedule = graph.getLastSchedule();
        Block[] blocks = schedule.getCFG().getBlocks();
        Block startBlock = schedule.getCFG().getStartBlock();
        assert startBlock != null;
        assert startBlock.getPredecessorCount() == 0;
        AbstractBlockBase<?>[] codeEmittingOrder = ComputeBlockOrder.computeCodeEmittingOrder(blocks.length, startBlock);
        AbstractBlockBase<?>[] linearScanOrder = ComputeBlockOrder.computeLinearScanOrder(blocks.length, startBlock);
        LIR lir = new LIR(schedule.getCFG(), linearScanOrder, codeEmittingOrder, graph.getOptions(), graph.getDebug());
        FrameMapBuilder frameMapBuilder = backend.newFrameMapBuilder(registerConfig);
        LIRGenerationResult lirGenRes = backend.newLIRGenerationResult(graph.compilationId(), lir, frameMapBuilder, graph, stub);
        LIRGeneratorTool lirGen = backend.newLIRGenerator(lirGenRes);
        NodeLIRBuilderTool nodeLirGen = backend.newNodeLIRBuilder(graph, lirGen);
        // LIR generation
        LIRGenerationContext context = new LIRGenerationContext(lirGen, nodeLirGen, graph, schedule);
        new LIRGenerationPhase().apply(backend.getTarget(), lirGenRes, context);
        try (DebugContext.Scope s = debug.scope("LIRStages", nodeLirGen, lirGenRes, lir)) {
            // Dump LIR along with HIR (the LIR is looked up from context)
            debug.dump(DebugContext.BASIC_LEVEL, graph.getLastSchedule(), "After LIR generation");
            LIRGenerationResult result = emitLowLevel(backend.getTarget(), lirGenRes, lirGen, lirSuites, backend.newRegisterAllocationConfig(registerConfig, allocationRestrictedTo));
            return result;
        } catch (Throwable e) {
            throw debug.handle(e);
        }
    } catch (Throwable e) {
        throw debug.handle(e);
    } finally {
        graph.checkCancellation();
    }
}
Also used : ScheduleResult(org.graalvm.compiler.nodes.StructuredGraph.ScheduleResult) FrameMapBuilder(org.graalvm.compiler.lir.framemap.FrameMapBuilder) DebugContext(org.graalvm.compiler.debug.DebugContext) AbstractBlockBase(org.graalvm.compiler.core.common.cfg.AbstractBlockBase) NodeLIRBuilderTool(org.graalvm.compiler.nodes.spi.NodeLIRBuilderTool) LIRGenerationResult(org.graalvm.compiler.lir.gen.LIRGenerationResult) LIRGenerationContext(org.graalvm.compiler.core.LIRGenerationPhase.LIRGenerationContext) LIR(org.graalvm.compiler.lir.LIR) Block(org.graalvm.compiler.nodes.cfg.Block) DebugCloseable(org.graalvm.compiler.debug.DebugCloseable) LIRGeneratorTool(org.graalvm.compiler.lir.gen.LIRGeneratorTool)

Example 8 with LIR

use of org.graalvm.compiler.lir.LIR 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 9 with LIR

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

the class SPARCHotSpotBackend method newCompilationResultBuilder.

@Override
public CompilationResultBuilder newCompilationResultBuilder(LIRGenerationResult lirGenRes, FrameMap frameMap, CompilationResult compilationResult, CompilationResultBuilderFactory factory) {
    HotSpotLIRGenerationResult gen = (HotSpotLIRGenerationResult) lirGenRes;
    LIR lir = gen.getLIR();
    assert gen.getDeoptimizationRescueSlot() == null || frameMap.frameNeedsAllocating() : "method that can deoptimize must have a frame";
    Stub stub = gen.getStub();
    Assembler masm = createAssembler(frameMap);
    // On SPARC we always use stack frames.
    HotSpotFrameContext frameContext = new HotSpotFrameContext(stub != null);
    DataBuilder dataBuilder = new HotSpotDataBuilder(getCodeCache().getTarget());
    OptionValues options = lir.getOptions();
    DebugContext debug = lir.getDebug();
    CompilationResultBuilder crb = factory.createBuilder(getProviders().getCodeCache(), getProviders().getForeignCalls(), frameMap, masm, dataBuilder, frameContext, options, debug, compilationResult);
    crb.setTotalFrameSize(frameMap.totalFrameSize());
    crb.setMaxInterpreterFrameSize(gen.getMaxInterpreterFrameSize());
    StackSlot deoptimizationRescueSlot = gen.getDeoptimizationRescueSlot();
    if (deoptimizationRescueSlot != null && stub == null) {
        crb.compilationResult.setCustomStackAreaOffset(deoptimizationRescueSlot);
    }
    if (stub != null) {
        // Even on sparc we need to save floating point registers
        EconomicSet<Register> destroyedCallerRegisters = gatherDestroyedCallerRegisters(lir);
        EconomicMap<LIRFrameState, SaveRegistersOp> calleeSaveInfo = gen.getCalleeSaveInfo();
        updateStub(stub, destroyedCallerRegisters, calleeSaveInfo, frameMap);
    }
    assert registerSizePredictionValidator(crb, debug);
    return crb;
}
Also used : LIRFrameState(org.graalvm.compiler.lir.LIRFrameState) OptionValues(org.graalvm.compiler.options.OptionValues) HotSpotLIRGenerationResult(org.graalvm.compiler.hotspot.HotSpotLIRGenerationResult) HotSpotDataBuilder(org.graalvm.compiler.hotspot.HotSpotDataBuilder) Stub(org.graalvm.compiler.hotspot.stubs.Stub) StackSlot(jdk.vm.ci.code.StackSlot) DebugContext(org.graalvm.compiler.debug.DebugContext) CompilationResultBuilder(org.graalvm.compiler.lir.asm.CompilationResultBuilder) LIR(org.graalvm.compiler.lir.LIR) HotSpotDataBuilder(org.graalvm.compiler.hotspot.HotSpotDataBuilder) DataBuilder(org.graalvm.compiler.lir.asm.DataBuilder) Register(jdk.vm.ci.code.Register) ValueUtil.isRegister(jdk.vm.ci.code.ValueUtil.isRegister) ValueUtil.asRegister(jdk.vm.ci.code.ValueUtil.asRegister) ScratchRegister(org.graalvm.compiler.asm.sparc.SPARCMacroAssembler.ScratchRegister) SPARCAssembler.isGlobalRegister(org.graalvm.compiler.asm.sparc.SPARCAssembler.isGlobalRegister) SPARCAssembler(org.graalvm.compiler.asm.sparc.SPARCAssembler) SPARCMacroAssembler(org.graalvm.compiler.asm.sparc.SPARCMacroAssembler) Assembler(org.graalvm.compiler.asm.Assembler) SaveRegistersOp(org.graalvm.compiler.lir.StandardOp.SaveRegistersOp)

Example 10 with LIR

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

the class GraalCompilerState method preLIRGeneration.

/**
 * Sets up {@link LIR} generation.
 */
protected final void preLIRGeneration() {
    assert request.graph.isFrozen() : "Graph not frozen.";
    Object stub = null;
    schedule = request.graph.getLastSchedule();
    ControlFlowGraph cfg = deepCopy(schedule.getCFG());
    Block[] blocks = cfg.getBlocks();
    Block startBlock = cfg.getStartBlock();
    assert startBlock != null;
    assert startBlock.getPredecessorCount() == 0;
    codeEmittingOrder = ComputeBlockOrder.computeCodeEmittingOrder(blocks.length, startBlock);
    linearScanOrder = ComputeBlockOrder.computeLinearScanOrder(blocks.length, startBlock);
    LIR lir = new LIR(cfg, linearScanOrder, codeEmittingOrder, getGraphOptions(), getGraphDebug());
    FrameMapBuilder frameMapBuilder = request.backend.newFrameMapBuilder(registerConfig);
    lirGenRes = request.backend.newLIRGenerationResult(graph.compilationId(), lir, frameMapBuilder, request.graph, stub);
    lirGenTool = request.backend.newLIRGenerator(lirGenRes);
    nodeLirGen = request.backend.newNodeLIRBuilder(request.graph, lirGenTool);
}
Also used : LIR(org.graalvm.compiler.lir.LIR) ControlFlowGraph(org.graalvm.compiler.nodes.cfg.ControlFlowGraph) FrameMapBuilder(org.graalvm.compiler.lir.framemap.FrameMapBuilder) Block(org.graalvm.compiler.nodes.cfg.Block)

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