Skip to content

Commit 653c5d7

Browse files
lu-zeroAmanieu
authored andcommitted
Add vec_mul
1 parent f509fbd commit 653c5d7

File tree

1 file changed

+63
-0
lines changed

1 file changed

+63
-0
lines changed

crates/core_arch/src/powerpc/altivec.rs

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1641,6 +1641,52 @@ mod sealed {
16411641
vmulesh(a, b)
16421642
}
16431643

1644+
#[unstable(feature = "stdarch_powerpc", issue = "111145")]
1645+
pub trait VectorMul {
1646+
unsafe fn vec_mul(self, b: Self) -> Self;
1647+
}
1648+
1649+
#[inline]
1650+
#[target_feature(enable = "altivec")]
1651+
#[cfg_attr(test, assert_instr(vmuluwm))]
1652+
unsafe fn vec_vmuluwm(a: vector_signed_int, b: vector_signed_int) -> vector_signed_int {
1653+
transmute(simd_mul::<i32x4>(transmute(a), transmute(b)))
1654+
}
1655+
1656+
#[inline]
1657+
#[target_feature(enable = "altivec")]
1658+
#[cfg_attr(test, assert_instr(xvmulsp))]
1659+
unsafe fn vec_xvmulsp(a: vector_float, b: vector_float) -> vector_float {
1660+
transmute(simd_mul::<f32x4>(transmute(a), transmute(b)))
1661+
}
1662+
1663+
#[unstable(feature = "stdarch_powerpc", issue = "111145")]
1664+
impl VectorMul for vector_signed_int {
1665+
#[inline]
1666+
#[target_feature(enable = "altivec")]
1667+
unsafe fn vec_mul(self, b: Self) -> Self {
1668+
vec_vmuluwm(self, b)
1669+
}
1670+
}
1671+
1672+
#[unstable(feature = "stdarch_powerpc", issue = "111145")]
1673+
impl VectorMul for vector_unsigned_int {
1674+
#[inline]
1675+
#[target_feature(enable = "altivec")]
1676+
unsafe fn vec_mul(self, b: Self) -> Self {
1677+
transmute(simd_mul::<u32x4>(transmute(self), transmute(b)))
1678+
}
1679+
}
1680+
1681+
#[unstable(feature = "stdarch_powerpc", issue = "111145")]
1682+
impl VectorMul for vector_float {
1683+
#[inline]
1684+
#[target_feature(enable = "altivec")]
1685+
unsafe fn vec_mul(self, b: Self) -> Self {
1686+
vec_xvmulsp(self, b)
1687+
}
1688+
}
1689+
16441690
#[unstable(feature = "stdarch_powerpc", issue = "111145")]
16451691
pub trait VectorMule<Result> {
16461692
unsafe fn vec_mule(self, b: Self) -> Result;
@@ -4047,6 +4093,23 @@ mod endian {
40474093
}
40484094
}
40494095

4096+
/// Vector Multiply
4097+
///
4098+
/// ## Purpose
4099+
/// Compute the products of corresponding elements of two vectors.
4100+
///
4101+
/// ## Result value
4102+
/// Each element of r receives the product of the corresponding elements of a and b.
4103+
#[inline]
4104+
#[target_feature(enable = "altivec")]
4105+
#[unstable(feature = "stdarch_powerpc", issue = "111145")]
4106+
pub unsafe fn vec_mul<T>(a: T, b: T) -> T
4107+
where
4108+
T: sealed::VectorMul,
4109+
{
4110+
a.vec_mul(b)
4111+
}
4112+
40504113
/// Vector Multiply Add Saturated
40514114
#[inline]
40524115
#[target_feature(enable = "altivec")]

0 commit comments

Comments
 (0)