Search in sources :

Example 31 with Type

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

the class Module method createFunction.

private void createFunction(long[] args) {
    final int recordOffset = useStrTab() ? STRTAB_RECORD_OFFSET : 0;
    Type type = types.get(args[FUNCTION_TYPE + recordOffset]);
    if (type instanceof PointerType) {
        type = ((PointerType) type).getPointeeType();
    }
    final FunctionType functionType = (FunctionType) type;
    final boolean isPrototype = args[FUNCTION_ISPROTOTYPE + recordOffset] != 0;
    final Linkage linkage = Linkage.decode(args[FUNCTION_LINKAGE + recordOffset]);
    final AttributesCodeEntry paramAttr = paramAttributes.getCodeEntry(args[FUNCTION_PARAMATTR + recordOffset]);
    if (isPrototype) {
        final FunctionDeclaration function = new FunctionDeclaration(functionType, linkage, paramAttr);
        module.addFunctionDeclaration(function);
        scope.addSymbol(function, function.getType());
        if (useStrTab()) {
            readNameFromStrTab(args, function);
        }
    } else {
        final FunctionDefinition function = new FunctionDefinition(functionType, linkage, paramAttr);
        module.addFunctionDefinition(function);
        scope.addSymbol(function, function.getType());
        if (useStrTab()) {
            readNameFromStrTab(args, function);
        }
        functionQueue.addLast(function);
    }
}
Also used : FunctionDeclaration(com.oracle.truffle.llvm.parser.model.functions.FunctionDeclaration) PointerType(com.oracle.truffle.llvm.runtime.types.PointerType) Type(com.oracle.truffle.llvm.runtime.types.Type) FunctionType(com.oracle.truffle.llvm.runtime.types.FunctionType) Linkage(com.oracle.truffle.llvm.parser.model.enums.Linkage) AttributesCodeEntry(com.oracle.truffle.llvm.parser.model.attributes.AttributesCodeEntry) FunctionType(com.oracle.truffle.llvm.runtime.types.FunctionType) PointerType(com.oracle.truffle.llvm.runtime.types.PointerType) FunctionDefinition(com.oracle.truffle.llvm.parser.model.functions.FunctionDefinition)

Example 32 with Type

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

the class StackManager method createFrame.

public static FrameDescriptor createFrame(FunctionDefinition function) {
    final FrameDescriptor frame = new FrameDescriptor();
    frame.addFrameSlot(LLVMException.FRAME_SLOT_ID, null, FrameSlotKind.Object);
    frame.addFrameSlot(LLVMStack.FRAME_ID, PointerType.VOID, FrameSlotKind.Object);
    for (FunctionParameter parameter : function.getParameters()) {
        Type type = parameter.getType();
        if (parameter.isSourceVariable()) {
            type = type.shallowCopy();
        }
        frame.addFrameSlot(parameter.getName(), type, Type.getFrameSlotKind(type));
    }
    final StackAllocationFunctionVisitor functionVisitor = new StackAllocationFunctionVisitor(frame);
    function.accept((FunctionVisitor) functionVisitor);
    return frame;
}
Also used : FrameDescriptor(com.oracle.truffle.api.frame.FrameDescriptor) Type(com.oracle.truffle.llvm.runtime.types.Type) PointerType(com.oracle.truffle.llvm.runtime.types.PointerType) FunctionParameter(com.oracle.truffle.llvm.parser.model.functions.FunctionParameter)

Example 33 with Type

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

the class LLVMSetInteropTypeNode method executeGeneric.

@Override
public Object executeGeneric(VirtualFrame frame) {
    final Type type = (Type) frameSlot.getInfo();
    type.setInteropType(interopType);
    return null;
}
Also used : Type(com.oracle.truffle.llvm.runtime.types.Type) LLVMInteropType(com.oracle.truffle.llvm.runtime.interop.access.LLVMInteropType)

Example 34 with Type

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

the class BasicNodeFactory method createVectorLiteralNode.

