Skip to content

Commit 9a50433

Browse files
folkertdevAmanieu
authored andcommitted
add vec_sum2, vec_sum4 and vec_sum_u128
1 parent 017ba77 commit 9a50433

File tree

1 file changed

+132
-0
lines changed

1 file changed

+132
-0
lines changed

crates/core_arch/src/s390x/vector.rs

Lines changed: 132 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,16 @@ unsafe extern "unadjusted" {
102102
#[link_name = "llvm.s390.verimg"] fn verimg(a: vector_signed_long_long, b: vector_signed_long_long, c: vector_signed_long_long, d: i32) -> vector_signed_long_long;
103103

104104
#[link_name = "llvm.s390.vperm"] fn vperm(a: vector_signed_char, b: vector_signed_char, c: vector_unsigned_char) -> vector_signed_char;
105+
106+
#[link_name = "llvm.s390.vsumb"] fn vsumb(a: vector_unsigned_char, b: vector_unsigned_char) -> vector_unsigned_int;
107+
#[link_name = "llvm.s390.vsumh"] fn vsumh(a: vector_unsigned_short, b: vector_unsigned_short) -> vector_unsigned_int;
108+
109+
#[link_name = "llvm.s390.vsumgh"] fn vsumgh(a: vector_unsigned_short, b: vector_unsigned_short) -> vector_unsigned_long_long;
110+
#[link_name = "llvm.s390.vsumgf"] fn vsumgf(a: vector_unsigned_int, b: vector_unsigned_int) -> vector_unsigned_long_long;
111+
112+
#[link_name = "llvm.s390.vsumqf"] fn vsumqf(a: vector_unsigned_int, b: vector_unsigned_int) -> u128;
113+
#[link_name = "llvm.s390.vsumqg"] fn vsumqg(a: vector_unsigned_long_long, b: vector_unsigned_long_long) -> u128;
114+
105115
}
106116

107117
impl_from! { i8x16, u8x16, i16x8, u16x8, i32x4, u32x4, i64x2, u64x2, f32x4, f64x2 }
@@ -1295,6 +1305,95 @@ mod sealed {
12951305
vector_float,
12961306
vector_double
12971307
}
1308+
1309+
#[unstable(feature = "stdarch_s390x", issue = "135681")]
1310+
pub trait VectorSumU128 {
1311+
unsafe fn vec_sum_u128(self, other: Self) -> vector_unsigned_char;
1312+
}
1313+
1314+
#[inline]
1315+
#[target_feature(enable = "vector")]
1316+
#[cfg_attr(test, assert_instr(vsumqf))]
1317+
pub unsafe fn vec_vsumqf(a: vector_unsigned_int, b: vector_unsigned_int) -> u128 {
1318+
transmute(vsumqf(a, b))
1319+
}
1320+
1321+
#[inline]
1322+
#[target_feature(enable = "vector")]
1323+
#[cfg_attr(test, assert_instr(vsumqg))]
1324+
pub unsafe fn vec_vsumqg(a: vector_unsigned_long_long, b: vector_unsigned_long_long) -> u128 {
1325+
transmute(vsumqg(a, b))
1326+
}
1327+
1328+
#[unstable(feature = "stdarch_s390x", issue = "135681")]
1329+
impl VectorSumU128 for vector_unsigned_int {
1330+
#[inline]
1331+
#[target_feature(enable = "vector")]
1332+
unsafe fn vec_sum_u128(self, other: Self) -> vector_unsigned_char {
1333+
transmute(vec_vsumqf(self, other))
1334+
}
1335+
}
1336+
1337+
#[unstable(feature = "stdarch_s390x", issue = "135681")]
1338+
impl VectorSumU128 for vector_unsigned_long_long {
1339+
#[inline]
1340+
#[target_feature(enable = "vector")]
1341+
unsafe fn vec_sum_u128(self, other: Self) -> vector_unsigned_char {
1342+
transmute(vec_vsumqg(self, other))
1343+
}
1344+
}
1345+
1346+
#[unstable(feature = "stdarch_s390x", issue = "135681")]
1347+
pub trait VectorSum2 {
1348+
unsafe fn vec_sum2(self, other: Self) -> vector_unsigned_long_long;
1349+
}
1350+
1351+
test_impl! { vec_vsumgh (a: vector_unsigned_short, b: vector_unsigned_short) -> vector_unsigned_long_long [vsumgh, vsumgh] }
1352+
test_impl! { vec_vsumgf (a: vector_unsigned_int, b: vector_unsigned_int) -> vector_unsigned_long_long [vsumgf, vsumgf] }
1353+
1354+
#[unstable(feature = "stdarch_s390x", issue = "135681")]
1355+
impl VectorSum2 for vector_unsigned_short {
1356+
#[inline]
1357+
#[target_feature(enable = "vector")]
1358+
unsafe fn vec_sum2(self, other: Self) -> vector_unsigned_long_long {
1359+
vec_vsumgh(self, other)
1360+
}
1361+
}
1362+
1363+
#[unstable(feature = "stdarch_s390x", issue = "135681")]
1364+
impl VectorSum2 for vector_unsigned_int {
1365+
#[inline]
1366+
#[target_feature(enable = "vector")]
1367+
unsafe fn vec_sum2(self, other: Self) -> vector_unsigned_long_long {
1368+
vec_vsumgf(self, other)
1369+
}
1370+
}
1371+
1372+
#[unstable(feature = "stdarch_s390x", issue = "135681")]
1373+
pub trait VectorSum4 {
1374+
unsafe fn vec_sum4(self, other: Self) -> vector_unsigned_int;
1375+
}
1376+
1377+
test_impl! { vec_vsumb (a: vector_unsigned_char, b: vector_unsigned_char) -> vector_unsigned_int [vsumb, vsumb] }
1378+
test_impl! { vec_vsumh (a: vector_unsigned_short, b: vector_unsigned_short) -> vector_unsigned_int [vsumh, vsumh] }
1379+
1380+
#[unstable(feature = "stdarch_s390x", issue = "135681")]
1381+
impl VectorSum4 for vector_unsigned_char {
1382+
#[inline]
1383+
#[target_feature(enable = "vector")]
1384+
unsafe fn vec_sum4(self, other: Self) -> vector_unsigned_int {
1385+
vec_vsumb(self, other)
1386+
}
1387+
}
1388+
1389+
#[unstable(feature = "stdarch_s390x", issue = "135681")]
1390+
impl VectorSum4 for vector_unsigned_short {
1391+
#[inline]
1392+
#[target_feature(enable = "vector")]
1393+
unsafe fn vec_sum4(self, other: Self) -> vector_unsigned_int {
1394+
vec_vsumh(self, other)
1395+
}
1396+
}
12981397
}
12991398

