nish:simd

Sixteen-byte vectors of one lane type, and the lane-wise operations on them, each lowered to target-independent LLVM vector IR.

import {
  FloatVector,
  IntegerVector,
  SimdMask,
  SimdVector,
  abs,
  add,
  addWrapping,
  all,
  and,
  any,
  asF32x4,
  asF64x2,
  asI32x4,
  asU16x8,
  asU32x4,
  asU8x16,
  bitmask,
  div,
  eq,
  extract,
  f32x4,
  f32x4,
  f64x2,
  f64x2,
  ge,
  gt,
  i32x4,
  i32x4,
  le,
  loadF32x4,
  loadF64x2,
  loadI32x4,
  loadU16x8,
  loadU32x4,
  loadU8x16,
  lt,
  mask16x8,
  mask32x4,
  mask64x2,
  mask8x16,
  max,
  min,
  mul,
  mulWrapping,
  ne,
  neg,
  not,
  or,
  replace,
  rotl,
  rotr,
  select,
  shl,
  shr,
  shuffle,
  splatF32x4,
  splatF64x2,
  splatI32x4,
  splatU16x8,
  splatU32x4,
  splatU8x16,
  sqrt,
  store,
  sub,
  subWrapping,
  sum,
  sumWrapping,
  u16x8,
  u16x8,
  u32x4,
  u32x4,
  u8x16,
  u8x16,
  xor,
} from "nish:simd";
import { u32x4, loadI32x4, store, extract, replace, addWrapping, xor, rotl } from "nish:simd";

export const bumpFirst = (xs: i32[], at: i32): i32 => {
  const v = loadI32x4(xs, at);
  store(replace(v, 0, extract(v, 0) + 1), xs, at);
  return extract(v, 3);
};

// One ChaCha20 quarter-round step on four blocks at once: lane k is block k.
export const step = (a: u32x4, b: u32x4, d: u32x4): u32 => {
  const a2 = addWrapping(a, b);
  return extract(rotl(xor(d, a2), 16), 0);
};

A vector is a value: copied by assignment, passed and returned in registers, held in a local, a class field or an array. Every operation is a free function, because TypeScript cannot overload +, and the operand types pick the lowering. Nothing names a target: no golden holds llvm.x86. or llvm.aarch64., and LLVM picks the instructions.

Every name is used only through an import of nish:simd (NL2578). A vector has no operators and no comparison: +, a truthiness test and printing a whole vector are refused, and === and < are NL2581; compare with eq and the rest and ask the mask all or any. Every operand of one call is one vector type (NL2623, NL2638). A lane index, a shift count and a shuffle index are integer literals in range (NL2580, NL2583, NL2630 to NL2635). A mask is held only in a local, a parameter or a return of a function the module keeps (NL2622). A vector is not a Map key, not Secret, not nullable, and does not cross the interop boundary yet.

Layout

In an object or an array a vector is sixteen bytes aligned to sixteen, as clang lays out __attribute__((vector_size(16))); an array of vectors steps by sixteen. A load or store is aligned to the lane, not to sixteen.

Integer lanes wrap, and the names say so

add is float arithmetic; an integer lane's form is addWrapping, because making a lane trap as scalar + does would cost the speed the type is for. A sum that could overflow is sumWrapping.

Under Node

runtime/nish.mjs answers the import with runtime/core.mjs, where a vector is a fresh typed array of its lanes, made once and never written after, whose element type does the lane's arithmetic: an integer lane wraps through its array type (Uint8Array for a u8 lane), and an f32 lane rounds through Float32Array. A mask is an array of booleans, and a rotate is two shifts and an or. tests/run.js's simd section holds the native, WASI and Node outputs to one.

Rules: https://github.com/amritk/nish/blob/main/docs/LANGUAGE.md#nishsimd-sixteen-byte-vectors and https://github.com/amritk/nish/blob/main/docs/LANGUAGE.md#nishsimd-lane-operations-and-masks

Functions

abs

Each float lane's absolute value, llvm.fabs: the sign bit cleared.

const abs: <V extends FloatVector>(a: V) => V
aVrequired

An f32x4 or f64x2.

returnsV

The vector of absolute values.

add

The lane-wise sum of two float vectors, fadd with no fast-math flags. An integer vector is refused (NL2623): its form is addWrapping.

const add: <V extends FloatVector>(a: V, b: V) => V
aVrequired

An f32x4 or f64x2.

