Skip to content

Commit eba5adf

Browse files
folkertdevAmanieu
authored andcommitted
add vec_gfmsum_accum and vec_gfmsum_accum_128
1 parent 75e9c9e commit eba5adf

File tree

1 file changed

+67
-0
lines changed

1 file changed

+67
-0
lines changed

crates/core_arch/src/s390x/vector.rs

+67
Original file line numberDiff line numberDiff line change
@@ -202,6 +202,10 @@ unsafe extern "unadjusted" {
202202
#[link_name = "llvm.s390.vgfmf"] fn vgfmf(a: vector_unsigned_int, b: vector_unsigned_int) -> vector_unsigned_long_long;
203203
#[link_name = "llvm.s390.vgfmg"] fn vgfmg(a: vector_unsigned_long_long, b: vector_unsigned_long_long) -> u128;
204204

205+
#[link_name = "llvm.s390.vgfmab"] fn vgfmab(a: vector_unsigned_char, b: vector_unsigned_char, c: vector_unsigned_short) -> vector_unsigned_short;
206+
#[link_name = "llvm.s390.vgfmah"] fn vgfmah(a: vector_unsigned_short, b: vector_unsigned_short, c: vector_unsigned_int) -> vector_unsigned_int;
207+
#[link_name = "llvm.s390.vgfmaf"] fn vgfmaf(a: vector_unsigned_int, b: vector_unsigned_int, c: vector_unsigned_long_long) -> vector_unsigned_long_long;
208+
#[link_name = "llvm.s390.vgfmag"] fn vgfmag(a: vector_unsigned_long_long, b: vector_unsigned_long_long, c: u128) -> u128;
205209
}
206210

207211
impl_from! { i8x16, u8x16, i16x8, u16x8, i32x4, u32x4, i64x2, u64x2, f32x4, f64x2 }
@@ -2510,6 +2514,44 @@ mod sealed {
25102514
impl_mul!([VectorGfmsum vec_gfmsum] vec_vgfmb (vector_unsigned_char, vector_unsigned_char) -> vector_unsigned_short );
25112515
impl_mul!([VectorGfmsum vec_gfmsum] vec_vgfmh (vector_unsigned_short, vector_unsigned_short) -> vector_unsigned_int);
25122516
impl_mul!([VectorGfmsum vec_gfmsum] vec_vgfmf (vector_unsigned_int, vector_unsigned_int) -> vector_unsigned_long_long );
2517+
2518+
#[unstable(feature = "stdarch_s390x", issue = "135681")]
2519+
pub trait VectorGfmsumAccum {
2520+
type Result;
2521+
unsafe fn vec_gfmsum_accum(self, b: Self, c: Self::Result) -> Self::Result;
2522+
}
2523+
2524+
test_impl! { vec_vgfmab(a: vector_unsigned_char, b: vector_unsigned_char, c: vector_unsigned_short) -> vector_unsigned_short [ vgfmab, vgfmab ] }
2525+
test_impl! { vec_vgfmah(a: vector_unsigned_short, b: vector_unsigned_short, c: vector_unsigned_int) -> vector_unsigned_int[ vgfmah, vgfmah] }
2526+
test_impl! { vec_vgfmaf(a: vector_unsigned_int, b: vector_unsigned_int, c: vector_unsigned_long_long) -> vector_unsigned_long_long [ vgfmaf, vgfmaf ] }
2527+
2528+
#[unstable(feature = "stdarch_s390x", issue = "135681")]
2529+
impl VectorGfmsumAccum for vector_unsigned_char {
2530+
type Result = vector_unsigned_short;
2531+
#[inline]
2532+
#[target_feature(enable = "vector")]
2533+
unsafe fn vec_gfmsum_accum(self, b: Self, c: Self::Result) -> Self::Result {
2534+
vec_vgfmab(self, b, c)
2535+
}
2536+
}
2537+
#[unstable(feature = "stdarch_s390x", issue = "135681")]
2538+
impl VectorGfmsumAccum for vector_unsigned_short {
2539+
type Result = vector_unsigned_int;
2540+
#[inline]
2541+
#[target_feature(enable = "vector")]
2542+
unsafe fn vec_gfmsum_accum(self, b: Self, c: Self::Result) -> Self::Result {
2543+
vec_vgfmah(self, b, c)
2544+
}
2545+
}
2546+
#[unstable(feature = "stdarch_s390x", issue = "135681")]
2547+
impl VectorGfmsumAccum for vector_unsigned_int {
2548+
type Result = vector_unsigned_long_long;
2549+
#[inline]
2550+
#[target_feature(enable = "vector")]
2551+
unsafe fn vec_gfmsum_accum(self, b: Self, c: Self::Result) -> Self::Result {
2552+
vec_vgfmaf(self, b, c)
2553+
}
2554+
}
25132555
}
25142556

25152557
/// Load Count to Block Boundary
@@ -3611,6 +3653,18 @@ pub unsafe fn vec_gfmsum<T: sealed::VectorGfmsum<U>, U>(a: T, b: T) -> U {
36113653
a.vec_gfmsum(b)
36123654
}
36133655

3656+
/// Vector Galois Field Multiply Sum
3657+
#[inline]
3658+
#[target_feature(enable = "vector")]
3659+
#[unstable(feature = "stdarch_s390x", issue = "135681")]
3660+
pub unsafe fn vec_gfmsum_accum<T: sealed::VectorGfmsumAccum>(
3661+
a: T,
3662+
b: T,
3663+
c: T::Result,
3664+
) -> T::Result {
3665+
a.vec_gfmsum_accum(b, c)
3666+
}
3667+
36143668
/// Vector Galois Field Multiply Sum 128-bits
36153669
#[inline]
36163670
#[target_feature(enable = "vector")]
@@ -3623,6 +3677,19 @@ pub unsafe fn vec_gfmsum_128(
36233677
transmute(vgfmg(a, b))
36243678
}
36253679

3680+
/// Vector Galois Field Multiply Sum and Accumulate 128-bits
3681+
#[inline]
3682+
#[target_feature(enable = "vector")]
3683+
#[unstable(feature = "stdarch_s390x", issue = "135681")]
3684+
#[cfg_attr(test, assert_instr(vgfmag))]
3685+
pub unsafe fn vec_gfmsum_accum_128(
3686+
a: vector_unsigned_long_long,
3687+
b: vector_unsigned_long_long,
3688+
c: vector_unsigned_char,
3689+
) -> vector_unsigned_char {
3690+
transmute(vgfmag(a, b, transmute(c)))
3691+
}
3692+
36263693
#[cfg(test)]
36273694
mod tests {
36283695
use super::*;

0 commit comments

Comments
 (0)