Skip to content

Commit 32d5a80

Browse files
folkertdevAmanieu
authored andcommitted
add vec_fp_test_data_class
1 parent e355bf4 commit 32d5a80

File tree

1 file changed

+125
-0
lines changed

1 file changed

+125
-0
lines changed

crates/core_arch/src/s390x/vector.rs

Lines changed: 125 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -208,6 +208,9 @@ unsafe extern "unadjusted" {
208208
#[link_name = "llvm.s390.vgfmag"] fn vgfmag(a: vector_unsigned_long_long, b: vector_unsigned_long_long, c: u128) -> u128;
209209

210210
#[link_name = "llvm.s390.vbperm"] fn vbperm(a: vector_unsigned_char, b: vector_unsigned_char) -> vector_unsigned_long_long;
211+
212+
#[link_name = "llvm.s390.vftcisb"] fn vftcisb(a: vector_float, b: u32) -> PackedTuple<vector_bool_int, i32>;
213+
#[link_name = "llvm.s390.vftcidb"] fn vftcidb(a: vector_double, b: u32) -> PackedTuple<vector_bool_long_long, i32>;
211214
}
212215

213216
impl_from! { i8x16, u8x16, i16x8, u16x8, i32x4, u32x4, i64x2, u64x2, f32x4, f64x2 }
@@ -2783,6 +2786,38 @@ mod sealed {
27832786
vector_float
27842787
vector_double
27852788
}
2789+
2790+
#[unstable(feature = "stdarch_s390x", issue = "135681")]
2791+
pub trait VectorFpTestDataClass {
2792+
type Result;
2793+
unsafe fn vec_fp_test_data_class<const CLASS: u32>(self, ptr: *mut i32) -> Self::Result;
2794+
}
2795+
2796+
#[unstable(feature = "stdarch_s390x", issue = "135681")]
2797+
impl VectorFpTestDataClass for vector_float {
2798+
type Result = vector_bool_int;
2799+
2800+
#[inline]
2801+
#[target_feature(enable = "vector")]
2802+
unsafe fn vec_fp_test_data_class<const CLASS: u32>(self, ptr: *mut i32) -> Self::Result {
2803+
let PackedTuple { x, y } = vftcisb(self, CLASS);
2804+
unsafe { ptr.write(y) };
2805+
x
2806+
}
2807+
}
2808+
2809+
#[unstable(feature = "stdarch_s390x", issue = "135681")]
2810+
impl VectorFpTestDataClass for vector_double {
2811+
type Result = vector_bool_long_long;
2812+
2813+
#[inline]
2814+
#[target_feature(enable = "vector")]
2815+
unsafe fn vec_fp_test_data_class<const CLASS: u32>(self, ptr: *mut i32) -> Self::Result {
2816+
let PackedTuple { x, y } = vftcidb(self, CLASS);
2817+
unsafe { ptr.write(y) };
2818+
x
2819+
}
2820+
}
27862821
}
27872822

27882823
/// Load Count to Block Boundary
@@ -3961,6 +3996,61 @@ pub unsafe fn vec_sel<T: sealed::VectorSel<U>, U>(a: T, b: T, c: U) -> T {
39613996
a.vec_sel(b, c)
39623997
}
39633998

