Search in sources :

Example 26 with LLVMTruffleObject

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

the class LLVMI32ArrayLiteralNode method foreignWriteI32.

@Specialization(guards = "addr.isManaged()")
@ExplodeLoop
protected LLVMTruffleObject foreignWriteI32(VirtualFrame frame, LLVMTruffleObject addr, @Cached("createForeignWrite()") LLVMForeignWriteNode foreignWrite) {
    LLVMTruffleObject currentPtr = addr;
    for (int i = 0; i < values.length; i++) {
        int currentValue = LLVMTypesGen.asInteger(values[i].executeGeneric(frame));
        foreignWrite.execute(currentPtr, currentValue);
        currentPtr = currentPtr.increment(stride);
    }
    return addr;
}
Also used : LLVMTruffleObject(com.oracle.truffle.llvm.runtime.LLVMTruffleObject) Specialization(com.oracle.truffle.api.dsl.Specialization) ExplodeLoop(com.oracle.truffle.api.nodes.ExplodeLoop)

Example 27 with LLVMTruffleObject

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

the class LLVMI8ArrayLiteralNode method foreignWriteI8.

@Specialization(guards = "addr.isManaged()")
@ExplodeLoop
protected LLVMTruffleObject foreignWriteI8(VirtualFrame frame, LLVMTruffleObject addr, @Cached("createForeignWrite()") LLVMForeignWriteNode foreignWrite) {
    LLVMTruffleObject currentPtr = addr;
    for (int i = 0; i < values.length; i++) {
        byte currentValue = LLVMTypesGen.asByte(values[i].executeGeneric(frame));
        foreignWrite.execute(currentPtr, currentValue);
        currentPtr = currentPtr.increment(stride);
    }
    return addr;
}
Also used : LLVMTruffleObject(com.oracle.truffle.llvm.runtime.LLVMTruffleObject) Specialization(com.oracle.truffle.api.dsl.Specialization) ExplodeLoop(com.oracle.truffle.api.nodes.ExplodeLoop)

Example 28 with LLVMTruffleObject

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

the class LLVMStructArrayLiteralNode method doVoid.

@Specialization(guards = { "noOffset(addr)" })
@ExplodeLoop
protected Object doVoid(VirtualFrame frame, LLVMTruffleObject addr) {
    LLVMTruffleObject currentPtr = addr;
    for (int i = 0; i < values.length; i++) {
        LLVMTruffleObject currentValue = (LLVMTruffleObject) values[i].executeGeneric(frame);
        memMove.executeWithTarget(currentPtr, currentValue, stride);
        currentPtr = currentPtr.increment(stride);
    }
    return addr;
}
Also used : LLVMTruffleObject(com.oracle.truffle.llvm.runtime.LLVMTruffleObject) Specialization(com.oracle.truffle.api.dsl.Specialization) ExplodeLoop(com.oracle.truffle.api.nodes.ExplodeLoop)

Example 29 with LLVMTruffleObject

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

the class LLVMX86_64VAStart method storeArgument.

