Skip to content

Commit f7eaa02

Browse files
committed
add vec_find_any_eq_or_0_idx and vec_find_any_ne_or_0_idx
1 parent 77a2abf commit f7eaa02

File tree

1 file changed

+146
-38
lines changed

1 file changed

+146
-38
lines changed

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 }
@@ -1539,85 +1547,105 @@ mod sealed {
15391547
impl_vec_trait! { [VectorSqrt vec_sqrt] vec_sqrt_f32 (vector_float) }
15401548
impl_vec_trait! { [VectorSqrt vec_sqrt] vec_sqrt_f64 (vector_double) }
15411549

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

15701576
macro_rules! impl_vfae {
1571-
([cc $Trait:ident $m:ident] $imm:literal $($fun:ident $ty:ident)*) => {
1577+
([idx_cc $Trait:ident $m:ident] $imm:ident $($fun:ident $ty:ident $r:ident)*) => {
1578+
$(
1579+
#[unstable(feature = "stdarch_s390x", issue = "135681")]
1580+
impl $Trait<Self> for $ty {
1581+
type Result = $r;
1582+
#[inline]
1583+
#[target_feature(enable = "vector")]
1584+
unsafe fn $m(self, b: Self, c: *mut i32) -> Self::Result {
1585+
let PackedTuple { x, y } = $fun::<{ FindImm::$imm as i32 }>(transmute(self), transmute(b));
1586+
c.write(y);
1587+
transmute(x)
1588+
}
1589+
}
1590+
)*
1591+
};
1592+
([cc $Trait:ident $m:ident] $imm:ident $($fun:ident $ty:ident)*) => {
15721593
$(
15731594
#[unstable(feature = "stdarch_s390x", issue = "135681")]
15741595
impl $Trait<Self> for $ty {
15751596
type Result = t_b!($ty);
15761597
#[inline]
15771598
#[target_feature(enable = "vector")]
15781599
unsafe fn $m(self, b: Self, c: *mut i32) -> Self::Result {
1579-
let PackedTuple { x, y } = $fun::<$imm>(transmute(self), transmute(b));
1600+
let PackedTuple { x, y } = $fun::<{ FindImm::$imm as i32 }>(transmute(self), transmute(b));
15801601
c.write(y);
15811602
transmute(x)
15821603
}
15831604
}
15841605
)*
15851606
};
1586-
([idx $Trait:ident $m:ident] $imm:literal $($fun:ident $ty:ident $r:ident)*) => {
1607+
([idx $Trait:ident $m:ident] $imm:ident $($fun:ident $ty:ident $r:ident)*) => {
15871608
$(
15881609
#[unstable(feature = "stdarch_s390x", issue = "135681")]
15891610
impl $Trait<Self> for $ty {
15901611
type Result = $r;
15911612
#[inline]
15921613
#[target_feature(enable = "vector")]
15931614
unsafe fn $m(self, b: Self) -> Self::Result {
1594-
transmute($fun::<$imm>(transmute(self), transmute(b)))
1615+
transmute($fun::<{ FindImm::$imm as i32 }>(transmute(self), transmute(b)))
15951616
}
15961617
}
15971618
)*
15981619
};
1599-
([$Trait:ident $m:ident] $imm:literal $($fun:ident $ty:ident)*) => {
1620+
([$Trait:ident $m:ident] $imm:ident $($fun:ident $ty:ident)*) => {
16001621
$(
16011622
#[unstable(feature = "stdarch_s390x", issue = "135681")]
16021623
impl $Trait<Self> for $ty {
16031624
type Result = t_b!($ty);
16041625
#[inline]
16051626
#[target_feature(enable = "vector")]
16061627
unsafe fn $m(self, b: Self) -> Self::Result {
1607-
transmute($fun::<$imm>(transmute(self), transmute(b)))
1628+
transmute($fun::<{ FindImm::$imm as i32 }>(transmute(self), transmute(b)))
16081629
}
16091630
}
16101631
)*
16111632
};
16121633
}
16131634

1635+
enum FindImm {
1636+
Eq = 4,
1637+
Ne = 12,
1638+
EqIdx = 0,
1639+
NeIdx = 8,
1640+
}
1641+
16141642
#[unstable(feature = "stdarch_s390x", issue = "135681")]
16151643
pub trait VectorFindAnyEq<Other> {
16161644
type Result;
16171645
unsafe fn vec_find_any_eq(self, other: Other) -> Self::Result;
16181646
}
16191647

1620-
impl_vfae! { [VectorFindAnyEq vec_find_any_eq] 4
1648+
impl_vfae! { [VectorFindAnyEq vec_find_any_eq] Eq
16211649
vfaeb vector_signed_char
16221650
vfaeb vector_unsigned_char
16231651
vfaeb vector_bool_char
@@ -1637,7 +1665,7 @@ mod sealed {
16371665
unsafe fn vec_find_any_ne(self, other: Other) -> Self::Result;
16381666
}
16391667

1640-
impl_vfae! { [VectorFindAnyNe vec_find_any_ne] 12
1668+
impl_vfae! { [VectorFindAnyNe vec_find_any_ne] Ne
16411669
vfaeb vector_signed_char
16421670
vfaeb vector_unsigned_char
16431671
vfaeb vector_bool_char
@@ -1651,13 +1679,53 @@ mod sealed {
16511679
vfaef vector_bool_int
16521680
}
16531681

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

1660-
impl_vfae! { [idx VectorFindAnyEqIdx vec_find_any_eq_idx] 0
1728+
impl_vfae! { [idx VectorFindAnyEqIdx vec_find_any_eq_idx] EqIdx
16611729
vfaeb vector_signed_char vector_signed_char
16621730
vfaeb vector_unsigned_char vector_unsigned_char
16631731
vfaeb vector_bool_char vector_unsigned_char
@@ -1677,7 +1745,7 @@ mod sealed {
16771745
unsafe fn vec_find_any_ne_idx(self, other: Other) -> Self::Result;
16781746
}
16791747

1680-
impl_vfae! { [idx VectorFindAnyNeIdx vec_find_any_ne_idx] 8
1748+
impl_vfae! { [idx VectorFindAnyNeIdx vec_find_any_ne_idx] NeIdx
16811749
vfaeb vector_signed_char vector_signed_char
16821750
vfaeb vector_unsigned_char vector_unsigned_char
16831751
vfaeb vector_bool_char vector_unsigned_char
@@ -1725,7 +1793,7 @@ mod sealed {
17251793
unsafe fn vec_find_any_eq_cc(self, other: Other, c: *mut i32) -> Self::Result;
17261794
}
17271795

1728-
impl_vfae! { [cc VectorFindAnyEqCC vec_find_any_eq_cc] 4
1796+
impl_vfae! { [cc VectorFindAnyEqCC vec_find_any_eq_cc] Eq
17291797
vfaebs vector_signed_char
17301798
vfaebs vector_unsigned_char
17311799
vfaebs vector_bool_char
@@ -1745,7 +1813,7 @@ mod sealed {
17451813
unsafe fn vec_find_any_ne_cc(self, other: Other, c: *mut i32) -> Self::Result;
17461814
}
17471815

1748-
impl_vfae! { [cc VectorFindAnyNeCC vec_find_any_ne_cc] 12
1816+
impl_vfae! { [cc VectorFindAnyNeCC vec_find_any_ne_cc] Ne
17491817
vfaebs vector_signed_char
17501818
vfaebs vector_unsigned_char
17511819
vfaebs vector_bool_char
@@ -1758,6 +1826,46 @@ mod sealed {
17581826
vfaefs vector_unsigned_int
17591827
vfaefs vector_bool_int
17601828
}
1829+
1830+
#[unstable(feature = "stdarch_s390x", issue = "135681")]
1831+
pub trait VectorFindAnyEqIdxCC<Other> {
1832+
type Result;
1833+
unsafe fn vec_find_any_eq_idx_cc(self, other: Other, c: *mut i32) -> Self::Result;
1834+
}
1835+
1836+
impl_vfae! { [idx_cc VectorFindAnyEqIdxCC vec_find_any_eq_idx_cc] EqIdx
1837+
vfaebs vector_signed_char vector_signed_char
1838+
vfaebs vector_unsigned_char vector_unsigned_char
1839+
vfaebs vector_bool_char vector_unsigned_char
1840+
1841+
vfaehs vector_signed_short vector_signed_short
1842+
vfaehs vector_unsigned_short vector_unsigned_short
1843+
vfaehs vector_bool_short vector_unsigned_short
1844+
1845+
vfaefs vector_signed_int vector_signed_int
1846+
vfaefs vector_unsigned_int vector_unsigned_int
1847+
vfaefs vector_bool_int vector_unsigned_int
1848+
}
1849+
1850+
#[unstable(feature = "stdarch_s390x", issue = "135681")]
1851+
pub trait VectorFindAnyNeIdxCC<Other> {
1852+
type Result;
1853+
unsafe fn vec_find_any_ne_idx_cc(self, other: Other, c: *mut i32) -> Self::Result;
1854+
}
1855+
1856+
impl_vfae! { [idx_cc VectorFindAnyNeIdxCC vec_find_any_ne_idx_cc] NeIdx
1857+
vfaebs vector_signed_char vector_signed_char
1858+
vfaebs vector_unsigned_char vector_unsigned_char
1859+
vfaebs vector_bool_char vector_unsigned_char
1860+
1861+
vfaehs vector_signed_short vector_signed_short
1862+
vfaehs vector_unsigned_short vector_unsigned_short
1863+
vfaehs vector_bool_short vector_unsigned_short
1864+
1865+
vfaefs vector_signed_int vector_signed_int
1866+
vfaefs vector_unsigned_int vector_unsigned_int
1867+
vfaefs vector_bool_int vector_unsigned_int
1868+
}
17611869
}
17621870

17631871
/// Vector element-wise addition.

0 commit comments

Comments
 (0)