rust-lang/portable-simd#250: Add bitmask i{N <8} -> u8 impls
...and copy the notes for why they're legal.
This commit is contained in:
parent
a5789d17bf
commit
30975615b7
@ -130,6 +130,14 @@ extern "platform-intrinsic" {
|
||||
pub(crate) fn simd_reduce_xor<T, U>(x: T) -> U;
|
||||
|
||||
// truncate integer vector to bitmask
|
||||
// `fn simd_bitmask(vector) -> unsigned integer` takes a vector of integers and
|
||||
// returns either an unsigned integer or array of `u8`.
|
||||
// Every element in the vector becomes a single bit in the returned bitmask.
|
||||
// If the vector has less than 8 lanes, a u8 is returned with zeroed trailing bits.
|
||||
// The bit order of the result depends on the byte endianness. LSB-first for little
|
||||
// endian and MSB-first for big endian.
|
||||
//
|
||||
// UB if called on a vector with values other than 0 and -1.
|
||||
#[allow(unused)]
|
||||
pub(crate) fn simd_bitmask<T, U>(x: T) -> U;
|
||||
|
||||
|
@ -50,6 +50,9 @@ macro_rules! impl_integer_intrinsic {
|
||||
}
|
||||
|
||||
impl_integer_intrinsic! {
|
||||
unsafe impl ToBitMask<BitMask=u8> for Mask<_, 1>
|
||||
unsafe impl ToBitMask<BitMask=u8> for Mask<_, 2>
|
||||
unsafe impl ToBitMask<BitMask=u8> for Mask<_, 4>
|
||||
unsafe impl ToBitMask<BitMask=u8> for Mask<_, 8>
|
||||
unsafe impl ToBitMask<BitMask=u16> for Mask<_, 16>
|
||||
unsafe impl ToBitMask<BitMask=u32> for Mask<_, 32>
|
||||
|
Loading…
x
Reference in New Issue
Block a user