Skip to content

Commit f2a3d78

Browse files
committed
add vec_nmadd
1 parent 43014f1 commit f2a3d78

File tree

1 file changed

+49
-0
lines changed

1 file changed

+49
-0
lines changed

crates/core_arch/src/s390x/vector.rs

+49
Original file line numberDiff line numberDiff line change
@@ -700,6 +700,47 @@ mod sealed {
700700
}
701701
}
702702

703+
#[unstable(feature = "stdarch_s390x", issue = "135681")]
704+
pub trait VectorNmadd {
705+
unsafe fn vec_nmadd(self, b: Self, c: Self) -> Self;
706+
}
707+
708+
#[inline]
709+
#[target_feature(enable = "vector")]
710+
#[cfg_attr(
711+
all(test, target_feature = "vector-enhancements-2"),
712+
assert_instr(vfnmasb)
713+
)]
714+
unsafe fn vec_nmadd_f32(a: vector_float, b: vector_float, c: vector_float) -> vector_float {
715+
simd_neg(simd_fma(a, b, c))
716+
}
717+
718+
#[unstable(feature = "stdarch_s390x", issue = "135681")]
719+
impl VectorNmadd for vector_float {
720+
#[target_feature(enable = "vector")]
721+
unsafe fn vec_nmadd(self, b: Self, c: Self) -> Self {
722+
vec_nmadd_f32(self, b, c)
723+
}
724+
}
725+
726+
#[inline]
727+
#[target_feature(enable = "vector")]
728+
#[cfg_attr(
729+
all(test, target_feature = "vector-enhancements-2"),
730+
assert_instr(vfnmadb)
731+
)]
732+
unsafe fn vec_nmadd_f64(a: vector_double, b: vector_double, c: vector_double) -> vector_double {
733+
simd_neg(simd_fma(a, b, c))
734+
}
735+
736+
#[unstable(feature = "stdarch_s390x", issue = "135681")]
737+
impl VectorNmadd for vector_double {
738+
#[target_feature(enable = "vector")]
739+
unsafe fn vec_nmadd(self, b: Self, c: Self) -> Self {
740+
vec_nmadd_f64(self, b, c)
741+
}
742+
}
743+
703744
#[unstable(feature = "stdarch_s390x", issue = "135681")]
704745
pub trait VectorSplat {
705746
unsafe fn vec_splat<const IMM: u32>(self) -> Self;
@@ -2678,6 +2719,14 @@ pub unsafe fn vec_nabs<T: sealed::VectorNabs>(a: T) -> T {
26782719
a.vec_nabs()
26792720
}
26802721

2722+
/// Vector Negative Multiply Add
2723+
#[inline]
2724+
#[target_feature(enable = "vector")]
2725+
#[unstable(feature = "stdarch_s390x", issue = "135681")]
2726+
pub unsafe fn vec_nmadd<T: sealed::VectorNmadd>(a: T, b: T, c: T) -> T {
2727+
a.vec_nmadd(b, c)
2728+
}
2729+
26812730
/// Vector Negative Multiply Subtract
26822731
#[inline]
26832732
#[target_feature(enable = "vector")]

0 commit comments

Comments
 (0)