Skip to content

Commit f93c22b

Browse files
folkertdevAmanieu
authored andcommitted
add vec_find_any_eq_or_0_idx and vec_find_any_ne_or_0_idx
1 parent 143539e commit f93c22b

File tree

1 file changed

+146
-38
lines changed

1 file changed

+146
-38
lines changed

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

+146-38
Original file line numberDiff line numberDiff line change
@@ -131,9 +131,17 @@ unsafe extern "unadjusted" {
131131
#[link_name = "llvm.s390.vfaeh"] fn vfaeh(a: vector_signed_short, b: vector_signed_short, c: i32) -> vector_signed_short;
132132
#[link_name = "llvm.s390.vfaef"] fn vfaef(a: vector_signed_int, b: vector_signed_int, c: i32) -> vector_signed_int;
133133

134+
#[link_name = "llvm.s390.vfaezb"] fn vfaezb(a: vector_signed_char, b: vector_signed_char, c: i32) -> vector_signed_char;
135+
#[link_name = "llvm.s390.vfaezh"] fn vfaezh(a: vector_signed_short, b: vector_signed_short, c: i32) -> vector_signed_short;
136+
#[link_name = "llvm.s390.vfaezf"] fn vfaezf(a: vector_signed_int, b: vector_signed_int, c: i32) -> vector_signed_int;
137+
134138
#[link_name = "llvm.s390.vfaebs"] fn vfaebs(a: vector_signed_char, b: vector_signed_char, c: i32) -> PackedTuple<vector_signed_char, i32>;
135139
#[link_name = "llvm.s390.vfaehs"] fn vfaehs(a: vector_signed_short, b: vector_signed_short, c: i32) -> PackedTuple<vector_signed_short, i32>;
136140
#[link_name = "llvm.s390.vfaefs"] fn vfaefs(a: vector_signed_int, b: vector_signed_int, c: i32) -> PackedTuple<vector_signed_int, i32>;
141+
142+
#[link_name = "llvm.s390.vfaezbs"] fn vfaezbs(a: vector_signed_char, b: vector_signed_char, c: i32) -> PackedTuple<vector_signed_char, i32>;
143+
#[link_name = "llvm.s390.vfaezhs"] fn vfaezhs(a: vector_signed_short, b: vector_signed_short, c: i32) -> PackedTuple<vector_signed_short, i32>;
144+
#[link_name = "llvm.s390.vfaezfs"] fn vfaezfs(a: vector_signed_int, b: vector_signed_int, c: i32) -> PackedTuple<vector_signed_int, i32>;
137145
}
138146

