Search in sources :

Example 1 with SIMDType

use of com.github.anba.es6draft.runtime.objects.simd.SIMDType in project es6draft by anba.

the class SIMD method SIMDBinaryOpDouble.

/**
     * Internal algorithms on SIMD types
     * <p>
     * SIMDBinaryOp( a, b, op, outputDescriptor )
     * 
     * @param a
     *            the first operand
     * @param b
     *            the second operand
     * @param op
     *            the binary operator
     * @param outputDescriptor
     *            the output type descriptor, always boolean SIMD type
     * @return the new SIMD value
     */
public static SIMDValue SIMDBinaryOpDouble(SIMDValue a, SIMDValue b, DoubleBiPredicate op, SIMDType outputDescriptor) {
    /* step 1 */
    assert a.getType() == b.getType();
    assert a.getType() == SIMDType.Float64x2 && outputDescriptor == SIMDType.Bool64x2;
    /* step 2 */
    SIMDType descriptor = a.getType();
    /* step 3 (not applicable) */
    /* step 4 */
    boolean[] list = new boolean[outputDescriptor.getVectorLength()];
    /* step 5 */
    for (int i = 0, len = descriptor.getVectorLength(); i < len; ++i) {
        /* step 5.a */
        double ax = MaybeFlushDenormalDouble(SIMDExtractLaneFloat(a, i));
        /* step 5.b */
        double bx = MaybeFlushDenormalDouble(SIMDExtractLaneFloat(b, i));
        /* steps 5.c-d */
        boolean res = op.test(ax, bx);
        /* step 5.e (not applicable) */
        /* step 5.f */
        list[i] = res;
    }
    /* step 6 */
    return SIMDCreate(outputDescriptor, list);
}
Also used : SIMDType(com.github.anba.es6draft.runtime.objects.simd.SIMDType)

Example 2 with SIMDType

use of com.github.anba.es6draft.runtime.objects.simd.SIMDType in project es6draft by anba.

the class SIMD method SIMDScalarOp.

/**
     * Internal algorithms on SIMD types
     * <p>
     * SIMDScalarOp( a, scalar, op )
     * 
     * @param a
     *            the operand value
     * @param scalar
     *            the scalar value
     * @param op
     *            the binary operator
     * @return the new SIMD value
     */
public static SIMDValue SIMDScalarOp(SIMDValue a, int scalar, IntBinaryOperator op) {
    /* step 1 */
    SIMDType descriptor = a.getType();
    assert descriptor.isInteger();
    // FIXME: spec issue - instead assert descriptor is integer type!
    assert !descriptor.isFloatingPoint();
    /* step 3 */
    int[] list = new int[descriptor.getVectorLength()];
    /* step 5 */
    for (int i = 0, len = descriptor.getVectorLength(); i < len; ++i) {
        /* step 5.a */
        int ax = SIMDExtractLaneInt(a, i);
        /* steps 5.b-c */
        int res = op.applyAsInt(ax, scalar);
        /* step 5.d */
        list[i] = res;
    }
    /* step 6 */
    return SIMDCreate(descriptor, list);
}
Also used : SIMDType(com.github.anba.es6draft.runtime.objects.simd.SIMDType)

Example 3 with SIMDType

use of com.github.anba.es6draft.runtime.objects.simd.SIMDType in project es6draft by anba.

the class SIMD method SIMDUnaryOpInt.

/**
     * Internal algorithms on SIMD types
     * <p>
     * SIMDUnaryOp( a, op [ , flushDenormal ] )
     * 
     * @param a
     *            the operand value
     * @param op
     *            the unary operator
     * @return the new SIMD value
     */
