Search in sources :

Example 16 with LLVMAddress

use of com.oracle.truffle.llvm.runtime.LLVMAddress 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 17 with LLVMAddress

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

the class LLVMString method memcpy.

public static void memcpy(LLVMMemory memory, byte[] src, LLVMAddress dst, long size) {
    int min = src.length;
    if (min > size) {
        min = (int) size;
    }
    LLVMAddress ptr = dst;
    for (int i = 0; i < min; i++) {
        memory.putI8(ptr, src[i]);
        ptr = ptr.increment(1);
    }
}
Also used : LLVMAddress(com.oracle.truffle.llvm.runtime.LLVMAddress)

Example 18 with LLVMAddress

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

the class LLVMString method memcpy.

public static byte[] memcpy(LLVMMemory memory, LLVMAddress address, int size) {
    byte[] out = new byte[size];
    LLVMAddress ptr = address;
    for (int i = 0; i < size; i++) {
        out[i] = memory.getI8(ptr);
        ptr = ptr.increment(1);
    }
    return out;
}
Also used : LLVMAddress(com.oracle.truffle.llvm.runtime.LLVMAddress)

Aggregations

LLVMAddress (com.oracle.truffle.llvm.runtime.LLVMAddress)18 Specialization (com.oracle.truffle.api.dsl.Specialization)6 ExplodeLoop (com.oracle.truffle.api.nodes.ExplodeLoop)3 UnexpectedResultException (com.oracle.truffle.api.nodes.UnexpectedResultException)3 LLVMTruffleObject (com.oracle.truffle.llvm.runtime.LLVMTruffleObject)3 TruffleBoundary (com.oracle.truffle.api.CompilerDirectives.TruffleBoundary)1 FrameSlotTypeException (com.oracle.truffle.api.frame.FrameSlotTypeException)1 TruffleObject (com.oracle.truffle.api.interop.TruffleObject)1 LLVMException (com.oracle.truffle.llvm.runtime.LLVMException)1 LLVMVarArgCompoundValue (com.oracle.truffle.llvm.runtime.LLVMVarArgCompoundValue)1 LLVM80BitFloat (com.oracle.truffle.llvm.runtime.floating.LLVM80BitFloat)1 LLVMGlobal (com.oracle.truffle.llvm.runtime.global.LLVMGlobal)1 LLVMStack (com.oracle.truffle.llvm.runtime.memory.LLVMStack)1 LLVMFloatVector (com.oracle.truffle.llvm.runtime.vector.LLVMFloatVector)1