@@ -308,6 +308,16 @@ extern "C" {
308
308
fn vpkswus ( a : vector_signed_int , b : vector_signed_int ) -> vector_unsigned_short ;
309
309
#[ link_name = "llvm.ppc.altivec.vpkuwus" ]
310
310
fn vpkuwus ( a : vector_unsigned_int , b : vector_unsigned_int ) -> vector_unsigned_short ;
311
+
312
+ #[ link_name = "llvm.ppc.altivec.vupkhsb" ]
313
+ fn vupkhsb ( a : vector_signed_char ) -> vector_signed_short ;
314
+ #[ link_name = "llvm.ppc.altivec.vupklsb" ]
315
+ fn vupklsb ( a : vector_signed_char ) -> vector_signed_short ;
316
+
317
+ #[ link_name = "llvm.ppc.altivec.vupkhsh" ]
318
+ fn vupkhsh ( a : vector_signed_short ) -> vector_signed_int ;
319
+ #[ link_name = "llvm.ppc.altivec.vupklsh" ]
320
+ fn vupklsh ( a : vector_signed_short ) -> vector_signed_int ;
311
321
}
312
322
313
323
macro_rules! s_t_l {
@@ -2270,6 +2280,47 @@ mod sealed {
2270
2280
impl_vec_trait ! { [ VectorPacksu vec_packsu] vec_vpkuhus ( vector_unsigned_short, vector_unsigned_short) -> vector_unsigned_char }
2271
2281
impl_vec_trait ! { [ VectorPacksu vec_packsu] vec_vpkswus ( vector_signed_int, vector_signed_int) -> vector_unsigned_short }
2272
2282
impl_vec_trait ! { [ VectorPacksu vec_packsu] vec_vpkuwus ( vector_unsigned_int, vector_unsigned_int) -> vector_unsigned_short }
2283
+
2284
+ macro_rules! impl_vec_unpack {
2285
+ ( $fun: ident ( $a: ident) -> $r: ident [ $little: ident, $big: ident] ) => {
2286
+ #[ inline]
2287
+ #[ target_feature( enable = "altivec" ) ]
2288
+ #[ cfg_attr( all( test, target_endiant = "little" ) , assert_instr( $little) ) ]
2289
+ #[ cfg_attr( all( test, target_endiant = "big" ) , assert_instr( $big) ) ]
2290
+ unsafe fn $fun( a: $a) -> $r {
2291
+ if cfg!( target_endian = "little" ) {
2292
+ $little( a)
2293
+ } else {
2294
+ $big( a)
2295
+ }
2296
+ }
2297
+ } ;
2298
+ }
2299
+
2300
+ impl_vec_unpack ! { vec_vupkhsb ( vector_signed_char) -> vector_signed_short [ vupklsb, vupkhsb] }
2301
+ impl_vec_unpack ! { vec_vupklsb ( vector_signed_char) -> vector_signed_short [ vupkhsb, vupklsb] }
2302
+ impl_vec_unpack ! { vec_vupkhsh ( vector_signed_short) -> vector_signed_int [ vupklsh, vupkhsh] }
2303
+ impl_vec_unpack ! { vec_vupklsh ( vector_signed_short) -> vector_signed_int [ vupkhsh, vupklsh] }
2304
+
2305
+ pub trait VectorUnpackh {
2306
+ type Result ;
2307
+ unsafe fn vec_unpackh ( self ) -> Self :: Result ;
2308
+ }
2309
+
2310
+ impl_vec_trait ! { [ VectorUnpackh vec_unpackh] vec_vupkhsb ( vector_signed_char) -> vector_signed_short }
2311
+ impl_vec_trait ! { [ VectorUnpackh vec_unpackh] + vec_vupkhsb ( vector_bool_char) -> vector_bool_short }
2312
+ impl_vec_trait ! { [ VectorUnpackh vec_unpackh] vec_vupkhsh ( vector_signed_short) -> vector_signed_int }
2313
+ impl_vec_trait ! { [ VectorUnpackh vec_unpackh] + vec_vupkhsh ( vector_bool_short) -> vector_bool_int }
2314
+
2315
+ pub trait VectorUnpackl {
2316
+ type Result ;
2317
+ unsafe fn vec_unpackl ( self ) -> Self :: Result ;
2318
+ }
2319
+
2320
+ impl_vec_trait ! { [ VectorUnpackl vec_unpackl] vec_vupklsb ( vector_signed_char) -> vector_signed_short }
2321
+ impl_vec_trait ! { [ VectorUnpackl vec_unpackl] + vec_vupklsb ( vector_bool_char) -> vector_bool_short }
2322
+ impl_vec_trait ! { [ VectorUnpackl vec_unpackl] vec_vupklsh ( vector_signed_short) -> vector_signed_int }
2323
+ impl_vec_trait ! { [ VectorUnpackl vec_unpackl] + vec_vupklsh ( vector_bool_short) -> vector_bool_int }
2273
2324
}
2274
2325
2275
2326
/// Vector Merge Low
@@ -2322,6 +2373,26 @@ where
2322
2373
a. vec_packsu ( b)
2323
2374
}
2324
2375
2376
+ /// Vector Unpack High
2377
+ #[ inline]
2378
+ #[ target_feature( enable = "altivec" ) ]
2379
+ pub unsafe fn vec_unpackh < T > ( a : T ) -> <T as sealed:: VectorUnpackh >:: Result
2380
+ where
2381
+ T : sealed:: VectorUnpackh ,
2382
+ {
2383
+ a. vec_unpackh ( )
2384
+ }
2385
+
2386
+ /// Vector Unpack Low
2387
+ #[ inline]
2388
+ #[ target_feature( enable = "altivec" ) ]
2389
+ pub unsafe fn vec_unpackl < T > ( a : T ) -> <T as sealed:: VectorUnpackl >:: Result
2390
+ where
2391
+ T : sealed:: VectorUnpackl ,
2392
+ {
2393
+ a. vec_unpackl ( )
2394
+ }
2395
+
2325
2396
/// Vector Load Indexed.
2326
2397
#[ inline]
2327
2398
#[ target_feature( enable = "altivec" ) ]
0 commit comments