Skip to content

Commit

Permalink
Simplify vec_andc implementation
Browse files Browse the repository at this point in the history
  • Loading branch information
lu-zero authored and Amanieu committed May 6, 2024
1 parent 7463dc7 commit 72a8921
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 26 deletions.
26 changes: 1 addition & 25 deletions crates/core_arch/src/powerpc/altivec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1293,31 +1293,7 @@ mod sealed {
unsafe fn vec_andc(self, b: Other) -> Self::Result;
}

macro_rules! impl_vec_andc {
(($a:ty, $b:ty) -> $r:ty) => {
#[unstable(feature = "stdarch_powerpc", issue = "111145")]
impl VectorAndc<$b> for $a {
type Result = $r;
#[inline]
#[target_feature(enable = "altivec")]
unsafe fn vec_andc(self, b: $b) -> Self::Result {
transmute(andc(transmute(self), transmute(b)))
}
}
};
(($a:ty, ~$b:ty) -> $r:ty) => {
impl_vec_andc! { ($a, $a) -> $r }
impl_vec_andc! { ($a, $b) -> $r }
impl_vec_andc! { ($b, $a) -> $r }
};
}

impl_vec_andc! { (vector_unsigned_char, ~vector_bool_char) -> vector_unsigned_char }
impl_vec_andc! { (vector_signed_char, ~vector_bool_char) -> vector_signed_char }
impl_vec_andc! { (vector_unsigned_short, ~vector_bool_short) -> vector_unsigned_short }
impl_vec_andc! { (vector_signed_short, ~vector_bool_short) -> vector_signed_short }
impl_vec_andc! { (vector_unsigned_int, ~vector_bool_int) -> vector_unsigned_int }
impl_vec_andc! { (vector_signed_int, ~vector_bool_int) -> vector_signed_int }
impl_vec_trait! { [VectorAndc vec_andc]+ 2b (andc) }

test_impl! { vec_vand(a: vector_signed_char, b: vector_signed_char) -> vector_signed_char [ simd_and, vand / xxland ] }

Expand Down
5 changes: 4 additions & 1 deletion crates/core_arch/src/powerpc/macros.rs
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,10 @@ macro_rules! impl_vec_trait {
impl_vec_trait!{ [$Trait $m]+ $w (vector_bool_int, vector_bool_int) -> vector_bool_int }
impl_vec_trait!{ [$Trait $m]+ $w (vector_unsigned_int, vector_unsigned_int) -> vector_unsigned_int }
impl_vec_trait!{ [$Trait $m]+ $w (vector_signed_int, vector_signed_int) -> vector_signed_int }
}
};
([$Trait:ident $m:ident]+ 2b ($fn:ident)) => {
impl_vec_trait!{ [$Trait $m]+ 2b ($fn, $fn, $fn) }
};
}

macro_rules! s_t_l {
Expand Down

0 comments on commit 72a8921

Please sign in to comment.