Search in sources :

Example 1 with TypesRecord

use of com.oracle.truffle.llvm.parser.records.TypesRecord in project sulong by graalvm.

the class Types method record.

@Override
public void record(long id, long[] args) {
    TypesRecord record = TypesRecord.decode(id);
    Type type;
    switch(record) {
        case NUMBER_OF_ENTRIES:
            table = new Type[(int) args[0]];
            return;
        case VOID:
            type = VoidType.INSTANCE;
            break;
        case FLOAT:
            type = PrimitiveType.FLOAT;
            break;
        case DOUBLE:
            type = PrimitiveType.DOUBLE;
            break;
        case LABEL:
            type = MetaType.LABEL;
            break;
        case OPAQUE:
            if (structName != null) {
                type = new OpaqueType(LLVMIdentifier.toLocalIdentifier(structName));
                structName = null;
                module.addGlobalType(type);
            } else {
                type = new OpaqueType();
            }
            break;
        case INTEGER:
            type = Type.getIntegerType((int) args[0]);
            break;
        case POINTER:
            {
                final PointerType pointerType = new PointerType(null);
                setType((int) args[0], pointerType::setPointeeType);
                type = pointerType;
                break;
            }
        case FUNCTION_OLD:
            {
                final FunctionType functionType = new FunctionType(null, toTypes(args, 3, args.length), args[0] != 0);
                setType((int) args[2], functionType::setReturnType);
                type = functionType;
                break;
            }
        case HALF:
            type = PrimitiveType.HALF;
            break;
        case ARRAY:
            {
                final ArrayType arrayType = new ArrayType(null, (int) args[0]);
                setType((int) args[1], arrayType::setElementType);
                type = arrayType;
                break;
            }
        case VECTOR:
            {
                final VectorType vectorType = new VectorType(null, (int) args[0]);
                setType((int) args[1], vectorType::setElementType);
                type = vectorType;
                break;
            }
        case X86_FP80:
            type = PrimitiveType.X86_FP80;
            break;
        case FP128:
            type = PrimitiveType.F128;
            break;
        case PPC_FP128:
            type = PrimitiveType.PPC_FP128;
            break;
        case METADATA:
            type = MetaType.METADATA;
            break;
        case X86_MMX:
            type = MetaType.X86MMX;
            break;
        case STRUCT_NAME:
            {
                structName = Records.toString(args);
                return;
            }
        case STRUCT_ANON:
        case STRUCT_NAMED:
            {
                final boolean isPacked = args[0] != 0;
                final Type[] members = toTypes(args, 1, args.length);
                if (structName != null) {
                    type = new StructureType(LLVMIdentifier.toTypeIdentifier(structName), isPacked, members);
                    structName = null;
                    module.addGlobalType(type);
                } else {
                    type = new StructureType(isPacked, members);
                }
                break;
            }
        case FUNCTION:
            {
                final FunctionType functionType = new FunctionType(null, toTypes(args, 2, args.length), args[0] != 0);
                setType((int) args[1], functionType::setReturnType);
                type = functionType;
                break;
            }
        case TOKEN:
            type = MetaType.TOKEN;
            break;
        default:
            type = MetaType.UNKNOWN;
            break;
    }
    if (table[size] != null) {
        ((UnresolvedType) table[size]).dependent.accept(type);
    }
    table[size++] = type;
}
Also used : ArrayType(com.oracle.truffle.llvm.runtime.types.ArrayType) OpaqueType(com.oracle.truffle.llvm.runtime.types.OpaqueType) PrimitiveType(com.oracle.truffle.llvm.runtime.types.PrimitiveType) LLVMInteropType(com.oracle.truffle.llvm.runtime.interop.access.LLVMInteropType) MetaType(com.oracle.truffle.llvm.runtime.types.MetaType) VectorType(com.oracle.truffle.llvm.runtime.types.VectorType) OpaqueType(com.oracle.truffle.llvm.runtime.types.OpaqueType) PointerType(com.oracle.truffle.llvm.runtime.types.PointerType) Type(com.oracle.truffle.llvm.runtime.types.Type) StructureType(com.oracle.truffle.llvm.runtime.types.StructureType) FunctionType(com.oracle.truffle.llvm.runtime.types.FunctionType) VoidType(com.oracle.truffle.llvm.runtime.types.VoidType) ArrayType(com.oracle.truffle.llvm.runtime.types.ArrayType) VectorType(com.oracle.truffle.llvm.runtime.types.VectorType) FunctionType(com.oracle.truffle.llvm.runtime.types.FunctionType) StructureType(com.oracle.truffle.llvm.runtime.types.StructureType) TypesRecord(com.oracle.truffle.llvm.parser.records.TypesRecord) PointerType(com.oracle.truffle.llvm.runtime.types.PointerType)

Aggregations

TypesRecord (com.oracle.truffle.llvm.parser.records.TypesRecord)1 LLVMInteropType (com.oracle.truffle.llvm.runtime.interop.access.LLVMInteropType)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 OpaqueType (com.oracle.truffle.llvm.runtime.types.OpaqueType)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 VectorType (com.oracle.truffle.llvm.runtime.types.VectorType)1 VoidType (com.oracle.truffle.llvm.runtime.types.VoidType)1