Skip to content

Commit e2959af

Browse files
lu-zeroAmanieu
authored andcommitted
Add vec_sro
1 parent d514086 commit e2959af

File tree

1 file changed

+28
-2
lines changed

1 file changed

+28
-2
lines changed

crates/core_arch/src/powerpc/altivec.rs

Lines changed: 28 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -350,6 +350,8 @@ extern "C" {
350350

351351
#[link_name = "llvm.ppc.altivec.srl"]
352352
fn vsr(a: vector_signed_int, b: vector_signed_int) -> vector_signed_int;
353+
#[link_name = "llvm.ppc.altivec.sro"]
354+
fn vsro(a: vector_signed_int, b: vector_signed_int) -> vector_signed_int;
353355
}
354356

355357
macro_rules! s_t_l {
@@ -2885,7 +2887,7 @@ mod sealed {
28852887

28862888
impl_vec_shift_long! { [VectorSrl vec_srl] (vsr) }
28872889

2888-
macro_rules! impl_vec_slo {
2890+
macro_rules! impl_vec_shift_octect {
28892891
([$Trait:ident $m:ident] ($f:ident)) => {
28902892
impl_vec_trait!{ [$Trait $m]+ $f (vector_unsigned_char, vector_signed_char) -> vector_unsigned_char }
28912893
impl_vec_trait!{ [$Trait $m]+ $f (vector_signed_char, vector_signed_char) -> vector_signed_char }
@@ -2910,7 +2912,15 @@ mod sealed {
29102912
unsafe fn vec_slo(self, b: Other) -> Self::Result;
29112913
}
29122914

2913-
impl_vec_slo! { [VectorSlo vec_slo] (vslo) }
2915+
impl_vec_shift_octect! { [VectorSlo vec_slo] (vslo) }
2916+
2917+
#[unstable(feature = "stdarch_powerpc", issue = "111145")]
2918+
pub trait VectorSro<Other> {
2919+
type Result;
2920+
unsafe fn vec_sro(self, b: Other) -> Self::Result;
2921+
}
2922+
2923+
impl_vec_shift_octect! { [VectorSro vec_sro] (vsro) }
29142924
}
29152925

29162926
/// Vector Merge Low
@@ -3111,6 +3121,22 @@ where
31113121
a.vec_slo(b)
31123122
}
31133123

3124+
/// Vector Shift Right by Octets
3125+
///
3126+
/// ## Endian considerations
3127+
/// This intrinsic is not endian-neutral, so uses of vec_sro in big-endian code must be rewritten
3128+
/// for little-endian targets. The shift count is in element 15 of b for big-endian, but in element
3129+
/// 0 of b for little-endian.
3130+
#[inline]
3131+
#[target_feature(enable = "altivec")]
3132+
#[unstable(feature = "stdarch_powerpc", issue = "111145")]
3133+
pub unsafe fn vec_sro<T, U>(a: T, b: U) -> <T as sealed::VectorSro<U>>::Result
3134+
where
3135+
T: sealed::VectorSro<U>,
3136+
{
3137+
a.vec_sro(b)
3138+
}
3139+
31143140
/// Vector Load Indexed.
31153141
#[inline]
31163142
#[target_feature(enable = "altivec")]

0 commit comments

Comments
 (0)