3999+
#[unstable(feature = "stdarch_s390x", issue = "135681")]
4000+
pub const __VEC_CLASS_FP_ZERO_P: u32 = 1 << 11;
4001+
#[unstable(feature = "stdarch_s390x", issue = "135681")]
4002+
pub const __VEC_CLASS_FP_ZERO_N: u32 = 1 << 10;
4003+
#[unstable(feature = "stdarch_s390x", issue = "135681")]
4004+
pub const __VEC_CLASS_FP_ZERO: u32 = __VEC_CLASS_FP_ZERO_P | __VEC_CLASS_FP_ZERO_N;
4005+
#[unstable(feature = "stdarch_s390x", issue = "135681")]
4006+
pub const __VEC_CLASS_FP_NORMAL_P: u32 = 1 << 9;
4007+
#[unstable(feature = "stdarch_s390x", issue = "135681")]
4008+
pub const __VEC_CLASS_FP_NORMAL_N: u32 = 1 << 8;
4009+
#[unstable(feature = "stdarch_s390x", issue = "135681")]
4010+
pub const __VEC_CLASS_FP_NORMAL: u32 = __VEC_CLASS_FP_NORMAL_P | __VEC_CLASS_FP_NORMAL_N;
4011+
#[unstable(feature = "stdarch_s390x", issue = "135681")]
4012+
pub const __VEC_CLASS_FP_SUBNORMAL_P: u32 = 1 << 7;
4013+
#[unstable(feature = "stdarch_s390x", issue = "135681")]
4014+
pub const __VEC_CLASS_FP_SUBNORMAL_N: u32 = 1 << 6;
4015+
#[unstable(feature = "stdarch_s390x", issue = "135681")]
4016+
pub const __VEC_CLASS_FP_SUBNORMAL: u32 = __VEC_CLASS_FP_SUBNORMAL_P | __VEC_CLASS_FP_SUBNORMAL_N;
4017+
#[unstable(feature = "stdarch_s390x", issue = "135681")]
4018+
pub const __VEC_CLASS_FP_INFINITY_P: u32 = 1 << 5;
4019+
#[unstable(feature = "stdarch_s390x", issue = "135681")]
4020+
pub const __VEC_CLASS_FP_INFINITY_N: u32 = 1 << 4;
4021+
#[unstable(feature = "stdarch_s390x", issue = "135681")]
4022+
pub const __VEC_CLASS_FP_INFINITY: u32 = __VEC_CLASS_FP_INFINITY_P | __VEC_CLASS_FP_INFINITY_N;
4023+
#[unstable(feature = "stdarch_s390x", issue = "135681")]
4024+
pub const __VEC_CLASS_FP_QNAN_P: u32 = 1 << 3;
4025+
#[unstable(feature = "stdarch_s390x", issue = "135681")]
4026+
pub const __VEC_CLASS_FP_QNAN_N: u32 = 1 << 2;
4027+
#[unstable(feature = "stdarch_s390x", issue = "135681")]
4028+
pub const __VEC_CLASS_FP_QNAN: u32 = __VEC_CLASS_FP_QNAN_P | __VEC_CLASS_FP_QNAN_N;
4029+
#[unstable(feature = "stdarch_s390x", issue = "135681")]
4030+
pub const __VEC_CLASS_FP_SNAN_P: u32 = 1 << 1;
4031+
#[unstable(feature = "stdarch_s390x", issue = "135681")]
4032+
pub const __VEC_CLASS_FP_SNAN_N: u32 = 1 << 0;
4033+
#[unstable(feature = "stdarch_s390x", issue = "135681")]
4034+
pub const __VEC_CLASS_FP_SNAN: u32 = __VEC_CLASS_FP_SNAN_P | __VEC_CLASS_FP_SNAN_N;
4035+
#[unstable(feature = "stdarch_s390x", issue = "135681")]
4036+
pub const __VEC_CLASS_FP_NAN: u32 = __VEC_CLASS_FP_QNAN | __VEC_CLASS_FP_SNAN;
4037+
#[unstable(feature = "stdarch_s390x", issue = "135681")]
4038+
pub const __VEC_CLASS_FP_NOT_NORMAL: u32 =
4039+
__VEC_CLASS_FP_NAN | __VEC_CLASS_FP_SUBNORMAL | __VEC_CLASS_FP_ZERO | __VEC_CLASS_FP_INFINITY;
4040+
4041+
/// Vector Floating-Point Test Data Class
4042+
///
4043+
/// You can use the `__VEC_CLASS_FP_*` constants as the argument for this operand
4044+
#[inline]
4045+
#[target_feature(enable = "vector")]
4046+
#[unstable(feature = "stdarch_s390x", issue = "135681")]
4047+
pub unsafe fn vec_fp_test_data_class<T: sealed::VectorFpTestDataClass, const CLASS: u32>(
4048+
a: T,
4049+
c: *mut i32,
4050+
) -> T::Result {
4051+
a.vec_fp_test_data_class::<CLASS>(c)
4052+
}
4053+
39644054
#[cfg(test)]
39654055
mod tests {
39664056
use super::*;
@@ -4946,4 +5036,39 @@ mod tests {
49465036
assert_eq!(d2.as_array(), &[25, 2, 3, 4]);
49475037
}
49485038
}
5039+
5040+
#[simd_test(enable = "vector")]
5041+
fn test_vec_fp_test_data_class() {
5042+
let mut cc = 42;
5043+
5044+
let v1 = vector_double([0.0, f64::NAN]);
5045+
let v2 = vector_double([f64::INFINITY, 1.0]);
5046+
let v3 = vector_double([1.0, 2.0]);
5047+
5048+
unsafe {
5049+
let d = vec_fp_test_data_class::<_, __VEC_CLASS_FP_ZERO>(v1, &mut cc);
5050+
assert_eq!(cc, 1);
5051+
assert_eq!(d.as_array(), &[!0, 0]);
5052+
5053+
let d = vec_fp_test_data_class::<_, __VEC_CLASS_FP_NAN>(v1, &mut cc);
5054+
assert_eq!(cc, 1);
5055+
assert_eq!(d.as_array(), &[0, !0]);
5056+
5057+
let d = vec_fp_test_data_class::<_, __VEC_CLASS_FP_INFINITY>(v2, &mut cc);
5058+
assert_eq!(cc, 1);
5059+
assert_eq!(d.as_array(), &[!0, 0]);
5060+
5061+
let d = vec_fp_test_data_class::<_, __VEC_CLASS_FP_INFINITY_N>(v2, &mut cc);
5062+
assert_eq!(cc, 3);
5063+
assert_eq!(d.as_array(), &[0, 0]);
5064+
5065+
let d = vec_fp_test_data_class::<_, __VEC_CLASS_FP_NORMAL>(v2, &mut cc);
5066+
assert_eq!(cc, 1);
5067+
assert_eq!(d.as_array(), &[0, !0]);
5068+
5069+
let d = vec_fp_test_data_class::<_, __VEC_CLASS_FP_NORMAL>(v3, &mut cc);
5070+
assert_eq!(cc, 0);
5071+
assert_eq!(d.as_array(), &[!0, !0]);
5072+
}
5073+
}
49495074
}

0 commit comments

Comments
 (0)