@@ -97,6 +97,10 @@ unsafe extern "unadjusted" {
97
97
#[ link_name = "llvm.s390.vsrlb" ] fn vsrlb ( a : vector_signed_char , b : vector_signed_char ) -> vector_signed_char ;
98
98
#[ link_name = "llvm.s390.vslb" ] fn vslb ( a : vector_signed_char , b : vector_signed_char ) -> vector_signed_char ;
99
99
100
+ #[ link_name = "llvm.s390.vsldb" ] fn vsldb ( a : i8x16 , b : i8x16 , c : u32 ) -> i8x16 ;
101
+ #[ link_name = "llvm.s390.vsld" ] fn vsld ( a : i8x16 , b : i8x16 , c : u32 ) -> i8x16 ;
102
+ #[ link_name = "llvm.s390.vsrd" ] fn vsrd ( a : i8x16 , b : i8x16 , c : u32 ) -> i8x16 ;
103
+
100
104
#[ link_name = "llvm.fshl.v16i8" ] fn fshlb ( a : vector_unsigned_char , b : vector_unsigned_char , c : vector_unsigned_char ) -> vector_unsigned_char ;
101
105
#[ link_name = "llvm.fshl.v8i16" ] fn fshlh ( a : vector_unsigned_short , b : vector_unsigned_short , c : vector_unsigned_short ) -> vector_unsigned_short ;
102
106
#[ link_name = "llvm.fshl.v4i32" ] fn fshlf ( a : vector_unsigned_int , b : vector_unsigned_int , c : vector_unsigned_int ) -> vector_unsigned_int ;
@@ -3170,6 +3174,86 @@ mod sealed {
3170
3174
vec_vistrfs vector_bool_int
3171
3175
vec_vistrfs vector_unsigned_int
3172
3176
}
3177
+
3178
+ #[ unstable( feature = "stdarch_s390x" , issue = "135681" ) ]
3179
+ pub trait VectorSrdb {
3180
+ unsafe fn vec_srdb < const C : u32 > ( self , b : Self ) -> Self ;
3181
+ }
3182
+
3183
+ #[ unstable( feature = "stdarch_s390x" , issue = "135681" ) ]
3184
+ pub trait VectorSld {
3185
+ unsafe fn vec_sld < const C : u32 > ( self , b : Self ) -> Self ;
3186
+
3187
+ unsafe fn vec_sldw < const C : u32 > ( self , b : Self ) -> Self ;
3188
+
3189
+ unsafe fn vec_sldb < const C : u32 > ( self , b : Self ) -> Self ;
3190
+ }
3191
+
3192
+ // FIXME(llvm) https://github.com/llvm/llvm-project/issues/129955
3193
+ // ideally we could implement this in terms of llvm.fshl.i128
3194
+ // #[link_name = "llvm.fshl.i128"] fn fshl_i128(a: u128, b: u128, c: u128) -> u128;
3195
+ // transmute(fshl_i128(transmute(a), transmute(b), const { C * 8 } ))
3196
+
3197
+ macro_rules! impl_vec_sld {
3198
+ ( $( $ty: ident) * ) => {
3199
+ $(
3200
+ #[ unstable( feature = "stdarch_s390x" , issue = "135681" ) ]
3201
+ impl VectorSld for $ty {
3202
+ #[ inline]
3203
+ #[ target_feature( enable = "vector" ) ]
3204
+ unsafe fn vec_sld<const C : u32 >( self , b: Self ) -> Self {
3205
+ static_assert_uimm_bits!( C , 4 ) ;
3206
+ transmute( vsldb( transmute( self ) , transmute( b) , C ) )
3207
+ }
3208
+
3209
+ #[ inline]
3210
+ #[ target_feature( enable = "vector" ) ]
3211
+ unsafe fn vec_sldw<const C : u32 >( self , b: Self ) -> Self {
3212
+ static_assert_uimm_bits!( C , 2 ) ;
3213
+ transmute( vsldb( transmute( self ) , transmute( b) , const { 4 * C } ) )
3214
+ }
3215
+
3216
+ #[ inline]
3217
+ #[ target_feature( enable = "vector-enhancements-2" ) ]
3218
+ unsafe fn vec_sldb<const C : u32 >( self , b: Self ) -> Self {
3219
+ static_assert_uimm_bits!( C , 3 ) ;
3220
+ transmute( vsld( transmute( self ) , transmute( b) , C ) )
3221
+ }
3222
+ }
3223
+
3224
+ #[ unstable( feature = "stdarch_s390x" , issue = "135681" ) ]
3225
+ impl VectorSrdb for $ty {
3226
+ #[ inline]
3227
+ #[ target_feature( enable = "vector-enhancements-2" ) ]
3228
+ unsafe fn vec_srdb<const C : u32 >( self , b: Self ) -> Self {
3229
+ static_assert_uimm_bits!( C , 3 ) ;
3230
+ transmute( vsrd( transmute( self ) , transmute( b) , C ) )
3231
+ }
3232
+ }
3233
+ ) *
3234
+ }
3235
+ }
3236
+
3237
+ impl_vec_sld ! {
3238
+ vector_signed_char
3239
+ vector_bool_char
3240
+ vector_unsigned_char
3241
+
3242
+ vector_signed_short
3243
+ vector_bool_short
3244
+ vector_unsigned_short
3245
+
3246
+ vector_signed_int
3247
+ vector_bool_int
3248
+ vector_unsigned_int
3249
+
3250
+ vector_signed_long_long
3251
+ vector_bool_long_long
3252
+ vector_unsigned_long_long
3253
+
3254
+ vector_float
3255
+ vector_double
3256
+ }
3173
3257
}
3174
3258
3175
3259
/// Load Count to Block Boundary
@@ -4542,6 +4626,42 @@ pub unsafe fn vec_msum_u128<const D: u32>(
4542
4626
transmute ( vmslg ( a, b, transmute ( c) , D ) )
4543
4627
}
4544
4628
4629
+ /// Vector Shift Left Double by Byte
4630
+ #[ inline]
4631
+ #[ target_feature( enable = "vector" ) ]
4632
+ #[ unstable( feature = "stdarch_s390x" , issue = "135681" ) ]
4633
+ pub unsafe fn vec_sld < T : sealed:: VectorSld , const C : u32 > ( a : T , b : T ) -> T {
4634
+ static_assert_uimm_bits ! ( C , 4 ) ;
4635
+ a. vec_sld :: < C > ( b)
4636
+ }
4637
+
4638
+ /// Vector Shift Left Double by Word
4639
+ #[ inline]
4640
+ #[ target_feature( enable = "vector" ) ]
4641
+ #[ unstable( feature = "stdarch_s390x" , issue = "135681" ) ]
4642
+ pub unsafe fn vec_sldw < T : sealed:: VectorSld , const C : u32 > ( a : T , b : T ) -> T {
4643
+ static_assert_uimm_bits ! ( C , 2 ) ;
4644
+ a. vec_sldw :: < C > ( b)
4645
+ }
4646
+
4647
+ /// Vector Shift Left Double by Bit
4648
+ #[ inline]
4649
+ #[ target_feature( enable = "vector-enhancements-2" ) ]
4650
+ #[ unstable( feature = "stdarch_s390x" , issue = "135681" ) ]
4651
+ pub unsafe fn vec_sldb < T : sealed:: VectorSld , const C : u32 > ( a : T , b : T ) -> T {
4652
+ static_assert_uimm_bits ! ( C , 3 ) ;
4653
+ a. vec_sldb :: < C > ( b)
4654
+ }
4655
+
4656
+ /// Vector Shift Right Double by Bit
4657
+ #[ inline]
4658
+ #[ target_feature( enable = "vector-enhancements-2" ) ]
4659
+ #[ unstable( feature = "stdarch_s390x" , issue = "135681" ) ]
4660
+ pub unsafe fn vec_srdb < T : sealed:: VectorSrdb , const C : u32 > ( a : T , b : T ) -> T {
4661
+ static_assert_uimm_bits ! ( C , 3 ) ;
4662
+ a. vec_srdb :: < C > ( b)
4663
+ }
4664
+
4545
4665
#[ cfg( test) ]
4546
4666
mod tests {
4547
4667
use super :: * ;
@@ -5775,4 +5895,49 @@ mod tests {
5775
5895
assert_eq ! ( d, ( 1 * 3 ) * 2 + ( 2 * 4 ) * 2 + 100 ) ;
5776
5896
}
5777
5897
}
5898
+
5899
+ #[ simd_test( enable = "vector" ) ]
5900
+ fn test_vec_sld ( ) {
5901
+ let a = vector_unsigned_long_long ( [ 0xAAAAAAAAAAAAAAAA , 0xAAAAAAAAAAAAAAAA ] ) ;
5902
+ let b = vector_unsigned_long_long ( [ 0xBBBBBBBBBBBBBBBB , 0xBBBBBBBBBBBBBBBB ] ) ;
5903
+
5904
+ unsafe {
5905
+ let d = vec_sld :: < _ , 4 > ( a, b) ;
5906
+ assert_eq ! ( d. as_array( ) , & [ 0xAAAAAAAAAAAAAAAA , 0xAAAAAAAABBBBBBBB ] ) ;
5907
+ }
5908
+ }
5909
+
5910
+ #[ simd_test( enable = "vector" ) ]
5911
+ fn test_vec_sldw ( ) {
5912
+ let a = vector_unsigned_long_long ( [ 0xAAAAAAAAAAAAAAAA , 0xAAAAAAAAAAAAAAAA ] ) ;
5913
+ let b = vector_unsigned_long_long ( [ 0xBBBBBBBBBBBBBBBB , 0xBBBBBBBBBBBBBBBB ] ) ;
5914
+
5915
+ unsafe {
5916
+ let d = vec_sldw :: < _ , 1 > ( a, b) ;
5917
+ assert_eq ! ( d. as_array( ) , & [ 0xAAAAAAAAAAAAAAAA , 0xAAAAAAAABBBBBBBB ] ) ;
5918
+ }
5919
+ }
5920
+
5921
+ #[ simd_test( enable = "vector-enhancements-2" ) ]
5922
+ fn test_vec_sldb ( ) {
5923
+ let a = vector_unsigned_long_long ( [ 0xAAAAAAAAAAAAAAAA , 0xAAAAAAAAAAAAAAAA ] ) ;
5924
+ let b = vector_unsigned_long_long ( [ 0xBBBBBBBBBBBBBBBB , 0xBBBBBBBBBBBBBBBB ] ) ;
5925
+
5926
+ unsafe {
5927
+ let d = vec_sldb :: < _ , 4 > ( a, b) ;
5928
+ assert_eq ! ( d. as_array( ) , & [ 0xAAAAAAAAAAAAAAAA , 0xAAAAAAAAAAAAAAAB ] ) ;
5929
+ }
5930
+ }
5931
+
5932
+ #[ simd_test( enable = "vector-enhancements-2" ) ]
5933
+ fn test_vec_srdb ( ) {
5934
+ let a = vector_unsigned_long_long ( [ 0xAAAAAAAAAAAAAAAA , 0xAAAAAAAAAAAAAAAA ] ) ;
5935
+ let b = vector_unsigned_long_long ( [ 0xBBBBBBBBBBBBBBBB , 0xBBBBBBBBBBBBBBBB ] ) ;
5936
+
5937
+ unsafe {
5938
+ let d = vec_srdb :: < _ , 4 > ( a, b) ;
5939
+ println ! ( "{:x?}" , & d) ;
5940
+ assert_eq ! ( d. as_array( ) , & [ 0xABBBBBBBBBBBBBBB , 0xBBBBBBBBBBBBBBBB ] ) ;
5941
+ }
5942
+ }
5778
5943
}
0 commit comments