pub trait Simd: Copy {
type V: Copy;
const BYTES: usize;
const PX: usize;
Show 112 methods
// Required methods
fn zero(self) -> Self::V;
fn splat8(self, v: u8) -> Self::V;
fn splat16(self, v: u16) -> Self::V;
fn splat32(self, v: u32) -> Self::V;
fn splat64(self, v: u64) -> Self::V;
fn splatf(self, v: f32) -> Self::V;
fn load(self, b: &[u8]) -> Self::V;
fn store(self, b: &mut [u8], v: Self::V);
fn load_px(self, b: &[u8]) -> Self::V;
fn store_px(self, b: &mut [u8], v: Self::V);
fn bcast_px(self, b: &[u8]) -> Self::V;
fn load_raw(self, b: &[u8]) -> Self::V;
fn store_raw(self, b: &mut [u8], v: Self::V);
fn widen_px(self, v: Self::V) -> Self::V;
fn load_lane32(self, b: &[u8]) -> Self::V;
fn load_i32(self, b: &[i32]) -> Self::V;
fn store_i32(self, b: &mut [i32], v: Self::V);
fn from_i32(self, v: i32) -> Self::V;
fn to_i32(self, v: Self::V) -> i32;
fn add8(self, a: Self::V, b: Self::V) -> Self::V;
fn sub8(self, a: Self::V, b: Self::V) -> Self::V;
fn addus8(self, a: Self::V, b: Self::V) -> Self::V;
fn subus8(self, a: Self::V, b: Self::V) -> Self::V;
fn maxu8(self, a: Self::V, b: Self::V) -> Self::V;
fn minu8(self, a: Self::V, b: Self::V) -> Self::V;
fn cmpeq8(self, a: Self::V, b: Self::V) -> Self::V;
fn avgu8(self, a: Self::V, b: Self::V) -> Self::V;
fn movemask8(self, a: Self::V) -> u32;
fn unpacklo8(self, a: Self::V, b: Self::V) -> Self::V;
fn unpackhi8(self, a: Self::V, b: Self::V) -> Self::V;
fn packus16(self, a: Self::V, b: Self::V) -> Self::V;
fn add16(self, a: Self::V, b: Self::V) -> Self::V;
fn sub16(self, a: Self::V, b: Self::V) -> Self::V;
fn subus16(self, a: Self::V, b: Self::V) -> Self::V;
fn mullo16(self, a: Self::V, b: Self::V) -> Self::V;
fn mulhiu16(self, a: Self::V, b: Self::V) -> Self::V;
fn mins16(self, a: Self::V, b: Self::V) -> Self::V;
fn maxs16(self, a: Self::V, b: Self::V) -> Self::V;
fn cmpeq16(self, a: Self::V, b: Self::V) -> Self::V;
fn cmpgts16(self, a: Self::V, b: Self::V) -> Self::V;
fn srl16<const N: i32>(self, a: Self::V) -> Self::V;
fn sll16<const N: i32>(self, a: Self::V) -> Self::V;
fn shuf16<const IMM: i32>(self, a: Self::V) -> Self::V;
fn unpacklo16(self, a: Self::V, b: Self::V) -> Self::V;
fn unpackhi16(self, a: Self::V, b: Self::V) -> Self::V;
fn packs32(self, a: Self::V, b: Self::V) -> Self::V;
fn madd16(self, a: Self::V, b: Self::V) -> Self::V;
fn add32(self, a: Self::V, b: Self::V) -> Self::V;
fn sub32(self, a: Self::V, b: Self::V) -> Self::V;
fn cmpeq32(self, a: Self::V, b: Self::V) -> Self::V;
fn cmpgts32(self, a: Self::V, b: Self::V) -> Self::V;
fn movemask32(self, a: Self::V) -> u32;
fn shuf32<const IMM: i32>(self, a: Self::V) -> Self::V;
fn shufps<const IMM: i32>(self, a: Self::V, b: Self::V) -> Self::V;
fn srl32<const N: i32>(self, a: Self::V) -> Self::V;
fn sll32<const N: i32>(self, a: Self::V) -> Self::V;
fn sra32<const N: i32>(self, a: Self::V) -> Self::V;
fn bsll<const N: i32>(self, a: Self::V) -> Self::V;
fn bsrl<const N: i32>(self, a: Self::V) -> Self::V;
fn and(self, a: Self::V, b: Self::V) -> Self::V;
fn andnot(self, a: Self::V, b: Self::V) -> Self::V;
fn or(self, a: Self::V, b: Self::V) -> Self::V;
fn xor(self, a: Self::V, b: Self::V) -> Self::V;
fn cvt_i32_f32(self, a: Self::V) -> Self::V;
fn cvtt_f32_i32(self, a: Self::V) -> Self::V;
fn cvtr_f32_i32(self, a: Self::V) -> Self::V;
fn addf(self, a: Self::V, b: Self::V) -> Self::V;
fn subf(self, a: Self::V, b: Self::V) -> Self::V;
fn mulf(self, a: Self::V, b: Self::V) -> Self::V;
fn divf(self, a: Self::V, b: Self::V) -> Self::V;
fn splatd(self, v: f64) -> Self::V;
fn addd(self, a: Self::V, b: Self::V) -> Self::V;
fn subd(self, a: Self::V, b: Self::V) -> Self::V;
fn muld(self, a: Self::V, b: Self::V) -> Self::V;
fn divd(self, a: Self::V, b: Self::V) -> Self::V;
fn sqrtd(self, a: Self::V) -> Self::V;
fn maxd(self, a: Self::V, b: Self::V) -> Self::V;
fn mind(self, a: Self::V, b: Self::V) -> Self::V;
fn cmpltd(self, a: Self::V, b: Self::V) -> Self::V;
fn cvt_i32_f64(self, a: Self::V) -> Self::V;
fn cvtt_f64_i32(self, a: Self::V) -> Self::V;
fn store_i32_half(self, b: &mut [i32], v: Self::V);
fn sra16<const N: i32>(self, a: Self::V) -> Self::V;
fn mulhis16(self, a: Self::V, b: Self::V) -> Self::V;
fn packs16(self, a: Self::V, b: Self::V) -> Self::V;
fn load_i16(self, b: &[i16]) -> Self::V;
fn store_i16(self, b: &mut [i16], v: Self::V);
fn store_lanes2(self, b: &mut [u8], lo: Self::V, hi: Self::V);
fn load_lanes2(self, b: &[u8]) -> (Self::V, Self::V);
fn load_i16_lanes(self, a: &[i16], b: &[i16]) -> Self::V;
fn store_raw_lanes(self, a: &mut [u8], b: &mut [u8], v: Self::V);
fn sadu8(self, a: Self::V, b: Self::V) -> Self::V;
fn add64(self, a: Self::V, b: Self::V) -> Self::V;
fn maxf(self, a: Self::V, b: Self::V) -> Self::V;
fn minf(self, a: Self::V, b: Self::V) -> Self::V;
fn sqrtf(self, a: Self::V) -> Self::V;
fn load_u16(self, b: &[u16]) -> Self::V;
fn store_u16(self, b: &mut [u16], v: Self::V);
fn load_u16_lo(self, b: &[u16]) -> Self::V;
fn store_u16_lo(self, b: &mut [u16], v: Self::V);
fn srl16x(self, a: Self::V, n: u32) -> Self::V;
fn load_f32(self, b: &[f32]) -> Self::V;
fn store_f32(self, b: &mut [f32], v: Self::V);
fn adds8(self, a: Self::V, b: Self::V) -> Self::V;
fn subs8(self, a: Self::V, b: Self::V) -> Self::V;
fn cmpltf(self, a: Self::V, b: Self::V) -> Self::V;
fn load_f32_lanes(self, a: &[f32], b: &[f32]) -> Self::V;
fn store_f32_lanes(self, a: &mut [f32], b: &mut [f32], v: Self::V);
fn packssdw(self, a: Self::V, b: Self::V) -> Self::V;
fn packuswb_px(self, v: Self::V) -> Self::V;
fn ptest_raw(self, a: Self::V, b: Self::V) -> u32;
fn ptestz_raw(self, a: Self::V, b: Self::V) -> bool;
}Expand description
operations of one register type; integer lanes are named by their width (8 / 16 / 32), signed operations end in s, unsigned in u
Required Associated Constants§
Required Associated Types§
Required Methods§
fn zero(self) -> Self::V
fn splat8(self, v: u8) -> Self::V
fn splat16(self, v: u16) -> Self::V
fn splat32(self, v: u32) -> Self::V
fn splat64(self, v: u64) -> Self::V
fn splatf(self, v: f32) -> Self::V
fn store(self, b: &mut [u8], v: Self::V)
Sourcefn store_px(self, b: &mut [u8], v: Self::V)
fn store_px(self, b: &mut [u8], v: Self::V)
pixel lanes saturated to bytes (packuswb), 4 * PX bytes
Sourcefn load_raw(self, b: &[u8]) -> Self::V
fn load_raw(self, b: &[u8]) -> Self::V
4 * PX bytes as they are (“raw” pixels: SSE2 the low 8 bytes, AVX2 the low 16)
fn store_raw(self, b: &mut [u8], v: Self::V)
Sourcefn load_lane32(self, b: &[u8]) -> Self::V
fn load_lane32(self, b: &[u8]) -> Self::V
4 bytes into the low dword of every 128-bit lane (BYTES / 4 bytes), the rest 0
fn store_i32(self, b: &mut [i32], v: Self::V)
fn to_i32(self, v: Self::V) -> i32
fn add8(self, a: Self::V, b: Self::V) -> Self::V
fn sub8(self, a: Self::V, b: Self::V) -> Self::V
fn addus8(self, a: Self::V, b: Self::V) -> Self::V
fn subus8(self, a: Self::V, b: Self::V) -> Self::V
fn maxu8(self, a: Self::V, b: Self::V) -> Self::V
fn minu8(self, a: Self::V, b: Self::V) -> Self::V
fn cmpeq8(self, a: Self::V, b: Self::V) -> Self::V
fn avgu8(self, a: Self::V, b: Self::V) -> Self::V
fn unpacklo8(self, a: Self::V, b: Self::V) -> Self::V
fn unpackhi8(self, a: Self::V, b: Self::V) -> Self::V
fn packus16(self, a: Self::V, b: Self::V) -> Self::V
fn add16(self, a: Self::V, b: Self::V) -> Self::V
fn sub16(self, a: Self::V, b: Self::V) -> Self::V
fn subus16(self, a: Self::V, b: Self::V) -> Self::V
fn mullo16(self, a: Self::V, b: Self::V) -> Self::V
fn mulhiu16(self, a: Self::V, b: Self::V) -> Self::V
fn mins16(self, a: Self::V, b: Self::V) -> Self::V
fn maxs16(self, a: Self::V, b: Self::V) -> Self::V
fn cmpeq16(self, a: Self::V, b: Self::V) -> Self::V
fn cmpgts16(self, a: Self::V, b: Self::V) -> Self::V
fn srl16<const N: i32>(self, a: Self::V) -> Self::V
fn sll16<const N: i32>(self, a: Self::V) -> Self::V
Sourcefn shuf16<const IMM: i32>(self, a: Self::V) -> Self::V
fn shuf16<const IMM: i32>(self, a: Self::V) -> Self::V
pshuflw + pshufhw with the same immediate (per 64-bit half)
fn unpacklo16(self, a: Self::V, b: Self::V) -> Self::V
fn unpackhi16(self, a: Self::V, b: Self::V) -> Self::V
fn packs32(self, a: Self::V, b: Self::V) -> Self::V
Sourcefn madd16(self, a: Self::V, b: Self::V) -> Self::V
fn madd16(self, a: Self::V, b: Self::V) -> Self::V
pmaddwd: i32 lanes = a0 * b0 + a1 * b1 of the signed 16-bit pairs
fn add32(self, a: Self::V, b: Self::V) -> Self::V
fn sub32(self, a: Self::V, b: Self::V) -> Self::V
fn cmpeq32(self, a: Self::V, b: Self::V) -> Self::V
fn cmpgts32(self, a: Self::V, b: Self::V) -> Self::V
Sourcefn movemask32(self, a: Self::V) -> u32
fn movemask32(self, a: Self::V) -> u32
bit i = top bit of dword i (BYTES / 4 bits)
Sourcefn shufps<const IMM: i32>(self, a: Self::V, b: Self::V) -> Self::V
fn shufps<const IMM: i32>(self, a: Self::V, b: Self::V) -> Self::V
shufps on integer registers: dwords 0, 1 from a, 2, 3 from b (per 128-bit lane)
fn srl32<const N: i32>(self, a: Self::V) -> Self::V
fn sll32<const N: i32>(self, a: Self::V) -> Self::V
fn sra32<const N: i32>(self, a: Self::V) -> Self::V
Sourcefn bsll<const N: i32>(self, a: Self::V) -> Self::V
fn bsll<const N: i32>(self, a: Self::V) -> Self::V
pslldq / psrldq: byte shifts per 128-bit lane
fn bsrl<const N: i32>(self, a: Self::V) -> Self::V
fn and(self, a: Self::V, b: Self::V) -> Self::V
fn or(self, a: Self::V, b: Self::V) -> Self::V
fn xor(self, a: Self::V, b: Self::V) -> Self::V
fn cvt_i32_f32(self, a: Self::V) -> Self::V
Sourcefn cvtt_f32_i32(self, a: Self::V) -> Self::V
fn cvtt_f32_i32(self, a: Self::V) -> Self::V
truncating (0x80000000 for NaN / out of range)
Sourcefn cvtr_f32_i32(self, a: Self::V) -> Self::V
fn cvtr_f32_i32(self, a: Self::V) -> Self::V
rounding to nearest even (cvtps2dq)
fn addf(self, a: Self::V, b: Self::V) -> Self::V
fn subf(self, a: Self::V, b: Self::V) -> Self::V
fn mulf(self, a: Self::V, b: Self::V) -> Self::V
fn divf(self, a: Self::V, b: Self::V) -> Self::V
fn splatd(self, v: f64) -> Self::V
fn addd(self, a: Self::V, b: Self::V) -> Self::V
fn subd(self, a: Self::V, b: Self::V) -> Self::V
fn muld(self, a: Self::V, b: Self::V) -> Self::V
fn divd(self, a: Self::V, b: Self::V) -> Self::V
fn sqrtd(self, a: Self::V) -> Self::V
fn mind(self, a: Self::V, b: Self::V) -> Self::V
Sourcefn cmpltd(self, a: Self::V, b: Self::V) -> Self::V
fn cmpltd(self, a: Self::V, b: Self::V) -> Self::V
cmpltpd: all ones where a < b (false when unordered)
Sourcefn cvt_i32_f64(self, a: Self::V) -> Self::V
fn cvt_i32_f64(self, a: Self::V) -> Self::V
cvtdq2pd: the first BYTES / 8 i32 lanes to f64
Sourcefn cvtt_f64_i32(self, a: Self::V) -> Self::V
fn cvtt_f64_i32(self, a: Self::V) -> Self::V
cvttpd2dq: f64 lanes to the first BYTES / 8 i32 lanes (truncating, 0x80000000 when out of range), the rest 0
Sourcefn store_i32_half(self, b: &mut [i32], v: Self::V)
fn store_i32_half(self, b: &mut [i32], v: Self::V)
the first BYTES / 8 i32 lanes
Sourcefn sra16<const N: i32>(self, a: Self::V) -> Self::V
fn sra16<const N: i32>(self, a: Self::V) -> Self::V
psraw: arithmetic right shift of the i16 lanes
Sourcefn mulhis16(self, a: Self::V, b: Self::V) -> Self::V
fn mulhis16(self, a: Self::V, b: Self::V) -> Self::V
pmulhw: high 16 bits of the signed 16-bit products
Sourcefn packs16(self, a: Self::V, b: Self::V) -> Self::V
fn packs16(self, a: Self::V, b: Self::V) -> Self::V
packsswb: i16 lanes of a, then b, saturated to i8
fn store_i16(self, b: &mut [i16], v: Self::V)
Sourcefn store_lanes2(self, b: &mut [u8], lo: Self::V, hi: Self::V)
fn store_lanes2(self, b: &mut [u8], lo: Self::V, hi: Self::V)
2 * BYTES bytes: per 128-bit lane k, lane k of lo then lane k of hi (SSE2: lo, hi; AVX2: vperm2i128) – 2 x 4 pixels per lane in pixel order
Sourcefn load_lanes2(self, b: &[u8]) -> (Self::V, Self::V)
fn load_lanes2(self, b: &[u8]) -> (Self::V, Self::V)
the inverse of store_lanes2: 2 * BYTES bytes -> (lo, hi)
Sourcefn load_i16_lanes(self, a: &[i16], b: &[i16]) -> Self::V
fn load_i16_lanes(self, a: &[i16], b: &[i16]) -> Self::V
8 i16 per 128-bit lane from separate sources: lane 0 from a, lane 1 from b (SSE2: a)
Sourcefn store_raw_lanes(self, a: &mut [u8], b: &mut [u8], v: Self::V)
fn store_raw_lanes(self, a: &mut [u8], b: &mut [u8], v: Self::V)
the low 8 bytes of every 128-bit lane to separate places: lane 0 to a, lane 1 to b (SSE2: a)
Sourcefn sadu8(self, a: Self::V, b: Self::V) -> Self::V
fn sadu8(self, a: Self::V, b: Self::V) -> Self::V
(main agent) psadbw: per 8-byte group the sum of |a - b| (u8) in its u64 lane
fn minf(self, a: Self::V, b: Self::V) -> Self::V
fn store_u16(self, b: &mut [u16], v: Self::V)
Sourcefn load_u16_lo(self, b: &[u16]) -> Self::V
fn load_u16_lo(self, b: &[u16]) -> Self::V
movq: 4 u16 values into the low 64 bits (the rest 0) / the low 64 bits to 4 u16 values
fn store_u16_lo(self, b: &mut [u16], v: Self::V)
Sourcefn srl16x(self, a: Self::V, n: u32) -> Self::V
fn srl16x(self, a: Self::V, n: u32) -> Self::V
psrlw with a register count: logical right shift of the 16-bit lanes by n (n > 15: 0)
fn store_f32(self, b: &mut [f32], v: Self::V)
Sourcefn adds8(self, a: Self::V, b: Self::V) -> Self::V
fn adds8(self, a: Self::V, b: Self::V) -> Self::V
paddsb: signed saturating add of the i8 lanes
Sourcefn subs8(self, a: Self::V, b: Self::V) -> Self::V
fn subs8(self, a: Self::V, b: Self::V) -> Self::V
psubsb: signed saturating subtract of the i8 lanes
Sourcefn cmpltf(self, a: Self::V, b: Self::V) -> Self::V
fn cmpltf(self, a: Self::V, b: Self::V) -> Self::V
cmpltps: all ones where a < b (false when unordered)
Sourcefn load_f32_lanes(self, a: &[f32], b: &[f32]) -> Self::V
fn load_f32_lanes(self, a: &[f32], b: &[f32]) -> Self::V
4 f32 per 128-bit lane from separate sources: lane 0 from a, lane 1 from b (SSE2: a)
Sourcefn store_f32_lanes(self, a: &mut [f32], b: &mut [f32], v: Self::V)
fn store_f32_lanes(self, a: &mut [f32], b: &mut [f32], v: Self::V)
the 4 f32 of every 128-bit lane to separate places: lane 0 to a, lane 1 to b (SSE2: a)
Sourcefn packssdw(self, a: Self::V, b: Self::V) -> Self::V
fn packssdw(self, a: Self::V, b: Self::V) -> Self::V
packs32 (packssdw), on AVX2 without the clamps
Sourcefn packuswb_px(self, v: Self::V) -> Self::V
fn packuswb_px(self, v: Self::V) -> Self::V
pixel lanes to raw pixels: packuswb (+ vpermq 0x08 on AVX2) as in store_px, on AVX2 without the clamps; the inverse of widen_px
Sourcefn ptest_raw(self, a: Self::V, b: Self::V) -> u32
fn ptest_raw(self, a: Self::V, b: Self::V) -> u32
ptest on the raw-pixel bytes (SSE2: the low 8, AVX2: the low 16): 1 when a & b == 0 (ZF), else 2 when !a & b == 0 (CF), else 0. AVX2: vptest + jz + jnc, the CF case falls through (inline assembly: core::arch writes ptest as or-reductions, and LLVM then often builds shuffle / reduce sequences or loses the CF test); branch on the result, the branches thread through
Sourcefn ptestz_raw(self, a: Self::V, b: Self::V) -> bool
fn ptestz_raw(self, a: Self::V, b: Self::V) -> bool
ptest ZF on the raw-pixel bytes: a & b == 0 (AVX2: vptest + jz)
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".