Search in sources :

Example 1 with NFIContextExtension

use of com.oracle.truffle.llvm.runtime.NFIContextExtension in project sulong by graalvm.

the class LLVMDispatchNode method getSignature.

private String getSignature() {
    if (signature == null) {
        CompilerDirectives.transferToInterpreterAndInvalidate();
        try {
            LLVMContext context = getContextReference().get();
            NFIContextExtension nfiContextExtension = context.getContextExtension(NFIContextExtension.class);
            this.signature = nfiContextExtension.getNativeSignature(type, LLVMCallNode.USER_ARGUMENT_OFFSET);
        } catch (UnsupportedNativeTypeException ex) {
            throw new AssertionError(ex);
        }
    }
    return signature;
}
Also used : LLVMContext(com.oracle.truffle.llvm.runtime.LLVMContext) UnsupportedNativeTypeException(com.oracle.truffle.llvm.runtime.NFIContextExtension.UnsupportedNativeTypeException) NFIContextExtension(com.oracle.truffle.llvm.runtime.NFIContextExtension)

Example 2 with NFIContextExtension

use of com.oracle.truffle.llvm.runtime.NFIContextExtension in project sulong by graalvm.

the class LLVMNativeDispatchNode method identityFunction.

@TruffleBoundary
protected TruffleObject identityFunction() {
    LLVMContext context = getContextReference().get();
    NFIContextExtension nfiContextExtension = context.getContextExtension(NFIContextExtension.class);
    String signature;
    try {
        signature = nfiContextExtension.getNativeSignature(type, LLVMCallNode.USER_ARGUMENT_OFFSET);
    } catch (UnsupportedNativeTypeException e) {
        throw new IllegalStateException(e);
    }
    return nfiContextExtension.getNativeFunction(context, "@identity", String.format("(POINTER):%s", signature));
}
Also used : LLVMContext(com.oracle.truffle.llvm.runtime.LLVMContext) UnsupportedNativeTypeException(com.oracle.truffle.llvm.runtime.NFIContextExtension.UnsupportedNativeTypeException) NFIContextExtension(com.oracle.truffle.llvm.runtime.NFIContextExtension) TruffleBoundary(com.oracle.truffle.api.CompilerDirectives.TruffleBoundary)

Example 3 with NFIContextExtension

use of com.oracle.truffle.llvm.runtime.NFIContextExtension in project sulong by graalvm.

the class BasicNodeFactory method allocateGlobalIntern.

private static Object allocateGlobalIntern(LLVMParserRuntime runtime, final GlobalValueSymbol global, LLVMSourceSymbol sourceSymbol) {
    final Type resolvedType = ((PointerType) global.getType()).getPointeeType();
    final String name = global.getName();
    LLVMContext context = runtime.getContext();
    if (global.isExternal()) {
        NFIContextExtension nfiContextExtension = context.getContextExtension(NFIContextExtension.class);
        return LLVMGlobal.external(context, global, name, resolvedType, LLVMAddress.fromLong(nfiContextExtension.getNativeHandle(context, name)), sourceSymbol);
    } else {
        return LLVMGlobal.internal(context, global, name, resolvedType, sourceSymbol);
    }
}
Also used : LLVMSourcePointerType(com.oracle.truffle.llvm.runtime.debug.LLVMSourcePointerType) VariableBitWidthType(com.oracle.truffle.llvm.runtime.types.VariableBitWidthType) PrimitiveType(com.oracle.truffle.llvm.runtime.types.PrimitiveType) VectorType(com.oracle.truffle.llvm.runtime.types.VectorType) AggregateType(com.oracle.truffle.llvm.runtime.types.AggregateType) PointerType(com.oracle.truffle.llvm.runtime.types.PointerType) FunctionType(com.oracle.truffle.llvm.runtime.types.FunctionType) LLVMConversionType(com.oracle.truffle.llvm.parser.instructions.LLVMConversionType) MetaType(com.oracle.truffle.llvm.runtime.types.MetaType) StructureType(com.oracle.truffle.llvm.runtime.types.StructureType) ArrayType(com.oracle.truffle.llvm.runtime.types.ArrayType) VoidType(com.oracle.truffle.llvm.runtime.types.VoidType) LLVMInteropType(com.oracle.truffle.llvm.runtime.interop.access.LLVMInteropType) LLVMArithmeticInstructionType(com.oracle.truffle.llvm.parser.instructions.LLVMArithmeticInstructionType) Type(com.oracle.truffle.llvm.runtime.types.Type) LLVMSourceType(com.oracle.truffle.llvm.runtime.debug.LLVMSourceType) LLVMContext(com.oracle.truffle.llvm.runtime.LLVMContext) LLVMSourcePointerType(com.oracle.truffle.llvm.runtime.debug.LLVMSourcePointerType) PointerType(com.oracle.truffle.llvm.runtime.types.PointerType) NFIContextExtension(com.oracle.truffle.llvm.runtime.NFIContextExtension)

Example 4 with NFIContextExtension

use of com.oracle.truffle.llvm.runtime.NFIContextExtension in project sulong by graalvm.

the class LLVMAMD64PosixCallNode method createFunction.

protected TruffleObject createFunction() {
    LLVMContext context = getContextReference().get();
    NFIContextExtension nfiContextExtension = context.getContextExtension(NFIContextExtension.class);
    return nfiContextExtension.getNativeFunction(context, "@__sulong_posix_" + name, signature);
}
Also used : LLVMContext(com.oracle.truffle.llvm.runtime.LLVMContext) NFIContextExtension(com.oracle.truffle.llvm.runtime.NFIContextExtension)

Aggregations

LLVMContext (com.oracle.truffle.llvm.runtime.LLVMContext)4 NFIContextExtension (com.oracle.truffle.llvm.runtime.NFIContextExtension)4 UnsupportedNativeTypeException (com.oracle.truffle.llvm.runtime.NFIContextExtension.UnsupportedNativeTypeException)2 TruffleBoundary (com.oracle.truffle.api.CompilerDirectives.TruffleBoundary)1 LLVMArithmeticInstructionType (com.oracle.truffle.llvm.parser.instructions.LLVMArithmeticInstructionType)1 LLVMConversionType (com.oracle.truffle.llvm.parser.instructions.LLVMConversionType)1 LLVMSourcePointerType (com.oracle.truffle.llvm.runtime.debug.LLVMSourcePointerType)1 LLVMSourceType (com.oracle.truffle.llvm.runtime.debug.LLVMSourceType)1 LLVMInteropType (com.oracle.truffle.llvm.runtime.interop.access.LLVMInteropType)1 AggregateType (com.oracle.truffle.llvm.runtime.types.AggregateType)1 ArrayType (com.oracle.truffle.llvm.runtime.types.ArrayType)1 FunctionType (com.oracle.truffle.llvm.runtime.types.FunctionType)1 MetaType (com.oracle.truffle.llvm.runtime.types.MetaType)1 PointerType (com.oracle.truffle.llvm.runtime.types.PointerType)1 PrimitiveType (com.oracle.truffle.llvm.runtime.types.PrimitiveType)1 StructureType (com.oracle.truffle.llvm.runtime.types.StructureType)1 Type (com.oracle.truffle.llvm.runtime.types.Type)1 VariableBitWidthType (com.oracle.truffle.llvm.runtime.types.VariableBitWidthType)1 VectorType (com.oracle.truffle.llvm.runtime.types.VectorType)1 VoidType (com.oracle.truffle.llvm.runtime.types.VoidType)1