Search in sources :

Example 1 with LLVMSourceFunctionType

use of com.oracle.truffle.llvm.runtime.debug.type.LLVMSourceFunctionType in project graal by oracle.

the class LLVMFunctionCode method initForeignConstructorCallTarget.

@TruffleBoundary
private void initForeignConstructorCallTarget() {
    synchronized (this) {
        if (foreignConstructorCallTarget != null) {
            return;
        }
        LLVMLanguage language = LLVMLanguage.get(null);
        LLVMSourceFunctionType sourceType = getFunction().getSourceType();
        LLVMInteropType interopType = language.getInteropType(sourceType);
        LLVMInteropType extractedType = ((LLVMInteropType.Function) interopType).getParameter(0);
        if (extractedType instanceof LLVMInteropType.Value) {
            LLVMInteropType.Structured structured = ((LLVMInteropType.Value) extractedType).baseType;
            LLVMForeignCallNode foreignCall = LLVMForeignConstructorCallNode.create(language, this, interopType, sourceType, structured);
            foreignConstructorCallTarget = foreignCall.getCallTarget();
        }
    }
}
Also used : LLVMForeignCallNode(com.oracle.truffle.llvm.runtime.interop.LLVMForeignCallNode) LLVMSourceFunctionType(com.oracle.truffle.llvm.runtime.debug.type.LLVMSourceFunctionType) LLVMInteropType(com.oracle.truffle.llvm.runtime.interop.access.LLVMInteropType) TruffleBoundary(com.oracle.truffle.api.CompilerDirectives.TruffleBoundary)

Example 2 with LLVMSourceFunctionType

use of com.oracle.truffle.llvm.runtime.debug.type.LLVMSourceFunctionType in project graal by oracle.

the class DITypeExtractor method visit.

@Override
public void visit(MDSubprogram mdSubprogram) {
    // 'this' parameter of thunk methods is missing in the debug info, thus fix here.
    LLVMSourceType llvmSourceType = resolve(mdSubprogram.getType());
    if (Flags.THUNK.isSetIn(mdSubprogram.getFlags())) {
        SymbolImpl symbol = MDValue.getIfInstance(mdSubprogram.getFunction());
        if (symbol != null && symbol instanceof FunctionDefinition) {
            FunctionDefinition function = (FunctionDefinition) symbol;
            final DataLayout dataLayout = LLVMLanguage.get(null).getDefaultDataLayout();
            LLVMSourceType llvmSourceReturnType = LLVMSourceTypeFactory.resolveType(function.getType().getReturnType(), dataLayout);
            List<LLVMSourceType> typeList = new ArrayList<>();
            typeList.add(llvmSourceReturnType);
            for (FunctionParameter fp : function.getParameters()) {
                LLVMSourceType parameterSourceType = LLVMSourceTypeFactory.resolveType(fp.getType(), dataLayout);
                typeList.add(parameterSourceType);
            }
            llvmSourceType = new LLVMSourceFunctionType(typeList);
        }
    }
    parsedTypes.put(mdSubprogram, llvmSourceType);
}
Also used : DataLayout(com.oracle.truffle.llvm.runtime.datalayout.DataLayout) SymbolImpl(com.oracle.truffle.llvm.parser.model.SymbolImpl) ArrayList(java.util.ArrayList) FunctionDefinition(com.oracle.truffle.llvm.parser.model.functions.FunctionDefinition) LLVMSourceType(com.oracle.truffle.llvm.runtime.debug.type.LLVMSourceType) LLVMSourceFunctionType(com.oracle.truffle.llvm.runtime.debug.type.LLVMSourceFunctionType) FunctionParameter(com.oracle.truffle.llvm.parser.model.functions.FunctionParameter)

Example 3 with LLVMSourceFunctionType

use of com.oracle.truffle.llvm.runtime.debug.type.LLVMSourceFunctionType in project graal by oracle.

the class DebugInfoFunctionProcessor method initSourceFunction.

private void initSourceFunction(FunctionDefinition function, Source bitcodeSource) {
    final MDBaseNode debugInfo = getDebugInfo(function);
    LLVMSourceLocation scope = null;
    LLVMSourceFunctionType type = null;
    if (debugInfo != null) {
        scope = cache.buildLocation(debugInfo);
        LLVMSourceType actualType = cache.parseType(debugInfo);
        if (actualType instanceof LLVMSourceFunctionType) {
            type = (LLVMSourceFunctionType) actualType;
        }
    }
    if (scope == null) {
        final String sourceText = String.format("%s:%s", bitcodeSource.getName(), function.getName());
        final Source irSource = Source.newBuilder("llvm", sourceText, sourceText).mimeType(DIScopeBuilder.getMimeType(null)).build();
        final SourceSection simpleSection = irSource.createSection(1);
        scope = LLVMSourceLocation.createBitcodeFunction(function.getName(), simpleSection);
    }
    final SourceFunction sourceFunction = new SourceFunction(scope, type);
    function.setSourceFunction(sourceFunction);
}
Also used : MDBaseNode(com.oracle.truffle.llvm.parser.metadata.MDBaseNode) LLVMSourceLocation(com.oracle.truffle.llvm.runtime.debug.scope.LLVMSourceLocation) LLVMSourceType(com.oracle.truffle.llvm.runtime.debug.type.LLVMSourceType) SourceSection(com.oracle.truffle.api.source.SourceSection) LLVMSourceFunctionType(com.oracle.truffle.llvm.runtime.debug.type.LLVMSourceFunctionType) Source(com.oracle.truffle.api.source.Source)

