Skip to content

Commit dbddfa7

Browse files
committed
add vec_find_any_eq and vec_find_any_ne
1 parent 1520599 commit dbddfa7

File tree

1 file changed

+119
-0
lines changed

1 file changed

+119
-0
lines changed

crates/core_arch/src/s390x/vector.rs

Lines changed: 119 additions & 0 deletions
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 }
@@ -1525,6 +1528,90 @@ mod sealed {
15251528

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

15301617
/// Vector element-wise addition.
@@ -2310,6 +2397,26 @@ pub unsafe fn vec_splat_u64<const IMM: i16>() -> vector_unsigned_long_long {
23102397
vector_unsigned_long_long([IMM as u64; 2])
23112398
}
23122399

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

0 commit comments

Comments
 (0)