[−][src]Macro safe_arch::shuffle_i32_m128i
Shuffles the i32
lanes around.
This is a macro because the shuffle pattern must be a compile time constant, and Rust doesn't currently support that for functions.
$a
must obviously be anm128i
expression.- Each of the lane selection values is a lane index (
0..4
). They can be any integer type as long as all four lane indexes are the same type. Out of bounds index values are wrapped to just the low 2 bits. - The lane selection values are combined into a private
const
which is computed at compile time and then used at runtime. This means that you can use literals, but you can also use the names of other constants or even aconst fn
expression, if that is somehow is useful to you.
let a = m128i::from([6, 7, 8, 9]); // let c = shuffle_i32_m128i!(a, 0, 0, 0, 0); assert_eq!(<[i32; 4]>::from(c), [6, 6, 6, 6]); // let c = shuffle_i32_m128i!(a, 0, 1, 2, 3); assert_eq!(<[i32; 4]>::from(c), [6, 7, 8, 9]); // let c = shuffle_i32_m128i!(a, 0, 2, 2, 1); assert_eq!(<[i32; 4]>::from(c), [6, 8, 8, 7]);