@@ -51,6 +51,12 @@ types! {
51
51
pub struct vector_double( 2 x f64 ) ;
52
52
}
53
53
54
+ #[ repr( packed) ]
55
+ struct PackedTuple < T , U > {
56
+ x : T ,
57
+ y : U ,
58
+ }
59
+
54
60
#[ allow( improper_ctypes) ]
55
61
#[ rustfmt:: skip]
56
62
unsafe extern "unadjusted" {
@@ -124,6 +130,10 @@ unsafe extern "unadjusted" {
124
130
#[ link_name = "llvm.s390.vfaeb" ] fn vfaeb ( a : vector_signed_char , b : vector_signed_char , c : i32 ) -> vector_signed_char ;
125
131
#[ link_name = "llvm.s390.vfaeh" ] fn vfaeh ( a : vector_signed_short , b : vector_signed_short , c : i32 ) -> vector_signed_short ;
126
132
#[ link_name = "llvm.s390.vfaef" ] fn vfaef ( a : vector_signed_int , b : vector_signed_int , c : i32 ) -> vector_signed_int ;
133
+
134
+ #[ link_name = "llvm.s390.vfaebs" ] fn vfaebs ( a : vector_signed_char , b : vector_signed_char , c : i32 ) -> PackedTuple < vector_signed_char , i32 > ;
135
+ #[ link_name = "llvm.s390.vfaehs" ] fn vfaehs ( a : vector_signed_short , b : vector_signed_short , c : i32 ) -> PackedTuple < vector_signed_short , i32 > ;
136
+ #[ link_name = "llvm.s390.vfaefs" ] fn vfaefs ( a : vector_signed_int , b : vector_signed_int , c : i32 ) -> PackedTuple < vector_signed_int , i32 > ;
127
137
}
128
138
129
139
impl_from ! { i8x16, u8x16, i16x8, u16x8, i32x4, u32x4, i64x2, u64x2, f32x4, f64x2 }
@@ -1558,6 +1568,21 @@ mod sealed {
1558
1568
}
1559
1569
1560
1570
macro_rules! impl_vfae {
1571
+ ( [ cc $Trait: ident $m: ident] $imm: literal $( $fun: ident $ty: ident) * ) => {
1572
+ $(
1573
+ #[ unstable( feature = "stdarch_s390x" , issue = "135681" ) ]
1574
+ impl $Trait<Self > for $ty {
1575
+ type Result = t_b!( $ty) ;
1576
+ #[ inline]
1577
+ #[ target_feature( enable = "vector" ) ]
1578
+ unsafe fn $m( self , b: Self , c: * mut i32 ) -> Self :: Result {
1579
+ let PackedTuple { x, y } = $fun:: <$imm>( transmute( self ) , transmute( b) ) ;
1580
+ c. write( y) ;
1581
+ transmute( x)
1582
+ }
1583
+ }
1584
+ ) *
1585
+ } ;
1561
1586
( [ idx $Trait: ident $m: ident] $imm: literal $( $fun: ident $ty: ident $r: ident) * ) => {
1562
1587
$(
1563
1588
#[ unstable( feature = "stdarch_s390x" , issue = "135681" ) ]
@@ -1665,6 +1690,74 @@ mod sealed {
1665
1690
vfaef vector_unsigned_int vector_unsigned_int
1666
1691
vfaef vector_bool_int vector_unsigned_int
1667
1692
}
1693
+
1694
+ #[ inline]
1695
+ #[ target_feature( enable = "vector" ) ]
1696
+ #[ cfg_attr( test, assert_instr( vfaebs, IMM = 0 ) ) ]
1697
+ unsafe fn vfaebs < const IMM : i32 > (
1698
+ a : vector_signed_char ,
1699
+ b : vector_signed_char ,
1700
+ ) -> PackedTuple < vector_signed_char , i32 > {
1701
+ super :: vfaebs ( a, b, IMM )
1702
+ }
1703
+ #[ inline]
1704
+ #[ target_feature( enable = "vector" ) ]
1705
+ #[ cfg_attr( test, assert_instr( vfaehs, IMM = 0 ) ) ]
1706
+ unsafe fn vfaehs < const IMM : i32 > (
1707
+ a : vector_signed_short ,
1708
+ b : vector_signed_short ,
1709
+ ) -> PackedTuple < vector_signed_short , i32 > {
1710
+ super :: vfaehs ( a, b, IMM )
1711
+ }
1712
+ #[ inline]
1713
+ #[ target_feature( enable = "vector" ) ]
1714
+ #[ cfg_attr( test, assert_instr( vfaefs, IMM = 0 ) ) ]
1715
+ unsafe fn vfaefs < const IMM : i32 > (
1716
+ a : vector_signed_int ,
1717
+ b : vector_signed_int ,
1718
+ ) -> PackedTuple < vector_signed_int , i32 > {
1719
+ super :: vfaefs ( a, b, IMM )
1720
+ }
1721
+
1722
+ #[ unstable( feature = "stdarch_s390x" , issue = "135681" ) ]
1723
+ pub trait VectorFindAnyEqCC < Other > {
1724
+ type Result ;
1725
+ unsafe fn vec_find_any_eq_cc ( self , other : Other , c : * mut i32 ) -> Self :: Result ;
1726
+ }
1727
+
1728
+ impl_vfae ! { [ cc VectorFindAnyEqCC vec_find_any_eq_cc] 4
1729
+ vfaebs vector_signed_char
1730
+ vfaebs vector_unsigned_char
1731
+ vfaebs vector_bool_char
1732
+
1733
+ vfaehs vector_signed_short
1734
+ vfaehs vector_unsigned_short
1735
+ vfaehs vector_bool_short
1736
+
1737
+ vfaefs vector_signed_int
1738
+ vfaefs vector_unsigned_int
1739
+ vfaefs vector_bool_int
1740
+ }
1741
+
1742
+ #[ unstable( feature = "stdarch_s390x" , issue = "135681" ) ]
1743
+ pub trait VectorFindAnyNeCC < Other > {
1744
+ type Result ;
1745
+ unsafe fn vec_find_any_ne_cc ( self , other : Other , c : * mut i32 ) -> Self :: Result ;
1746
+ }
1747
+
1748
+ impl_vfae ! { [ cc VectorFindAnyNeCC vec_find_any_ne_cc] 12
1749
+ vfaebs vector_signed_char
1750
+ vfaebs vector_unsigned_char
1751
+ vfaebs vector_bool_char
1752
+
1753
+ vfaehs vector_signed_short
1754
+ vfaehs vector_unsigned_short
1755
+ vfaehs vector_bool_short
1756
+
1757
+ vfaefs vector_signed_int
1758
+ vfaefs vector_unsigned_int
1759
+ vfaefs vector_bool_int
1760
+ }
1668
1761
}
1669
1762
1670
1763
/// Vector element-wise addition.
@@ -2490,6 +2583,34 @@ where
2490
2583
a. vec_find_any_ne_idx ( b)
2491
2584
}
2492
2585
2586
+ #[ inline]
2587
+ #[ target_feature( enable = "vector" ) ]
2588
+ #[ unstable( feature = "stdarch_s390x" , issue = "135681" ) ]
2589
+ pub unsafe fn vec_find_any_eq_cc < T , U > (
2590
+ a : T ,
2591
+ b : U ,
2592
+ c : * mut i32 ,
2593
+ ) -> <T as sealed:: VectorFindAnyEqCC < U > >:: Result
2594
+ where
2595
+ T : sealed:: VectorFindAnyEqCC < U > ,
2596
+ {
2597
+ a. vec_find_any_eq_cc ( b, c)
2598
+ }
2599
+
2600
+ #[ inline]
2601
+ #[ target_feature( enable = "vector" ) ]
2602
+ #[ unstable( feature = "stdarch_s390x" , issue = "135681" ) ]
2603
+ pub unsafe fn vec_find_any_ne_cc < T , U > (
2604
+ a : T ,
2605
+ b : U ,
2606
+ c : * mut i32 ,
2607
+ ) -> <T as sealed:: VectorFindAnyNeCC < U > >:: Result
2608
+ where
2609
+ T : sealed:: VectorFindAnyNeCC < U > ,
2610
+ {
2611
+ a. vec_find_any_ne_cc ( b, c)
2612
+ }
2613
+
2493
2614
#[ cfg( test) ]
2494
2615
mod tests {
2495
2616
use super :: * ;
@@ -3039,4 +3160,40 @@ mod tests {
3039
3160
[ 1 , 2 , 3 , 4 ] ,
3040
3161
[ 0 , 16 , 0 , 0 ]
3041
3162
}
3163
+
3164
+ #[ simd_test( enable = "vector" ) ]
3165
+ fn test_vec_find_any_eq_cc ( ) {
3166
+ let mut c = 0i32 ;
3167
+
3168
+ let a = vector_unsigned_int ( [ 1 , 2 , 3 , 4 ] ) ;
3169
+ let b = vector_unsigned_int ( [ 5 , 3 , 7 , 8 ] ) ;
3170
+
3171
+ let d = unsafe { vec_find_any_eq_cc ( a, b, & mut c) } ;
3172
+ assert_eq ! ( c, 1 ) ;
3173
+ assert_eq ! ( d. as_array( ) , & [ 0 , 0 , -1 , 0 ] ) ;
3174
+
3175
+ let a = vector_unsigned_int ( [ 1 , 2 , 3 , 4 ] ) ;
3176
+ let b = vector_unsigned_int ( [ 5 , 6 , 7 , 8 ] ) ;
3177
+ let d = unsafe { vec_find_any_eq_cc ( a, b, & mut c) } ;
3178
+ assert_eq ! ( c, 3 ) ;
3179
+ assert_eq ! ( d. as_array( ) , & [ 0 , 0 , 0 , 0 ] ) ;
3180
+ }
3181
+
3182
+ #[ simd_test( enable = "vector" ) ]
3183
+ fn test_vec_find_any_ne_cc ( ) {
3184
+ let mut c = 0i32 ;
3185
+
3186
+ let a = vector_unsigned_int ( [ 1 , 2 , 3 , 4 ] ) ;
3187
+ let b = vector_unsigned_int ( [ 5 , 3 , 7 , 8 ] ) ;
3188
+
3189
+ let d = unsafe { vec_find_any_ne_cc ( a, b, & mut c) } ;
3190
+ assert_eq ! ( c, 1 ) ;
3191
+ assert_eq ! ( d. as_array( ) , & [ -1 , -1 , 0 , -1 ] ) ;
3192
+
3193
+ let a = vector_unsigned_int ( [ 1 , 2 , 3 , 4 ] ) ;
3194
+ let b = vector_unsigned_int ( [ 1 , 2 , 3 , 4 ] ) ;
3195
+ let d = unsafe { vec_find_any_ne_cc ( a, b, & mut c) } ;
3196
+ assert_eq ! ( c, 3 ) ;
3197
+ assert_eq ! ( d. as_array( ) , & [ 0 , 0 , 0 , 0 ] ) ;
3198
+ }
3042
3199
}
0 commit comments