139147
impl_from! { i8x16, u8x16, i16x8, u16x8, i32x4, u32x4, i64x2, u64x2, f32x4, f64x2 }
@@ -1535,85 +1543,105 @@ mod sealed {
15351543
impl_vec_trait! { [VectorSqrt vec_sqrt] vec_sqrt_f32 (vector_float) }
15361544
impl_vec_trait! { [VectorSqrt vec_sqrt] vec_sqrt_f64 (vector_double) }
15371545

1538-
#[inline]
1539-
#[target_feature(enable = "vector")]
1540-
#[cfg_attr(test, assert_instr(vfaeb, IMM = 0))]
1541-
unsafe fn vfaeb<const IMM: i32>(
1542-
a: vector_signed_char,
1543-
b: vector_signed_char,
1544-
) -> vector_signed_char {
1545-
super::vfaeb(a, b, IMM)
1546-
}
1547-
#[inline]
1548-
#[target_feature(enable = "vector")]
1549-
#[cfg_attr(test, assert_instr(vfaeh, IMM = 0))]
1550-
unsafe fn vfaeh<const IMM: i32>(
1551-
a: vector_signed_short,
1552-
b: vector_signed_short,
1553-
) -> vector_signed_short {
1554-
super::vfaeh(a, b, IMM)
1555-
}
1556-
#[inline]
1557-
#[target_feature(enable = "vector")]
1558-
#[cfg_attr(test, assert_instr(vfaef, IMM = 0))]
1559-
unsafe fn vfaef<const IMM: i32>(
1560-
a: vector_signed_int,
1561-
b: vector_signed_int,
1562-
) -> vector_signed_int {
1563-
super::vfaef(a, b, IMM)
1546+
macro_rules! vfae_wrapper {
1547+
($($name:ident $ty:ident)*) => {
1548+
$(
1549+
#[inline]
1550+
#[target_feature(enable = "vector")]
1551+
#[cfg_attr(test, assert_instr($name, IMM = 0))]
1552+
unsafe fn $name<const IMM: i32>(
1553+
a: $ty,
1554+
b: $ty,
1555+
) -> $ty {
1556+
super::$name(a, b, IMM)
1557+
}
1558+
)*
1559+
}
1560+
}
1561+
1562+
vfae_wrapper! {
1563+
vfaeb vector_signed_char
1564+
vfaeh vector_signed_short
1565+
vfaef vector_signed_int
1566+
1567+
vfaezb vector_signed_char
1568+
vfaezh vector_signed_short
1569+
vfaezf vector_signed_int
15641570
}
15651571

15661572
macro_rules! impl_vfae {
1567-
([cc $Trait:ident $m:ident] $imm:literal $($fun:ident $ty:ident)*) => {
1573+
([idx_cc $Trait:ident $m:ident] $imm:ident $($fun:ident $ty:ident $r:ident)*) => {
1574+
$(
1575+
#[unstable(feature = "stdarch_s390x", issue = "135681")]
1576+
impl $Trait<Self> for $ty {
1577+
type Result = $r;
1578+
#[inline]
1579+
#[target_feature(enable = "vector")]
1580+
unsafe fn $m(self, b: Self, c: *mut i32) -> Self::Result {
1581+
let PackedTuple { x, y } = $fun::<{ FindImm::$imm as i32 }>(transmute(self), transmute(b));
1582+
c.write(y);
1583+
transmute(x)
1584+
}
1585+
}
1586+
)*
1587+
};
1588+
([cc $Trait:ident $m:ident] $imm:ident $($fun:ident $ty:ident)*) => {
15681589
$(
15691590
#[unstable(feature = "stdarch_s390x", issue = "135681")]
15701591
impl $Trait<Self> for $ty {
15711592
type Result = t_b!($ty);
15721593
#[inline]
15731594
#[target_feature(enable = "vector")]
15741595
unsafe fn $m(self, b: Self, c: *mut i32) -> Self::Result {
1575-
let PackedTuple { x, y } = $fun::<$imm>(transmute(self), transmute(b));
1596+
let PackedTuple { x, y } = $fun::<{ FindImm::$imm as i32 }>(transmute(self), transmute(b));
15761597
c.write(y);
15771598
transmute(x)
15781599
}
15791600
}
15801601
)*
15811602
};
1582-
([idx $Trait:ident $m:ident] $imm:literal $($fun:ident $ty:ident $r:ident)*) => {
1603+
([idx $Trait:ident $m:ident] $imm:ident $($fun:ident $ty:ident $r:ident)*) => {
15831604
$(
15841605
#[unstable(feature = "stdarch_s390x", issue = "135681")]
15851606
impl $Trait<Self> for $ty {
15861607
type Result = $r;
15871608
#[inline]
15881609
#[target_feature(enable = "vector")]
15891610
unsafe fn $m(self, b: Self) -> Self::Result {
1590-
transmute($fun::<$imm>(transmute(self), transmute(b)))
1611+
transmute($fun::<{ FindImm::$imm as i32 }>(transmute(self), transmute(b)))
15911612
}
15921613
}
15931614
)*
15941615
};
1595-
([$Trait:ident $m:ident] $imm:literal $($fun:ident $ty:ident)*) => {
1616+
([$Trait:ident $m:ident] $imm:ident $($fun:ident $ty:ident)*) => {
15961617
$(
15971618
#[unstable(feature = "stdarch_s390x", issue = "135681")]
15981619
impl $Trait<Self> for $ty {
15991620
type Result = t_b!($ty);
16001621
#[inline]
16011622
#[target_feature(enable = "vector")]
16021623
unsafe fn $m(self, b: Self) -> Self::Result {
1603-
transmute($fun::<$imm>(transmute(self), transmute(b)))
1624+
transmute($fun::<{ FindImm::$imm as i32 }>(transmute(self), transmute(b)))
16041625
}
16051626
}
16061627
)*
16071628
};
16081629
}
16091630

1631+
enum FindImm {
1632+
Eq = 4,
1633+
Ne = 12,
1634+
EqIdx = 0,
1635+
NeIdx = 8,
1636+
}
1637+
16101638
#[unstable(feature = "stdarch_s390x", issue = "135681")]
16111639
pub trait VectorFindAnyEq<Other> {
16121640
type Result;
16131641
unsafe fn vec_find_any_eq(self, other: Other) -> Self::Result;
16141642
}
16151643

1616-
impl_vfae! { [VectorFindAnyEq vec_find_any_eq] 4
1644+
impl_vfae! { [VectorFindAnyEq vec_find_any_eq] Eq
16171645
vfaeb vector_signed_char
16181646
vfaeb vector_unsigned_char
16191647
vfaeb vector_bool_char
@@ -1633,7 +1661,7 @@ mod sealed {
16331661
unsafe fn vec_find_any_ne(self, other: Other) -> Self::Result;
16341662
}
16351663

1636-
impl_vfae! { [VectorFindAnyNe vec_find_any_ne] 12
1664+
impl_vfae! { [VectorFindAnyNe vec_find_any_ne] Ne
16371665
vfaeb vector_signed_char
16381666
vfaeb vector_unsigned_char
16391667
vfaeb vector_bool_char
@@ -1647,13 +1675,53 @@ mod sealed {
16471675
vfaef vector_bool_int
16481676
}
16491677

1678+
#[unstable(feature = "stdarch_s390x", issue = "135681")]
1679+
pub trait VectorFindAnyEqOrZeroIdx<Other> {
1680+
type Result;
1681+
unsafe fn vec_find_any_eq_or_0_idx(self, other: Other) -> Self::Result;
1682+
}
1683+
1684+
impl_vfae! { [idx VectorFindAnyEqOrZeroIdx vec_find_any_eq_or_0_idx] Eq
1685+
vfaezb vector_signed_char vector_signed_char
1686+
vfaezb vector_unsigned_char vector_unsigned_char
1687+
vfaezb vector_bool_char vector_unsigned_char
1688+
1689+
vfaezh vector_signed_short vector_signed_short
1690+
vfaezh vector_unsigned_short vector_unsigned_short
1691+
vfaezh vector_bool_short vector_unsigned_short
1692+
1693+
vfaezf vector_signed_int vector_signed_int
1694+
vfaezf vector_unsigned_int vector_unsigned_int
1695+
vfaezf vector_bool_int vector_unsigned_int
1696+
}
1697+
1698+
#[unstable(feature = "stdarch_s390x", issue = "135681")]
1699+
pub trait VectorFindAnyNeOrZeroIdx<Other> {
1700+
type Result;
1701+
unsafe fn vec_find_any_ne_or_0_idx(self, other: Other) -> Self::Result;
1702+
}
1703+
1704+
impl_vfae! { [idx VectorFindAnyNeOrZeroIdx vec_find_any_ne_or_0_idx] Ne
1705+
vfaezb vector_signed_char vector_signed_char
1706+
vfaezb vector_unsigned_char vector_unsigned_char
1707+
vfaezb vector_bool_char vector_unsigned_char
1708+
1709+
vfaezh vector_signed_short vector_signed_short
1710+
vfaezh vector_unsigned_short vector_unsigned_short
1711+
vfaezh vector_bool_short vector_unsigned_short
1712+
1713+
vfaezf vector_signed_int vector_signed_int
1714+
vfaezf vector_unsigned_int vector_unsigned_int
1715+
vfaezf vector_bool_int vector_unsigned_int
1716+
}
1717+
16501718
#[unstable(feature = "stdarch_s390x", issue = "135681")]
16511719
pub trait VectorFindAnyEqIdx<Other> {
16521720
type Result;
16531721
unsafe fn vec_find_any_eq_idx(self, other: Other) -> Self::Result;
16541722
}
16551723

1656-
impl_vfae! { [idx VectorFindAnyEqIdx vec_find_any_eq_idx] 0
1724+
impl_vfae! { [idx VectorFindAnyEqIdx vec_find_any_eq_idx] EqIdx
16571725
vfaeb vector_signed_char vector_signed_char
16581726
vfaeb vector_unsigned_char vector_unsigned_char
16591727
vfaeb vector_bool_char vector_unsigned_char
@@ -1673,7 +1741,7 @@ mod sealed {
16731741
unsafe fn vec_find_any_ne_idx(self, other: Other) -> Self::Result;
16741742
}
16751743

1676-
impl_vfae! { [idx VectorFindAnyNeIdx vec_find_any_ne_idx] 8
1744+
impl_vfae! { [idx VectorFindAnyNeIdx vec_find_any_ne_idx] NeIdx
16771745
vfaeb vector_signed_char vector_signed_char
16781746
vfaeb vector_unsigned_char vector_unsigned_char
16791747
vfaeb vector_bool_char vector_unsigned_char
@@ -1721,7 +1789,7 @@ mod sealed {
17211789
unsafe fn vec_find_any_eq_cc(self, other: Other, c: *mut i32) -> Self::Result;
17221790
}
17231791

1724-
impl_vfae! { [cc VectorFindAnyEqCC vec_find_any_eq_cc] 4
1792+
impl_vfae! { [cc VectorFindAnyEqCC vec_find_any_eq_cc] Eq
17251793
vfaebs vector_signed_char
17261794
vfaebs vector_unsigned_char
17271795
vfaebs vector_bool_char
@@ -1741,7 +1809,7 @@ mod sealed {
17411809
unsafe fn vec_find_any_ne_cc(self, other: Other, c: *mut i32) -> Self::Result;
17421810
}
17431811

1744-
impl_vfae! { [cc VectorFindAnyNeCC vec_find_any_ne_cc] 12
1812+
impl_vfae! { [cc VectorFindAnyNeCC vec_find_any_ne_cc] Ne
17451813
vfaebs vector_signed_char
17461814
vfaebs vector_unsigned_char
17471815
vfaebs vector_bool_char
@@ -1754,6 +1822,46 @@ mod sealed {
17541822
vfaefs vector_unsigned_int
17551823
vfaefs vector_bool_int
17561824
}
1825+
1826+
#[unstable(feature = "stdarch_s390x", issue = "135681")]
1827+
pub trait VectorFindAnyEqIdxCC<Other> {
1828+
type Result;
1829+
unsafe fn vec_find_any_eq_idx_cc(self, other: Other, c: *mut i32) -> Self::Result;
1830+
}
1831+
1832+
impl_vfae! { [idx_cc VectorFindAnyEqIdxCC vec_find_any_eq_idx_cc] EqIdx
1833+
vfaebs vector_signed_char vector_signed_char
1834+
vfaebs vector_unsigned_char vector_unsigned_char
1835+
vfaebs vector_bool_char vector_unsigned_char
1836+
1837+
vfaehs vector_signed_short vector_signed_short
1838+
vfaehs vector_unsigned_short vector_unsigned_short
1839+
vfaehs vector_bool_short vector_unsigned_short
1840+
1841+
vfaefs vector_signed_int vector_signed_int
1842+
vfaefs vector_unsigned_int vector_unsigned_int
1843+
vfaefs vector_bool_int vector_unsigned_int
1844+
}
1845+
1846+
#[unstable(feature = "stdarch_s390x", issue = "135681")]
1847+
pub trait VectorFindAnyNeIdxCC<Other> {
1848+
type Result;
1849+
unsafe fn vec_find_any_ne_idx_cc(self, other: Other, c: *mut i32) -> Self::Result;
1850+
}
1851+
1852+
impl_vfae! { [idx_cc VectorFindAnyNeIdxCC vec_find_any_ne_idx_cc] NeIdx
1853+
vfaebs vector_signed_char vector_signed_char
1854+
vfaebs vector_unsigned_char vector_unsigned_char
1855+
vfaebs vector_bool_char vector_unsigned_char
1856+
1857+
vfaehs vector_signed_short vector_signed_short
1858+
vfaehs vector_unsigned_short vector_unsigned_short
1859+
vfaehs vector_bool_short vector_unsigned_short
1860+
1861+
vfaefs vector_signed_int vector_signed_int
1862+
vfaefs vector_unsigned_int vector_unsigned_int
1863+
vfaefs vector_bool_int vector_unsigned_int
1864+
}
17571865
}
17581866

17591867
/// Vector element-wise addition.

0 commit comments

Comments
 (0)