Search in sources :

Example 21 with Type

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

the class Function method createLoad.

private void createLoad(long[] args) {
    int i = 0;
    final int src = getIndex(args[i++]);
    final Type srcType;
    if (scope.isValueForwardRef(src)) {
        srcType = types.get(args[i++]);
    } else {
        srcType = scope.getValueType(src);
    }
    final Type opType;
    if (i + LOAD_ARGS_EXPECTED_AFTER_TYPE == args.length) {
        opType = types.get(args[i++]);
    } else {
        opType = ((PointerType) srcType).getPointeeType();
    }
    final int align = getAlign(args[i++]);
    final boolean isVolatile = args[i] != 0;
    emit(LoadInstruction.fromSymbols(scope.getSymbols(), opType, src, align, isVolatile));
}
Also used : PrimitiveType(com.oracle.truffle.llvm.runtime.types.PrimitiveType) VectorType(com.oracle.truffle.llvm.runtime.types.VectorType) StructureType(com.oracle.truffle.llvm.runtime.types.StructureType) ArrayType(com.oracle.truffle.llvm.runtime.types.ArrayType) AggregateType(com.oracle.truffle.llvm.runtime.types.AggregateType) Type(com.oracle.truffle.llvm.runtime.types.Type) PointerType(com.oracle.truffle.llvm.runtime.types.PointerType) FunctionType(com.oracle.truffle.llvm.runtime.types.FunctionType) VoidType(com.oracle.truffle.llvm.runtime.types.VoidType)

Example 22 with Type

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

the class Function method createLandingpad.

private void createLandingpad(long[] args) {
    int i = 0;
    final Type type = types.get(args[i++]);
    final boolean isCleanup = args[i++] != 0;
    final int numClauses = (int) args[i++];
    // catch = 0, filter = 1
    long[] clauseKinds = new long[numClauses];
    long[] clauseTypes = new long[numClauses];
    for (int j = 0; j < numClauses; j++) {
        clauseKinds[j] = args[i++];
        clauseTypes[j] = getIndex(args[i++]);
        if (scope.isValueForwardRef(clauseTypes[j])) {
            i++;
        }
    }
    emit(LandingpadInstruction.generate(scope.getSymbols(), type, isCleanup, clauseKinds, clauseTypes));
}
Also used : PrimitiveType(com.oracle.truffle.llvm.runtime.types.PrimitiveType) VectorType(com.oracle.truffle.llvm.runtime.types.VectorType) StructureType(com.oracle.truffle.llvm.runtime.types.StructureType) ArrayType(com.oracle.truffle.llvm.runtime.types.ArrayType) AggregateType(com.oracle.truffle.llvm.runtime.types.AggregateType) Type(com.oracle.truffle.llvm.runtime.types.Type) PointerType(com.oracle.truffle.llvm.runtime.types.PointerType) FunctionType(com.oracle.truffle.llvm.runtime.types.FunctionType) VoidType(com.oracle.truffle.llvm.runtime.types.VoidType)

Example 23 with Type

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

the class Function method createInvoke.

