Search in sources :

Example 46 with Type

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

the class Function method createCompareExchange.

private void createCompareExchange(long[] args, FunctionRecord record) {
    int i = 0;
    final Type ptrType;
    final int ptr = getIndex(args[i]);
    if (scope.isValueForwardRef(ptr)) {
        ptrType = types.get(args[++i]);
    } else {
        ptrType = scope.getValueType(ptr);
    }
    final int cmp = getIndex(args[++i]);
    if (record == FunctionRecord.CMPXCHG && scope.isValueForwardRef(cmp)) {
        // type of cmp
        ++i;
    }
    final int replace = getIndex(args[++i]);
    final boolean isVolatile = args[++i] != 0;
    final long successOrdering = args[++i];
    final long synchronizationScope = args[++i];
    final long failureOrdering = i < args.length - 1 ? args[++i] : -1L;
    final boolean addExtractValue = i >= args.length - 1;
    final boolean isWeak = addExtractValue || (args[++i] != 0);
    final Type type = findCmpxchgResultType(((PointerType) ptrType).getPointeeType());
    emit(CompareExchangeInstruction.fromSymbols(scope.getSymbols(), type, ptr, cmp, replace, isVolatile, successOrdering, synchronizationScope, failureOrdering, isWeak));
    if (addExtractValue) {
        // in older llvm versions cmpxchg just returned the new value at the pointer, to emulate
        // this we have to add an extractelvalue instruction. llvm does the same thing
        createExtractValue(new long[] { 1, 0 });
        // register the implicit index
        implicitIndices.add(scope.getNextValueIndex() - 1);
    }
}
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 47 with Type

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

the class Function method createBinaryOperation.

private void createBinaryOperation(long[] args) {
    int i = 0;
    Type type;
    int lhs = getIndex(args[i++]);
    if (scope.isValueForwardRef(lhs)) {
        type = types.get(args[i++]);
    } else {
        type = scope.getValueType(lhs);
    }
    int rhs = getIndex(args[i++]);
    int opcode = (int) args[i++];
    int flags = i < args.length ? (int) args[i] : 0;
    emit(BinaryOperationInstruction.fromSymbols(scope.getSymbols(), type, opcode, flags, lhs, rhs));
}
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 48 with Type

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

the class Function method createLoadAtomic.

private void createLoadAtomic(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 + LOADATOMIC_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;
    final long atomicOrdering = args[i++];
    final long synchronizationScope = args[i];
    emit(LoadInstruction.fromSymbols(scope.getSymbols(), opType, src, align, isVolatile, atomicOrdering, synchronizationScope));
}
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 49 with Type

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

the class Function method createExtractElement.

private void createExtractElement(long[] args) {
    int i = 0;
    int vector = getIndex(args[i++]);
    Type vectorType;
    if (scope.isValueForwardRef(vector)) {
        vectorType = types.get(args[i++]);
    } else {
        vectorType = scope.getValueType(vector);
    }
    int index = getIndex(args[i]);
    final Type elementType = ((VectorType) vectorType).getElementType();
    emit(ExtractElementInstruction.fromSymbols(scope.getSymbols(), elementType, vector, index));
}
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)

Example 50 with Type

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

the class Function method createCompare2.

private void createCompare2(long[] args) {
    int i = 0;
    Type operandType;
    int lhs = getIndex(args[i++]);
    if (scope.isValueForwardRef(lhs)) {
        operandType = types.get(args[i++]);
    } else {
        operandType = scope.getValueType(lhs);
    }
    int rhs = getIndex(args[i++]);
    int opcode = (int) args[i];
    Type type = operandType instanceof VectorType ? new VectorType(PrimitiveType.I1, ((VectorType) operandType).getNumberOfElements()) : PrimitiveType.I1;
    emit(CompareInstruction.fromSymbols(scope.getSymbols(), type, opcode, lhs, rhs));
}
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