@@ -213,6 +213,14 @@ unsafe extern "unadjusted" {
213
213
#[ link_name = "llvm.s390.vftcidb" ] fn vftcidb ( a : vector_double , b : u32 ) -> PackedTuple < vector_bool_long_long , i32 > ;
214
214
215
215
#[ link_name = "llvm.s390.vtm" ] fn vtm ( a : i8x16 , b : i8x16 ) -> i32 ;
216
+
217
+ #[ link_name = "llvm.s390.vstrsb" ] fn vstrsb ( a : vector_unsigned_char , b : vector_unsigned_char , c : vector_unsigned_char ) -> PackedTuple < vector_unsigned_char , i32 > ;
218
+ #[ link_name = "llvm.s390.vstrsh" ] fn vstrsh ( a : vector_unsigned_short , b : vector_unsigned_short , c : vector_unsigned_char ) -> PackedTuple < vector_unsigned_char , i32 > ;
219
+ #[ link_name = "llvm.s390.vstrsf" ] fn vstrsf ( a : vector_unsigned_int , b : vector_unsigned_int , c : vector_unsigned_char ) -> PackedTuple < vector_unsigned_char , i32 > ;
220
+
221
+ #[ link_name = "llvm.s390.vstrszb" ] fn vstrszb ( a : vector_unsigned_char , b : vector_unsigned_char , c : vector_unsigned_char ) -> PackedTuple < vector_unsigned_char , i32 > ;
222
+ #[ link_name = "llvm.s390.vstrszh" ] fn vstrszh ( a : vector_unsigned_short , b : vector_unsigned_short , c : vector_unsigned_char ) -> PackedTuple < vector_unsigned_char , i32 > ;
223
+ #[ link_name = "llvm.s390.vstrszf" ] fn vstrszf ( a : vector_unsigned_int , b : vector_unsigned_int , c : vector_unsigned_char ) -> PackedTuple < vector_unsigned_char , i32 > ;
216
224
}
217
225
218
226
impl_from ! { i8x16, u8x16, i16x8, u16x8, i32x4, u32x4, i64x2, u64x2, f32x4, f64x2 }
@@ -2858,6 +2866,63 @@ mod sealed {
2858
2866
vector_float
2859
2867
vector_double
2860
2868
}
2869
+
2870
+ #[ unstable( feature = "stdarch_s390x" , issue = "135681" ) ]
2871
+ pub trait VectorSearchString {
2872
+ unsafe fn vec_search_string_cc (
2873
+ self ,
2874
+ b : Self ,
2875
+ c : vector_unsigned_char ,
2876
+ d : & mut i32 ,
2877
+ ) -> vector_unsigned_char ;
2878
+
2879
+ unsafe fn vec_search_string_until_zero_cc (
2880
+ self ,
2881
+ b : Self ,
2882
+ c : vector_unsigned_char ,
2883
+ d : & mut i32 ,
2884
+ ) -> vector_unsigned_char ;
2885
+ }
2886
+
2887
+ macro_rules! impl_vec_search_string{
2888
+ ( $( $intr_s: ident $intr_sz: ident $ty: ident) * ) => {
2889
+ $(
2890
+ #[ unstable( feature = "stdarch_s390x" , issue = "135681" ) ]
2891
+ impl VectorSearchString for $ty {
2892
+ #[ inline]
2893
+ #[ target_feature( enable = "vector" ) ]
2894
+ unsafe fn vec_search_string_cc( self , b: Self , c: vector_unsigned_char, d: & mut i32 ) -> vector_unsigned_char {
2895
+ let PackedTuple { x, y } = $intr_s( transmute( self ) , transmute( b) , c) ;
2896
+ * d = y;
2897
+ x
2898
+ }
2899
+
2900
+ #[ inline]
2901
+ #[ target_feature( enable = "vector" ) ]
2902
+ unsafe fn vec_search_string_until_zero_cc( self , b: Self , c: vector_unsigned_char, d: & mut i32 ) -> vector_unsigned_char {
2903
+ let PackedTuple { x, y } = $intr_sz( transmute( self ) , transmute( b) , c) ;
2904
+ * d = y;
2905
+ x
2906
+ }
2907
+ }
2908
+
2909
+ ) *
2910
+ }
2911
+ }
2912
+
2913
+ impl_vec_search_string ! {
2914
+ vstrsb vstrszb vector_signed_char
2915
+ vstrsb vstrszb vector_bool_char
2916
+ vstrsb vstrszb vector_unsigned_char
2917
+
2918
+ vstrsh vstrszh vector_signed_short
2919
+ vstrsh vstrszh vector_bool_short
2920
+ vstrsh vstrszh vector_unsigned_short
2921
+
2922
+ vstrsf vstrszf vector_signed_int
2923
+ vstrsf vstrszf vector_bool_int
2924
+ vstrsf vstrszf vector_unsigned_int
2925
+ }
2861
2926
}
2862
2927
2863
2928
/// Load Count to Block Boundary
@@ -4101,6 +4166,32 @@ pub unsafe fn vec_test_mask<T: sealed::VectorTestMask>(a: T, b: T::Mask) -> i32
4101
4166
a. vec_test_mask ( b)
4102
4167
}
4103
4168
4169
+ /// Vector Search String
4170
+ #[ inline]
4171
+ #[ target_feature( enable = "vector" ) ]
4172
+ #[ unstable( feature = "stdarch_s390x" , issue = "135681" ) ]
4173
+ pub unsafe fn vec_search_string_cc < T : sealed:: VectorSearchString > (
4174
+ a : T ,
4175
+ b : T ,
4176
+ c : vector_unsigned_char ,
4177
+ d : & mut i32 ,
4178
+ ) -> vector_unsigned_char {
4179
+ a. vec_search_string_cc ( b, c, d)
4180
+ }
4181
+
4182
+ /// Vector Search String Until Zero
4183
+ #[ inline]
4184
+ #[ target_feature( enable = "vector" ) ]
4185
+ #[ unstable( feature = "stdarch_s390x" , issue = "135681" ) ]
4186
+ pub unsafe fn vec_search_string_until_zero_cc < T : sealed:: VectorSearchString > (
4187
+ a : T ,
4188
+ b : T ,
4189
+ c : vector_unsigned_char ,
4190
+ d : & mut i32 ,
4191
+ ) -> vector_unsigned_char {
4192
+ a. vec_search_string_until_zero_cc ( b, c, d)
4193
+ }
4194
+
4104
4195
#[ cfg( test) ]
4105
4196
mod tests {
4106
4197
use super :: * ;
@@ -5142,4 +5233,72 @@ mod tests {
5142
5233
assert_eq ! ( vec_test_mask( v, m) , 3 ) ;
5143
5234
}
5144
5235
}
5236
+
5237
+ #[ simd_test( enable = "vector-enhancements-2" ) ]
5238
+ fn test_vec_search_string_cc ( ) {
5239
+ unsafe {
5240
+ let b = vector_unsigned_char ( * b"ABCD------------" ) ;
5241
+ let c = vector_unsigned_char ( [ 4 ; 16 ] ) ;
5242
+ let mut d = 0i32 ;
5243
+
5244
+ let haystack = vector_unsigned_char ( * b"__ABCD__________" ) ;
5245
+ let result = vec_search_string_cc ( haystack, b, c, & mut d) ;
5246
+ assert_eq ! ( result. as_array( ) [ 7 ] , 2 ) ;
5247
+ assert_eq ! ( d, 2 ) ;
5248
+
5249
+ let haystack = vector_unsigned_char ( * b"___ABCD_________" ) ;
5250
+ let result = vec_search_string_cc ( haystack, b, c, & mut d) ;
5251
+ assert_eq ! ( result. as_array( ) [ 7 ] , 3 ) ;
5252
+ assert_eq ! ( d, 2 ) ;
5253
+
5254
+ let haystack = vector_unsigned_char ( * b"________________" ) ;
5255
+ let result = vec_search_string_cc ( haystack, b, c, & mut d) ;
5256
+ assert_eq ! ( result. as_array( ) [ 7 ] , 16 ) ;
5257
+ assert_eq ! ( d, 0 ) ;
5258
+
5259
+ let haystack = vector_unsigned_char ( * b"______\0 _________" ) ;
5260
+ let result = vec_search_string_cc ( haystack, b, c, & mut d) ;
5261
+ assert_eq ! ( result. as_array( ) [ 7 ] , 16 ) ;
5262
+ assert_eq ! ( d, 0 ) ;
5263
+
5264
+ let haystack = vector_unsigned_char ( * b"______\0 __ABCD___" ) ;
5265
+ let result = vec_search_string_cc ( haystack, b, c, & mut d) ;
5266
+ assert_eq ! ( result. as_array( ) [ 7 ] , 9 ) ;
5267
+ assert_eq ! ( d, 2 ) ;
5268
+ }
5269
+ }
5270
+
5271
+ #[ simd_test( enable = "vector-enhancements-2" ) ]
5272
+ fn test_vec_search_string_until_zero_cc ( ) {
5273
+ unsafe {
5274
+ let b = vector_unsigned_char ( * b"ABCD\0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 " ) ;
5275
+ let c = vector_unsigned_char ( [ 16 ; 16 ] ) ;
5276
+ let mut d = 0i32 ;
5277
+
5278
+ let haystack = vector_unsigned_char ( * b"__ABCD__________" ) ;
5279
+ let result = vec_search_string_until_zero_cc ( haystack, b, c, & mut d) ;
5280
+ assert_eq ! ( result. as_array( ) [ 7 ] , 2 ) ;
5281
+ assert_eq ! ( d, 2 ) ;
5282
+
5283
+ let haystack = vector_unsigned_char ( * b"___ABCD_________" ) ;
5284
+ let result = vec_search_string_until_zero_cc ( haystack, b, c, & mut d) ;
5285
+ assert_eq ! ( result. as_array( ) [ 7 ] , 3 ) ;
5286
+ assert_eq ! ( d, 2 ) ;
5287
+
5288
+ let haystack = vector_unsigned_char ( * b"________________" ) ;
5289
+ let result = vec_search_string_until_zero_cc ( haystack, b, c, & mut d) ;
5290
+ assert_eq ! ( result. as_array( ) [ 7 ] , 16 ) ;
5291
+ assert_eq ! ( d, 0 ) ;
5292
+
5293
+ let haystack = vector_unsigned_char ( * b"______\0 _________" ) ;
5294
+ let result = vec_search_string_until_zero_cc ( haystack, b, c, & mut d) ;
5295
+ assert_eq ! ( result. as_array( ) [ 7 ] , 16 ) ;
5296
+ assert_eq ! ( d, 1 ) ;
5297
+
5298
+ let haystack = vector_unsigned_char ( * b"______\0 __ABCD___" ) ;
5299
+ let result = vec_search_string_until_zero_cc ( haystack, b, c, & mut d) ;
5300
+ assert_eq ! ( result. as_array( ) [ 7 ] , 16 ) ;
5301
+ assert_eq ! ( d, 1 ) ;
5302
+ }
5303
+ }
5145
5304
}
0 commit comments