SIMD module

Simd_128

unionSource

One 16-byte block viewed as every lane layout that fits it: _u8 (16 lanes) through _u64 (2 lanes), _float32 (4) and _float64 (2). All members share the same bytes, so writing one lane type and reading another reinterprets the bits.

This is a type-punning view and not a vector register; no procedure takes it directly, but each member is a SIMD_Array and takes part in all of them. Lanes are in memory order, so on a little-endian target (every supported one) lane 0 of _u8 is the low byte of lane 0 of _u32.

ExampleOpen in playground ↗
block: Simd_128;
block._u32.data[0] = 0x04030201;
assert(block._u8.data[0] == 1 && block._u8.data[3] == 4);
assert(size_of(Simd_128) == 16);

Fields

_u8: SIMD_Array(16, u8)
_s8: SIMD_Array(16, s8)
_u16: SIMD_Array(8, u16)
_s16: SIMD_Array(8, s16)
_u32: SIMD_Array(4, u32)
_s32: SIMD_Array(4, s32)
_u64: SIMD_Array(2, u64)
_s64: SIMD_Array(2, s64)
_float32: SIMD_Array(4, float32)
_float64: SIMD_Array(2, float64)

See also