bVrequired

A vector of a's type.

returnsV

Each lane's sum.

addWrapping

The lane-wise sum of two integer vectors, add with no nsw or nuw: each lane wraps at the lane width.

const addWrapping: <V extends IntegerVector>(
  a: V,
  b: V,
) => V
aVrequired

A u8x16, u16x8, i32x4 or u32x4.

bVrequired

A vector of a's type.

returnsV

Each lane's sum, wrapped.

all

Whether every lane of m is set, llvm.vector.reduce.and.

const all: (m: SimdMask) => boolean
mSimdMaskrequired

A mask.

returnsboolean

true when no lane is clear.

and

Bitwise and, on integer lanes or lane by lane on two masks.

const and: <V extends IntegerVector | SimdMask>(
  a: V,
  b: V,
) => V
aVrequired

An integer vector or a mask.

bVrequired

A vector or mask of a's type.

returnsV

The bitwise and, of a's type.

any

Whether any lane of m is set, llvm.vector.reduce.or.

const any: (m: SimdMask) => boolean
mSimdMaskrequired

A mask.

returnsboolean

true when one lane or more is set.

asF32x4

The same sixteen bytes read as an f32x4, one bitcast.

const asF32x4: (v: SimdVector) => f32x4
vSimdVectorrequired

Any vector.

returnsf32x4

The bytes as 4 f32 lanes.

asF64x2

The same sixteen bytes read as an f64x2, one bitcast.

const asF64x2: (v: SimdVector) => f64x2
vSimdVectorrequired

Any vector.

returnsf64x2

The bytes as 2 f64 lanes.

asI32x4

The same sixteen bytes read as an i32x4, one bitcast.

const asI32x4: (v: SimdVector) => i32x4
vSimdVectorrequired

Any vector.

returnsi32x4

The bytes as 4 i32 lanes.

asU16x8

The same sixteen bytes read as a u16x8, one bitcast.

const asU16x8: (v: SimdVector) => u16x8
vSimdVectorrequired

Any vector.

returnsu16x8

The bytes as 8 u16 lanes.

asU32x4

The same sixteen bytes read as a u32x4, one bitcast.

const asU32x4: (v: SimdVector) => u32x4
vSimdVectorrequired

Any vector.

returnsu32x4

The bytes as 4 u32 lanes.

asU8x16

The same sixteen bytes read as a u8x16, one bitcast.

const asU8x16: (v: SimdVector) => u8x16
vSimdVectorrequired

Any vector.

returnsu8x16

The bytes as 16 u8 lanes.

bitmask

The mask as bits: a bitcast of <N x i1> to iN, zero-extended. Storable where the mask is not.

const bitmask: (m: SimdMask) => i32
mSimdMaskrequired

A mask.

returnsi32

An i32 with bit k set when lane k is.

div

The lane-wise quotient of two float vectors, fdiv with no fast-math flags. An integer vector is refused (NL2623).

const div: <V extends FloatVector>(a: V, b: V) => V
aVrequired

An f32x4 or f64x2.

bVrequired

A vector of a's type.

returnsV

Each lane's quotient.

eq

Whether each lane of a is equal to the lane of b: icmp, unsigned on a u* lane, or on float lanes fcmp oeq.

const eq: <V extends SimdVector>(a: V, b: V) => V["__mask"]
aVrequired

Any vector (NL2638 for a scalar).

bVrequired

A vector of a's type.

returnsV["__mask"]

The mask of the lane width: mask8x16, mask16x8, mask32x4 or mask64x2.

extract

Lane k of v, one extractelement at a constant.

const extract: <V extends SimdVector>(
  v: V,
  k: i32,
) => V["__lane"]
vVrequired

The vector (NL2582 when it is not one).

ki32required

An integer literal from 0 to one less than the lane count (NL2580 for a variable, NL2583 for a literal past the end).

returnsV["__lane"]

The lane, of the lane type.

f32x4

An f32x4 of 4 lanes, one argument per lane, lane 0 first.

const f32x4: (a0: f32, a1: f32, a2: f32, a3: f32) => f32x4
a0f32required

Lane 0, an f32.

a1f32required

Lane 1, an f32.

a2f32required

Lane 2, an f32.

a3f32required

Lane 3, an f32.

returnsf32x4

The vector.

f64x2

An f64x2 of 2 lanes, one argument per lane, lane 0 first.

const f64x2: (a0: f64, a1: f64) => f64x2
a0f64required

