core/portable-simd/crates/core_simd/src/ops/
shift_scalar.rsuse crate::simd::{LaneCount, Simd, SupportedLaneCount};
macro_rules! impl_splatted_shifts {
{ impl $trait:ident :: $trait_fn:ident for $ty:ty } => {
impl<const N: usize> core::ops::$trait<$ty> for Simd<$ty, N>
where
LaneCount<N>: SupportedLaneCount,
{
type Output = Self;
#[inline]
fn $trait_fn(self, rhs: $ty) -> Self::Output {
self.$trait_fn(Simd::splat(rhs))
}
}
impl<const N: usize> core::ops::$trait<&$ty> for Simd<$ty, N>
where
LaneCount<N>: SupportedLaneCount,
{
type Output = Self;
#[inline]
fn $trait_fn(self, rhs: &$ty) -> Self::Output {
self.$trait_fn(Simd::splat(*rhs))
}
}
impl<'lhs, const N: usize> core::ops::$trait<$ty> for &'lhs Simd<$ty, N>
where
LaneCount<N>: SupportedLaneCount,
{
type Output = Simd<$ty, N>;
#[inline]
fn $trait_fn(self, rhs: $ty) -> Self::Output {
self.$trait_fn(Simd::splat(rhs))
}
}
impl<'lhs, const N: usize> core::ops::$trait<&$ty> for &'lhs Simd<$ty, N>
where
LaneCount<N>: SupportedLaneCount,
{
type Output = Simd<$ty, N>;
#[inline]
fn $trait_fn(self, rhs: &$ty) -> Self::Output {
self.$trait_fn(Simd::splat(*rhs))
}
}
};
{ $($ty:ty),* } => {
$(
impl_splatted_shifts! { impl Shl::shl for $ty }
impl_splatted_shifts! { impl Shr::shr for $ty }
)*
}
}
impl_splatted_shifts! { i8, i16, i32, i64, isize, u8, u16, u32, u64, usize }