Skip to content

Commit d7b6db5

Browse files
lu-zeroAmanieu
authored andcommitted
Add vec_sr
1 parent 6210016 commit d7b6db5

File tree

1 file changed

+35
-12
lines changed

1 file changed

+35
-12
lines changed

stdarch/crates/core_arch/src/powerpc/altivec.rs

Lines changed: 35 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2663,14 +2663,8 @@ mod sealed {
26632663
};
26642664
}
26652665

2666-
#[unstable(feature = "stdarch_powerpc", issue = "111145")]
2667-
pub trait VectorSl<Other> {
2668-
type Result;
2669-
unsafe fn vec_sl(self, b: Other) -> Self::Result;
2670-
}
2671-
2672-
macro_rules! impl_sl {
2673-
($fun:ident $ty:ident) => {
2666+
macro_rules! impl_shift {
2667+
($fun:ident $intr:ident $ty:ident) => {
26742668
#[inline]
26752669
#[target_feature(enable = "altivec")]
26762670
#[cfg_attr(test, assert_instr($fun))]
@@ -2681,17 +2675,35 @@ mod sealed {
26812675
<t_t_s!($ty)>::splat(mem::size_of::<$ty>() as $ty * $ty::BITS as $ty),
26822676
);
26832677

2684-
transmute(simd_shl(a, b))
2678+
transmute($intr(a, b))
26852679
}
26862680
};
26872681
}
26882682

2689-
impl_sl! { vslb u8 }
2690-
impl_sl! { vslh u16 }
2691-
impl_sl! { vslw u32 }
2683+
#[unstable(feature = "stdarch_powerpc", issue = "111145")]
2684+
pub trait VectorSl<Other> {
2685+
type Result;
2686+
unsafe fn vec_sl(self, b: Other) -> Self::Result;
2687+
}
2688+
2689+
impl_shift! { vslb simd_shl u8 }
2690+
impl_shift! { vslh simd_shl u16 }
2691+
impl_shift! { vslw simd_shl u32 }
26922692

26932693
impl_vec_shift! { [VectorSl vec_sl] (vslb, vslh, vslw) }
26942694

2695+
#[unstable(feature = "stdarch_powerpc", issue = "111145")]
2696+
pub trait VectorSr<Other> {
2697+
type Result;
2698+
unsafe fn vec_sr(self, b: Other) -> Self::Result;
2699+
}
2700+
2701+
impl_shift! { vsrb simd_shr u8 }
2702+
impl_shift! { vsrh simd_shr u16 }
2703+
impl_shift! { vsrw simd_shr u32 }
2704+
2705+
impl_vec_shift! { [VectorSr vec_sr] (vsrb, vsrh, vsrw) }
2706+
26952707
#[unstable(feature = "stdarch_powerpc", issue = "111145")]
26962708
pub trait VectorSld {
26972709
unsafe fn vec_sld<const UIMM4: i32>(self, b: Self) -> Self;
@@ -2963,6 +2975,17 @@ where
29632975
a.vec_sl(b)
29642976
}
29652977

2978+
/// Vector Shift Right
2979+
#[inline]
2980+
#[target_feature(enable = "altivec")]
2981+
#[unstable(feature = "stdarch_powerpc", issue = "111145")]
2982+
pub unsafe fn vec_sr<T, U>(a: T, b: U) -> <T as sealed::VectorSr<U>>::Result
2983+
where
2984+
T: sealed::VectorSr<U>,
2985+
{
2986+
a.vec_sr(b)
2987+
}
2988+
29662989
/// Vector Shift Left Double
29672990
///
29682991
/// ## Endian considerations

0 commit comments

Comments
 (0)