Lane 0, an f64.

a1f64required

Lane 1, an f64.

returnsf64x2

The vector.

ge

Whether each lane of a is at least the lane of b: icmp, unsigned on a u* lane, or on float lanes ordered fcmp.

const ge: <V extends SimdVector>(a: V, b: V) => V["__mask"]
aVrequired

Any vector (NL2638 for a scalar).

bVrequired

A vector of a's type.

returnsV["__mask"]

The mask of the lane width: mask8x16, mask16x8, mask32x4 or mask64x2.

gt

Whether each lane of a is greater than the lane of b: icmp, unsigned on a u* lane, or on float lanes ordered fcmp.

const gt: <V extends SimdVector>(a: V, b: V) => V["__mask"]
aVrequired

Any vector (NL2638 for a scalar).

bVrequired

A vector of a's type.

returnsV["__mask"]

The mask of the lane width: mask8x16, mask16x8, mask32x4 or mask64x2.

i32x4

An i32x4 of 4 lanes, one argument per lane, lane 0 first.

const i32x4: (a0: i32, a1: i32, a2: i32, a3: i32) => i32x4
a0i32required

Lane 0, an i32.

a1i32required

Lane 1, an i32.

a2i32required

Lane 2, an i32.

a3i32required

Lane 3, an i32.

returnsi32x4

The vector.

le

Whether each lane of a is at most the lane of b: icmp, unsigned on a u* lane, or on float lanes ordered fcmp.

const le: <V extends SimdVector>(a: V, b: V) => V["__mask"]
aVrequired

Any vector (NL2638 for a scalar).

bVrequired

A vector of a's type.

returnsV["__mask"]

The mask of the lane width: mask8x16, mask16x8, mask32x4 or mask64x2.

loadF32x4

xs[i] to xs[i + 3] as one f32x4, bounds-checked once for the whole vector: a load whose last lane is past the end panics before it reads, naming a lane past the end (the first when it is out of range, else the last) and the length, as xs[i] does.

const loadF32x4: (xs: readonly f32[], i: i32) => f32x4
xsreadonly f32[]required

An f32[], exactly the lane type (NL2579 otherwise); a readonly array may be loaded from.

ii32required

The index of lane 0, an i32.

returnsf32x4

The vector.

loadF64x2

xs[i] to xs[i + 1] as one f64x2, bounds-checked once for the whole vector: a load whose last lane is past the end panics before it reads, naming a lane past the end (the first when it is out of range, else the last) and the length, as xs[i] does.

const loadF64x2: (xs: readonly f64[], i: i32) => f64x2
xsreadonly f64[]required

An f64[], exactly the lane type (NL2579 otherwise); a readonly array may be loaded from.

ii32required

The index of lane 0, an i32.

returnsf64x2

The vector.

loadI32x4

xs[i] to xs[i + 3] as one i32x4, bounds-checked once for the whole vector: a load whose last lane is past the end panics before it reads, naming a lane past the end (the first when it is out of range, else the last) and the length, as xs[i] does.

const loadI32x4: (xs: readonly i32[], i: i32) => i32x4
xsreadonly i32[]required

An i32[], exactly the lane type (NL2579 otherwise); a readonly array may be loaded from.

ii32required

The index of lane 0, an i32.

returnsi32x4

The vector.

loadU16x8

xs[i] to xs[i + 7] as one u16x8, bounds-checked once for the whole vector: a load whose last lane is past the end panics before it reads, naming a lane past the end (the first when it is out of range, else the last) and the length, as xs[i] does.

const loadU16x8: (xs: readonly u16[], i: i32) => u16x8
xsreadonly u16[]required

A u16[], exactly the lane type (NL2579 otherwise); a readonly array may be loaded from.

ii32required

The index of lane 0, an i32.

returnsu16x8

The vector.

loadU32x4

xs[i] to xs[i + 3] as one u32x4, bounds-checked once for the whole vector: a load whose last lane is past the end panics before it reads, naming a lane past the end (the first when it is out of range, else the last) and the length, as xs[i] does.

const loadU32x4: (xs: readonly u32[], i: i32) => u32x4
xsreadonly u32[]required

A u32[], exactly the lane type (NL2579 otherwise); a readonly array may be loaded from.

ii32required

The index of lane 0, an i32.

returnsu32x4

The vector.

loadU8x16

