Search in sources :

Example 26 with LLVM80BitFloat

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

the class LLVM80BitFloatArrayLiteralNode method write80BitFloat.

@Specialization
@ExplodeLoop
protected LLVMAddress write80BitFloat(VirtualFrame frame, LLVMAddress addr, @Cached("getLLVMMemory()") LLVMMemory memory) {
    long currentPtr = addr.getVal();
    for (int i = 0; i < values.length; i++) {
        try {
            LLVM80BitFloat currentValue = values[i].executeLLVM80BitFloat(frame);
            memory.put80BitFloat(currentPtr, currentValue);
            currentPtr += stride;
        } catch (UnexpectedResultException e) {
            CompilerDirectives.transferToInterpreter();
            throw new IllegalStateException(e);
        }
    }
    return addr;
}
Also used : UnexpectedResultException(com.oracle.truffle.api.nodes.UnexpectedResultException) LLVM80BitFloat(com.oracle.truffle.llvm.runtime.floating.LLVM80BitFloat) Specialization(com.oracle.truffle.api.dsl.Specialization) ExplodeLoop(com.oracle.truffle.api.nodes.ExplodeLoop)

Example 27 with LLVM80BitFloat

use of com.oracle.truffle.llvm.runtime.floating.LLVM80BitFloat 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 28 with LLVM80BitFloat

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

the class LLVM80BitFromDoubleTest method testMinusZero2.

@Test
public void testMinusZero2() {
    LLVM80BitFloat val = LLVM80BitFloat.fromRawValues(true, 0, 0);
    assertEquals(val, val(-0.0));
}
Also used : LLVM80BitFloat(com.oracle.truffle.llvm.runtime.floating.LLVM80BitFloat) Test(org.junit.Test)

Example 29 with LLVM80BitFloat

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

the class LLVM80BitFromDoubleTest method testNaN.

@Test
public void testNaN() {
    LLVM80BitFloat val = LLVM80BitFloat.fromDouble(Double.NaN);
    LLVM80BitFloat expected = LLVM80BitFloat.fromRawValues(false, 0x7fff, 0xc000000000000000L);
    assertEquals(expected, val);
}
Also used : LLVM80BitFloat(com.oracle.truffle.llvm.runtime.floating.LLVM80BitFloat) Test(org.junit.Test)

Example 30 with LLVM80BitFloat

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

the class LLVM80BitFromDoubleTest method testPositiveInfinity.

@Test
public void testPositiveInfinity() {
    LLVM80BitFloat val = LLVM80BitFloat.fromDouble(Double.POSITIVE_INFINITY);
    LLVM80BitFloat expected = LLVM80BitFloat.fromRawValues(false, 0x7fff, 0x8000000000000000L);
    assertEquals(expected, val);
}
Also used : LLVM80BitFloat(com.oracle.truffle.llvm.runtime.floating.LLVM80BitFloat) Test(org.junit.Test)

Aggregations

LLVM80BitFloat (com.oracle.truffle.llvm.runtime.floating.LLVM80BitFloat)42 Test (org.junit.Test)38 LLVMTruffleObject (com.oracle.truffle.llvm.runtime.LLVMTruffleObject)3 Specialization (com.oracle.truffle.api.dsl.Specialization)2 ExplodeLoop (com.oracle.truffle.api.nodes.ExplodeLoop)2 UnexpectedResultException (com.oracle.truffle.api.nodes.UnexpectedResultException)2 LLVMVarArgCompoundValue (com.oracle.truffle.llvm.runtime.LLVMVarArgCompoundValue)2 LLVMAddress (com.oracle.truffle.llvm.runtime.LLVMAddress)1 LLVMGlobal (com.oracle.truffle.llvm.runtime.global.LLVMGlobal)1 LLVMFloatVector (com.oracle.truffle.llvm.runtime.vector.LLVMFloatVector)1