Skip to content

Commit ed8a610

Browse files
folkertdevAmanieu
authored andcommitted
add vec_find_any_eq_idx and vec_find_any_ne_idx
1 parent c837061 commit ed8a610

File tree

1 file changed

+95
-0
lines changed

1 file changed

+95
-0
lines changed

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

+95
Original file line numberDiff line numberDiff line change
@@ -1554,6 +1554,19 @@ mod sealed {
15541554
}
15551555

15561556
macro_rules! impl_vfae {
1557+
([idx $Trait:ident $m:ident] $imm:literal $($fun:ident $ty:ident $r:ident)*) => {
1558+
$(
1559+
#[unstable(feature = "stdarch_s390x", issue = "135681")]
1560+
impl $Trait<Self> for $ty {
1561+
type Result = $r;
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+
};
15571570
([$Trait:ident $m:ident] $imm:literal $($fun:ident $ty:ident)*) => {
15581571
$(
15591572
#[unstable(feature = "stdarch_s390x", issue = "135681")]
@@ -1608,6 +1621,46 @@ mod sealed {
16081621
vfaef vector_unsigned_int
16091622
vfaef vector_bool_int
16101623
}
1624+
1625+
#[unstable(feature = "stdarch_s390x", issue = "135681")]
1626+
pub trait VectorFindAnyEqIdx<Other> {
1627+
type Result;
1628+
unsafe fn vec_find_any_eq_idx(self, other: Other) -> Self::Result;
1629+
}
1630+
1631+
impl_vfae! { [idx VectorFindAnyEqIdx vec_find_any_eq_idx] 0
1632+
vfaeb vector_signed_char vector_signed_char
1633+
vfaeb vector_unsigned_char vector_unsigned_char
1634+
vfaeb vector_bool_char vector_unsigned_char
1635+
1636+
vfaeh vector_signed_short vector_signed_short
1637+
vfaeh vector_unsigned_short vector_unsigned_short
1638+
vfaeh vector_bool_short vector_unsigned_short
1639+
1640+
vfaef vector_signed_int vector_signed_int
1641+
vfaef vector_unsigned_int vector_unsigned_int
1642+
vfaef vector_bool_int vector_unsigned_int
1643+
}
1644+
1645+
#[unstable(feature = "stdarch_s390x", issue = "135681")]
1646+
pub trait VectorFindAnyNeIdx<Other> {
1647+
type Result;
1648+
unsafe fn vec_find_any_ne_idx(self, other: Other) -> Self::Result;
1649+
}
1650+
1651+
impl_vfae! { [idx VectorFindAnyNeIdx vec_find_any_ne_idx] 8
1652+
vfaeb vector_signed_char vector_signed_char
1653+
vfaeb vector_unsigned_char vector_unsigned_char
1654+
vfaeb vector_bool_char vector_unsigned_char
1655+
1656+
vfaeh vector_signed_short vector_signed_short
1657+
vfaeh vector_unsigned_short vector_unsigned_short
1658+
vfaeh vector_bool_short vector_unsigned_short
1659+
1660+
vfaef vector_signed_int vector_signed_int
1661+
vfaef vector_unsigned_int vector_unsigned_int
1662+
vfaef vector_bool_int vector_unsigned_int
1663+
}
16111664
}
16121665

16131666
/// Vector element-wise addition.
@@ -2413,6 +2466,26 @@ where
24132466
a.vec_find_any_ne(b)
24142467
}
24152468

2469+
#[inline]
2470+
#[target_feature(enable = "vector")]
2471+
#[unstable(feature = "stdarch_s390x", issue = "135681")]
2472+
pub unsafe fn vec_find_any_eq_idx<T, U>(a: T, b: U) -> <T as sealed::VectorFindAnyEqIdx<U>>::Result
2473+
where
2474+
T: sealed::VectorFindAnyEqIdx<U>,
2475+
{
2476+
a.vec_find_any_eq_idx(b)
2477+
}
2478+
2479+
#[inline]
2480+
#[target_feature(enable = "vector")]
2481+
#[unstable(feature = "stdarch_s390x", issue = "135681")]
2482+
pub unsafe fn vec_find_any_ne_idx<T, U>(a: T, b: U) -> <T as sealed::VectorFindAnyNeIdx<U>>::Result
2483+
where
2484+
T: sealed::VectorFindAnyNeIdx<U>,
2485+
{
2486+
a.vec_find_any_ne_idx(b)
2487+
}
2488+
24162489
#[cfg(test)]
24172490
mod tests {
24182491
use super::*;
@@ -2945,4 +3018,26 @@ mod tests {
29453018
[-5, 3, -7, 8],
29463019
[0xFFFFFFFF, 0xFFFFFFFF, 0, 0xFFFFFFFF]
29473020
}
3021+
3022+
test_vec_2! { test_vec_find_any_eq_idx_1, vec_find_any_eq_idx, i32x4, i32x4 -> u32x4,
3023+
[1, 2, 3, 4],
3024+
[5, 3, 7, 8],
3025+
[0, 8, 0, 0]
3026+
}
3027+
test_vec_2! { test_vec_find_any_eq_idx_2, vec_find_any_eq_idx, i32x4, i32x4 -> u32x4,
3028+
[1, 2, 3, 4],
3029+
[5, 6, 7, 8],
3030+
[0, 16, 0, 0]
3031+
}
3032+
3033+
test_vec_2! { test_vec_find_any_ne_idx_1, vec_find_any_ne_idx, i32x4, i32x4 -> u32x4,
3034+
[1, 2, 3, 4],
3035+
[1, 5, 3, 4],
3036+
[0, 4, 0, 0]
3037+
}
3038+
test_vec_2! { test_vec_find_any_ne_idx_2, vec_find_any_ne_idx, i32x4, i32x4 -> u32x4,
3039+
[1, 2, 3, 4],
3040+
[1, 2, 3, 4],
3041+
[0, 16, 0, 0]
3042+
}
29483043
}

0 commit comments

Comments
 (0)