xs[i] to xs[i + 15] as one u8x16, bounds-checked once for the whole vector: a load whose last lane is past the end panics before it reads, naming a lane past the end (the first when it is out of range, else the last) and the length, as xs[i] does.

const loadU8x16: (xs: readonly u8[], i: i32) => u8x16
xsreadonly u8[]required

A u8[], exactly the lane type (NL2579 otherwise); a readonly array may be loaded from.

ii32required

The index of lane 0, an i32.

returnsu8x16

The vector.

lt

Whether each lane of a is less than the lane of b: icmp, unsigned on a u* lane, or on float lanes ordered fcmp.

const lt: <V extends SimdVector>(a: V, b: V) => V["__mask"]
aVrequired

Any vector (NL2638 for a scalar).

bVrequired

A vector of a's type.

returnsV["__mask"]

The mask of the lane width: mask8x16, mask16x8, mask32x4 or mask64x2.

max

The greater of each pair of lanes: llvm.umax or llvm.smax on integer lanes, llvm.maximum on float lanes, where a NaN lane answers NaN and -0 is below +0, as Math.max.

const max: <V extends SimdVector>(a: V, b: V) => V
aVrequired

Any vector.

bVrequired

A vector of a's type (NL2623 otherwise).

returnsV

Each lane's greater.

min

The lesser of each pair of lanes: llvm.umin or llvm.smin on integer lanes, llvm.minimum on float lanes, where a NaN lane answers NaN and -0 is below +0, as Math.min.

const min: <V extends SimdVector>(a: V, b: V) => V
aVrequired

Any vector.

bVrequired

A vector of a's type (NL2623 otherwise).

returnsV

Each lane's lesser.

mul

The lane-wise product of two float vectors, fmul with no fast-math flags. An integer vector is refused (NL2623): its form is mulWrapping.

const mul: <V extends FloatVector>(a: V, b: V) => V
aVrequired

An f32x4 or f64x2.

bVrequired

A vector of a's type.

returnsV

Each lane's product.

mulWrapping

The lane-wise product of two integer vectors, mul with no nsw or nuw: each lane wraps at the lane width.

const mulWrapping: <V extends IntegerVector>(
  a: V,
  b: V,
) => V
aVrequired

A u8x16, u16x8, i32x4 or u32x4.

bVrequired

A vector of a's type.

returnsV

Each lane's product, wrapped.

ne

Whether each lane of a is not equal to the lane of b: icmp, unsigned on a u* lane, or on float lanes fcmp une, unordered, so a NaN lane is not equal.

const ne: <V extends SimdVector>(a: V, b: V) => V["__mask"]
aVrequired

Any vector (NL2638 for a scalar).

bVrequired

A vector of a's type.

returnsV["__mask"]

The mask of the lane width: mask8x16, mask16x8, mask32x4 or mask64x2.

neg

Each float lane negated, fneg: the sign bit flipped.

const neg: <V extends FloatVector>(a: V) => V
aVrequired

An f32x4 or f64x2.

returnsV

The negated vector.

not

Every bit flipped, xor with all-ones, on integer lanes or a mask.

const not: <V extends IntegerVector | SimdMask>(a: V) => V
aVrequired

An integer vector or a mask.

returnsV

The complement, of a's type.

or

Bitwise or, on integer lanes or lane by lane on two masks.

const or: <V extends IntegerVector | SimdMask>(
  a: V,
  b: V,
) => V
aVrequired

An integer vector or a mask.

bVrequired

A vector or mask of a's type.

returnsV

The bitwise or, of a's type.

replace

A new vector: v with lane k set to x, one insertelement at a constant. v is unchanged; under Node replace copies.

const replace: <V extends SimdVector>(
  v: V,
  k: i32,
  x: V["__lane"],
) => V
vVrequired

The vector.

ki32required

An integer literal lane index in range, as extract takes.

xV["__lane"]required

The new lane, of the lane type.

returnsV

The new vector.

rotl

Each lane rotated left by count, llvm.fshl with v as both halves. Signed and unsigned lanes rotate alike.

const rotl: <V extends IntegerVector>(v: V, count: i32) => V
vVrequired

A u8x16, u16x8, i32x4 or u32x4.

counti32required

An integer literal below the lane width: 0 to 7, 15 or 31 (NL2630 for a variable, NL2631 for the width or more).

returnsV

The vector of rotated lanes.

rotr

Each lane rotated right by count, llvm.fshr with v as both halves. Signed and unsigned lanes rotate alike.

