diff --git a/crates/core_simd/src/fmt.rs b/crates/core_simd/src/fmt.rs index 16b8f3b95d9a..6fa238cfda6a 100644 --- a/crates/core_simd/src/fmt.rs +++ b/crates/core_simd/src/fmt.rs @@ -33,7 +33,10 @@ macro_rules! impl_fmt_trait { { $($type:ident => $(($trait:ident, $format:ident)),*;)* } => { $( // repeat type $( // repeat trait - impl core::fmt::$trait for crate::$type { + impl core::fmt::$trait for crate::$type + where + Self: crate::LanesAtMost64, + { fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result { $format(self.as_ref(), f) } diff --git a/crates/core_simd/src/lanes_at_most_64.rs b/crates/core_simd/src/lanes_at_most_64.rs new file mode 100644 index 000000000000..63882152b6d9 --- /dev/null +++ b/crates/core_simd/src/lanes_at_most_64.rs @@ -0,0 +1,35 @@ +/// Implemented for bitmask sizes that are supported by the implementation. +pub trait LanesAtMost64 {} + +macro_rules! impl_for { + { $name:ident } => { + impl LanesAtMost64 for $name<1> {} + impl LanesAtMost64 for $name<2> {} + impl LanesAtMost64 for $name<4> {} + impl LanesAtMost64 for $name<8> {} + impl LanesAtMost64 for $name<16> {} + impl LanesAtMost64 for $name<32> {} + impl LanesAtMost64 for $name<64> {} + } +} + +use crate::*; + +impl_for! { SimdU8 } +impl_for! { SimdU16 } +impl_for! { SimdU32 } +impl_for! { SimdU64 } +impl_for! { SimdU128 } +impl_for! { SimdUsize } + +impl_for! { SimdI8 } +impl_for! { SimdI16 } +impl_for! { SimdI32 } +impl_for! { SimdI64 } +impl_for! { SimdI128 } +impl_for! { SimdIsize } + +impl_for! { SimdF32 } +impl_for! { SimdF64 } + +impl_for! { BitMask } diff --git a/crates/core_simd/src/lib.rs b/crates/core_simd/src/lib.rs index de9cb566022e..1f216bacd9af 100644 --- a/crates/core_simd/src/lib.rs +++ b/crates/core_simd/src/lib.rs @@ -14,6 +14,9 @@ mod intrinsics; mod ops; mod round; +mod lanes_at_most_64; +pub use lanes_at_most_64::LanesAtMost64; + mod masks; pub use masks::*; diff --git a/crates/core_simd/src/macros.rs b/crates/core_simd/src/macros.rs index 0abafe71f50d..5328f22b42ab 100644 --- a/crates/core_simd/src/macros.rs +++ b/crates/core_simd/src/macros.rs @@ -29,7 +29,7 @@ macro_rules! from_transmute_x86 { /// Implements common traits on the specified vector `$name`, holding multiple `$lanes` of `$type`. macro_rules! impl_vector { { $name:ident, $type:ty } => { - impl $name { + impl $name where Self: crate::LanesAtMost64 { /// Construct a SIMD vector by setting all lanes to the given value. pub const fn splat(value: $type) -> Self { Self([value; LANES]) @@ -72,23 +72,23 @@ macro_rules! impl_vector { } } - impl Copy for $name {} + impl Copy for $name where Self: crate::LanesAtMost64 {} - impl Clone for $name { + impl Clone for $name where Self: crate::LanesAtMost64 { #[inline] fn clone(&self) -> Self { *self } } - impl Default for $name { + impl Default for $name where Self: crate::LanesAtMost64 { #[inline] fn default() -> Self { Self::splat(<$type>::default()) } } - impl PartialEq for $name { + impl PartialEq for $name where Self: crate::LanesAtMost64 { #[inline] fn eq(&self, other: &Self) -> bool { // TODO use SIMD equality @@ -96,7 +96,7 @@ macro_rules! impl_vector { } } - impl PartialOrd for $name { + impl PartialOrd for $name where Self: crate::LanesAtMost64 { #[inline] fn partial_cmp(&self, other: &Self) -> Option { // TODO use SIMD equalitya @@ -105,14 +105,14 @@ macro_rules! impl_vector { } // array references - impl AsRef<[$type; LANES]> for $name { + impl AsRef<[$type; LANES]> for $name where Self: crate::LanesAtMost64 { #[inline] fn as_ref(&self) -> &[$type; LANES] { &self.0 } } - impl AsMut<[$type; LANES]> for $name { + impl AsMut<[$type; LANES]> for $name where Self: crate::LanesAtMost64 { #[inline] fn as_mut(&mut self) -> &mut [$type; LANES] { &mut self.0 @@ -120,14 +120,14 @@ macro_rules! impl_vector { } // slice references - impl AsRef<[$type]> for $name { + impl AsRef<[$type]> for $name where Self: crate::LanesAtMost64 { #[inline] fn as_ref(&self) -> &[$type] { &self.0 } } - impl AsMut<[$type]> for $name { + impl AsMut<[$type]> for $name where Self: crate::LanesAtMost64 { #[inline] fn as_mut(&mut self) -> &mut [$type] { &mut self.0 @@ -135,14 +135,14 @@ macro_rules! impl_vector { } // vector/array conversion - impl From<[$type; LANES]> for $name { + impl From<[$type; LANES]> for $name where Self: crate::LanesAtMost64 { fn from(array: [$type; LANES]) -> Self { Self(array) } } // splat - impl From<$type> for $name { + impl From<$type> for $name where Self: crate::LanesAtMost64 { #[inline] fn from(value: $type) -> Self { Self::splat(value) @@ -158,9 +158,9 @@ macro_rules! impl_integer_vector { { $name:ident, $type:ty } => { impl_vector! { $name, $type } - impl Eq for $name {} + impl Eq for $name where Self: crate::LanesAtMost64 {} - impl Ord for $name { + impl Ord for $name where Self: crate::LanesAtMost64 { #[inline] fn cmp(&self, other: &Self) -> core::cmp::Ordering { // TODO use SIMD cmp @@ -168,7 +168,7 @@ macro_rules! impl_integer_vector { } } - impl core::hash::Hash for $name { + impl core::hash::Hash for $name where Self: crate::LanesAtMost64 { #[inline] fn hash(&self, state: &mut H) where @@ -187,7 +187,11 @@ macro_rules! impl_float_vector { { $name:ident, $type:ty, $bits_ty:ident } => { impl_vector! { $name, $type } - impl $name { + impl $name + where + Self: crate::LanesAtMost64, + crate::$bits_ty: crate::LanesAtMost64, + { /// Raw transmutation to an unsigned integer vector type with the /// same size and number of lanes. #[inline] diff --git a/crates/core_simd/src/masks/bitmask.rs b/crates/core_simd/src/masks/bitmask.rs index 51ed8037043d..b9b1160a3f38 100644 --- a/crates/core_simd/src/masks/bitmask.rs +++ b/crates/core_simd/src/masks/bitmask.rs @@ -1,12 +1,4 @@ -/// Implemented for bitmask sizes that are supported by the implementation. -pub trait LanesAtMost64 {} -impl LanesAtMost64 for BitMask<1> {} -impl LanesAtMost64 for BitMask<2> {} -impl LanesAtMost64 for BitMask<4> {} -impl LanesAtMost64 for BitMask<8> {} -impl LanesAtMost64 for BitMask<16> {} -impl LanesAtMost64 for BitMask<32> {} -impl LanesAtMost64 for BitMask<64> {} +use crate::LanesAtMost64; /// A mask where each lane is represented by a single bit. #[derive(Copy, Clone, Debug)] diff --git a/crates/core_simd/src/masks/full_masks.rs b/crates/core_simd/src/masks/full_masks.rs index d7c4af47727c..fa93d252df46 100644 --- a/crates/core_simd/src/masks/full_masks.rs +++ b/crates/core_simd/src/masks/full_masks.rs @@ -16,11 +16,31 @@ impl core::fmt::Display for TryFromMaskError { macro_rules! define_mask { { $(#[$attr:meta])* struct $name:ident($type:ty); } => { $(#[$attr])* - #[derive(Copy, Clone, Default, PartialEq, PartialOrd, Eq, Ord, Hash)] + #[derive(Default, PartialEq, PartialOrd, Eq, Ord, Hash)] #[repr(transparent)] - pub struct $name($type); + pub struct $name($type) + where + $type: crate::LanesAtMost64; - impl $name<$lanes> { + impl Copy for $name + where + $type: crate::LanesAtMost64, + {} + + impl Clone for $name + where + $type: crate::LanesAtMost64, + { + #[inline] + fn clone(&self) -> Self { + *self + } + } + + impl $name<$lanes> + where + $type: crate::LanesAtMost64, + { /// Construct a mask by setting all lanes to the given value. pub fn splat(value: bool) -> Self { Self(<$type>::splat( @@ -57,13 +77,19 @@ macro_rules! define_mask { } } - impl core::convert::From for $name<$lanes> { + impl core::convert::From for $name<$lanes> + where + $type: crate::LanesAtMost64, + { fn from(value: bool) -> Self { Self::splat(value) } } - impl core::convert::TryFrom<$type> for $name<$lanes> { + impl core::convert::TryFrom<$type> for $name<$lanes> + where + $type: crate::LanesAtMost64, + { type Error = TryFromMaskError; fn try_from(value: $type) -> Result { if value.as_slice().iter().all(|x| *x == 0 || *x == -1) { @@ -74,7 +100,10 @@ macro_rules! define_mask { } } - impl core::convert::From<$name<$lanes>> for $type { + impl core::convert::From<$name<$lanes>> for $type + where + $type: crate::LanesAtMost64, + { fn from(value: $name<$lanes>) -> Self { value.0 } @@ -82,6 +111,7 @@ macro_rules! define_mask { impl core::convert::From> for $name<$lanes> where + $type: crate::LanesAtMost64, crate::BitMask<$lanes>: crate::LanesAtMost64, { fn from(value: crate::BitMask<$lanes>) -> Self { @@ -96,6 +126,7 @@ macro_rules! define_mask { impl core::convert::From<$name<$lanes>> for crate::BitMask<$lanes> where + $type: crate::LanesAtMost64, crate::BitMask<$lanes>: crate::LanesAtMost64, { fn from(value: $name<$lanes>) -> Self { @@ -108,7 +139,10 @@ macro_rules! define_mask { } } - impl core::fmt::Debug for $name<$lanes> { + impl core::fmt::Debug for $name<$lanes> + where + $type: crate::LanesAtMost64, + { fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result { f.debug_list() .entries((0..LANES).map(|lane| self.test(lane))) @@ -116,31 +150,46 @@ macro_rules! define_mask { } } - impl core::fmt::Binary for $name<$lanes> { + impl core::fmt::Binary for $name<$lanes> + where + $type: crate::LanesAtMost64, + { fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result { core::fmt::Binary::fmt(&self.0, f) } } - impl core::fmt::Octal for $name<$lanes> { + impl core::fmt::Octal for $name<$lanes> + where + $type: crate::LanesAtMost64, + { fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result { core::fmt::Octal::fmt(&self.0, f) } } - impl core::fmt::LowerHex for $name<$lanes> { + impl core::fmt::LowerHex for $name<$lanes> + where + $type: crate::LanesAtMost64, + { fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result { core::fmt::LowerHex::fmt(&self.0, f) } } - impl core::fmt::UpperHex for $name<$lanes> { + impl core::fmt::UpperHex for $name<$lanes> + where + $type: crate::LanesAtMost64, + { fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result { core::fmt::UpperHex::fmt(&self.0, f) } } - impl core::ops::BitAnd for $name { + impl core::ops::BitAnd for $name + where + $type: crate::LanesAtMost64, + { type Output = Self; #[inline] fn bitand(self, rhs: Self) -> Self { @@ -148,7 +197,10 @@ macro_rules! define_mask { } } - impl core::ops::BitAnd for $name { + impl core::ops::BitAnd for $name + where + $type: crate::LanesAtMost64, + { type Output = Self; #[inline] fn bitand(self, rhs: bool) -> Self { @@ -156,7 +208,10 @@ macro_rules! define_mask { } } - impl core::ops::BitAnd<$name> for bool { + impl core::ops::BitAnd<$name> for bool + where + $type: crate::LanesAtMost64, + { type Output = $name; #[inline] fn bitand(self, rhs: $name) -> $name { @@ -164,7 +219,10 @@ macro_rules! define_mask { } } - impl core::ops::BitOr for $name { + impl core::ops::BitOr for $name + where + $type: crate::LanesAtMost64, + { type Output = Self; #[inline] fn bitor(self, rhs: Self) -> Self { @@ -172,7 +230,10 @@ macro_rules! define_mask { } } - impl core::ops::BitOr for $name { + impl core::ops::BitOr for $name + where + $type: crate::LanesAtMost64, + { type Output = Self; #[inline] fn bitor(self, rhs: bool) -> Self { @@ -180,7 +241,10 @@ macro_rules! define_mask { } } - impl core::ops::BitOr<$name> for bool { + impl core::ops::BitOr<$name> for bool + where + $type: crate::LanesAtMost64, + { type Output = $name; #[inline] fn bitor(self, rhs: $name) -> $name { @@ -188,7 +252,10 @@ macro_rules! define_mask { } } - impl core::ops::BitXor for $name { + impl core::ops::BitXor for $name + where + $type: crate::LanesAtMost64, + { type Output = Self; #[inline] fn bitxor(self, rhs: Self) -> Self::Output { @@ -196,7 +263,10 @@ macro_rules! define_mask { } } - impl core::ops::BitXor for $name { + impl core::ops::BitXor for $name + where + $type: crate::LanesAtMost64, + { type Output = Self; #[inline] fn bitxor(self, rhs: bool) -> Self::Output { @@ -204,7 +274,10 @@ macro_rules! define_mask { } } - impl core::ops::BitXor<$name> for bool { + impl core::ops::BitXor<$name> for bool + where + $type: crate::LanesAtMost64, + { type Output = $name; #[inline] fn bitxor(self, rhs: $name) -> Self::Output { @@ -212,7 +285,10 @@ macro_rules! define_mask { } } - impl core::ops::Not for $name { + impl core::ops::Not for $name + where + $type: crate::LanesAtMost64, + { type Output = $name; #[inline] fn not(self) -> Self::Output { @@ -220,42 +296,60 @@ macro_rules! define_mask { } } - impl core::ops::BitAndAssign for $name { + impl core::ops::BitAndAssign for $name + where + $type: crate::LanesAtMost64, + { #[inline] fn bitand_assign(&mut self, rhs: Self) { self.0 &= rhs.0; } } - impl core::ops::BitAndAssign for $name { + impl core::ops::BitAndAssign for $name + where + $type: crate::LanesAtMost64, + { #[inline] fn bitand_assign(&mut self, rhs: bool) { *self &= Self::splat(rhs); } } - impl core::ops::BitOrAssign for $name { + impl core::ops::BitOrAssign for $name + where + $type: crate::LanesAtMost64, + { #[inline] fn bitor_assign(&mut self, rhs: Self) { self.0 |= rhs.0; } } - impl core::ops::BitOrAssign for $name { + impl core::ops::BitOrAssign for $name + where + $type: crate::LanesAtMost64, + { #[inline] fn bitor_assign(&mut self, rhs: bool) { *self |= Self::splat(rhs); } } - impl core::ops::BitXorAssign for $name { + impl core::ops::BitXorAssign for $name + where + $type: crate::LanesAtMost64, + { #[inline] fn bitxor_assign(&mut self, rhs: Self) { self.0 ^= rhs.0; } } - impl core::ops::BitXorAssign for $name { + impl core::ops::BitXorAssign for $name + where + $type: crate::LanesAtMost64, + { #[inline] fn bitxor_assign(&mut self, rhs: bool) { *self ^= Self::splat(rhs); @@ -291,11 +385,11 @@ define_mask! { define_mask! { /// A mask equivalent to [SimdI128](crate::SimdI128), where all bits in the lane must be either set /// or unset. - struct SimdMask128(crate::SimdI64); + struct SimdMask128(crate::SimdI128); } define_mask! { /// A mask equivalent to [SimdIsize](crate::SimdIsize), where all bits in the lane must be either set /// or unset. - struct SimdMaskSize(crate::SimdI64); + struct SimdMaskSize(crate::SimdIsize); } diff --git a/crates/core_simd/src/masks/mod.rs b/crates/core_simd/src/masks/mod.rs index e51052f53f2f..7d7f7af627df 100644 --- a/crates/core_simd/src/masks/mod.rs +++ b/crates/core_simd/src/masks/mod.rs @@ -7,16 +7,22 @@ pub use full_masks::*; mod bitmask; pub use bitmask::*; +use crate::LanesAtMost64; + macro_rules! define_opaque_mask { { $(#[$attr:meta])* struct $name:ident($inner_ty:ty); + @bits $bits_ty:ty } => { $(#[$attr])* #[allow(non_camel_case_types)] - pub struct $name($inner_ty) where BitMask: LanesAtMost64; + pub struct $name($inner_ty) where $bits_ty: LanesAtMost64; - impl $name<$lanes> where BitMask<$lanes>: LanesAtMost64 { + impl $name<$lanes> + where + $bits_ty: LanesAtMost64 + { /// Construct a mask by setting all lanes to the given value. pub fn splat(value: bool) -> Self { Self(<$inner_ty>::splat(value)) @@ -43,6 +49,7 @@ macro_rules! define_opaque_mask { impl From> for $name<$lanes> where + $bits_ty: LanesAtMost64, BitMask<$lanes>: LanesAtMost64, { fn from(value: BitMask<$lanes>) -> Self { @@ -52,6 +59,7 @@ macro_rules! define_opaque_mask { impl From<$name<$lanes>> for crate::BitMask<$lanes> where + $bits_ty: LanesAtMost64, BitMask<$lanes>: LanesAtMost64, { fn from(value: $name<$lanes>) -> Self { @@ -61,7 +69,7 @@ macro_rules! define_opaque_mask { impl From<$inner_ty> for $name<$lanes> where - BitMask<$lanes>: LanesAtMost64, + $bits_ty: LanesAtMost64, { fn from(value: $inner_ty) -> Self { Self(value) @@ -70,50 +78,72 @@ macro_rules! define_opaque_mask { impl From<$name<$lanes>> for $inner_ty where - BitMask<$lanes>: LanesAtMost64, + $bits_ty: LanesAtMost64, { fn from(value: $name<$lanes>) -> Self { value.0 } } - impl Copy for $name<$lanes> where BitMask<$lanes>: LanesAtMost64 {} + impl Copy for $name<$lanes> + where + $inner_ty: Copy, + $bits_ty: LanesAtMost64, + {} - impl Clone for $name<$lanes> where BitMask<$lanes>: LanesAtMost64 { + impl Clone for $name<$lanes> + where + $bits_ty: LanesAtMost64, + { #[inline] fn clone(&self) -> Self { *self } } - impl Default for $name<$lanes> where BitMask<$lanes>: LanesAtMost64 { + impl Default for $name<$lanes> + where + $bits_ty: LanesAtMost64, + { #[inline] fn default() -> Self { Self::splat(false) } } - impl PartialEq for $name<$lanes> where BitMask<$lanes>: LanesAtMost64 { + impl PartialEq for $name<$lanes> + where + $bits_ty: LanesAtMost64, + { #[inline] fn eq(&self, other: &Self) -> bool { self.0 == other.0 } } - impl PartialOrd for $name<$lanes> where BitMask<$lanes>: LanesAtMost64 { + impl PartialOrd for $name<$lanes> + where + $bits_ty: LanesAtMost64, + { #[inline] fn partial_cmp(&self, other: &Self) -> Option { self.0.partial_cmp(&other.0) } } - impl core::fmt::Debug for $name<$lanes> where BitMask<$lanes>: LanesAtMost64 { + impl core::fmt::Debug for $name<$lanes> + where + $bits_ty: LanesAtMost64, + { fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result { core::fmt::Debug::fmt(&self.0, f) } } - impl core::ops::BitAnd for $name where BitMask: LanesAtMost64 { + impl core::ops::BitAnd for $name + where + $bits_ty: LanesAtMost64, + { type Output = Self; #[inline] fn bitand(self, rhs: Self) -> Self { @@ -121,7 +151,10 @@ macro_rules! define_opaque_mask { } } - impl core::ops::BitAnd for $name where BitMask: LanesAtMost64 { + impl core::ops::BitAnd for $name + where + $bits_ty: LanesAtMost64, + { type Output = Self; #[inline] fn bitand(self, rhs: bool) -> Self { @@ -129,7 +162,10 @@ macro_rules! define_opaque_mask { } } - impl core::ops::BitAnd<$name> for bool where BitMask: LanesAtMost64 { + impl core::ops::BitAnd<$name> for bool + where + $bits_ty: LanesAtMost64, + { type Output = $name; #[inline] fn bitand(self, rhs: $name) -> $name { @@ -137,7 +173,10 @@ macro_rules! define_opaque_mask { } } - impl core::ops::BitOr for $name where BitMask: LanesAtMost64 { + impl core::ops::BitOr for $name + where + $bits_ty: LanesAtMost64, + { type Output = Self; #[inline] fn bitor(self, rhs: Self) -> Self { @@ -145,7 +184,10 @@ macro_rules! define_opaque_mask { } } - impl core::ops::BitOr for $name where BitMask: LanesAtMost64 { + impl core::ops::BitOr for $name + where + $bits_ty: LanesAtMost64, + { type Output = Self; #[inline] fn bitor(self, rhs: bool) -> Self { @@ -153,7 +195,10 @@ macro_rules! define_opaque_mask { } } - impl core::ops::BitOr<$name> for bool where BitMask: LanesAtMost64 { + impl core::ops::BitOr<$name> for bool + where + $bits_ty: LanesAtMost64, + { type Output = $name; #[inline] fn bitor(self, rhs: $name) -> $name { @@ -161,7 +206,10 @@ macro_rules! define_opaque_mask { } } - impl core::ops::BitXor for $name where BitMask: LanesAtMost64 { + impl core::ops::BitXor for $name + where + $bits_ty: LanesAtMost64, + { type Output = Self; #[inline] fn bitxor(self, rhs: Self) -> Self::Output { @@ -169,7 +217,10 @@ macro_rules! define_opaque_mask { } } - impl core::ops::BitXor for $name where BitMask: LanesAtMost64 { + impl core::ops::BitXor for $name + where + $bits_ty: LanesAtMost64, + { type Output = Self; #[inline] fn bitxor(self, rhs: bool) -> Self::Output { @@ -177,7 +228,10 @@ macro_rules! define_opaque_mask { } } - impl core::ops::BitXor<$name> for bool where BitMask: LanesAtMost64 { + impl core::ops::BitXor<$name> for bool + where + $bits_ty: LanesAtMost64, + { type Output = $name; #[inline] fn bitxor(self, rhs: $name) -> Self::Output { @@ -185,7 +239,10 @@ macro_rules! define_opaque_mask { } } - impl core::ops::Not for $name where BitMask: LanesAtMost64 { + impl core::ops::Not for $name + where + $bits_ty: LanesAtMost64, + { type Output = $name; #[inline] fn not(self) -> Self::Output { @@ -193,42 +250,60 @@ macro_rules! define_opaque_mask { } } - impl core::ops::BitAndAssign for $name where BitMask: LanesAtMost64 { + impl core::ops::BitAndAssign for $name + where + $bits_ty: LanesAtMost64, + { #[inline] fn bitand_assign(&mut self, rhs: Self) { self.0 &= rhs.0; } } - impl core::ops::BitAndAssign for $name where BitMask: LanesAtMost64 { + impl core::ops::BitAndAssign for $name + where + $bits_ty: LanesAtMost64, + { #[inline] fn bitand_assign(&mut self, rhs: bool) { *self &= Self::splat(rhs); } } - impl core::ops::BitOrAssign for $name where BitMask: LanesAtMost64 { + impl core::ops::BitOrAssign for $name + where + $bits_ty: LanesAtMost64, + { #[inline] fn bitor_assign(&mut self, rhs: Self) { self.0 |= rhs.0; } } - impl core::ops::BitOrAssign for $name where BitMask: LanesAtMost64 { + impl core::ops::BitOrAssign for $name + where + $bits_ty: LanesAtMost64, + { #[inline] fn bitor_assign(&mut self, rhs: bool) { *self |= Self::splat(rhs); } } - impl core::ops::BitXorAssign for $name where BitMask: LanesAtMost64 { + impl core::ops::BitXorAssign for $name + where + $bits_ty: LanesAtMost64, + { #[inline] fn bitxor_assign(&mut self, rhs: Self) { self.0 ^= rhs.0; } } - impl core::ops::BitXorAssign for $name where BitMask: LanesAtMost64 { + impl core::ops::BitXorAssign for $name + where + $bits_ty: LanesAtMost64, + { #[inline] fn bitxor_assign(&mut self, rhs: bool) { *self ^= Self::splat(rhs); @@ -242,6 +317,7 @@ define_opaque_mask! { /// /// The layout of this type is unspecified. struct Mask8(SimdMask8); + @bits crate::SimdI8 } define_opaque_mask! { @@ -249,6 +325,7 @@ define_opaque_mask! { /// /// The layout of this type is unspecified. struct Mask16(SimdMask16); + @bits crate::SimdI16 } define_opaque_mask! { @@ -256,6 +333,7 @@ define_opaque_mask! { /// /// The layout of this type is unspecified. struct Mask32(SimdMask32); + @bits crate::SimdI32 } define_opaque_mask! { @@ -263,6 +341,7 @@ define_opaque_mask! { /// /// The layout of this type is unspecified. struct Mask64(SimdMask64); + @bits crate::SimdI64 } define_opaque_mask! { @@ -270,6 +349,7 @@ define_opaque_mask! { /// /// The layout of this type is unspecified. struct Mask128(SimdMask128); + @bits crate::SimdI128 } define_opaque_mask! { @@ -277,12 +357,17 @@ define_opaque_mask! { /// /// The layout of this type is unspecified. struct MaskSize(SimdMaskSize); + @bits crate::SimdIsize } macro_rules! implement_mask_ops { - { $($vector:ident => $mask:ident,)* } => { + { $($vector:ident => $mask:ident ($inner_ty:ident),)* } => { $( - impl crate::$vector where BitMask: LanesAtMost64 { + impl crate::$vector + where + crate::$vector: LanesAtMost64, + crate::$inner_ty: LanesAtMost64, + { /// Test if each lane is equal to the corresponding lane in `other`. #[inline] pub fn lanes_eq(&self, other: &Self) -> $mask { @@ -324,22 +409,22 @@ macro_rules! implement_mask_ops { } implement_mask_ops! { - SimdI8 => Mask8, - SimdI16 => Mask16, - SimdI32 => Mask32, - SimdI64 => Mask64, - SimdI128 => Mask128, - SimdIsize => MaskSize, + SimdI8 => Mask8 (SimdI8), + SimdI16 => Mask16 (SimdI16), + SimdI32 => Mask32 (SimdI32), + SimdI64 => Mask64 (SimdI64), + SimdI128 => Mask128 (SimdI128), + SimdIsize => MaskSize (SimdIsize), - SimdU8 => Mask8, - SimdU16 => Mask16, - SimdU32 => Mask32, - SimdU64 => Mask64, - SimdU128 => Mask128, - SimdUsize => MaskSize, + SimdU8 => Mask8 (SimdI8), + SimdU16 => Mask16 (SimdI16), + SimdU32 => Mask32 (SimdI32), + SimdU64 => Mask64 (SimdI64), + SimdU128 => Mask128 (SimdI128), + SimdUsize => MaskSize (SimdIsize), - SimdF32 => Mask32, - SimdF64 => Mask64, + SimdF32 => Mask32 (SimdI32), + SimdF64 => Mask64 (SimdI64), } /// Vector of eight 8-bit masks diff --git a/crates/core_simd/src/ops.rs b/crates/core_simd/src/ops.rs index ae7c86c81c50..1d9e1eeb92ce 100644 --- a/crates/core_simd/src/ops.rs +++ b/crates/core_simd/src/ops.rs @@ -1,3 +1,5 @@ +use crate::LanesAtMost64; + /// Checks if the right-hand side argument of a left- or right-shift would cause overflow. fn invalid_shift_rhs(rhs: T) -> bool where @@ -12,21 +14,30 @@ where macro_rules! impl_ref_ops { // binary op { - impl core::ops::$trait:ident<$rhs:ty> for $type:ty { + impl core::ops::$trait:ident<$rhs:ty> for $type:ty + where + $($bound:path: LanesAtMost64,)* + { type Output = $output:ty; $(#[$attrs:meta])* fn $fn:ident($self_tok:ident, $rhs_arg:ident: $rhs_arg_ty:ty) -> Self::Output $body:tt } } => { - impl core::ops::$trait<$rhs> for $type { + impl core::ops::$trait<$rhs> for $type + where + $($bound: LanesAtMost64,)* + { type Output = $output; $(#[$attrs])* fn $fn($self_tok, $rhs_arg: $rhs_arg_ty) -> Self::Output $body } - impl core::ops::$trait<&'_ $rhs> for $type { + impl core::ops::$trait<&'_ $rhs> for $type + where + $($bound: LanesAtMost64,)* + { type Output = <$type as core::ops::$trait<$rhs>>::Output; $(#[$attrs])* @@ -35,7 +46,10 @@ macro_rules! impl_ref_ops { } } - impl core::ops::$trait<$rhs> for &'_ $type { + impl core::ops::$trait<$rhs> for &'_ $type + where + $($bound: LanesAtMost64,)* + { type Output = <$type as core::ops::$trait<$rhs>>::Output; $(#[$attrs])* @@ -44,7 +58,10 @@ macro_rules! impl_ref_ops { } } - impl core::ops::$trait<&'_ $rhs> for &'_ $type { + impl core::ops::$trait<&'_ $rhs> for &'_ $type + where + $($bound: LanesAtMost64,)* + { type Output = <$type as core::ops::$trait<$rhs>>::Output; $(#[$attrs])* @@ -56,17 +73,26 @@ macro_rules! impl_ref_ops { // binary assignment op { - impl core::ops::$trait:ident<$rhs:ty> for $type:ty { + impl core::ops::$trait:ident<$rhs:ty> for $type:ty + where + $($bound:path: LanesAtMost64,)* + { $(#[$attrs:meta])* fn $fn:ident(&mut $self_tok:ident, $rhs_arg:ident: $rhs_arg_ty:ty) $body:tt } } => { - impl core::ops::$trait<$rhs> for $type { + impl core::ops::$trait<$rhs> for $type + where + $($bound: LanesAtMost64,)* + { $(#[$attrs])* fn $fn(&mut $self_tok, $rhs_arg: $rhs_arg_ty) $body } - impl core::ops::$trait<&'_ $rhs> for $type { + impl core::ops::$trait<&'_ $rhs> for $type + where + $($bound: LanesAtMost64,)* + { $(#[$attrs])* fn $fn(&mut $self_tok, $rhs_arg: &$rhs_arg_ty) { core::ops::$trait::$fn($self_tok, *$rhs_arg) @@ -76,17 +102,26 @@ macro_rules! impl_ref_ops { // unary op { - impl core::ops::$trait:ident for $type:ty { + impl core::ops::$trait:ident for $type:ty + where + $($bound:path: LanesAtMost64,)* + { type Output = $output:ty; fn $fn:ident($self_tok:ident) -> Self::Output $body:tt } } => { - impl core::ops::$trait for $type { + impl core::ops::$trait for $type + where + $($bound: LanesAtMost64,)* + { type Output = $output; fn $fn($self_tok) -> Self::Output $body } - impl core::ops::$trait for &'_ $type { + impl core::ops::$trait for &'_ $type + where + $($bound: LanesAtMost64,)* + { type Output = <$type as core::ops::$trait>::Output; fn $fn($self_tok) -> Self::Output { core::ops::$trait::$fn(*$self_tok) @@ -130,7 +165,10 @@ macro_rules! impl_op { { impl Not for $type:ident, $scalar:ty } => { impl_ref_ops! { - impl core::ops::Not for crate::$type { + impl core::ops::Not for crate::$type + where + crate::$type: LanesAtMost64, + { type Output = Self; fn not(self) -> Self::Output { self ^ Self::splat(!<$scalar>::default()) @@ -141,7 +179,10 @@ macro_rules! impl_op { { impl Neg for $type:ident, $scalar:ty } => { impl_ref_ops! { - impl core::ops::Neg for crate::$type { + impl core::ops::Neg for crate::$type + where + crate::$type: LanesAtMost64, + { type Output = Self; fn neg(self) -> Self::Output { Self::splat(0) - self @@ -152,7 +193,12 @@ macro_rules! impl_op { { impl Neg for $type:ident, $scalar:ty, @float } => { impl_ref_ops! { - impl core::ops::Neg for crate::$type { + impl core::ops::Neg for crate::$type + where + crate::$type: LanesAtMost64, + crate::SimdU32: LanesAtMost64, + crate::SimdU64: LanesAtMost64, + { type Output = Self; fn neg(self) -> Self::Output { // FIXME: Replace this with fneg intrinsic once available. @@ -166,6 +212,7 @@ macro_rules! impl_op { { impl Index for $type:ident, $scalar:ty } => { impl core::ops::Index for crate::$type where + Self: LanesAtMost64, I: core::slice::SliceIndex<[$scalar]>, { type Output = I::Output; @@ -177,6 +224,7 @@ macro_rules! impl_op { impl core::ops::IndexMut for crate::$type where + Self: LanesAtMost64, I: core::slice::SliceIndex<[$scalar]>, { fn index_mut(&mut self, index: I) -> &mut Self::Output { @@ -189,7 +237,10 @@ macro_rules! impl_op { // generic binary op with assignment when output is `Self` { @binary $type:ident, $scalar:ty, $trait:ident :: $trait_fn:ident, $assign_trait:ident :: $assign_trait_fn:ident, $intrinsic:ident } => { impl_ref_ops! { - impl core::ops::$trait for crate::$type { + impl core::ops::$trait for crate::$type + where + crate::$type: LanesAtMost64, + { type Output = Self; #[inline] @@ -202,7 +253,10 @@ macro_rules! impl_op { } impl_ref_ops! { - impl core::ops::$trait<$scalar> for crate::$type { + impl core::ops::$trait<$scalar> for crate::$type + where + crate::$type: LanesAtMost64, + { type Output = Self; #[inline] @@ -213,7 +267,10 @@ macro_rules! impl_op { } impl_ref_ops! { - impl core::ops::$trait> for $scalar { + impl core::ops::$trait> for $scalar + where + crate::$type: LanesAtMost64, + { type Output = crate::$type; #[inline] @@ -224,7 +281,10 @@ macro_rules! impl_op { } impl_ref_ops! { - impl core::ops::$assign_trait for crate::$type { + impl core::ops::$assign_trait for crate::$type + where + crate::$type: LanesAtMost64, + { #[inline] fn $assign_trait_fn(&mut self, rhs: Self) { unsafe { @@ -235,7 +295,10 @@ macro_rules! impl_op { } impl_ref_ops! { - impl core::ops::$assign_trait<$scalar> for crate::$type { + impl core::ops::$assign_trait<$scalar> for crate::$type + where + crate::$type: LanesAtMost64, + { #[inline] fn $assign_trait_fn(&mut self, rhs: $scalar) { core::ops::$assign_trait::$assign_trait_fn(self, Self::splat(rhs)); @@ -278,7 +341,10 @@ macro_rules! impl_unsigned_int_ops { // Integers panic on divide by 0 impl_ref_ops! { - impl core::ops::Div for crate::$vector { + impl core::ops::Div for crate::$vector + where + crate::$vector: LanesAtMost64, + { type Output = Self; #[inline] @@ -303,7 +369,10 @@ macro_rules! impl_unsigned_int_ops { } impl_ref_ops! { - impl core::ops::Div<$scalar> for crate::$vector { + impl core::ops::Div<$scalar> for crate::$vector + where + crate::$vector: LanesAtMost64, + { type Output = Self; #[inline] @@ -323,7 +392,10 @@ macro_rules! impl_unsigned_int_ops { } impl_ref_ops! { - impl core::ops::Div> for $scalar { + impl core::ops::Div> for $scalar + where + crate::$vector: LanesAtMost64, + { type Output = crate::$vector; #[inline] @@ -334,7 +406,10 @@ macro_rules! impl_unsigned_int_ops { } impl_ref_ops! { - impl core::ops::DivAssign for crate::$vector { + impl core::ops::DivAssign for crate::$vector + where + crate::$vector: LanesAtMost64, + { #[inline] fn div_assign(&mut self, rhs: Self) { *self = *self / rhs; @@ -343,7 +418,10 @@ macro_rules! impl_unsigned_int_ops { } impl_ref_ops! { - impl core::ops::DivAssign<$scalar> for crate::$vector { + impl core::ops::DivAssign<$scalar> for crate::$vector + where + crate::$vector: LanesAtMost64, + { #[inline] fn div_assign(&mut self, rhs: $scalar) { *self = *self / rhs; @@ -353,7 +431,10 @@ macro_rules! impl_unsigned_int_ops { // remainder panics on zero divisor impl_ref_ops! { - impl core::ops::Rem for crate::$vector { + impl core::ops::Rem for crate::$vector + where + crate::$vector: LanesAtMost64, + { type Output = Self; #[inline] @@ -378,7 +459,10 @@ macro_rules! impl_unsigned_int_ops { } impl_ref_ops! { - impl core::ops::Rem<$scalar> for crate::$vector { + impl core::ops::Rem<$scalar> for crate::$vector + where + crate::$vector: LanesAtMost64, + { type Output = Self; #[inline] @@ -398,7 +482,10 @@ macro_rules! impl_unsigned_int_ops { } impl_ref_ops! { - impl core::ops::Rem> for $scalar { + impl core::ops::Rem> for $scalar + where + crate::$vector: LanesAtMost64, + { type Output = crate::$vector; #[inline] @@ -409,7 +496,10 @@ macro_rules! impl_unsigned_int_ops { } impl_ref_ops! { - impl core::ops::RemAssign for crate::$vector { + impl core::ops::RemAssign for crate::$vector + where + crate::$vector: LanesAtMost64, + { #[inline] fn rem_assign(&mut self, rhs: Self) { *self = *self % rhs; @@ -418,7 +508,10 @@ macro_rules! impl_unsigned_int_ops { } impl_ref_ops! { - impl core::ops::RemAssign<$scalar> for crate::$vector { + impl core::ops::RemAssign<$scalar> for crate::$vector + where + crate::$vector: LanesAtMost64, + { #[inline] fn rem_assign(&mut self, rhs: $scalar) { *self = *self % rhs; @@ -428,7 +521,10 @@ macro_rules! impl_unsigned_int_ops { // shifts panic on overflow impl_ref_ops! { - impl core::ops::Shl for crate::$vector { + impl core::ops::Shl for crate::$vector + where + crate::$vector: LanesAtMost64, + { type Output = Self; #[inline] @@ -447,7 +543,10 @@ macro_rules! impl_unsigned_int_ops { } impl_ref_ops! { - impl core::ops::Shl<$scalar> for crate::$vector { + impl core::ops::Shl<$scalar> for crate::$vector + where + crate::$vector: LanesAtMost64, + { type Output = Self; #[inline] @@ -463,7 +562,10 @@ macro_rules! impl_unsigned_int_ops { impl_ref_ops! { - impl core::ops::ShlAssign for crate::$vector { + impl core::ops::ShlAssign for crate::$vector + where + crate::$vector: LanesAtMost64, + { #[inline] fn shl_assign(&mut self, rhs: Self) { *self = *self << rhs; @@ -472,7 +574,10 @@ macro_rules! impl_unsigned_int_ops { } impl_ref_ops! { - impl core::ops::ShlAssign<$scalar> for crate::$vector { + impl core::ops::ShlAssign<$scalar> for crate::$vector + where + crate::$vector: LanesAtMost64, + { #[inline] fn shl_assign(&mut self, rhs: $scalar) { *self = *self << rhs; @@ -481,7 +586,10 @@ macro_rules! impl_unsigned_int_ops { } impl_ref_ops! { - impl core::ops::Shr for crate::$vector { + impl core::ops::Shr for crate::$vector + where + crate::$vector: LanesAtMost64, + { type Output = Self; #[inline] @@ -500,7 +608,10 @@ macro_rules! impl_unsigned_int_ops { } impl_ref_ops! { - impl core::ops::Shr<$scalar> for crate::$vector { + impl core::ops::Shr<$scalar> for crate::$vector + where + crate::$vector: LanesAtMost64, + { type Output = Self; #[inline] @@ -516,7 +627,10 @@ macro_rules! impl_unsigned_int_ops { impl_ref_ops! { - impl core::ops::ShrAssign for crate::$vector { + impl core::ops::ShrAssign for crate::$vector + where + crate::$vector: LanesAtMost64, + { #[inline] fn shr_assign(&mut self, rhs: Self) { *self = *self >> rhs; @@ -525,7 +639,10 @@ macro_rules! impl_unsigned_int_ops { } impl_ref_ops! { - impl core::ops::ShrAssign<$scalar> for crate::$vector { + impl core::ops::ShrAssign<$scalar> for crate::$vector + where + crate::$vector: LanesAtMost64, + { #[inline] fn shr_assign(&mut self, rhs: $scalar) { *self = *self >> rhs; diff --git a/crates/core_simd/src/round.rs b/crates/core_simd/src/round.rs index d77bc4e8fa7e..ee232e2b2225 100644 --- a/crates/core_simd/src/round.rs +++ b/crates/core_simd/src/round.rs @@ -2,7 +2,10 @@ macro_rules! implement { { $type:ident, $int_type:ident } => { - impl crate::$type { + impl crate::$type + where + Self: crate::LanesAtMost64, + { /// Returns the largest integer less than or equal to each lane. #[must_use = "method returns a new vector and does not mutate the original value"] #[inline] @@ -16,7 +19,13 @@ macro_rules! implement { pub fn ceil(self) -> Self { unsafe { crate::intrinsics::simd_ceil(self) } } + } + impl crate::$type + where + Self: crate::LanesAtMost64, + crate::$int_type: crate::LanesAtMost64, + { /// Rounds toward zero and converts to the same-width integer type, assuming that /// the value is finite and fits in that type. /// diff --git a/crates/core_simd/src/vectors_f32.rs b/crates/core_simd/src/vectors_f32.rs index 0b5d8c6ec49b..5bb8f3a1c34d 100644 --- a/crates/core_simd/src/vectors_f32.rs +++ b/crates/core_simd/src/vectors_f32.rs @@ -2,7 +2,9 @@ /// A SIMD vector of containing `LANES` `f32` values. #[repr(simd)] -pub struct SimdF32([f32; LANES]); +pub struct SimdF32([f32; LANES]) +where + Self: crate::LanesAtMost64; impl_float_vector! { SimdF32, f32, SimdU32 } diff --git a/crates/core_simd/src/vectors_f64.rs b/crates/core_simd/src/vectors_f64.rs index 307f8a4acacd..c0dca6a52ac6 100644 --- a/crates/core_simd/src/vectors_f64.rs +++ b/crates/core_simd/src/vectors_f64.rs @@ -2,7 +2,9 @@ /// A SIMD vector of containing `LANES` `f64` values. #[repr(simd)] -pub struct SimdF64([f64; LANES]); +pub struct SimdF64([f64; LANES]) +where + Self: crate::LanesAtMost64; impl_float_vector! { SimdF64, f64, SimdU64 } diff --git a/crates/core_simd/src/vectors_i128.rs b/crates/core_simd/src/vectors_i128.rs index 16e6162be552..568fa81da80e 100644 --- a/crates/core_simd/src/vectors_i128.rs +++ b/crates/core_simd/src/vectors_i128.rs @@ -2,7 +2,9 @@ /// A SIMD vector of containing `LANES` `i128` values. #[repr(simd)] -pub struct SimdI128([i128; LANES]); +pub struct SimdI128([i128; LANES]) +where + Self: crate::LanesAtMost64; impl_integer_vector! { SimdI128, i128 } diff --git a/crates/core_simd/src/vectors_i16.rs b/crates/core_simd/src/vectors_i16.rs index 08cc4af2a5ea..d77e593a2edc 100644 --- a/crates/core_simd/src/vectors_i16.rs +++ b/crates/core_simd/src/vectors_i16.rs @@ -2,7 +2,9 @@ /// A SIMD vector of containing `LANES` `i16` values. #[repr(simd)] -pub struct SimdI16([i16; LANES]); +pub struct SimdI16([i16; LANES]) +where + Self: crate::LanesAtMost64; impl_integer_vector! { SimdI16, i16 } diff --git a/crates/core_simd/src/vectors_i32.rs b/crates/core_simd/src/vectors_i32.rs index 116f2abaeeed..0a89eeda3b2f 100644 --- a/crates/core_simd/src/vectors_i32.rs +++ b/crates/core_simd/src/vectors_i32.rs @@ -2,7 +2,9 @@ /// A SIMD vector of containing `LANES` `i32` values. #[repr(simd)] -pub struct SimdI32([i32; LANES]); +pub struct SimdI32([i32; LANES]) +where + Self: crate::LanesAtMost64; impl_integer_vector! { SimdI32, i32 } diff --git a/crates/core_simd/src/vectors_i64.rs b/crates/core_simd/src/vectors_i64.rs index 6a1e2094179b..017140654a51 100644 --- a/crates/core_simd/src/vectors_i64.rs +++ b/crates/core_simd/src/vectors_i64.rs @@ -2,7 +2,9 @@ /// A SIMD vector of containing `LANES` `i64` values. #[repr(simd)] -pub struct SimdI64([i64; LANES]); +pub struct SimdI64([i64; LANES]) +where + Self: crate::LanesAtMost64; impl_integer_vector! { SimdI64, i64 } diff --git a/crates/core_simd/src/vectors_i8.rs b/crates/core_simd/src/vectors_i8.rs index 0ac5ba9efee5..e21126533b88 100644 --- a/crates/core_simd/src/vectors_i8.rs +++ b/crates/core_simd/src/vectors_i8.rs @@ -2,7 +2,9 @@ /// A SIMD vector of containing `LANES` `i8` values. #[repr(simd)] -pub struct SimdI8([i8; LANES]); +pub struct SimdI8([i8; LANES]) +where + Self: crate::LanesAtMost64; impl_integer_vector! { SimdI8, i8 } diff --git a/crates/core_simd/src/vectors_isize.rs b/crates/core_simd/src/vectors_isize.rs index 6856f305092d..ee23dfe7d865 100644 --- a/crates/core_simd/src/vectors_isize.rs +++ b/crates/core_simd/src/vectors_isize.rs @@ -2,7 +2,9 @@ /// A SIMD vector of containing `LANES` `isize` values. #[repr(simd)] -pub struct SimdIsize([isize; LANES]); +pub struct SimdIsize([isize; LANES]) +where + Self: crate::LanesAtMost64; impl_integer_vector! { SimdIsize, isize } diff --git a/crates/core_simd/src/vectors_u128.rs b/crates/core_simd/src/vectors_u128.rs index 522404f133e5..7931b9e088f6 100644 --- a/crates/core_simd/src/vectors_u128.rs +++ b/crates/core_simd/src/vectors_u128.rs @@ -2,7 +2,9 @@ /// A SIMD vector of containing `LANES` `u128` values. #[repr(simd)] -pub struct SimdU128([u128; LANES]); +pub struct SimdU128([u128; LANES]) +where + Self: crate::LanesAtMost64; impl_integer_vector! { SimdU128, u128 } diff --git a/crates/core_simd/src/vectors_u16.rs b/crates/core_simd/src/vectors_u16.rs index efe7dea58dc4..91c0e6168089 100644 --- a/crates/core_simd/src/vectors_u16.rs +++ b/crates/core_simd/src/vectors_u16.rs @@ -2,7 +2,9 @@ /// A SIMD vector of containing `LANES` `u16` values. #[repr(simd)] -pub struct SimdU16([u16; LANES]); +pub struct SimdU16([u16; LANES]) +where + Self: crate::LanesAtMost64; impl_integer_vector! { SimdU16, u16 } diff --git a/crates/core_simd/src/vectors_u32.rs b/crates/core_simd/src/vectors_u32.rs index a6cef5baeb73..b0400b5ba3a9 100644 --- a/crates/core_simd/src/vectors_u32.rs +++ b/crates/core_simd/src/vectors_u32.rs @@ -2,7 +2,9 @@ /// A SIMD vector of containing `LANES` `u32` values. #[repr(simd)] -pub struct SimdU32([u32; LANES]); +pub struct SimdU32([u32; LANES]) +where + Self: crate::LanesAtMost64; impl_integer_vector! { SimdU32, u32 } diff --git a/crates/core_simd/src/vectors_u64.rs b/crates/core_simd/src/vectors_u64.rs index 3982e30f5705..0f3712241fe7 100644 --- a/crates/core_simd/src/vectors_u64.rs +++ b/crates/core_simd/src/vectors_u64.rs @@ -2,7 +2,9 @@ /// A SIMD vector of containing `LANES` `u64` values. #[repr(simd)] -pub struct SimdU64([u64; LANES]); +pub struct SimdU64([u64; LANES]) +where + Self: crate::LanesAtMost64; impl_integer_vector! { SimdU64, u64 } diff --git a/crates/core_simd/src/vectors_u8.rs b/crates/core_simd/src/vectors_u8.rs index 9cc4eaca47ad..6cf623f68013 100644 --- a/crates/core_simd/src/vectors_u8.rs +++ b/crates/core_simd/src/vectors_u8.rs @@ -2,7 +2,7 @@ /// A SIMD vector of containing `LANES` `u8` values. #[repr(simd)] -pub struct SimdU8([u8; LANES]); +pub struct SimdU8([u8; LANES]) where Self: crate::LanesAtMost64; impl_integer_vector! { SimdU8, u8 } diff --git a/crates/core_simd/src/vectors_usize.rs b/crates/core_simd/src/vectors_usize.rs index c882898f9fbe..ea089aeb9d3c 100644 --- a/crates/core_simd/src/vectors_usize.rs +++ b/crates/core_simd/src/vectors_usize.rs @@ -2,7 +2,9 @@ /// A SIMD vector of containing `LANES` `usize` values. #[repr(simd)] -pub struct SimdUsize([usize; LANES]); +pub struct SimdUsize([usize; LANES]) +where + Self: crate::LanesAtMost64; impl_integer_vector! { SimdUsize, usize }