Example 4 with LLVMSourceFunctionType

use of com.oracle.truffle.llvm.runtime.debug.type.LLVMSourceFunctionType in project graal by oracle.

the class LLVMFunctionCode method initForeignCallTarget.

@TruffleBoundary
private void initForeignCallTarget() {
    synchronized (this) {
        if (foreignFunctionCallTarget != null) {
            return;
        }
        LLVMLanguage language = LLVMLanguage.get(null);
        LLVMSourceFunctionType sourceType = getFunction().getSourceType();
        LLVMInteropType interopType = language.getInteropType(sourceType);
        RootNode foreignCall;
        if (isIntrinsicFunctionSlowPath()) {
            FunctionType type = getLLVMFunction().getType();
            foreignCall = LLVMForeignIntrinsicCallNode.create(language, getIntrinsicSlowPath(), type, (LLVMInteropType.Function) interopType);
        } else {
            foreignCall = LLVMForeignFunctionCallNode.create(language, this, interopType, sourceType);
        }
        foreignFunctionCallTarget = foreignCall.getCallTarget();
    }
}
Also used : RootNode(com.oracle.truffle.api.nodes.RootNode) LLVMSourceFunctionType(com.oracle.truffle.llvm.runtime.debug.type.LLVMSourceFunctionType) FunctionType(com.oracle.truffle.llvm.runtime.types.FunctionType) LLVMSourceFunctionType(com.oracle.truffle.llvm.runtime.debug.type.LLVMSourceFunctionType) LLVMInteropType(com.oracle.truffle.llvm.runtime.interop.access.LLVMInteropType) TruffleBoundary(com.oracle.truffle.api.CompilerDirectives.TruffleBoundary)

Example 5 with LLVMSourceFunctionType

use of com.oracle.truffle.llvm.runtime.debug.type.LLVMSourceFunctionType in project graal by oracle.

the class DITypeExtractor method visit.

@Override
public void visit(MDSubroutine mdSubroutine) {
    final List<LLVMSourceType> members = new ArrayList<>();
    final LLVMSourceFunctionType type = new LLVMSourceFunctionType(members);
    parsedTypes.put(mdSubroutine, type);
    getElements(mdSubroutine.getTypes(), members, true);
}
Also used : ArrayList(java.util.ArrayList) LLVMSourceType(com.oracle.truffle.llvm.runtime.debug.type.LLVMSourceType) LLVMSourceFunctionType(com.oracle.truffle.llvm.runtime.debug.type.LLVMSourceFunctionType)

Aggregations

LLVMSourceFunctionType (com.oracle.truffle.llvm.runtime.debug.type.LLVMSourceFunctionType)6 LLVMSourceType (com.oracle.truffle.llvm.runtime.debug.type.LLVMSourceType)4 ArrayList (java.util.ArrayList)3 TruffleBoundary (com.oracle.truffle.api.CompilerDirectives.TruffleBoundary)2 MDBaseNode (com.oracle.truffle.llvm.parser.metadata.MDBaseNode)2 LLVMSourceLocation (com.oracle.truffle.llvm.runtime.debug.scope.LLVMSourceLocation)2 LLVMInteropType (com.oracle.truffle.llvm.runtime.interop.access.LLVMInteropType)2 RootNode (com.oracle.truffle.api.nodes.RootNode)1 Source (com.oracle.truffle.api.source.Source)1 SourceSection (com.oracle.truffle.api.source.SourceSection)1 MDNode (com.oracle.truffle.llvm.parser.metadata.MDNode)1 MDString (com.oracle.truffle.llvm.parser.metadata.MDString)1 MDSubprogram (com.oracle.truffle.llvm.parser.metadata.MDSubprogram)1 MetadataValueList (com.oracle.truffle.llvm.parser.metadata.MetadataValueList)1 SymbolImpl (com.oracle.truffle.llvm.parser.model.SymbolImpl)1 FunctionDefinition (com.oracle.truffle.llvm.parser.model.functions.FunctionDefinition)1 FunctionParameter (com.oracle.truffle.llvm.parser.model.functions.FunctionParameter)1 DataLayout (com.oracle.truffle.llvm.runtime.datalayout.DataLayout)1 LLVMSourceArrayLikeType (com.oracle.truffle.llvm.runtime.debug.type.LLVMSourceArrayLikeType)1 LLVMSourceClassLikeType (com.oracle.truffle.llvm.runtime.debug.type.LLVMSourceClassLikeType)1