@Override
public LLVMExpressionNode createVectorLiteralNode(LLVMParserRuntime runtime, List<LLVMExpressionNode> listValues, Type type) {
    LLVMExpressionNode[] vals = listValues.toArray(new LLVMExpressionNode[listValues.size()]);
    Type llvmType = ((VectorType) type).getElementType();
    if (llvmType instanceof PrimitiveType) {
        switch(((PrimitiveType) llvmType).getPrimitiveKind()) {
            case I1:
                return LLVMVectorI1LiteralNodeGen.create(vals);
            case I8:
                return LLVMVectorI8LiteralNodeGen.create(vals);
            case I16:
                return LLVMVectorI16LiteralNodeGen.create(vals);
            case I32:
                return LLVMVectorI32LiteralNodeGen.create(vals);
            case I64:
                return LLVMVectorI64LiteralNodeGen.create(vals);
            case FLOAT:
                return LLVMVectorFloatLiteralNodeGen.create(vals);
            case DOUBLE:
                return LLVMVectorDoubleLiteralNodeGen.create(vals);
            default:
                throw new AssertionError();
        }
    } else if (llvmType instanceof PointerType) {
        if (((PointerType) llvmType).getPointeeType() instanceof FunctionType) {
            return LLVMVectorFunctionLiteralNodeGen.create(vals);
        } else {
            return LLVMVectorAddressLiteralNodeGen.create(vals);
        }
    } else {
        throw new AssertionError(llvmType + " not yet supported");
    }
}
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) VectorType(com.oracle.truffle.llvm.runtime.types.VectorType) FunctionType(com.oracle.truffle.llvm.runtime.types.FunctionType) LLVMExpressionNode(com.oracle.truffle.llvm.runtime.nodes.api.LLVMExpressionNode) PrimitiveType(com.oracle.truffle.llvm.runtime.types.PrimitiveType) LLVMSourcePointerType(com.oracle.truffle.llvm.runtime.debug.LLVMSourcePointerType) PointerType(com.oracle.truffle.llvm.runtime.types.PointerType)

Example 35 with Type

use of com.oracle.truffle.llvm.runtime.types.Type 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)

Aggregations

Type (com.oracle.truffle.llvm.runtime.types.Type)76 PointerType (com.oracle.truffle.llvm.runtime.types.PointerType)68 PrimitiveType (com.oracle.truffle.llvm.runtime.types.PrimitiveType)64 StructureType (com.oracle.truffle.llvm.runtime.types.StructureType)63 FunctionType (com.oracle.truffle.llvm.runtime.types.FunctionType)57 ArrayType (com.oracle.truffle.llvm.runtime.types.ArrayType)54 AggregateType (com.oracle.truffle.llvm.runtime.types.AggregateType)50 VoidType (com.oracle.truffle.llvm.runtime.types.VoidType)43 LLVMExpressionNode (com.oracle.truffle.llvm.runtime.nodes.api.LLVMExpressionNode)33 VectorType (com.oracle.truffle.llvm.runtime.types.VectorType)32 LLVMArithmeticInstructionType (com.oracle.truffle.llvm.parser.instructions.LLVMArithmeticInstructionType)28 LLVMConversionType (com.oracle.truffle.llvm.parser.instructions.LLVMConversionType)28 MetaType (com.oracle.truffle.llvm.runtime.types.MetaType)13 SymbolImpl (com.oracle.truffle.llvm.parser.model.SymbolImpl)9 LLVMInteropType (com.oracle.truffle.llvm.runtime.interop.access.LLVMInteropType)8 VariableBitWidthType (com.oracle.truffle.llvm.runtime.types.VariableBitWidthType)8 LLVMSourcePointerType (com.oracle.truffle.llvm.runtime.debug.LLVMSourcePointerType)6 LLVMSourceType (com.oracle.truffle.llvm.runtime.debug.LLVMSourceType)6 FrameSlot (com.oracle.truffle.api.frame.FrameSlot)5 LLVMUnsupportedInlineAssemblerNode (com.oracle.truffle.llvm.nodes.others.LLVMUnsupportedInlineAssemblerNode)5