Search in sources :

Example 1 with LLVMLivenessAnalysisResult

use of com.oracle.truffle.llvm.parser.LLVMLivenessAnalysis.LLVMLivenessAnalysisResult in project sulong by graalvm.

the class LazyToTruffleConverterImpl method convert.

@Override
public RootCallTarget convert() {
    CompilerAsserts.neverPartOfCompilation();
    // parse the function block
    parser.parse(diProcessor, source);
    // prepare the phis
    final Map<InstructionBlock, List<Phi>> phis = LLVMPhiManager.getPhis(method);
    // setup the frameDescriptor
    final FrameDescriptor frame = StackManager.createFrame(method);
    LLVMLivenessAnalysisResult liveness = LLVMLivenessAnalysis.computeLiveness(frame, context, phis, method);
    LLVMSymbolReadResolver symbols = new LLVMSymbolReadResolver(runtime, frame);
    List<FrameSlot> notNullable = new ArrayList<>();
    LLVMRuntimeDebugInformation dbgInfoHandler = new LLVMRuntimeDebugInformation(frame, nodeFactory, context, notNullable, symbols, runtime);
    dbgInfoHandler.registerStaticDebugSymbols(method);
    LLVMBitcodeFunctionVisitor visitor = new LLVMBitcodeFunctionVisitor(runtime, frame, phis, nodeFactory, method.getParameters().size(), symbols, method, liveness, notNullable, dbgInfoHandler);
    method.accept(visitor);
    FrameSlot[][] nullableBeforeBlock = getNullableFrameSlots(frame, liveness.getNullableBeforeBlock(), notNullable);
    FrameSlot[][] nullableAfterBlock = getNullableFrameSlots(frame, liveness.getNullableAfterBlock(), notNullable);
    LLVMSourceLocation location = method.getLexicalScope();
    List<LLVMExpressionNode> copyArgumentsToFrame = copyArgumentsToFrame(frame);
    LLVMExpressionNode[] copyArgumentsToFrameArray = copyArgumentsToFrame.toArray(new LLVMExpressionNode[copyArgumentsToFrame.size()]);
    LLVMExpressionNode body = nodeFactory.createFunctionBlockNode(runtime, frame.findFrameSlot(LLVMException.FRAME_SLOT_ID), visitor.getBlocks(), nullableBeforeBlock, nullableAfterBlock, location, copyArgumentsToFrameArray);
    RootNode rootNode = nodeFactory.createFunctionStartNode(runtime, body, method.getSourceSection(), frame, method, source, location);
    return Truffle.getRuntime().createCallTarget(rootNode);
}
Also used : FrameDescriptor(com.oracle.truffle.api.frame.FrameDescriptor) RootNode(com.oracle.truffle.api.nodes.RootNode) LLVMLivenessAnalysisResult(com.oracle.truffle.llvm.parser.LLVMLivenessAnalysis.LLVMLivenessAnalysisResult) FrameSlot(com.oracle.truffle.api.frame.FrameSlot) LLVMSymbolReadResolver(com.oracle.truffle.llvm.parser.nodes.LLVMSymbolReadResolver) ArrayList(java.util.ArrayList) LLVMSourceLocation(com.oracle.truffle.llvm.runtime.debug.scope.LLVMSourceLocation) LLVMExpressionNode(com.oracle.truffle.llvm.runtime.nodes.api.LLVMExpressionNode) ArrayList(java.util.ArrayList) List(java.util.List) InstructionBlock(com.oracle.truffle.llvm.parser.model.blocks.InstructionBlock)

Aggregations

FrameDescriptor (com.oracle.truffle.api.frame.FrameDescriptor)1 FrameSlot (com.oracle.truffle.api.frame.FrameSlot)1 RootNode (com.oracle.truffle.api.nodes.RootNode)1 LLVMLivenessAnalysisResult (com.oracle.truffle.llvm.parser.LLVMLivenessAnalysis.LLVMLivenessAnalysisResult)1 InstructionBlock (com.oracle.truffle.llvm.parser.model.blocks.InstructionBlock)1 LLVMSymbolReadResolver (com.oracle.truffle.llvm.parser.nodes.LLVMSymbolReadResolver)1 LLVMSourceLocation (com.oracle.truffle.llvm.runtime.debug.scope.LLVMSourceLocation)1 LLVMExpressionNode (com.oracle.truffle.llvm.runtime.nodes.api.LLVMExpressionNode)1 ArrayList (java.util.ArrayList)1 List (java.util.List)1