private static int storeArgument(Object ptr, long offset, LLVMMemMoveNode memmove, LLVMIncrementPointerNode pointerArithmetic, LLVMStoreNode storeI64Node, LLVMStoreNode storeI32Node, LLVMStoreNode storeFP80Node, Object object) {
    if (object instanceof Number) {
        return doPrimitiveWrite(ptr, offset, pointerArithmetic, storeI64Node, object);
    } else if (object instanceof LLVMVarArgCompoundValue) {
        LLVMVarArgCompoundValue obj = (LLVMVarArgCompoundValue) object;
        Object currentPtr = pointerArithmetic.executeWithTarget(ptr, offset);
        memmove.executeWithTarget(currentPtr, obj.getAddr(), obj.getSize());
        return obj.getSize();
    } else if (object instanceof LLVMAddress || object instanceof LLVMGlobal || object instanceof LLVMTruffleObject) {
        Object currentPtr = pointerArithmetic.executeWithTarget(ptr, offset);
        storeI64Node.executeWithTarget(currentPtr, object);
        return X86_64BitVarArgs.STACK_STEP;
    } else if (object instanceof LLVM80BitFloat) {
        Object currentPtr = pointerArithmetic.executeWithTarget(ptr, offset);
        storeFP80Node.executeWithTarget(currentPtr, object);
        return 16;
    } else if (object instanceof LLVMFloatVector) {
        final LLVMFloatVector floatVec = (LLVMFloatVector) object;
        for (int i = 0; i < floatVec.getLength(); i++) {
            Object currentPtr = pointerArithmetic.executeWithTarget(ptr, offset + i * Float.BYTES);
            storeI32Node.executeWithTarget(currentPtr, Float.floatToIntBits(floatVec.getValue(i)));
        }
        return floatVec.getLength() * Float.BYTES;
    } else {
        throw new AssertionError(object);
    }
}
Also used : LLVMVarArgCompoundValue(com.oracle.truffle.llvm.runtime.LLVMVarArgCompoundValue) LLVMAddress(com.oracle.truffle.llvm.runtime.LLVMAddress) LLVMTruffleObject(com.oracle.truffle.llvm.runtime.LLVMTruffleObject) LLVMFloatVector(com.oracle.truffle.llvm.runtime.vector.LLVMFloatVector) LLVMGlobal(com.oracle.truffle.llvm.runtime.global.LLVMGlobal) LLVM80BitFloat(com.oracle.truffle.llvm.runtime.floating.LLVM80BitFloat) LLVMTruffleObject(com.oracle.truffle.llvm.runtime.LLVMTruffleObject)

Example 30 with LLVMTruffleObject

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

the class LLVMStoreVectorNode method writeVector.

@Specialization(guards = "address.isManaged()")
@ExplodeLoop
protected Object writeVector(LLVMTruffleObject address, LLVMFunctionVector value, @Cached("createForeignWrite()") LLVMForeignWriteNode foreignWrite) {
    assert value.getLength() == vectorLength;
    LLVMTruffleObject currentPtr = address;
    for (int i = 0; i < vectorLength; i++) {
        foreignWrite.execute(currentPtr, value.getValue(i));
        currentPtr = currentPtr.increment(I64_SIZE_IN_BYTES);
    }
    return null;
}
Also used : LLVMTruffleObject(com.oracle.truffle.llvm.runtime.LLVMTruffleObject) Specialization(com.oracle.truffle.api.dsl.Specialization) ExplodeLoop(com.oracle.truffle.api.nodes.ExplodeLoop)

Aggregations

LLVMTruffleObject (com.oracle.truffle.llvm.runtime.LLVMTruffleObject)35 Specialization (com.oracle.truffle.api.dsl.Specialization)33 ExplodeLoop (com.oracle.truffle.api.nodes.ExplodeLoop)22 TruffleObject (com.oracle.truffle.api.interop.TruffleObject)10 UnsupportedMessageException (com.oracle.truffle.api.interop.UnsupportedMessageException)5 UnknownIdentifierException (com.oracle.truffle.api.interop.UnknownIdentifierException)2 UnexpectedResultException (com.oracle.truffle.api.nodes.UnexpectedResultException)2 LLVMAddress (com.oracle.truffle.llvm.runtime.LLVMAddress)2 LLVM80BitFloat (com.oracle.truffle.llvm.runtime.floating.LLVM80BitFloat)2 LLVMTypedForeignObject (com.oracle.truffle.llvm.runtime.interop.LLVMTypedForeignObject)2 GuestLanguageRuntimeException (com.oracle.truffle.llvm.runtime.GuestLanguageRuntimeException)1 LLVMContext (com.oracle.truffle.llvm.runtime.LLVMContext)1 LLVMExitException (com.oracle.truffle.llvm.runtime.LLVMExitException)1 LLVMFunctionDescriptor (com.oracle.truffle.llvm.runtime.LLVMFunctionDescriptor)1 LLVMVarArgCompoundValue (com.oracle.truffle.llvm.runtime.LLVMVarArgCompoundValue)1 SulongRuntimeException (com.oracle.truffle.llvm.runtime.SulongRuntimeException)1 LLVMGlobal (com.oracle.truffle.llvm.runtime.global.LLVMGlobal)1 StackPointer (com.oracle.truffle.llvm.runtime.memory.LLVMStack.StackPointer)1 LLVMFloatVector (com.oracle.truffle.llvm.runtime.vector.LLVMFloatVector)1