@@ -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 ;
@@ -1586,6 +1652,17 @@ where
1586
1652
a. vec_sqrt ( )
1587
1653
}
1588
1654
1655
+ /// Vector Splat
1656
+ #[ inline]
1657
+ #[ target_feature( enable = "vector" ) ]
1658
+ #[ unstable( feature = "stdarch_s390x" , issue = "135681" ) ]
1659
+ pub unsafe fn vec_splat < T , const IMM : u32 > ( a : T ) -> T
1660
+ where
1661
+ T : sealed:: VectorSplat ,
1662
+ {
1663
+ a. vec_splat :: < IMM > ( )
1664
+ }
1665
+
1589
1666
/// Vector splats.
1590
1667
#[ inline]
1591
1668
#[ target_feature( enable = "vector" ) ]
@@ -2157,6 +2234,78 @@ pub unsafe fn vec_subec_u128(
2157
2234
transmute ( vsbcbiq ( transmute ( a) , transmute ( b) , transmute ( c) ) )
2158
2235
}
2159
2236
2237
+ /// Vector Splat Signed Byte
2238
+ #[ inline]
2239
+ #[ target_feature( enable = "vector" ) ]
2240
+ #[ unstable( feature = "stdarch_s390x" , issue = "135681" ) ]
2241
+ #[ cfg_attr( test, assert_instr( vrepib, IMM = 42 ) ) ]
2242
+ pub unsafe fn vec_splat_i8 < const IMM : i8 > ( ) -> vector_signed_char {
2243
+ vector_signed_char ( [ IMM ; 16 ] )
2244
+ }
2245
+
2246
+ /// Vector Splat Signed Halfword
2247
+ #[ inline]
2248
+ #[ target_feature( enable = "vector" ) ]
2249
+ #[ unstable( feature = "stdarch_s390x" , issue = "135681" ) ]
2250
+ #[ cfg_attr( test, assert_instr( vrepih, IMM = 42 ) ) ]
2251
+ pub unsafe fn vec_splat_i16 < const IMM : i16 > ( ) -> vector_signed_short {
2252
+ vector_signed_short ( [ IMM as i16 ; 8 ] )
2253
+ }
2254
+
2255
+ /// Vector Splat Signed Word
2256
+ #[ inline]
2257
+ #[ target_feature( enable = "vector" ) ]
2258
+ #[ unstable( feature = "stdarch_s390x" , issue = "135681" ) ]
2259
+ #[ cfg_attr( test, assert_instr( vrepif, IMM = 42 ) ) ]
2260
+ pub unsafe fn vec_splat_i32 < const IMM : i16 > ( ) -> vector_signed_int {
2261
+ vector_signed_int ( [ IMM as i32 ; 4 ] )
2262
+ }
2263
+
2264
+ /// Vector Splat Signed Doubleword
2265
+ #[ inline]
2266
+ #[ target_feature( enable = "vector" ) ]
2267
+ #[ unstable( feature = "stdarch_s390x" , issue = "135681" ) ]
2268
+ #[ cfg_attr( test, assert_instr( vrepig, IMM = 42 ) ) ]
2269
+ pub unsafe fn vec_splat_i64 < const IMM : i16 > ( ) -> vector_signed_long_long {
2270
+ vector_signed_long_long ( [ IMM as i64 ; 2 ] )
2271
+ }
2272
+
2273
+ /// Vector Splat Unsigned Byte
2274
+ #[ inline]
2275
+ #[ target_feature( enable = "vector" ) ]
2276
+ #[ unstable( feature = "stdarch_s390x" , issue = "135681" ) ]
2277
+ #[ cfg_attr( test, assert_instr( vrepib, IMM = 42 ) ) ]
2278
+ pub unsafe fn vec_splat_u8 < const IMM : u8 > ( ) -> vector_unsigned_char {
2279
+ vector_unsigned_char ( [ IMM ; 16 ] )
2280
+ }
2281
+
2282
+ /// Vector Splat Unsigned Halfword
2283
+ #[ inline]
2284
+ #[ target_feature( enable = "vector" ) ]
2285
+ #[ unstable( feature = "stdarch_s390x" , issue = "135681" ) ]
2286
+ #[ cfg_attr( test, assert_instr( vrepih, IMM = 42 ) ) ]
2287
+ pub unsafe fn vec_splat_u16 < const IMM : i16 > ( ) -> vector_unsigned_short {
2288
+ vector_unsigned_short ( [ IMM as u16 ; 8 ] )
2289
+ }
2290
+
2291
+ /// Vector Splat Unsigned Word
2292
+ #[ inline]
2293
+ #[ target_feature( enable = "vector" ) ]
2294
+ #[ unstable( feature = "stdarch_s390x" , issue = "135681" ) ]
2295
+ #[ cfg_attr( test, assert_instr( vrepif, IMM = 42 ) ) ]
2296
+ pub unsafe fn vec_splat_u32 < const IMM : i16 > ( ) -> vector_unsigned_int {
2297
+ vector_unsigned_int ( [ IMM as u32 ; 4 ] )
2298
+ }
2299
+
2300
+ /// Vector Splat Unsigned Doubleword
2301
+ #[ inline]
2302
+ #[ target_feature( enable = "vector" ) ]
2303
+ #[ unstable( feature = "stdarch_s390x" , issue = "135681" ) ]
2304
+ #[ cfg_attr( test, assert_instr( vrepig, IMM = 42 ) ) ]
2305
+ pub unsafe fn vec_splat_u64 < const IMM : i16 > ( ) -> vector_unsigned_long_long {
2306
+ vector_unsigned_long_long ( [ IMM as u64 ; 2 ] )
2307
+ }
2308
+
2160
2309
#[ cfg( test) ]
2161
2310
mod tests {
2162
2311
use super :: * ;
0 commit comments