private void createInvoke(long[] args) {
    int i = 0;
    final AttributesCodeEntry paramAttr = paramAttributes.getCodeEntry(args[i++]);
    final long ccInfo = args[i++];
    final InstructionBlock normalSuccessor = function.getBlock(args[i++]);
    final InstructionBlock unwindSuccessor = function.getBlock(args[i++]);
    FunctionType functionType = null;
    if (((ccInfo >> INVOKE_HASEXPLICITFUNCTIONTYPE_SHIFT) & 1) != 0) {
        functionType = (FunctionType) types.get(args[i++]);
    }
    final int target = getIndex(args[i++]);
    final Type calleeType;
    if (scope.isValueForwardRef(target)) {
        calleeType = types.get(args[i++]);
    } else {
        calleeType = scope.getValueType(target);
    }
    if (functionType == null) {
        if (calleeType instanceof PointerType) {
            functionType = (FunctionType) ((PointerType) calleeType).getPointeeType();
        } else if (calleeType instanceof FunctionType) {
            functionType = (FunctionType) calleeType;
        } else {
            throw new AssertionError("Cannot find Type of invoked function: " + calleeType.toString());
        }
    }
    int[] arguments = new int[args.length - i];
    int skipped = 0;
    int j = 0;
    while (j < functionType.getArgumentTypes().length && i < args.length) {
        arguments[j++] = getIndex(args[i++]);
    }
    while (i < args.length) {
        int index = getIndex(args[i++]);
        arguments[j++] = index;
        if (scope.isValueForwardRef(index)) {
            i++;
            skipped++;
        }
    }
    if (skipped > 0) {
        arguments = Arrays.copyOf(arguments, arguments.length - skipped);
    }
    final Type returnType = functionType.getReturnType();
    if (returnType == VoidType.INSTANCE) {
        emit(VoidInvokeInstruction.fromSymbols(scope, target, arguments, normalSuccessor, unwindSuccessor, paramAttr));
    } else {
        emit(InvokeInstruction.fromSymbols(scope, returnType, target, arguments, normalSuccessor, unwindSuccessor, paramAttr));
    }
    isLastBlockTerminated = true;
}
Also used : PrimitiveType(com.oracle.truffle.llvm.runtime.types.PrimitiveType) VectorType(com.oracle.truffle.llvm.runtime.types.VectorType) StructureType(com.oracle.truffle.llvm.runtime.types.StructureType) ArrayType(com.oracle.truffle.llvm.runtime.types.ArrayType) AggregateType(com.oracle.truffle.llvm.runtime.types.AggregateType) Type(com.oracle.truffle.llvm.runtime.types.Type) PointerType(com.oracle.truffle.llvm.runtime.types.PointerType) FunctionType(com.oracle.truffle.llvm.runtime.types.FunctionType) VoidType(com.oracle.truffle.llvm.runtime.types.VoidType) 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) InstructionBlock(com.oracle.truffle.llvm.parser.model.blocks.InstructionBlock)

Example 24 with Type

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

the class Function method createGetElementPointerOld.

private void createGetElementPointerOld(long[] args, boolean isInbounds) {
    int i = 0;
    int pointer = getIndex(args[i++]);
    Type base;
    if (scope.isValueForwardRef(pointer)) {
        base = types.get(args[i++]);
    } else {
        base = scope.getValueType(pointer);
    }
    List<Integer> indices = getIndices(args, i);
    Type type = new PointerType(getElementPointerType(base, indices));
    emit(GetElementPointerInstruction.fromSymbols(scope.getSymbols(), type, pointer, indices, isInbounds));
}
Also used : PrimitiveType(com.oracle.truffle.llvm.runtime.types.PrimitiveType) VectorType(com.oracle.truffle.llvm.runtime.types.VectorType) StructureType(com.oracle.truffle.llvm.runtime.types.StructureType) ArrayType(com.oracle.truffle.llvm.runtime.types.ArrayType) AggregateType(com.oracle.truffle.llvm.runtime.types.AggregateType) Type(com.oracle.truffle.llvm.runtime.types.Type) PointerType(com.oracle.truffle.llvm.runtime.types.PointerType) FunctionType(com.oracle.truffle.llvm.runtime.types.FunctionType) VoidType(com.oracle.truffle.llvm.runtime.types.VoidType) PointerType(com.oracle.truffle.llvm.runtime.types.PointerType)

Example 25 with Type

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

the class Function method createShuffleVector.

private void createShuffleVector(long[] args) {
    int i = 0;
    int vector1 = getIndex(args[i++]);
    Type vectorType;
    if (scope.isValueForwardRef(vector1)) {
        vectorType = types.get(args[i++]);
    } else {
        vectorType = scope.getValueType(vector1);
    }
    int vector2 = getIndex(args[i++]);
    int mask = getIndex(args[i]);
    Type subtype = ((VectorType) vectorType).getElementType();
    int length = ((VectorType) scope.getValueType(mask)).getNumberOfElements();
    Type type = new VectorType(subtype, length);
    emit(ShuffleVectorInstruction.fromSymbols(scope.getSymbols(), type, vector1, vector2, mask));
}
Also used : PrimitiveType(com.oracle.truffle.llvm.runtime.types.PrimitiveType) VectorType(com.oracle.truffle.llvm.runtime.types.VectorType) StructureType(com.oracle.truffle.llvm.runtime.types.StructureType) ArrayType(com.oracle.truffle.llvm.runtime.types.ArrayType) AggregateType(com.oracle.truffle.llvm.runtime.types.AggregateType) Type(com.oracle.truffle.llvm.runtime.types.Type) PointerType(com.oracle.truffle.llvm.runtime.types.PointerType) FunctionType(com.oracle.truffle.llvm.runtime.types.FunctionType) VoidType(com.oracle.truffle.llvm.runtime.types.VoidType) VectorType(com.oracle.truffle.llvm.runtime.types.VectorType)

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