Search in sources :

Example 56 with Type

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

the class Module method createGlobalAliasOld.

private void createGlobalAliasOld(long[] args) {
    final int recordOffset = useStrTab() ? STRTAB_RECORD_OFFSET : 0;
    final Type type = types.get(args[GLOBALALIAS_TYPE + recordOffset]);
    int value = (int) args[GLOBALALIAS_OLD_VALUE + recordOffset];
    long linkage = args[GLOBALALIAS_OLD_LINKAGE + recordOffset];
    final GlobalAlias global = GlobalAlias.create(type, linkage, Visibility.DEFAULT.ordinal(), scope.getSymbols(), value);
    if (useStrTab()) {
        readNameFromStrTab(args, global);
    }
    module.addGlobalSymbol(global);
    scope.addSymbol(global, global.getType());
}
Also used : PointerType(com.oracle.truffle.llvm.runtime.types.PointerType) Type(com.oracle.truffle.llvm.runtime.types.Type) FunctionType(com.oracle.truffle.llvm.runtime.types.FunctionType) GlobalAlias(com.oracle.truffle.llvm.parser.model.symbols.globals.GlobalAlias)

Example 57 with Type

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

the class ParseUtil method resolveReference.

static MDBaseNode resolveReference(long[] args, int index, MDBaseNode dependent, Metadata md) {
    final int typeIndex = index << 1;
    if (typeIndex >= args.length) {
        return MDVoidNode.INSTANCE;
    }
    final int valueIndex = typeIndex + 1;
    final Type type = md.getTypeById(args[typeIndex]);
    final long value = args[valueIndex];
    if (type == MetaType.METADATA) {
        return md.getScope().getMetadata().getNonNullable(value, dependent);
    } else if (type != VoidType.INSTANCE) {
        return MDValue.create(value, md.getScope());
    } else {
        return MDVoidNode.INSTANCE;
    }
}
Also used : Type(com.oracle.truffle.llvm.runtime.types.Type) VoidType(com.oracle.truffle.llvm.runtime.types.VoidType) MetaType(com.oracle.truffle.llvm.runtime.types.MetaType)

Example 58 with Type

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

the class ParseUtil method isInteger.

public static boolean isInteger(long[] args, int index, Metadata md) {
    final int typeIndex = index << 1;
    final Type type = md.getTypeById(args[typeIndex]);
    if (type == MetaType.METADATA || VoidType.INSTANCE.equals(type)) {
        return false;
    }
    final int valueIndex = typeIndex + 1;
    final SymbolImpl value = md.getScope().getSymbols().getOrNull((int) args[valueIndex]);
    return value instanceof IntegerConstant || value instanceof BigIntegerConstant || value instanceof NullConstant || value instanceof UndefinedConstant;
}
Also used : SymbolImpl(com.oracle.truffle.llvm.parser.model.SymbolImpl) Type(com.oracle.truffle.llvm.runtime.types.Type) VoidType(com.oracle.truffle.llvm.runtime.types.VoidType) MetaType(com.oracle.truffle.llvm.runtime.types.MetaType) UndefinedConstant(com.oracle.truffle.llvm.parser.model.symbols.constants.UndefinedConstant) BigIntegerConstant(com.oracle.truffle.llvm.parser.model.symbols.constants.integer.BigIntegerConstant) NullConstant(com.oracle.truffle.llvm.parser.model.symbols.constants.NullConstant) IntegerConstant(com.oracle.truffle.llvm.parser.model.symbols.constants.integer.IntegerConstant) BigIntegerConstant(com.oracle.truffle.llvm.parser.model.symbols.constants.integer.BigIntegerConstant)

Example 59 with Type

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

the class FunctionStart method parseArguments.

static void parseArguments(IRScope scope, SymbolImpl callTarget, Instruction inst, SymbolImpl[] target, int[] src) {
    if (src.length == 0) {
        return;
    }
    final Type[] paramTypes;
    if (callTarget instanceof FunctionDefinition) {
        paramTypes = ((FunctionDefinition) (callTarget)).getType().getArgumentTypes();
    } else if (callTarget instanceof FunctionDeclaration) {
        paramTypes = ((FunctionDeclaration) (callTarget)).getType().getArgumentTypes();
    } else {
        paramTypes = Type.EMPTY_ARRAY;
    }
    final SymbolTable symbols = scope.getSymbols();
    for (int i = Math.min(paramTypes.length, src.length) - 1; i >= 0; i--) {
        if (paramTypes[i] == MetaType.METADATA) {
            target[i] = MetadataSymbol.create(scope.getMetadata(), src[i]);
        } else {
            target[i] = symbols.getForwardReferenced(src[i], inst);
        }
    }
    // parse varargs
    for (int i = paramTypes.length; i < src.length; i++) {
        target[i] = symbols.getForwardReferenced(src[i], inst);
    }
}
Also used : FunctionDeclaration(com.oracle.truffle.llvm.parser.model.functions.FunctionDeclaration) Type(com.oracle.truffle.llvm.runtime.types.Type) MetaType(com.oracle.truffle.llvm.runtime.types.MetaType) SymbolTable(com.oracle.truffle.llvm.parser.model.SymbolTable) FunctionDefinition(com.oracle.truffle.llvm.parser.model.functions.FunctionDefinition)

Example 60 with Type

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

the class BasicNodeFactory method createStructureConstantNode.

@Override
public LLVMExpressionNode createStructureConstantNode(LLVMParserRuntime runtime, Type structType, boolean packed, Type[] types, LLVMExpressionNode[] constants) {
    int[] offsets = new int[types.length];
    LLVMStoreNode[] nodes = new LLVMStoreNode[types.length];
    int currentOffset = 0;
    LLVMExpressionNode alloc = createAlloca(runtime, structType);
    for (int i = 0; i < types.length; i++) {
        Type resolvedType = types[i];
        if (!packed) {
            currentOffset += runtime.getContext().getBytePadding(currentOffset, resolvedType);
        }
        offsets[i] = currentOffset;
        int byteSize = runtime.getContext().getByteSize(resolvedType);
        nodes[i] = createMemoryStore(runtime, resolvedType);
        currentOffset += byteSize;
    }
    return StructLiteralNodeGen.create(offsets, nodes, constants, alloc);
}
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) LLVMExpressionNode(com.oracle.truffle.llvm.runtime.nodes.api.LLVMExpressionNode) LLVMStoreNode(com.oracle.truffle.llvm.runtime.nodes.api.LLVMStoreNode)

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