SIMD.Uint32x4

This is an experimental technology
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 versions of browsers as the specification changes.

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

Syntax

SIMD.Uint32x4(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.

Constructor functions

In addition to the simple creator function, the SIMD API provides the following constructor functions.

SIMD.Uint32x4.splat()
Creates a Uint32x4 with all lanes set to a given value.

You can also convert from another SIMD data type to Uint32x4.

Note: SIMD types don't work with new, as SIMD values are no "boxed" objects (comparable to String(s) vs. new String(s), which creates a String object).

var v = new SIMD.Uint32x4(1, 2, 3, 4); 
// TypeError: SIMD.Uint32x4 is not a constructor
var w = new SIMD.Uint32x4.splat(3); 
// TypeError: SIMD.Uint32x4.splat is not a constructor

Instead, you just write:

var v = SIMD.Uint32x4(1, 2, 3, 4);
var w = SIMD.Uint32x4.splat(3);

Operations

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

Checking SIMD types

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

Accessing and mutating lanes

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

Loading from and storing into typed arrays

SIMD.Uint32x4.load()
SIMD.Uint32x4.load1()
SIMD.Uint32x4.load2()
SIMD.Uint32x4.load3()
Returns a new Uint32x4 with the lane values loaded from a typed array.
SIMD.Uint32x4.store()
SIMD.Uint32x4.store1()
SIMD.Uint32x4.store2()
SIMD.Uint32x4.store3()
Stores a Uint32x4 into a typed array.

Arithmetic operations

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

Shuffling and swizzling

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

Selections

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

Comparisons

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

Bitwise logical operations

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

Bitwise shift operations

SIMD.Uint32x4.shiftLeftByScalar()
Returns a new Uint32x4 with the lane values shifted left by a given bit count (a << bits).
SIMD.Uint32x4.shiftRightByScalar()
Returns a new Uint32x4 with the lane values shifted right.

Data conversions

SIMD.Uint32x4.fromFloat32x4()
Creates a new Uint32x4 data type with a float conversion from a Float32x4.
SIMD.Uint32x4.fromFloat32x4Bits()
Creates a new Uint32x4 data type with a bit-wise copy from a Float32x4.
SIMD.Uint32x4.fromFloat64x2Bits()
Creates a new Uint32x4 data type with a bit-wise copy from a Float64x2.
SIMD.Uint32x4.fromInt32x4Bits()
Creates a new Uint32x4 data type with a bit-wise copy from a Int32x4.
SIMD.Uint32x4.fromInt16x8Bits()
Creates a new Uint32x4 data type with a bit-wise copy from an Int16x8.
SIMD.Uint32x4.fromInt8x16Bits()
Creates a new Uint32x4 data type with a bit-wise copy from an Int8x16.
SIMD.Uint32x4.fromUint16x8Bits()
Creates a new Uint32x4 data type with a bit-wise copy from an Uint16x8.
SIMD.Uint32x4.fromUint8x16Bits()
Creates a new Uint32x4 data type with a bit-wise copy from an Uint8x16.

SIMD prototype

The following methods and properties are installed on the SIMD.Uint32x4.prototype.

SIMD.Uint32x4.prototype.constructor
Specifies the function that creates a SIMD object's prototype.
SIMD.Uint32x4.prototype.toLocaleString()
Returns a localized string representing the SIMD type and its elements. Overrides the Object.prototype.toLocaleString() method.
SIMD.Uint32x4.prototype.toString()
Returns a string representing the SIMD type and its elements. Overrides the Object.prototype.toString() method.
SIMD.Uint32x4.prototype.valueOf()
Returns the primitive value of a SIMD object.
SIMD.Uint32x4.prototype.toSource()
Returns a string representing the source code of the object. Overrides the Object.prototype.toSource() method.

Examples

Constructing a Uint32x4

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

Specifications

Specification Status Comment
SIMD
The definition of 'Uint32x4' in that specification.
Draft Initial definition.

Browser compatibility

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

See also

Document Tags and Contributors

 Contributors to this page: jameshkramer, nmve, fscholz
 Last updated by: jameshkramer,