Skip to content

Commit 84fc953

Browse files
authored
Merge pull request #1996 from folkertdev/s390x-nnp-assist
s390x: add `nnp-assist` intrinsics
2 parents 5829f21 + cf08a11 commit 84fc953

1 file changed

Lines changed: 74 additions & 0 deletions

File tree

  • library/stdarch/crates/core_arch/src/s390x

library/stdarch/crates/core_arch/src/s390x/vector.rs

Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -281,6 +281,12 @@ unsafe extern "unadjusted" {
281281
#[link_name = "llvm.s390.vfenezbs"] fn vfenezbs(a: i8x16, b: i8x16) -> PackedTuple<i8x16, i32>;
282282
#[link_name = "llvm.s390.vfenezhs"] fn vfenezhs(a: i16x8, b: i16x8) -> PackedTuple<i16x8, i32>;
283283
#[link_name = "llvm.s390.vfenezfs"] fn vfenezfs(a: i32x4, b: i32x4) -> PackedTuple<i32x4, i32>;
284+
285+
#[link_name = "llvm.s390.vclfnhs"] fn vclfnhs(a: vector_signed_short, immarg: i32) -> vector_float;
286+
#[link_name = "llvm.s390.vclfnls"] fn vclfnls(a: vector_signed_short, immarg: i32) -> vector_float;
287+
#[link_name = "llvm.s390.vcfn"] fn vcfn(a: vector_signed_short, immarg: i32) -> vector_signed_short;
288+
#[link_name = "llvm.s390.vcnf"] fn vcnf(a: vector_signed_short, immarg: i32) -> vector_signed_short;
289+
#[link_name = "llvm.s390.vcrnfs"] fn vcrnfs(a: vector_float, b: vector_float, immarg: i32) -> vector_signed_short;
284290
}
285291

286292
#[repr(simd)]
@@ -5911,6 +5917,74 @@ pub unsafe fn vec_promote<T: sealed::VectorPromote>(a: T::ElementType, b: i32) -
59115917
T::vec_promote(a, b)
59125918
}
59135919

5920+
/// Converts the left-most half of `a` to a vector of single-precision numbers.
5921+
/// The format of the source vector elements is specified by `B`.
5922+
#[inline]
5923+
#[target_feature(enable = "nnp-assist")]
5924+
#[cfg_attr(test, assert_instr(vclfnh, B = 0))]
5925+
#[unstable(feature = "stdarch_s390x", issue = "135681")]
5926+
pub unsafe fn vec_extend_to_fp32_hi<const B: i32>(a: vector_signed_short) -> vector_float {
5927+
// On processors implementing the IBM z16 architecture, only the value 0 is supported.
5928+
static_assert_uimm_bits!(B, 4);
5929+
5930+
vclfnhs(a, B)
5931+
}
5932+
5933+
/// Converts the right-most half of `a` to a vector of single-precision numbers.
5934+
/// The format of the source vector elements is specified by `B`.
5935+
#[inline]
5936+
#[target_feature(enable = "nnp-assist")]
5937+
#[cfg_attr(test, assert_instr(vclfnl, B = 0))]
5938+
#[unstable(feature = "stdarch_s390x", issue = "135681")]
5939+
pub unsafe fn vec_extend_to_fp32_lo<const B: i32>(a: vector_signed_short) -> vector_float {
5940+
// On processors implementing the IBM z16 architecture, only the value 0 is supported.
5941+
static_assert_uimm_bits!(B, 4);
5942+
5943+
vclfnls(a, B)
5944+
}
5945+
5946+
/// Converts the elements of vector `a` to the 16-bit IEEE floating point format.
5947+
/// The format of the source vector elements is specified by `B`.
5948+
#[inline]
5949+
#[target_feature(enable = "nnp-assist")]
5950+
#[cfg_attr(test, assert_instr(vcfn, B = 0))]
5951+
#[unstable(feature = "stdarch_s390x", issue = "135681")]
5952+
pub unsafe fn vec_convert_to_fp16<const B: i32>(a: vector_signed_short) -> vector_signed_short {
5953+
// On processors implementing the IBM z16 architecture, only the value 0 is supported.
5954+
static_assert_uimm_bits!(B, 4);
5955+
5956+
vcfn(a, B)
5957+
}
5958+
5959+
/// Converts the elements of vector `a` to an internal floating point format.
5960+
/// The format of the target vector elements is specified by `B`.
5961+
#[inline]
5962+
#[target_feature(enable = "nnp-assist")]
5963+
#[cfg_attr(test, assert_instr(vcnf, B = 0))]
5964+
#[unstable(feature = "stdarch_s390x", issue = "135681")]
5965+
pub unsafe fn vec_convert_from_fp16<const B: i32>(a: vector_signed_short) -> vector_signed_short {
5966+
// On processors implementing the IBM z16 architecture, only the value 0 is supported.
5967+
static_assert_uimm_bits!(B, 4);
5968+
5969+
vcnf(a, B)
5970+
}
5971+
5972+
/// Converts the elements of single-precision vectors `a` and `b` to an internal floating point
5973+
/// format with 16-bit sized elements. The format of the target vector elements is specified by `C`.
5974+
#[inline]
5975+
#[target_feature(enable = "nnp-assist")]
5976+
#[unstable(feature = "stdarch_s390x", issue = "135681")]
5977+
#[cfg_attr(test, assert_instr(vcrnf, C = 0))]
5978+
pub unsafe fn vec_round_from_fp32<const C: i32>(
5979+
a: vector_float,
5980+
b: vector_float,
5981+
) -> vector_signed_short {
5982+
// On processors implementing the IBM z16 architecture, only the value 0 is supported.
5983+
static_assert_uimm_bits!(C, 4);
5984+
5985+
vcrnfs(a, b, C)
5986+
}
5987+
59145988
#[cfg(test)]
59155989
mod tests {
59165990
use super::*;

0 commit comments

Comments
 (0)