const rotr: <V extends IntegerVector>(v: V, count: i32) => V
vVrequired

A u8x16, u16x8, i32x4 or u32x4.

counti32required

An integer literal below the lane width: 0 to 7, 15 or 31 (NL2630 for a variable, NL2631 for the width or more).

returnsV

The vector of rotated lanes.

select

Lane k of a where lane k of m is set, else lane k of b, one select.

const select: <V extends SimdVector>(
  m: V["__mask"],
  a: V,
  b: V,
) => V
mV["__mask"]required

The mask of a's lane width, the one a compare of two such vectors answers (NL2629 otherwise).

aVrequired

The vector lanes come from where m is set.

bVrequired

A vector of a's type, for the lanes where m is clear.

returnsV

The blended vector.

shl

Each lane shifted left by count, shl.

const shl: <V extends IntegerVector>(v: V, count: i32) => V
vVrequired

A u8x16, u16x8, i32x4 or u32x4.

counti32required

An integer literal below the lane width: 0 to 7, 15 or 31 (NL2630 for a variable, NL2631 for the width or more).

returnsV

The vector of shifted lanes.

shr

Each lane shifted right by count: lshr, logical, on u8x16, u16x8 and u32x4, and ashr, copying the sign, on i32x4.

const shr: <V extends IntegerVector>(v: V, count: i32) => V
vVrequired

A u8x16, u16x8, i32x4 or u32x4.

counti32required

An integer literal below the lane width: 0 to 7, 15 or 31 (NL2630 for a variable, NL2631 for the width or more).

returnsV

The vector of shifted lanes.

shuffle

Lanes picked from a then b, one shufflevector.

const shuffle: <V extends SimdVector>(
  a: V,
  b: V,
  ...lanes: i32[],
) => V
aVrequired

The vector whose lanes are indices 0 to N-1.

bVrequired

A vector of a's type, whose lanes are indices N to 2N-1.

...lanesi32[]required

One integer literal per lane of the answer, each from 0 to 2N-1; a wrong count, a variable or an index past the end is refused (NL2632 to NL2635).

returnsV

The vector of the picked lanes, lane 0 first.

splatF32x4

x in all 4 lanes: one insertelement and a shufflevector with a zeroinitializer mask.

const splatF32x4: (x: f32) => f32x4
xf32required

The lane value, an f32.

returnsf32x4

The vector.

splatF64x2

x in all 2 lanes: one insertelement and a shufflevector with a zeroinitializer mask.

const splatF64x2: (x: f64) => f64x2
xf64required

The lane value, an f64.

returnsf64x2

The vector.

splatI32x4

x in all 4 lanes: one insertelement and a shufflevector with a zeroinitializer mask.

const splatI32x4: (x: i32) => i32x4
xi32required

The lane value, an i32.

returnsi32x4

The vector.

splatU16x8

x in all 8 lanes: one insertelement and a shufflevector with a zeroinitializer mask.

const splatU16x8: (x: u16) => u16x8
xu16required

The lane value, a u16.

returnsu16x8

The vector.

splatU32x4

x in all 4 lanes: one insertelement and a shufflevector with a zeroinitializer mask.

const splatU32x4: (x: u32) => u32x4
xu32required

The lane value, a u32.

returnsu32x4

The vector.

splatU8x16

x in all 16 lanes: one insertelement and a shufflevector with a zeroinitializer mask.

const splatU8x16: (x: u8) => u8x16
xu8required

The lane value, a u8.

returnsu8x16

The vector.

sqrt

The square root of each float lane, llvm.sqrt.

const sqrt: <V extends FloatVector>(a: V) => V
aVrequired

An f32x4 or f64x2.

returnsV

Each lane's square root.

store

The lanes of v into xs[i] to xs[i + N - 1], N the lane count, under the same single check as a load, then one store; a statement.

const store: <V extends SimdVector>(
  v: V,
  xs: V["__lane"][],
  i: i32,
) => void
vVrequired

The vector.

xsV["__lane"][]required

An array of exactly v's lane type, not readonly.

ii32required

The index lane 0 goes to, an i32.

sub

The lane-wise difference of two float vectors, fsub with no fast-math flags. An integer vector is refused (NL2623): its form is subWrapping.

const sub: <V extends FloatVector>(a: V, b: V) => V
aVrequired

An f32x4 or f64x2.

bVrequired

A vector of a's type.

returnsV