13001399
/// Vector element-wise addition.
@@ -1855,6 +1954,39 @@ pub unsafe fn vec_perm<T: sealed::VectorPerm>(a: T, b: T, c: vector_unsigned_cha
18551954
a.vec_perm(b, c)
18561955
}
18571956

1957+
/// Vector Sum Across Quadword
1958+
///
1959+
/// Returns a vector containing the results of performing a sum across all the elements in each of the quadword of vector a,
1960+
/// and the rightmost word or doubleword element of the b. The result is an unsigned 128-bit integer.
1961+
#[inline]
1962+
#[target_feature(enable = "vector")]
1963+
#[unstable(feature = "stdarch_s390x", issue = "135681")]
1964+
pub unsafe fn vec_sum_u128<T: sealed::VectorSumU128>(a: T, b: T) -> vector_unsigned_char {
1965+
a.vec_sum_u128(b)
1966+
}
1967+
1968+
/// Vector Sum Across Doubleword
1969+
///
1970+
/// Returns a vector containing the results of performing a sum across all the elements in each of the doubleword of vector a,
1971+
/// and the rightmost sub-element of the corresponding doubleword of b.
1972+
#[inline]
1973+
#[target_feature(enable = "vector")]
1974+
#[unstable(feature = "stdarch_s390x", issue = "135681")]
1975+
pub unsafe fn vec_sum2<T: sealed::VectorSum2>(a: T, b: T) -> vector_unsigned_long_long {
1976+
a.vec_sum2(b)
1977+
}
1978+
1979+
/// Vector Sum Across Word
1980+
///
1981+
/// Returns a vector containing the results of performing a sum across all the elements in each of the word of vector a,
1982+
/// and the rightmost sub-element of the corresponding word of b.
1983+
#[inline]
1984+
#[target_feature(enable = "vector")]
1985+
#[unstable(feature = "stdarch_s390x", issue = "135681")]
1986+
pub unsafe fn vec_sum4<T: sealed::VectorSum4>(a: T, b: T) -> vector_unsigned_int {
1987+
a.vec_sum4(b)
1988+
}
1989+
18581990
#[cfg(test)]
18591991
mod tests {
18601992
use super::*;

0 commit comments

Comments
 (0)