diff options
| author | Jubilee <46493976+workingjubilee@users.noreply.github.com> | 2022-03-01 16:10:49 -0800 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2022-03-01 16:10:49 -0800 |
| commit | 30975615b7c206ee96eddbf84fc0f11ee896f849 (patch) | |
| tree | 6dc1ae2b924188553d1fcefd0a922cc96730d93a | |
| parent | a5789d17bfc8bb794ea6e3f1497b8026d07edd60 (diff) | |
| download | rust-30975615b7c206ee96eddbf84fc0f11ee896f849.tar.gz rust-30975615b7c206ee96eddbf84fc0f11ee896f849.zip | |
rust-lang/portable-simd#250: Add bitmask i{N <8} -> u8 impls
...and copy the notes for why they're legal.
| -rw-r--r-- | crates/core_simd/src/intrinsics.rs | 8 | ||||
| -rw-r--r-- | crates/core_simd/src/masks/to_bitmask.rs | 3 |
2 files changed, 11 insertions, 0 deletions
diff --git a/crates/core_simd/src/intrinsics.rs b/crates/core_simd/src/intrinsics.rs index e150946c705..47edff4a66a 100644 --- a/crates/core_simd/src/intrinsics.rs +++ b/crates/core_simd/src/intrinsics.rs @@ -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; diff --git a/crates/core_simd/src/masks/to_bitmask.rs b/crates/core_simd/src/masks/to_bitmask.rs index 1c2037764c1..c263f6a4eec 100644 --- a/crates/core_simd/src/masks/to_bitmask.rs +++ b/crates/core_simd/src/masks/to_bitmask.rs @@ -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> |
