X-Git-Url: https://git.lizzy.rs/?a=blobdiff_plain;f=crates%2Fcore_simd%2Fsrc%2Fmacros.rs;h=5328f22b42ab61a6783c426f3381870aa024c111;hb=6362540f11aaa2f133c12cbb0b3ee903ea6f7f0e;hp=0abafe71f50da54112a248da629696d33d659b75;hpb=1b0c23194829da3a75e641ff0424986cbeb5ff9e;p=rust.git diff --git a/crates/core_simd/src/macros.rs b/crates/core_simd/src/macros.rs index 0abafe71f50..5328f22b42a 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 @@ pub fn as_mut_slice(&mut self) -> &mut [$type] { } } - 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 @@ fn eq(&self, other: &Self) -> bool { } } - 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 @@ fn partial_cmp(&self, other: &Self) -> Option { } // 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 @@ fn partial_cmp(&self, other: &Self) -> Option { } // 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 @@ fn as_mut(&mut self) -> &mut [$type] { } // 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 @@ fn cmp(&self, other: &Self) -> core::cmp::Ordering { } } - 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]