Search in sources :

Example 16 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, LLVMI64Vector 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)

Example 17 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, LLVMI1Vector 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(I1_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)

Example 18 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, LLVMDoubleVector 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(DOUBLE_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)

Example 19 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, LLVMI32Vector 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(I32_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)

Example 20 with LLVMTruffleObject

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

the class LLVMTruffleReadNBytes method interop.

@Specialization
protected Object interop(LLVMTruffleObject objectWithOffset, int n, @Cached("createForeignReadNode()") Node foreignRead, @Cached("createToByteNode()") ForeignToLLVM toLLVM, @Cached("getContextReference()") ContextReference<LLVMContext> ctxRef) {
    long offset = objectWithOffset.getOffset();
    TruffleObject object = objectWithOffset.getObject();
    byte[] chars = new byte[n];
    for (int i = 0; i < n; i++) {
        Object rawValue;
        try {
            rawValue = ForeignAccess.sendRead(foreignRead, object, offset + i);
        } catch (UnknownIdentifierException | UnsupportedMessageException e) {
            CompilerDirectives.transferToInterpreter();
            throw new IllegalStateException(e);
        }
        chars[i] = (byte) toLLVM.executeWithTarget(rawValue);
    }
    TruffleObject ret = (TruffleObject) ctxRef.get().getEnv().asGuestValue(chars);
    return new LLVMTruffleObject(LLVMTypedForeignObject.createUnknown(ret));
}
Also used : UnsupportedMessageException(com.oracle.truffle.api.interop.UnsupportedMessageException) UnknownIdentifierException(com.oracle.truffle.api.interop.UnknownIdentifierException) TruffleObject(com.oracle.truffle.api.interop.TruffleObject) LLVMTruffleObject(com.oracle.truffle.llvm.runtime.LLVMTruffleObject) LLVMTypedForeignObject(com.oracle.truffle.llvm.runtime.interop.LLVMTypedForeignObject) TruffleObject(com.oracle.truffle.api.interop.TruffleObject) LLVMTruffleObject(com.oracle.truffle.llvm.runtime.LLVMTruffleObject) LLVMTruffleObject(com.oracle.truffle.llvm.runtime.LLVMTruffleObject) Specialization(com.oracle.truffle.api.dsl.Specialization)

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