@@ -531,6 +531,72 @@ mod sealed {
531
531
impl_vec_trait ! { [ VectorNabs vec_nabs] vec_nabs_f32 ( vector_float) }
532
532
impl_vec_trait ! { [ VectorNabs vec_nabs] vec_nabs_f64 ( vector_double) }
533
533
534
+ #[ unstable( feature = "stdarch_s390x" , issue = "135681" ) ]
535
+ pub trait VectorSplat {
536
+ unsafe fn vec_splat < const IMM : u32 > ( self ) -> Self ;
537
+ }
538
+
539
+ #[ inline]
540
+ #[ target_feature( enable = "vector" ) ]
541
+ #[ cfg_attr( test, assert_instr( vrepb, IMM2 = 1 ) ) ]
542
+ unsafe fn vrepb < const IMM2 : u32 > ( a : vector_signed_char ) -> vector_signed_char {
543
+ static_assert_uimm_bits ! ( IMM2 , 4 ) ;
544
+ simd_shuffle ( a, a, const { u32x16:: from_array ( [ IMM2 ; 16 ] ) } )
545
+ }
546
+
547
+ #[ inline]
548
+ #[ target_feature( enable = "vector" ) ]
549
+ #[ cfg_attr( test, assert_instr( vreph, IMM2 = 1 ) ) ]
550
+ unsafe fn vreph < const IMM2 : u32 > ( a : vector_signed_short ) -> vector_signed_short {
551
+ static_assert_uimm_bits ! ( IMM2 , 3 ) ;
552
+ simd_shuffle ( a, a, const { u32x8:: from_array ( [ IMM2 ; 8 ] ) } )
553
+ }
554
+
555
+ #[ inline]
556
+ #[ target_feature( enable = "vector" ) ]
557
+ #[ cfg_attr( test, assert_instr( vrepf, IMM2 = 1 ) ) ]
558
+ unsafe fn vrepf < const IMM2 : u32 > ( a : vector_signed_int ) -> vector_signed_int {
559
+ static_assert_uimm_bits ! ( IMM2 , 2 ) ;
560
+ simd_shuffle ( a, a, const { u32x4:: from_array ( [ IMM2 ; 4 ] ) } )
561
+ }
562
+
563
+ #[ inline]
564
+ #[ target_feature( enable = "vector" ) ]
565
+ #[ cfg_attr( test, assert_instr( vrepg, IMM2 = 1 ) ) ]
566
+ unsafe fn vrepg < const IMM2 : u32 > ( a : vector_signed_long_long ) -> vector_signed_long_long {
567
+ static_assert_uimm_bits ! ( IMM2 , 1 ) ;
568
+ simd_shuffle ( a, a, const { u32x2:: from_array ( [ IMM2 ; 2 ] ) } )
569
+ }
570
+
571
+ macro_rules! impl_vec_splat {
572
+ ( $ty: ty, $fun: ident) => {
573
+ #[ unstable( feature = "stdarch_s390x" , issue = "135681" ) ]
574
+ impl VectorSplat for $ty {
575
+ #[ inline]
576
+ #[ target_feature( enable = "vector" ) ]
577
+ unsafe fn vec_splat<const IMM : u32 >( self ) -> Self {
578
+ transmute( $fun:: <IMM >( transmute( self ) ) )
579
+ }
580
+ }
581
+ } ;
582
+ }
583
+
584
+ impl_vec_splat ! { vector_signed_char, vrepb }
585
+ impl_vec_splat ! { vector_unsigned_char, vrepb }
586
+ impl_vec_splat ! { vector_bool_char, vrepb }
587
+ impl_vec_splat ! { vector_signed_short, vreph }
588
+ impl_vec_splat ! { vector_unsigned_short, vreph }
589
+ impl_vec_splat ! { vector_bool_short, vreph }
590
+ impl_vec_splat ! { vector_signed_int, vrepf }
591
+ impl_vec_splat ! { vector_unsigned_int, vrepf }
592
+ impl_vec_splat ! { vector_bool_int, vrepf }
593
+ impl_vec_splat ! { vector_signed_long_long, vrepg }
594
+ impl_vec_splat ! { vector_unsigned_long_long, vrepg }
595
+ impl_vec_splat ! { vector_bool_long_long, vrepg }
596
+
597
+ impl_vec_splat ! { vector_float, vrepf }
598
+ impl_vec_splat ! { vector_double, vrepg }
599
+
534
600
#[ unstable( feature = "stdarch_s390x" , issue = "135681" ) ]
535
601
pub trait VectorSplats < Output > {
536
602
unsafe fn vec_splats ( self ) -> Output ;
@@ -1590,6 +1656,17 @@ where
1590
1656
a. vec_sqrt ( )
1591
1657
}
1592
1658
1659
+ /// Vector Splat
1660
+ #[ inline]
1661
+ #[ target_feature( enable = "vector" ) ]
1662
+ #[ unstable( feature = "stdarch_s390x" , issue = "135681" ) ]
1663
+ pub unsafe fn vec_splat < T , const IMM : u32 > ( a : T ) -> T
1664
+ where
1665
+ T : sealed:: VectorSplat ,
1666
+ {
1667
+ a. vec_splat :: < IMM > ( )
1668
+ }
1669
+
1593
1670
/// Vector splats.
1594
1671
#[ inline]
1595
1672
#[ target_feature( enable = "vector" ) ]
@@ -2161,6 +2238,78 @@ pub unsafe fn vec_subec_u128(
2161
2238
transmute ( vsbcbiq ( transmute ( a) , transmute ( b) , transmute ( c) ) )
2162
2239
}
2163
2240
2241
+ /// Vector Splat Signed Byte
2242
+ #[ inline]
2243
+ #[ target_feature( enable = "vector" ) ]
2244
+ #[ unstable( feature = "stdarch_s390x" , issue = "135681" ) ]
2245
+ #[ cfg_attr( test, assert_instr( vrepib, IMM = 42 ) ) ]
2246
+ pub unsafe fn vec_splat_i8 < const IMM : i8 > ( ) -> vector_signed_char {
2247
+ vector_signed_char ( [ IMM ; 16 ] )
2248
+ }
2249
+
2250
+ /// Vector Splat Signed Halfword
2251
+ #[ inline]
2252
+ #[ target_feature( enable = "vector" ) ]
2253
+ #[ unstable( feature = "stdarch_s390x" , issue = "135681" ) ]
2254
+ #[ cfg_attr( test, assert_instr( vrepih, IMM = 42 ) ) ]
2255
+ pub unsafe fn vec_splat_i16 < const IMM : i16 > ( ) -> vector_signed_short {
2256
+ vector_signed_short ( [ IMM as i16 ; 8 ] )
2257
+ }
2258
+
2259
+ /// Vector Splat Signed Word
2260
+ #[ inline]
2261
+ #[ target_feature( enable = "vector" ) ]
2262
+ #[ unstable( feature = "stdarch_s390x" , issue = "135681" ) ]
2263
+ #[ cfg_attr( test, assert_instr( vrepif, IMM = 42 ) ) ]
2264
+ pub unsafe fn vec_splat_i32 < const IMM : i16 > ( ) -> vector_signed_int {
2265
+ vector_signed_int ( [ IMM as i32 ; 4 ] )
2266
+ }
2267
+
2268
+ /// Vector Splat Signed Doubleword
2269
+ #[ inline]
2270
+ #[ target_feature( enable = "vector" ) ]
2271
+ #[ unstable( feature = "stdarch_s390x" , issue = "135681" ) ]
2272
+ #[ cfg_attr( test, assert_instr( vrepig, IMM = 42 ) ) ]
2273
+ pub unsafe fn vec_splat_i64 < const IMM : i16 > ( ) -> vector_signed_long_long {
2274
+ vector_signed_long_long ( [ IMM as i64 ; 2 ] )
2275
+ }
2276
+
2277
+ /// Vector Splat Unsigned Byte
2278
+ #[ inline]
2279
+ #[ target_feature( enable = "vector" ) ]
2280
+ #[ unstable( feature = "stdarch_s390x" , issue = "135681" ) ]
2281
+ #[ cfg_attr( test, assert_instr( vrepib, IMM = 42 ) ) ]
2282
+ pub unsafe fn vec_splat_u8 < const IMM : u8 > ( ) -> vector_unsigned_char {
2283
+ vector_unsigned_char ( [ IMM ; 16 ] )
2284
+ }
2285
+
2286
+ /// Vector Splat Unsigned Halfword
2287
+ #[ inline]
2288
+ #[ target_feature( enable = "vector" ) ]
2289
+ #[ unstable( feature = "stdarch_s390x" , issue = "135681" ) ]
2290
+ #[ cfg_attr( test, assert_instr( vrepih, IMM = 42 ) ) ]
2291
+ pub unsafe fn vec_splat_u16 < const IMM : i16 > ( ) -> vector_unsigned_short {
2292
+ vector_unsigned_short ( [ IMM as u16 ; 8 ] )
2293
+ }
2294
+
2295
+ /// Vector Splat Unsigned Word
2296
+ #[ inline]
2297
+ #[ target_feature( enable = "vector" ) ]
2298
+ #[ unstable( feature = "stdarch_s390x" , issue = "135681" ) ]
2299
+ #[ cfg_attr( test, assert_instr( vrepif, IMM = 42 ) ) ]
2300
+ pub unsafe fn vec_splat_u32 < const IMM : i16 > ( ) -> vector_unsigned_int {
2301
+ vector_unsigned_int ( [ IMM as u32 ; 4 ] )
2302
+ }
2303
+
2304
+ /// Vector Splat Unsigned Doubleword
2305
+ #[ inline]
2306
+ #[ target_feature( enable = "vector" ) ]
2307
+ #[ unstable( feature = "stdarch_s390x" , issue = "135681" ) ]
2308
+ #[ cfg_attr( test, assert_instr( vrepig, IMM = 42 ) ) ]
2309
+ pub unsafe fn vec_splat_u64 < const IMM : i16 > ( ) -> vector_unsigned_long_long {
2310
+ vector_unsigned_long_long ( [ IMM as u64 ; 2 ] )
2311
+ }
2312
+
2164
2313
#[ cfg( test) ]
2165
2314
mod tests {
2166
2315
use super :: * ;
0 commit comments