Search in sources :

Example 6 with LIRGeneratorTool

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

the class DimensionsNode method generate.

@Override
public void generate(NodeLIRBuilderTool gen) {
    LIRGeneratorTool lirGen = gen.getLIRGeneratorTool();
    int size = rank * 4;
    int wordSize = lirGen.target().wordSize;
    int slots = roundUp(size, wordSize) / wordSize;
    VirtualStackSlot array = lirGen.getResult().getFrameMapBuilder().allocateStackSlots(slots, new BitSet(0), null);
    Value result = lirGen.emitAddress(array);
    gen.setResult(this, result);
}
Also used : BitSet(java.util.BitSet) Value(jdk.vm.ci.meta.Value) LIRGeneratorTool(org.graalvm.compiler.lir.gen.LIRGeneratorTool) VirtualStackSlot(org.graalvm.compiler.lir.VirtualStackSlot)

Example 7 with LIRGeneratorTool

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

the class AArch64AddressNode method generate.

@Override
public void generate(NodeLIRBuilderTool gen) {
    LIRGeneratorTool tool = gen.getLIRGeneratorTool();
    AllocatableValue baseValue = base == null ? Value.ILLEGAL : tool.asAllocatable(gen.operand(base));
    AllocatableValue indexValue = index == null ? Value.ILLEGAL : tool.asAllocatable(gen.operand(index));
    AllocatableValue baseReference = LIRKind.derivedBaseFromValue(baseValue);
    AllocatableValue indexReference;
    if (index == null) {
        indexReference = null;
    } else if (addressingMode.equals(AddressingMode.IMMEDIATE_UNSCALED)) {
        indexReference = LIRKind.derivedBaseFromValue(indexValue);
    } else {
        if (LIRKind.isValue(indexValue.getValueKind())) {
            indexReference = null;
        } else {
            indexReference = Value.ILLEGAL;
        }
    }
    LIRKind kind = LIRKind.combineDerived(tool.getLIRKind(stamp(NodeView.DEFAULT)), baseReference, indexReference);
    gen.setResult(this, new AArch64AddressValue(kind, baseValue, indexValue, (int) displacement, scaleFactor, addressingMode));
}
Also used : AArch64AddressValue(org.graalvm.compiler.lir.aarch64.AArch64AddressValue) LIRKind(org.graalvm.compiler.core.common.LIRKind) LIRGeneratorTool(org.graalvm.compiler.lir.gen.LIRGeneratorTool) AllocatableValue(jdk.vm.ci.meta.AllocatableValue)

Example 8 with LIRGeneratorTool

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

the class AMD64AddressNode method generate.

@Override
public void generate(NodeLIRBuilderTool gen) {
    LIRGeneratorTool tool = gen.getLIRGeneratorTool();
    AllocatableValue baseValue = base == null ? Value.ILLEGAL : tool.asAllocatable(gen.operand(base));
    AllocatableValue indexValue = index == null ? Value.ILLEGAL : tool.asAllocatable(gen.operand(index));
    AllocatableValue baseReference = LIRKind.derivedBaseFromValue(baseValue);
    AllocatableValue indexReference;
    if (index == null) {
        indexReference = null;
    } else if (scale.equals(Scale.Times1)) {
        indexReference = LIRKind.derivedBaseFromValue(indexValue);
    } else {
        if (LIRKind.isValue(indexValue)) {
            indexReference = null;
        } else {
            indexReference = Value.ILLEGAL;
        }
    }
    LIRKind kind = LIRKind.combineDerived(tool.getLIRKind(stamp(NodeView.DEFAULT)), baseReference, indexReference);
    gen.setResult(this, new AMD64AddressValue(kind, baseValue, indexValue, scale, displacement));
}
Also used : AMD64AddressValue(org.graalvm.compiler.lir.amd64.AMD64AddressValue) LIRKind(org.graalvm.compiler.core.common.LIRKind) LIRGeneratorTool(org.graalvm.compiler.lir.gen.LIRGeneratorTool) AllocatableValue(jdk.vm.ci.meta.AllocatableValue)

Example 9 with LIRGeneratorTool

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

the class ConstantLoadOptimization method run.

@Override
protected void run(TargetDescription target, LIRGenerationResult lirGenRes, PreAllocationOptimizationContext context) {
    LIRGeneratorTool lirGen = context.lirGen;
    new Optimization(lirGenRes.getLIR(), lirGen).apply();
}
Also used : LIRGeneratorTool(org.graalvm.compiler.lir.gen.LIRGeneratorTool) LIROptimization(org.graalvm.compiler.lir.phases.LIRPhase.Options.LIROptimization)

Example 10 with LIRGeneratorTool

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

Aggregations

LIRGeneratorTool (org.graalvm.compiler.lir.gen.LIRGeneratorTool)18 Value (jdk.vm.ci.meta.Value)5 LIRKind (org.graalvm.compiler.core.common.LIRKind)5 SubstrateRegisterConfig (com.oracle.svm.core.graal.meta.SubstrateRegisterConfig)4 RegisterValue (jdk.vm.ci.code.RegisterValue)4 AllocatableValue (jdk.vm.ci.meta.AllocatableValue)3 SubstrateLIRGenerator (com.oracle.svm.core.graal.code.SubstrateLIRGenerator)1 BitSet (java.util.BitSet)1 LIRGenerationContext (org.graalvm.compiler.core.LIRGenerationPhase.LIRGenerationContext)1 AbstractBlockBase (org.graalvm.compiler.core.common.cfg.AbstractBlockBase)1 AbstractObjectStamp (org.graalvm.compiler.core.common.type.AbstractObjectStamp)1 DebugCloseable (org.graalvm.compiler.debug.DebugCloseable)1 DebugContext (org.graalvm.compiler.debug.DebugContext)1 LIR (org.graalvm.compiler.lir.LIR)1 LIRInstruction (org.graalvm.compiler.lir.LIRInstruction)1 VirtualStackSlot (org.graalvm.compiler.lir.VirtualStackSlot)1 AArch64AddressValue (org.graalvm.compiler.lir.aarch64.AArch64AddressValue)1 AMD64AddressValue (org.graalvm.compiler.lir.amd64.AMD64AddressValue)1 FrameMapBuilder (org.graalvm.compiler.lir.framemap.FrameMapBuilder)1 LIRGenerationResult (org.graalvm.compiler.lir.gen.LIRGenerationResult)1