Each lane's difference.

subWrapping

The lane-wise difference of two integer vectors, sub with no nsw or nuw: each lane wraps at the lane width.

const subWrapping: <V extends IntegerVector>(
  a: V,
  b: V,
) => V
aVrequired

A u8x16, u16x8, i32x4 or u32x4.

bVrequired

A vector of a's type.

returnsV

Each lane's difference, wrapped.

sum

The lanes of a u8x16 or u16x8 added in an i32, zext then llvm.vector.reduce.add: exact, since it cannot overflow. An i32x4 or u32x4 can, and is refused (NL2636): its total is sumWrapping.

const sum: (v: u8x16 | u16x8) => i32
vu8x16 | u16x8required

A u8x16 or u16x8.

returnsi32

The exact total.

The lanes of an f32x4 added from lane 0 to lane 3, llvm.vector.reduce.fadd without reassoc, so the bits are the same on every target.

const sum: (v: f32x4) => f32
vf32x4required

An f32x4.

returnsf32

The total, an f32.

The lanes of an f64x2 added, lane 0 first, likewise in order.

const sum: (v: f64x2) => f64
vf64x2required

An f64x2.

returnsf64

The total, an f64.

sumWrapping

The lanes of an i32x4 added, llvm.vector.reduce.add, wrapping as the lanes do.

const sumWrapping: (v: i32x4) => i32
vi32x4required

An i32x4.

returnsi32

The wrapped total, an i32.

The lanes of a u32x4 added, wrapping.

const sumWrapping: (v: u32x4) => u32
vu32x4required

A u32x4.

returnsu32

The wrapped total, a u32.

u16x8

A u16x8 of 8 lanes, one argument per lane, lane 0 first.

const u16x8: (
  a0: u16,
  a1: u16,
  a2: u16,
  a3: u16,
  a4: u16,
  a5: u16,
  a6: u16,
  a7: u16,
) => u16x8
a0u16required

Lane 0, a u16.

a1u16required

Lane 1, a u16.

a2u16required

Lane 2, a u16.

a3u16required

Lane 3, a u16.

a4u16required

Lane 4, a u16.

a5u16required

Lane 5, a u16.

a6u16required

Lane 6, a u16.

a7u16required

Lane 7, a u16.

returnsu16x8

The vector.

u32x4

A u32x4 of 4 lanes, one argument per lane, lane 0 first.

const u32x4: (a0: u32, a1: u32, a2: u32, a3: u32) => u32x4
a0u32required

Lane 0, a u32.

a1u32required

Lane 1, a u32.

a2u32required

Lane 2, a u32.

a3u32required

Lane 3, a u32.

returnsu32x4

The vector.

u8x16

A u8x16 of sixteen lanes: one insertelement per lane, which opt folds to a constant vector when every lane is one.

const u8x16: (
  a0: u8,
  a1: u8,
  a2: u8,
  a3: u8,
  a4: u8,
  a5: u8,
  a6: u8,
  a7: u8,
  a8: u8,
  a9: u8,
  a10: u8,
  a11: u8,
  a12: u8,
  a13: u8,
  a14: u8,
  a15: u8,
) => u8x16
a0u8required

Lane 0, a u8.

a1u8required

Lane 1, a u8.

a2u8required

Lane 2, a u8.

a3u8required

Lane 3, a u8.

a4u8required

Lane 4, a u8.

a5u8required

Lane 5, a u8.

a6u8required

Lane 6, a u8.

a7u8required

Lane 7, a u8.

a8u8required

Lane 8, a u8.

a9u8required

Lane 9, a u8.

a10u8required

Lane 10, a u8.

a11u8required

Lane 11, a u8.

a12u8required

Lane 12, a u8.

a13u8required

Lane 13, a u8.

a14u8required

Lane 14, a u8.

a15u8required

Lane 15, a u8.

returnsu8x16

The vector.

xor

Bitwise xor, on integer lanes or lane by lane on two masks.

const xor: <V extends IntegerVector | SimdMask>(
  a: V,
  b: V,
) => V
aVrequired

An integer vector or a mask.

bVrequired

A vector or mask of a's type.

returnsV

The bitwise xor, of a's type.

Interfaces

f32x4

Sixteen bytes as 4 f32 lanes, an LLVM <4 x float>. Opaque, as u8x16 is.

