Skip to content

Commit 1940d10

Browse files
lu-zeroAmanieu
authored andcommitted
Add vec_nand
1 parent c8ae80e commit 1940d10

File tree

1 file changed

+42
-0
lines changed

1 file changed

+42
-0
lines changed

crates/core_arch/src/powerpc/altivec.rs

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2547,6 +2547,31 @@ mod sealed {
25472547

25482548
impl_vec_trait! { [VectorNor vec_nor]+ 2b (vec_vnorsb, vec_vnorsh, vec_vnorsw) }
25492549

2550+
macro_rules! vector_vnand {
2551+
($fun:ident $ty:ident) => {
2552+
#[inline]
2553+
#[target_feature(enable = "altivec")]
2554+
#[cfg_attr(all(test, not(target_feature = "vsx")), assert_instr(vnand))]
2555+
#[cfg_attr(all(test, target_feature = "vsx"), assert_instr(xxlnand))]
2556+
pub unsafe fn $fun(a: t_t_l!($ty), b: t_t_l!($ty)) -> t_t_l!($ty) {
2557+
let o = vec_splats(!0 as $ty);
2558+
vec_xor(vec_and(a, b), o)
2559+
}
2560+
};
2561+
}
2562+
2563+
vector_vnand! { vec_vnandsb i8 }
2564+
vector_vnand! { vec_vnandsh i16 }
2565+
vector_vnand! { vec_vnandsw i32 }
2566+
2567+
#[unstable(feature = "stdarch_powerpc", issue = "111145")]
2568+
pub trait VectorNand<Other> {
2569+
type Result;
2570+
unsafe fn vec_nand(self, b: Other) -> Self::Result;
2571+
}
2572+
2573+
impl_vec_trait! { [VectorNand vec_nand]+ 2b (vec_vnandsb, vec_vnandsh, vec_vnandsw) }
2574+
25502575
#[inline]
25512576
#[target_feature(enable = "altivec")]
25522577
#[cfg_attr(test, assert_instr(vcfsx, IMM5 = 1))]
@@ -3744,6 +3769,23 @@ where
37443769
a.vec_or(b)
37453770
}
37463771

3772+
/// Vector NAND
3773+
///
3774+
/// ## Purpose
3775+
/// Performs a bitwise NAND of two vectors.
3776+
///
3777+
/// ## Result value
3778+
/// r is the bitwise NAND of a and b.
3779+
#[inline]
3780+
#[target_feature(enable = "altivec")]
3781+
#[unstable(feature = "stdarch_powerpc", issue = "111145")]
3782+
pub unsafe fn vec_nand<T, U>(a: T, b: U) -> <T as sealed::VectorNand<U>>::Result
3783+
where
3784+
T: sealed::VectorNand<U>,
3785+
{
3786+
a.vec_nand(b)
3787+
}
3788+
37473789
/// Vector nor.
37483790
#[inline]
37493791
#[target_feature(enable = "altivec")]

0 commit comments

Comments
 (0)