mozilla
Your Search Results

    SIMD.int32x4

    This is an experimental technology, part of the Harmony (ECMAScript 7) proposal.
    Because this technology's specification has not stabilized, check the compatibility table for usage in various browsers. Also note that the syntax and behavior of an experimental technology is subject to change in future version of browsers as the spec changes.

    The SIMD.int32x4 data type is a 128-bit vector divided into 4 lanes storing 32-bit signed integer values.

    SIMD.int32x4

    Figure 1: SIMD.int32x4 in a 128-bit SIMD register.

    Syntax

    SIMD.int32x4(x, y, z, w);

    Parameters

    x Optional
    An integer specifying the value of the first lane. Defaults to 0.
    y Optional
    An integer specifying the value of the second lane. Defaults to 0.
    z Optional
    An integer specifying the value of the third lane. Defaults to 0.
    w Optional
    An integer specifying the value of the fourth lane. Defaults to 0.

    Constructors

    In addition to the simple constructors, the SIMD API provides the following constructors. Note that you can also convert from another SIMD data type to int32x4.

    SIMD.int32x4.splat()
    Creates an int32x4 with all lanes set to a given value.
    SIMD.int32x4.bool()
    Creates an int32x4 with boolean parameters, allowing you to create an explicit selection mask.

    Operations

    To actually do something with SIMD types, SIMD operations are needed that work on SIMD data types.

    Checking SIMD types

    SIMD.int32x4.check()
    Returns a new int32x4 if the parameter is a valid int32x4 data type. Throws a TypeError otherwise.

    Accessing and mutating lanes

    SIMD.%type%.extractLane()
    Returns the value of the given lane.
    SIMD.%type%.replaceLane()
    Returns a new instance with the given lane value replaced.

    Loading from and storing into typed arrays

    SIMD.int32x4.load()
    Returns a new int32x4 with the lane values loaded from a typed array.
    SIMD.int32x4.store()
    Stores an int32x4 into a typed array.

    Arithmetic operations

    SIMD.int32x4.add()
    Returns a new int32x4 with the lane values added (a + b).
    SIMD.int32x4.mul()
    Returns a new int32x4 with the lane values multiplied (a * b).
    SIMD.int32x4.neg()
    Returns a new int32x4 with the negated lane values.
    SIMD.int32x4.sub()
    Returns a new int32x4 with the lane values subtracted (a - b).

    Shuffling and swizzling

    SIMD.int32x4.shuffle()
    Returns a new int32x4 with the lane values shuffled.
    SIMD.int32x4.swizzle()
    Returns a new int32x4 with the lane values swizzled.

    Selections

    SIMD.int32x4.select()
    Returns a new int32x4 with the lane values being a mix of the lanes depending on the selector mask.
    SIMD.int32x4.selectBits()
    Returns a new int32x4 with the lane values being a mix of bits depending on the selector mask.

    Comparisons

    SIMD.int32x4.equal()
    Returns a selection mask depending on a == b.
    SIMD.int32x4.notEqual()
    Returns a selection mask depending on a != b.
    SIMD.int32x4.lessThan()
    Returns a selection mask depending on a < b.
    SIMD.int32x4.lessThanOrEqual()
    Returns a selection mask depending on a <= b.
    SIMD.int32x4.greaterThan()
    Returns a selection mask depending on a > b.
    SIMD.int32x4.greaterThanOrEqual()
    Returns a selection mask depending on a >= b.

    Bitwise logical operations

    SIMD.int32x4.and()
    Returns a new int32x4 with the logical AND of the lane values (a & b).
    SIMD.int32x4.or()
    Returns a new int32x4 with the logical OR of the lane values (a | b).
    SIMD.int32x4.xor()
    Returns a new int32x4 with the logical XOR of the lane values (a ^ b).
    SIMD.int32x4.not()
    Returns a new int32x4 with lane with the logical NOT of the lane values (~a).

    Bitwise shift operations

    SIMD.int32x4.shiftLeftByScalar()
    Returns a new int32x4 with the lane values shifted left by a given bit count (a << bits).
    SIMD.int32x4.shiftRightArithmeticByScalar()
    Returns a new int32x4 with the lane values shifted right (arithmetic) by a given bit count (a >> bits).
    SIMD.int32x4.shiftRightLogicalByScalar()
    Returns a new int32x4 with the lane values shifted right (logical) by a given bit count (a >>> bits).

    Data conversions (packing / unpacking)

    SIMD.int32x4.fromFloat32x4()
    Creates a new int32x4 data type with a float conversion from a float32x4.
    SIMD.int32x4.fromFloat32x4Bits()
    Creates a new int32x4 data type with a bit-wise copy from a float32x4.
    SIMD.int32x4.fromFloat64x2()
    Creates a new int32x4 data type with a float conversion from a float64x2.
    SIMD.int32x4.fromFloat64x2Bits()
    Creates a new int32x4 data type with a bit-wise copy from a float64x2.
    SIMD.int32x4.fromInt16x8Bits()
    Creates a new int32x4 data type with a bit-wise copy from an int16x8.
    SIMD.int32x4.fromInt8x16Bits()
    Creates a new int32x4 data type with a bit-wise copy from an int8x16.

    Examples

    Constructing an int32x4

    new SIMD.int32x4(1, 2, 3, 4); // int32x4[1,2,3,4]
    new SIMD.int32x4(1, 2);       // int32x4[1,2,0,0]
    new SIMD.int32x4();           // int32x4[0,0,0,0]
    

    Specifications

    SIMD is not yet part of an official standards document or draft. For standardization work and a Polyfill implementation based on typed arrays, see the ecmascript_simd GitHub repository.

    Browser compatibility

    Feature Chrome Firefox (Gecko) Internet Explorer Opera Safari
    Basic support Not supported Nightly build Not supported Not supported Not supported
    Feature Android Chrome for Android Firefox Mobile (Gecko) IE Mobile Opera Mobile Safari Mobile
    Basic support Not supported Not supported Nightly build Not supported Not supported Not supported

    See also

    Document Tags and Contributors

    Contributors to this page: fscholz
    Last updated by: fscholz,
    Hide Sidebar