public static SIMDValue SIMDUnaryOpInt(SIMDValue a, IntUnaryOperator op) {
    /* step 1 */
    SIMDType descriptor = a.getType();
    assert descriptor.isInteger();
    /* step 2 (not applicable) */
    /* step 3 */
    int[] list = new int[descriptor.getVectorLength()];
    /* step 5 */
    for (int i = 0, len = descriptor.getVectorLength(); i < len; ++i) {
        /* step 5.a */
        int ax = SIMDExtractLaneInt(a, i);
        /* step 5.b (not applicable) */
        /* steps 5.c-d */
        int res = op.applyAsInt(ax);
        /* step 5.e (not applicable) */
        /* step 5.f */
        list[i] = res;
    }
    /* step 6 */
    return SIMDCreate(descriptor, list);
}
Also used : SIMDType(com.github.anba.es6draft.runtime.objects.simd.SIMDType)

Example 4 with SIMDType

use of com.github.anba.es6draft.runtime.objects.simd.SIMDType in project es6draft by anba.

the class SIMD method SIMDBinaryOpDouble.

/**
     * Internal algorithms on SIMD types
     * <p>
     * SIMDBinaryOp( a, b, op, outputDescriptor )
     * 
     * @param a
     *            the first operand
     * @param b
     *            the second operand
     * @param op
     *            the binary operator
     * @return the new SIMD value
     */
public static SIMDValue SIMDBinaryOpDouble(SIMDValue a, SIMDValue b, DoubleBinaryOperator op) {
    /* step 1 */
    assert a.getType() == b.getType();
    assert a.getType() == SIMDType.Float64x2;
    /* step 2 */
    SIMDType descriptor = a.getType();
    /* step 3 */
    SIMDType outputDescriptor = a.getType();
    /* step 4 */
    double[] list = new double[descriptor.getVectorLength()];
    /* step 5 */
    for (int i = 0, len = descriptor.getVectorLength(); i < len; ++i) {
        /* step 5.a */
        double ax = MaybeFlushDenormalDouble(SIMDExtractLaneFloat(a, i));
        /* step 5.b */
        double bx = MaybeFlushDenormalDouble(SIMDExtractLaneFloat(b, i));
        /* steps 5.c-d */
        double res = op.applyAsDouble(ax, bx);
        /* step 5.e */
        res = MaybeFlushDenormalDouble(res);
        /* step 5.f */
        list[i] = res;
    }
    /* step 6 */
    return SIMDCreate(outputDescriptor, list);
}
Also used : SIMDType(com.github.anba.es6draft.runtime.objects.simd.SIMDType)

Example 5 with SIMDType

use of com.github.anba.es6draft.runtime.objects.simd.SIMDType in project es6draft by anba.

the class SIMD method SIMDBinaryOpFloat.

/**
     * Internal algorithms on SIMD types
     * <p>
     * SIMDBinaryOp( a, b, op, outputDescriptor )
     * 
     * @param a
     *            the first operand
     * @param b
     *            the second operand
     * @param op
     *            the binary operator
     * @param outputDescriptor
     *            the output type descriptor, always boolean SIMD type
     * @return the new SIMD value
     */
public static SIMDValue SIMDBinaryOpFloat(SIMDValue a, SIMDValue b, DoubleBiPredicate op, SIMDType outputDescriptor) {
    /* step 1 */
    assert a.getType() == b.getType();
    assert a.getType() == SIMDType.Float32x4 && outputDescriptor == SIMDType.Bool32x4;
    /* step 2 */
    SIMDType descriptor = a.getType();
    /* step 3 (not applicable) */
    /* step 4 */
    boolean[] list = new boolean[descriptor.getVectorLength()];
    /* step 5 */
    for (int i = 0, len = descriptor.getVectorLength(); i < len; ++i) {
        /* step 5.a */
        double ax = MaybeFlushDenormalFloat(SIMDExtractLaneFloat(a, i));
        /* step 5.b */
        double bx = MaybeFlushDenormalFloat(SIMDExtractLaneFloat(b, i));
        /* steps 5.c-d */
        boolean res = op.test(ax, bx);
        /* step 5.e (not applicable) */
        /* step 5.f */
        list[i] = res;
    }
    /* step 6 */
    return SIMDCreate(outputDescriptor, list);
}
Also used : SIMDType(com.github.anba.es6draft.runtime.objects.simd.SIMDType)

Aggregations

SIMDType (com.github.anba.es6draft.runtime.objects.simd.SIMDType)15