interface f32x4
Member
readonly __lane: f32 The lane type, f32, for signatures to name. Not a field.
readonly __mask: mask32x4 The mask a compare of two f32x4 answers, mask32x4, for signatures to name. Not a field.
readonly __nishSimd: "f32x4" The type's brand, which keeps the six vector types apart. Not a field: it has no value.

f64x2

Sixteen bytes as 2 f64 lanes, an LLVM <2 x double>. Opaque, as u8x16 is.

interface f64x2
Member
readonly __lane: f64 The lane type, f64, for signatures to name. Not a field.
readonly __mask: mask64x2 The mask a compare of two f64x2 answers, mask64x2, for signatures to name. Not a field.
readonly __nishSimd: "f64x2" The type's brand, which keeps the six vector types apart. Not a field: it has no value.

i32x4

Sixteen bytes as 4 i32 lanes, an LLVM <4 x i32>. Opaque, as u8x16 is.

interface i32x4
Member
readonly __lane: i32 The lane type, i32, for signatures to name. Not a field.
readonly __mask: mask32x4 The mask a compare of two i32x4 answers, mask32x4, for signatures to name. Not a field.
readonly __nishSimd: "i32x4" The type's brand, which keeps the six vector types apart. Not a field: it has no value.

mask16x8

One boolean per lane of 8, an LLVM <8 x i1>, which a lane-wise compare of u16x8 answers. Held and made as mask8x16 is.

interface mask16x8
Member
readonly __nishMask: "mask16x8" The type's brand, which keeps the four mask types apart. Not a field.

mask32x4

One boolean per lane of 4, an LLVM <4 x i1>, which a lane-wise compare of i32x4, u32x4 and f32x4 answers. Held and made as mask8x16 is.

interface mask32x4
Member
readonly __nishMask: "mask32x4" The type's brand, which keeps the four mask types apart. Not a field.

mask64x2

One boolean per lane of 2, an LLVM <2 x i1>, which a lane-wise compare of f64x2 answers. Held and made as mask8x16 is.

interface mask64x2
Member
readonly __nishMask: "mask64x2" The type's brand, which keeps the four mask types apart. Not a field.

mask8x16

One boolean per lane of 16, an LLVM <16 x i1>, which a lane-wise compare of u8x16 answers. Under Node an array of booleans. nish keeps a mask in a local, a parameter or a return of a function the module keeps, and nowhere else; it has no constructor.

interface mask8x16
Member
readonly __nishMask: "mask8x16" The type's brand, which keeps the four mask types apart. Not a field.

u16x8

Sixteen bytes as 8 u16 lanes, an LLVM <8 x i16>. Opaque, as u8x16 is.

interface u16x8
Member
readonly __lane: u16 The lane type, u16, for signatures to name. Not a field.
readonly __mask: mask16x8 The mask a compare of two u16x8 answers, mask16x8, for signatures to name. Not a field.
readonly __nishSimd: "u16x8" The type's brand, which keeps the six vector types apart. Not a field: it has no value.

u32x4

Sixteen bytes as 4 u32 lanes, an LLVM <4 x i32>. Opaque, as u8x16 is.

interface u32x4
Member
readonly __lane: u32 The lane type, u32, for signatures to name. Not a field.
readonly __mask: mask32x4 The mask a compare of two u32x4 answers, mask32x4, for signatures to name. Not a field.
readonly __nishSimd: "u32x4" The type's brand, which keeps the six vector types apart. Not a field: it has no value.

u8x16

Sixteen bytes as 16 u8 lanes, an LLVM <16 x i8>. Opaque: TypeScript refuses + on one, as nish does, but lets === and < through, which nish refuses. Under Node it is a typed array made once and never written after.

interface u8x16
Member
readonly __lane: u8 The lane type, u8, for signatures to name. Not a field.
readonly __mask: mask8x16 The mask a compare of two u8x16 answers, mask8x16, for signatures to name. Not a field.
readonly __nishSimd: "u8x16" The type's brand, which keeps the six vector types apart. Not a field: it has no value.

Types

FloatVector

The two with float lanes.

type FloatVector = f32x4 | f64x2

IntegerVector

The four with integer lanes.

type IntegerVector = u8x16 | u16x8 | i32x4 | u32x4

SimdMask

Any of the four mask types.

type SimdMask = mask8x16 | mask16x8 | mask32x4 | mask64x2

SimdVector

Any of the six vector types.

type SimdVector = u8x16 | u16x8 | i32x4 | u32x4 | f32x4 | f64x2