Skip to content

Commit

Permalink
add vec_nmadd
Browse files Browse the repository at this point in the history
  • Loading branch information
folkertdev committed Mar 4, 2025
1 parent c5601aa commit 944966b
Showing 1 changed file with 49 additions and 0 deletions.
49 changes: 49 additions & 0 deletions crates/core_arch/src/s390x/vector.rs
Original file line number Diff line number Diff line change
Expand Up @@ -700,6 +700,47 @@ mod sealed {
}
}

#[unstable(feature = "stdarch_s390x", issue = "135681")]
pub trait VectorNmadd {
unsafe fn vec_nmadd(self, b: Self, c: Self) -> Self;
}

#[inline]
#[target_feature(enable = "vector")]
#[cfg_attr(
all(test, target_feature = "vector-enhancements-2"),
assert_instr(vfnmasb)
)]
unsafe fn vec_nmadd_f32(a: vector_float, b: vector_float, c: vector_float) -> vector_float {
simd_neg(simd_fma(a, b, c))
}

#[unstable(feature = "stdarch_s390x", issue = "135681")]
impl VectorNmadd for vector_float {
#[target_feature(enable = "vector")]
unsafe fn vec_nmadd(self, b: Self, c: Self) -> Self {
vec_nmadd_f32(self, b, c)
}
}

#[inline]
#[target_feature(enable = "vector")]
#[cfg_attr(
all(test, target_feature = "vector-enhancements-2"),
assert_instr(vfnmadb)
)]
unsafe fn vec_nmadd_f64(a: vector_double, b: vector_double, c: vector_double) -> vector_double {
simd_neg(simd_fma(a, b, c))
}

#[unstable(feature = "stdarch_s390x", issue = "135681")]
impl VectorNmadd for vector_double {
#[target_feature(enable = "vector")]
unsafe fn vec_nmadd(self, b: Self, c: Self) -> Self {
vec_nmadd_f64(self, b, c)
}
}

#[unstable(feature = "stdarch_s390x", issue = "135681")]
pub trait VectorSplat {
unsafe fn vec_splat<const IMM: u32>(self) -> Self;
Expand Down Expand Up @@ -2678,6 +2719,14 @@ pub unsafe fn vec_nabs<T: sealed::VectorNabs>(a: T) -> T {
a.vec_nabs()
}

/// Vector Negative Multiply Add
#[inline]
#[target_feature(enable = "vector")]
#[unstable(feature = "stdarch_s390x", issue = "135681")]
pub unsafe fn vec_nmadd<T: sealed::VectorNmadd>(a: T, b: T, c: T) -> T {
a.vec_nmadd(b, c)
}

/// Vector Negative Multiply Subtract
#[inline]
#[target_feature(enable = "vector")]
Expand Down

0 comments on commit 944966b

Please sign in to comment.