[−][src]Macro safe_arch::shuffle_i16_high_lanes_m128i
Shuffles the higher i16
lanes, low lanes unaffected.
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
) within the high lanes (eg: 0 to this macro is the 5thi16
lane ). 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([1_i16, 2, 3, 4, 5, 6, 7, 8]); // let c = shuffle_i16_high_lanes_m128i!(a, 0, 0, 0, 0); assert_eq!(<[i16; 8]>::from(c), [1_i16, 2, 3, 4, 5, 5, 5, 5]); // let c = shuffle_i16_high_lanes_m128i!(a, 0, 1, 2, 3); assert_eq!(<[i16; 8]>::from(c), [1_i16, 2, 3, 4, 5, 6, 7, 8]); // let c = shuffle_i16_high_lanes_m128i!(a, 0, 2, 2, 1); assert_eq!(<[i16; 8]>::from(c), [1_i16, 2, 3, 4, 5, 7, 7, 6]);