{{JSRef}} {{es7}}
The SIMD.Int16x8
data type is a 128-bit vector divided into 8 lanes storing 16-bit signed integer values.
Figure 1: SIMD.Int16x8 in a 128-bit SIMD register
Syntax
SIMD.Int16x8(s0, s1, s2, s3, s4, s5, s6, s7);
Parameters
s[0-7]
{{optional_inline}}- An integer specifying the value of the lane. Defaults to 0.
Constructor functions
In addition to the simple creator functions, the SIMD API provides the following constructor functions.
- {{jsxref("SIMD.splat", "SIMD.Int16x8.splat()")}}
- Creates an Int16x8 with all lanes set to a given value.
- {{jsxref("SIMD.bool", "SIMD.Int16x8.bool()")}}
- Creates an Int16x8 with boolean parameters, allowing you to create an explicit selection mask.
You can also convert from another SIMD data type to Int16x8.
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.Int16x8(1,2,3,4,5,6,7,8); // TypeError: SIMD.Int16x8 is not a constructor
Instead, you just write:
var v = SIMD.Int16x8(1,2,3,4,5,6,7,8);
Operations
To actually do something with SIMD types, SIMD operations are needed that work on SIMD data types.
Checking SIMD types
- {{jsxref("SIMD.check", "SIMD.Int16x8.check()")}}
- Returns a new Int16x8 if the parameter is a valid Int16x8 data type. Throws a {{jsxref("TypeError")}} otherwise.
Accessing and mutating lanes
- {{jsxref("SIMD.extractLane", "SIMD.Int16x8.extractLane()")}}
- Returns the value of the given lane.
- {{jsxref("SIMD.replaceLane", "SIMD.Int16x8.replaceLane()")}}
- Returns a new Int16x8 with the given lane value replaced.
Loading from and storing into typed arrays
- {{jsxref("SIMD.load", "SIMD.Int16x8.load()")}}
- Returns a new Int16x8 with the lane values loaded from a typed array.
- {{jsxref("SIMD.store", "SIMD.Int16x8.store()")}}
- Stores an Int16x8 into a typed array.
Arithmetic operations
- {{jsxref("SIMD.add", "SIMD.Int16x8.add()")}}
- Returns a new Int16x8 with the lane values added (
a + b
). - {{jsxref("SIMD.mul", "SIMD.Int16x8.mul()")}}
- Returns a new Int16x8 with the lane values multiplied (
a * b
). - {{jsxref("SIMD.neg", "SIMD.Int16x8.neg()")}}
- Returns a new Int16x8 with the negated lane values.
- {{jsxref("SIMD.sub", "SIMD.Int16x8.sub()")}}
- Returns a new Int16x8 with the lane values subtracted (
a - b
). -
Shuffling and swizzling
- {{jsxref("SIMD.shuffle", "SIMD.Int16x8.shuffle()")}}
- Returns a new Int16x8 with the lane values shuffled.
- {{jsxref("SIMD.swizzle", "SIMD.Int16x8.swizzle()")}}
- Returns a new Int16x8 with the lane values swizzled.
Selections
- {{jsxref("SIMD.select", "SIMD.Int16x8.select()")}}
- Returns a new Int16x8 with the lane values being a mix of the lanes depending on the selector mask.
- {{jsxref("SIMD.selectBits", "SIMD.Int16x8.selectBits()")}}
- Returns a new Int16x8 with the lane values being a mix of bits depending on the selector mask.
Comparisons
- {{jsxref("SIMD.equal", "SIMD.Int16x8.equal()")}}
- Returns a selection mask depending on
a == b
. - {{jsxref("SIMD.notEqual", "SIMD.Int16x8.notEqual()")}}
- Returns a selection mask depending on
a != b
. - {{jsxref("SIMD.lessThan", "SIMD.Int16x8.lessThan()")}}
- Returns a selection mask depending on
a < b
. - {{jsxref("SIMD.lessThanOrEqual", "SIMD.Int16x8.lessThanOrEqual()")}}
- Returns a selection mask depending on
a <= b
. - {{jsxref("SIMD.greaterThan", "SIMD.Int16x8.greaterThan()")}}
- Returns a selection mask depending on
a > b
. - {{jsxref("SIMD.greaterThanOrEqual", "SIMD.Int16x8.greaterThanOrEqual()")}}
- Returns a selection mask depending on
a >= b
.
Bitwise logical operations
- {{jsxref("SIMD.and", "SIMD.Int16x8.and()")}}
- Returns a new Int16x8 with the logical AND of the lane values (
a & b
). - {{jsxref("SIMD.or", "SIMD.Int16x8.or()")}}
- Returns a new Int16x8 with the logical OR of the lane values (
a | b
). - {{jsxref("SIMD.xor", "SIMD.Int16x8.xor()")}}
- Returns a new Int16x8 with the logical XOR of the lane values (
a ^ b
). - {{jsxref("SIMD.not", "SIMD.Int16x8.not()")}}
- Returns a new Int16x8 with lane with the logical NOT of the lane values (
~a
).
Bitwise shift operations
- {{jsxref("SIMD.shiftLeftByScalar", "SIMD.Int16x8.shiftLeftByScalar()")}}
- Returns a new Int16x8 with the lane values shifted left by a given bit count (
a << bits
). - {{jsxref("SIMD.shiftRightArithmeticByScalar", "SIMD.Int16x8.shiftRightArithmeticByScalar()")}}
- Returns a new Int16x8 with the lane values shifted right (arithmetic) by a given bit count (
a >> bits
). - {{jsxref("SIMD.shiftRightLogicalByScalar", "SIMD.Int16x8.shiftRightLogicalByScalar()")}}
- Returns a new Int16x8 with the lane values shifted right (logical) by a given bit count (
a >>> bits
).
Data conversions
- {{jsxref("SIMD.fromFloat32x4Bits", "SIMD.Int16x8.fromFloat32x4Bits()")}}
- Creates a new Int16x8 data type with a bit-wise copy from a Float32x4.
- {{jsxref("SIMD.fromFloat64x2Bits", "SIMD.Int16x8.fromFloat64x2Bits()")}}
- Creates a new Int16x8 data type with a bit-wise copy from a Float64x2.
- {{jsxref("SIMD.fromInt32x4Bits", "SIMD.Int16x8.fromInt32x4Bits()")}}
- Creates a new Int16x8 data type with a bit-wise copy from an Int32x4.
- {{jsxref("SIMD.fromInt8x16Bits", "SIMD.Int16x8.fromInt8x16Bits()")}}
- Creates a new Int16x8 data type with a bit-wise copy from an Int8x16.
Examples
Constructing an Int16x8
SIMD.Int16x8(1, 2, 3, 4, 5, 6, 7, 8); // Int16x8[1,2,3,4,5,6,7,8] SIMD.Int16x8(1, 2); // Int16x8[1,2,0,0,0,0,0,0] SIMD.Int16x8(); // Int16x8[0,0,0,0,0,0,0,0]
Specifications
Specification | Status | Comment |
---|---|---|
{{SpecName('SIMD', '#int16x8', 'Int16x8')}} | {{Spec2('SIMD')}} | Initial definition. |
Browser compatibility
{{CompatibilityTable}}
Feature | Chrome | Firefox (Gecko) | Internet Explorer | Opera | Safari |
---|---|---|---|---|---|
Basic support | {{CompatNo}} | {{CompatNightly("firefox")}} | {{CompatNo}} | {{CompatNo}} | {{CompatNo}} |
Feature | Android | Chrome for Android | Firefox Mobile (Gecko) | IE Mobile | Opera Mobile | Safari Mobile |
---|---|---|---|---|---|---|
Basic support | {{CompatNo}} | {{CompatNo}} | {{CompatNightly("firefox")}} | {{CompatNo}} | {{CompatNo}} | {{CompatNo}} |
See also
- {{jsxref("SIMD")}}