Skip to content

Commit c837061

Browse files
folkertdevAmanieu
authored andcommitted
add vec_find_any_eq and vec_find_any_ne
1 parent 35b576b commit c837061

File tree

1 file changed

+119
-0
lines changed

1 file changed

+119
-0
lines changed

Diff for: crates/core_arch/src/s390x/vector.rs

+119
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,9 @@ unsafe extern "unadjusted" {
121121
#[link_name = "llvm.s390.vscbif"] fn vscbif(a: vector_unsigned_int, b: vector_unsigned_int) -> vector_unsigned_int;
122122
#[link_name = "llvm.s390.vscbig"] fn vscbig(a: vector_unsigned_long_long, b: vector_unsigned_long_long) -> vector_unsigned_long_long;
123123

124+
#[link_name = "llvm.s390.vfaeb"] fn vfaeb(a: vector_signed_char, b: vector_signed_char, c: i32) -> vector_signed_char;
125+
#[link_name = "llvm.s390.vfaeh"] fn vfaeh(a: vector_signed_short, b: vector_signed_short, c: i32) -> vector_signed_short;
126+
#[link_name = "llvm.s390.vfaef"] fn vfaef(a: vector_signed_int, b: vector_signed_int, c: i32) -> vector_signed_int;
124127
}
125128

126129
impl_from! { i8x16, u8x16, i16x8, u16x8, i32x4, u32x4, i64x2, u64x2, f32x4, f64x2 }
@@ -1521,6 +1524,90 @@ mod sealed {
15211524

15221525
impl_vec_trait! { [VectorSqrt vec_sqrt] vec_sqrt_f32 (vector_float) }
15231526
impl_vec_trait! { [VectorSqrt vec_sqrt] vec_sqrt_f64 (vector_double) }
1527+
1528+
#[inline]
1529+
#[target_feature(enable = "vector")]
1530+
#[cfg_attr(test, assert_instr(vfaeb, IMM = 0))]
1531+
unsafe fn vfaeb<const IMM: i32>(
1532+
a: vector_signed_char,
1533+
b: vector_signed_char,
1534+
) -> vector_signed_char {
1535+
super::vfaeb(a, b, IMM)
1536+
}
1537+
#[inline]
1538+
#[target_feature(enable = "vector")]
1539+
#[cfg_attr(test, assert_instr(vfaeh, IMM = 0))]
1540+
unsafe fn vfaeh<const IMM: i32>(
1541+
a: vector_signed_short,
1542+
b: vector_signed_short,
1543+
) -> vector_signed_short {
1544+
super::vfaeh(a, b, IMM)
1545+
}
1546+
#[inline]
1547+
#[target_feature(enable = "vector")]
1548+
#[cfg_attr(test, assert_instr(vfaef, IMM = 0))]
1549+
unsafe fn vfaef<const IMM: i32>(
1550+
a: vector_signed_int,
1551+
b: vector_signed_int,
1552+
) -> vector_signed_int {
1553+
super::vfaef(a, b, IMM)
1554+
}
1555+
1556+
macro_rules! impl_vfae {
1557+
([$Trait:ident $m:ident] $imm:literal $($fun:ident $ty:ident)*) => {
1558+
$(
1559+
#[unstable(feature = "stdarch_s390x", issue = "135681")]
1560+
impl $Trait<Self> for $ty {
1561+
type Result = t_b!($ty);
1562+
#[inline]
1563+
#[target_feature(enable = "vector")]
1564+
unsafe fn $m(self, b: Self) -> Self::Result {
1565+
transmute($fun::<$imm>(transmute(self), transmute(b)))
1566+
}
1567+
}
1568+
)*
1569+
};
1570+
}
1571+
1572+
#[unstable(feature = "stdarch_s390x", issue = "135681")]
1573+
pub trait VectorFindAnyEq<Other> {
1574+
type Result;
1575+
unsafe fn vec_find_any_eq(self, other: Other) -> Self::Result;
1576+
}
1577+
1578+
impl_vfae! { [VectorFindAnyEq vec_find_any_eq] 4
1579+
vfaeb vector_signed_char
1580+
vfaeb vector_unsigned_char
1581+
vfaeb vector_bool_char
1582+
1583+
vfaeh vector_signed_short
1584+
vfaeh vector_unsigned_short
1585+
vfaeh vector_bool_short
1586+
1587+
vfaef vector_signed_int
1588+
vfaef vector_unsigned_int
1589+
vfaef vector_bool_int
1590+
}
1591+
1592+
#[unstable(feature = "stdarch_s390x", issue = "135681")]
1593+
pub trait VectorFindAnyNe<Other> {
1594+
type Result;
1595+
unsafe fn vec_find_any_ne(self, other: Other) -> Self::Result;
1596+
}
1597+
1598+
impl_vfae! { [VectorFindAnyNe vec_find_any_ne] 12
1599+
vfaeb vector_signed_char
1600+
vfaeb vector_unsigned_char
1601+
vfaeb vector_bool_char
1602+
1603+
vfaeh vector_signed_short
1604+
vfaeh vector_unsigned_short
1605+
vfaeh vector_bool_short
1606+
1607+
vfaef vector_signed_int
1608+
vfaef vector_unsigned_int
1609+
vfaef vector_bool_int
1610+
}
15241611
}
15251612

15261613
/// Vector element-wise addition.
@@ -2306,6 +2393,26 @@ pub unsafe fn vec_splat_u64<const IMM: i16>() -> vector_unsigned_long_long {
23062393
vector_unsigned_long_long([IMM as u64; 2])
23072394
}
23082395

2396+
#[inline]
2397+
#[target_feature(enable = "vector")]
2398+
#[unstable(feature = "stdarch_s390x", issue = "135681")]
2399+
pub unsafe fn vec_find_any_eq<T, U>(a: T, b: U) -> <T as sealed::VectorFindAnyEq<U>>::Result
2400+
where
2401+
T: sealed::VectorFindAnyEq<U>,
2402+
{
2403+
a.vec_find_any_eq(b)
2404+
}
2405+
2406+
#[inline]
2407+
#[target_feature(enable = "vector")]
2408+
#[unstable(feature = "stdarch_s390x", issue = "135681")]
2409+
pub unsafe fn vec_find_any_ne<T, U>(a: T, b: U) -> <T as sealed::VectorFindAnyNe<U>>::Result
2410+
where
2411+
T: sealed::VectorFindAnyNe<U>,
2412+
{
2413+
a.vec_find_any_ne(b)
2414+
}
2415+
23092416
#[cfg(test)]
23102417
mod tests {
23112418
use super::*;
@@ -2826,4 +2933,16 @@ mod tests {
28262933
test_vec_1! { test_vec_sqrt, vec_sqrt, f32x4,
28272934
[core::f32::consts::PI, 1.0, 25.0, 2.0],
28282935
[core::f32::consts::PI.sqrt(), 1.0, 5.0, core::f32::consts::SQRT_2] }
2936+
2937+
test_vec_2! { test_vec_find_any_eq, vec_find_any_eq, i32x4, i32x4 -> u32x4,
2938+
[1, -2, 3, -4],
2939+
[-5, 3, -7, 8],
2940+
[0, 0, 0xFFFFFFFF, 0]
2941+
}
2942+
2943+
test_vec_2! { test_vec_find_any_ne, vec_find_any_ne, i32x4, i32x4 -> u32x4,
2944+
[1, -2, 3, -4],
2945+
[-5, 3, -7, 8],
2946+
[0xFFFFFFFF, 0xFFFFFFFF, 0, 0xFFFFFFFF]
2947+
}
28292948
}

0 commit comments

Comments
 (0)