Skip to content

Commit 77285f9

Browse files
lu-zeroAmanieu
authored andcommitted
Add vec_adde
1 parent 39b6df9 commit 77285f9

File tree

1 file changed

+43
-0
lines changed

1 file changed

+43
-0
lines changed

crates/core_arch/src/powerpc/altivec.rs

+43
Original file line numberDiff line numberDiff line change
@@ -2244,6 +2244,33 @@ mod sealed {
22442244
}
22452245
}
22462246

2247+
#[unstable(feature = "stdarch_powerpc", issue = "111145")]
2248+
pub trait VectorAdde {
2249+
unsafe fn vec_adde(self, b: Self, c: Self) -> Self;
2250+
}
2251+
2252+
#[unstable(feature = "stdarch_powerpc", issue = "111145")]
2253+
impl VectorAdde for vector_unsigned_int {
2254+
#[inline]
2255+
#[target_feature(enable = "altivec")]
2256+
unsafe fn vec_adde(self, b: Self, c: Self) -> Self {
2257+
let mask: vector_unsigned_int = transmute(u32x4::new(1, 1, 1, 1));
2258+
let carry = vec_and(c, mask);
2259+
vec_add(vec_add(self, b), carry)
2260+
}
2261+
}
2262+
2263+
#[unstable(feature = "stdarch_powerpc", issue = "111145")]
2264+
impl VectorAdde for vector_signed_int {
2265+
#[inline]
2266+
#[target_feature(enable = "altivec")]
2267+
unsafe fn vec_adde(self, b: Self, c: Self) -> Self {
2268+
let mask: vector_signed_int = transmute(i32x4::new(1, 1, 1, 1));
2269+
let carry = vec_and(c, mask);
2270+
vec_add(vec_add(self, b), carry)
2271+
}
2272+
}
2273+
22472274
#[unstable(feature = "stdarch_powerpc", issue = "111145")]
22482275
pub trait VectorMladd<Other> {
22492276
type Result;
@@ -3523,6 +3550,22 @@ where
35233550
a.vec_add(b)
35243551
}
35253552

3553+
/// Vector Add Extended
3554+
///
3555+
/// ## Result value
3556+
/// The value of each element of r is produced by adding the corresponding elements of
3557+
/// a and b with a carry specified in the corresponding element of c (1 if there is a carry, 0
3558+
/// otherwise).
3559+
#[inline]
3560+
#[target_feature(enable = "altivec")]
3561+
#[unstable(feature = "stdarch_powerpc", issue = "111145")]
3562+
pub unsafe fn vec_adde<T>(a: T, b: T, c: T) -> T
3563+
where
3564+
T: sealed::VectorAdde,
3565+
{
3566+
a.vec_adde(b, c)
3567+
}
3568+
35263569
/// Vector Convert to Floating-Point
35273570
#[inline]
35283571
#[target_feature(enable = "altivec")]

0 commit comments

Comments
 (0)