Skip to content

Commit bc9bdcc

Browse files
committed
add vec_find_any_eq_idx and vec_find_any_ne_idx
1 parent dbddfa7 commit bc9bdcc

File tree

1 file changed

+95
-0
lines changed

1 file changed

+95
-0
lines changed

crates/core_arch/src/s390x/vector.rs

Lines changed: 95 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1558,6 +1558,19 @@ mod sealed {
15581558
}
15591559

15601560
macro_rules! impl_vfae {
1561+
([idx $Trait:ident $m:ident] $imm:literal $($fun:ident $ty:ident $r:ident)*) => {
1562+
$(
1563+
#[unstable(feature = "stdarch_s390x", issue = "135681")]
1564+
impl $Trait<Self> for $ty {
1565+
type Result = $r;
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+
};
15611574
([$Trait:ident $m:ident] $imm:literal $($fun:ident $ty:ident)*) => {
15621575
$(
15631576
#[unstable(feature = "stdarch_s390x", issue = "135681")]
@@ -1612,6 +1625,46 @@ mod sealed {
16121625
vfaef vector_unsigned_int
16131626
vfaef vector_bool_int
16141627
}
1628+
1629+
#[unstable(feature = "stdarch_s390x", issue = "135681")]
1630+
pub trait VectorFindAnyEqIdx<Other> {
1631+
type Result;
1632+
unsafe fn vec_find_any_eq_idx(self, other: Other) -> Self::Result;
1633+
}
1634+
1635+
impl_vfae! { [idx VectorFindAnyEqIdx vec_find_any_eq_idx] 0
1636+
vfaeb vector_signed_char vector_signed_char
1637+
vfaeb vector_unsigned_char vector_unsigned_char
1638+
vfaeb vector_bool_char vector_unsigned_char
1639+
1640+
vfaeh vector_signed_short vector_signed_short
1641+
vfaeh vector_unsigned_short vector_unsigned_short
1642+
vfaeh vector_bool_short vector_unsigned_short
1643+
1644+
vfaef vector_signed_int vector_signed_int
1645+
vfaef vector_unsigned_int vector_unsigned_int
1646+
vfaef vector_bool_int vector_unsigned_int
1647+
}
1648+
1649+
#[unstable(feature = "stdarch_s390x", issue = "135681")]
1650+
pub trait VectorFindAnyNeIdx<Other> {
1651+
type Result;
1652+
unsafe fn vec_find_any_ne_idx(self, other: Other) -> Self::Result;
1653+
}
1654+
1655+
impl_vfae! { [idx VectorFindAnyNeIdx vec_find_any_ne_idx] 8
1656+
vfaeb vector_signed_char vector_signed_char
1657+
vfaeb vector_unsigned_char vector_unsigned_char
1658+
vfaeb vector_bool_char vector_unsigned_char
1659+
1660+
vfaeh vector_signed_short vector_signed_short
1661+
vfaeh vector_unsigned_short vector_unsigned_short
1662+
vfaeh vector_bool_short vector_unsigned_short
1663+
1664+
vfaef vector_signed_int vector_signed_int
1665+
vfaef vector_unsigned_int vector_unsigned_int
1666+
vfaef vector_bool_int vector_unsigned_int
1667+
}
16151668
}
16161669

16171670
/// Vector element-wise addition.
@@ -2417,6 +2470,26 @@ where
24172470
a.vec_find_any_ne(b)
24182471
}
24192472

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

0 commit comments

Comments
 (0)