@@ -235,6 +235,14 @@ unsafe extern "unadjusted" {
235
235
#[ link_name = "llvm.s390.vistrfs" ] fn vistrfs ( a : vector_unsigned_int ) -> PackedTuple < vector_unsigned_int , i32 > ;
236
236
237
237
#[ link_name = "llvm.s390.vmslg" ] fn vmslg ( a : vector_unsigned_long_long , b : vector_unsigned_long_long , c : u128 , d : u32 ) -> u128 ;
238
+
239
+ #[ link_name = "llvm.s390.vstrcb" ] fn vstrcb ( a : vector_unsigned_char , b : vector_unsigned_char , c : vector_unsigned_char , d : u32 ) -> vector_bool_char ;
240
+ #[ link_name = "llvm.s390.vstrch" ] fn vstrch ( a : vector_unsigned_short , b : vector_unsigned_short , c : vector_unsigned_short , d : u32 ) -> vector_bool_short ;
241
+ #[ link_name = "llvm.s390.vstrcf" ] fn vstrcf ( a : vector_unsigned_int , b : vector_unsigned_int , c : vector_unsigned_int , d : u32 ) -> vector_bool_int ;
242
+
243
+ #[ link_name = "llvm.s390.vstrcbs" ] fn vstrcbs ( a : vector_unsigned_char , b : vector_unsigned_char , c : vector_unsigned_char , d : u32 ) -> PackedTuple < vector_bool_char , i32 > ;
244
+ #[ link_name = "llvm.s390.vstrchs" ] fn vstrchs ( a : vector_unsigned_short , b : vector_unsigned_short , c : vector_unsigned_short , d : u32 ) -> PackedTuple < vector_bool_short , i32 > ;
245
+ #[ link_name = "llvm.s390.vstrcfs" ] fn vstrcfs ( a : vector_unsigned_int , b : vector_unsigned_int , c : vector_unsigned_int , d : u32 ) -> PackedTuple < vector_bool_int , i32 > ;
238
246
}
239
247
240
248
impl_from ! { i8x16, u8x16, i16x8, u16x8, i32x4, u32x4, i64x2, u64x2, f32x4, f64x2 }
@@ -365,6 +373,13 @@ const fn validate_block_boundary(block_boundary: u16) -> u32 {
365
373
block_boundary as u32 >> 7
366
374
}
367
375
376
+ enum FindImm {
377
+ Eq = 4 ,
378
+ Ne = 12 ,
379
+ EqIdx = 0 ,
380
+ NeIdx = 8 ,
381
+ }
382
+
368
383
#[ macro_use]
369
384
mod sealed {
370
385
use super :: * ;
@@ -1922,13 +1937,6 @@ mod sealed {
1922
1937
} ;
1923
1938
}
1924
1939
1925
- enum FindImm {
1926
- Eq = 4 ,
1927
- Ne = 12 ,
1928
- EqIdx = 0 ,
1929
- NeIdx = 8 ,
1930
- }
1931
-
1932
1940
#[ unstable( feature = "stdarch_s390x" , issue = "135681" ) ]
1933
1941
pub trait VectorFindAnyEq < Other > {
1934
1942
type Result ;
@@ -3254,6 +3262,56 @@ mod sealed {
3254
3262
vector_float
3255
3263
vector_double
3256
3264
}
3265
+
3266
+ #[ unstable( feature = "stdarch_s390x" , issue = "135681" ) ]
3267
+ pub trait VectorCompareRange : Sized {
3268
+ type Result ;
3269
+
3270
+ unsafe fn vstrc < const IMM : u32 > ( self , b : Self , c : Self ) -> Self :: Result ;
3271
+ unsafe fn vstrcs < const IMM : u32 > ( self , b : Self , c : Self ) -> ( Self :: Result , i32 ) ;
3272
+ }
3273
+
3274
+ macro_rules! impl_compare_range {
3275
+ ( $( $ty: ident $vstrc: ident $vstrcs: ident) * ) => {
3276
+ $(
3277
+ #[ unstable( feature = "stdarch_s390x" , issue = "135681" ) ]
3278
+ impl VectorCompareRange for $ty {
3279
+ type Result = t_b!( $ty) ;
3280
+
3281
+ #[ inline]
3282
+ #[ target_feature( enable = "vector" ) ]
3283
+ unsafe fn vstrc<const IMM : u32 >( self , b: Self , c: Self ) -> Self :: Result {
3284
+ const {
3285
+ if !matches!( IMM , 0 | 4 | 8 | 12 ) {
3286
+ panic!( "IMM needs to be one of 0, 4, 8, 12" ) ;
3287
+ }
3288
+ } ;
3289
+
3290
+ $vstrc( self , b, c, IMM )
3291
+ }
3292
+
3293
+ #[ inline]
3294
+ #[ target_feature( enable = "vector" ) ]
3295
+ unsafe fn vstrcs<const IMM : u32 >( self , b: Self , c: Self ) -> ( Self :: Result , i32 ) {
3296
+ const {
3297
+ if !matches!( IMM , 0 | 4 | 8 | 12 ) {
3298
+ panic!( "IMM needs to be one of 0, 4, 8, 12" ) ;
3299
+ }
3300
+ } ;
3301
+
3302
+ let PackedTuple { x, y } = $vstrcs( self , b, c, IMM ) ;
3303
+ ( x, y)
3304
+ }
3305
+ }
3306
+ ) *
3307
+ }
3308
+ }
3309
+
3310
+ impl_compare_range ! {
3311
+ vector_unsigned_char vstrcb vstrcbs
3312
+ vector_unsigned_short vstrch vstrchs
3313
+ vector_unsigned_int vstrcf vstrcfs
3314
+ }
3257
3315
}
3258
3316
3259
3317
/// Load Count to Block Boundary
@@ -4662,6 +4720,13 @@ pub unsafe fn vec_srdb<T: sealed::VectorSrdb, const C: u32>(a: T, b: T) -> T {
4662
4720
a. vec_srdb :: < C > ( b)
4663
4721
}
4664
4722
4723
+ #[ inline]
4724
+ #[ target_feature( enable = "vector" ) ]
4725
+ #[ unstable( feature = "stdarch_s390x" , issue = "135681" ) ]
4726
+ pub unsafe fn vec_cmprg < T : sealed:: VectorCompareRange > ( a : T , b : T , c : T ) -> T :: Result {
4727
+ a. vstrc :: < { FindImm :: Eq as u32 } > ( b, c)
4728
+ }
4729
+
4665
4730
#[ cfg( test) ]
4666
4731
mod tests {
4667
4732
use super :: * ;
@@ -5936,8 +6001,32 @@ mod tests {
5936
6001
5937
6002
unsafe {
5938
6003
let d = vec_srdb :: < _ , 4 > ( a, b) ;
5939
- println ! ( "{:x?}" , & d) ;
5940
6004
assert_eq ! ( d. as_array( ) , & [ 0xABBBBBBBBBBBBBBB , 0xBBBBBBBBBBBBBBBB ] ) ;
5941
6005
}
5942
6006
}
6007
+
6008
+ #[ simd_test( enable = "vector" ) ]
6009
+ fn test_vec_cmprg ( ) {
6010
+ const GT : u32 = 0x20000000 ;
6011
+ const LT : u32 = 0x40000000 ;
6012
+ const EQ : u32 = 0x80000000 ;
6013
+
6014
+ let a = vector_unsigned_int ( [ 11 , 22 , 33 , 44 ] ) ;
6015
+ let b = vector_unsigned_int ( [ 10 , 20 , 30 , 40 ] ) ;
6016
+
6017
+ let c = vector_unsigned_int ( [ GT , LT , GT , LT ] ) ;
6018
+ let d = unsafe { vec_cmprg ( a, b, c) } ;
6019
+ assert_eq ! ( d. as_array( ) , & [ !0 , 0 , !0 , 0 ] ) ;
6020
+
6021
+ let c = vector_unsigned_int ( [ GT , LT , 0 , 0 ] ) ;
6022
+ let d = unsafe { vec_cmprg ( a, b, c) } ;
6023
+ assert_eq ! ( d. as_array( ) , & [ !0 , 0 , 0 , 0 ] ) ;
6024
+
6025
+ let a = vector_unsigned_int ( [ 11 , 22 , 33 , 30 ] ) ;
6026
+ let b = vector_unsigned_int ( [ 10 , 20 , 30 , 30 ] ) ;
6027
+
6028
+ let c = vector_unsigned_int ( [ GT , LT , EQ , EQ ] ) ;
6029
+ let d = unsafe { vec_cmprg ( a, b, c) } ;
6030
+ assert_eq ! ( d. as_array( ) , & [ !0 , 0 , 0 , !0 ] ) ;
6031
+ }
5943
6032
}
0 commit comments