Skip to content

Commit d514086

Browse files
lu-zeroAmanieu
authored andcommitted
Add vec_srl
1 parent 32cb2d0 commit d514086

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
@@ -347,6 +347,9 @@ extern "C" {
347347
fn vsrah(a: vector_signed_short, b: vector_unsigned_short) -> vector_signed_short;
348348
#[link_name = "llvm.ppc.altivec.sraw"]
349349
fn vsraw(a: vector_signed_int, b: vector_unsigned_int) -> vector_signed_int;
350+
351+
#[link_name = "llvm.ppc.altivec.srl"]
352+
fn vsr(a: vector_signed_int, b: vector_signed_int) -> vector_signed_int;
350353
}
351354

352355
macro_rules! s_t_l {
@@ -2855,7 +2858,7 @@ mod sealed {
28552858
impl_vec_sld! { vector_bool_int, vector_signed_int, vector_unsigned_int }
28562859
impl_vec_sld! { vector_float }
28572860

2858-
macro_rules! impl_vec_sll {
2861+
macro_rules! impl_vec_shift_long {
28592862
([$Trait:ident $m:ident] ($f:ident)) => {
28602863
impl_vec_trait!{ [$Trait $m]+ $f (vector_unsigned_char, vector_unsigned_char) -> vector_unsigned_char }
28612864
impl_vec_trait!{ [$Trait $m]+ $f (vector_signed_char, vector_unsigned_char) -> vector_signed_char }
@@ -2872,7 +2875,15 @@ mod sealed {
28722875
unsafe fn vec_sll(self, b: Other) -> Self::Result;
28732876
}
28742877

2875-
impl_vec_sll! { [VectorSll vec_sll] (vsl) }
2878+
impl_vec_shift_long! { [VectorSll vec_sll] (vsl) }
2879+
2880+
#[unstable(feature = "stdarch_powerpc", issue = "111145")]
2881+
pub trait VectorSrl<Other> {
2882+
type Result;
2883+
unsafe fn vec_srl(self, b: Other) -> Self::Result;
2884+
}
2885+
2886+
impl_vec_shift_long! { [VectorSrl vec_srl] (vsr) }
28762887

28772888
macro_rules! impl_vec_slo {
28782889
([$Trait:ident $m:ident] ($f:ident)) => {
@@ -3069,6 +3080,21 @@ where
30693080
a.vec_sll(b)
30703081
}
30713082

3083+
/// Vector Shift Right Long
3084+
///
3085+
/// ## Endian considerations
3086+
/// This intrinsic is not endian-neutral, so uses of vec_srl in big-endian
3087+
/// code must be rewritten for little-endian targets.
3088+
#[inline]
3089+
#[target_feature(enable = "altivec")]
3090+
#[unstable(feature = "stdarch_powerpc", issue = "111145")]
3091+
pub unsafe fn vec_srl<T, U>(a: T, b: U) -> <T as sealed::VectorSrl<U>>::Result
3092+
where
3093+
T: sealed::VectorSrl<U>,
3094+
{
3095+
a.vec_srl(b)
3096+
}
3097+
30723098
/// Vector Shift Left by Octets
30733099
///
30743100
/// ## Endian considerations

0 commit comments

Comments
 (0)