@@ -2118,6 +2118,56 @@ mod sealed {
2118
2118
2119
2119
impl_vec_trait ! { [ VectorMergel vec_mergel] + 2 b ( vec_vmrglb, vec_vmrglh, vec_vmrglw) }
2120
2120
impl_vec_trait ! { [ VectorMergel vec_mergel] + vec_vmrglw ( vector_float, vector_float) -> vector_float }
2121
+
2122
+ #[ inline]
2123
+ #[ target_feature( enable = "altivec" ) ]
2124
+ #[ cfg_attr( test, assert_instr( vpkuhum) ) ]
2125
+ unsafe fn vec_vpkuhum ( a : vector_signed_short , b : vector_signed_short ) -> vector_signed_char {
2126
+ let pack_perm = if cfg ! ( target_endian = "little" ) {
2127
+ transmute ( u8x16:: new (
2128
+ 0x00 , 0x02 , 0x04 , 0x06 , 0x08 , 0x0A , 0x0C , 0x0E , 0x10 , 0x12 , 0x14 , 0x16 , 0x18 , 0x1A ,
2129
+ 0x1C , 0x1E ,
2130
+ ) )
2131
+ } else {
2132
+ transmute ( u8x16:: new (
2133
+ 0x01 , 0x03 , 0x05 , 0x07 , 0x09 , 0x0B , 0x0D , 0x0F , 0x11 , 0x13 , 0x15 , 0x17 , 0x19 , 0x1B ,
2134
+ 0x1D , 0x1F ,
2135
+ ) )
2136
+ } ;
2137
+
2138
+ transmute ( vec_perm ( a, b, pack_perm) )
2139
+ }
2140
+
2141
+ #[ inline]
2142
+ #[ target_feature( enable = "altivec" ) ]
2143
+ #[ cfg_attr( test, assert_instr( vpkuwum) ) ]
2144
+ unsafe fn vec_vpkuwum ( a : vector_signed_int , b : vector_signed_int ) -> vector_signed_short {
2145
+ let pack_perm = if cfg ! ( target_endian = "little" ) {
2146
+ transmute ( u8x16:: new (
2147
+ 0x00 , 0x01 , 0x04 , 0x05 , 0x08 , 0x09 , 0x0C , 0x0D , 0x10 , 0x11 , 0x14 , 0x15 , 0x18 , 0x19 ,
2148
+ 0x1C , 0x1D ,
2149
+ ) )
2150
+ } else {
2151
+ transmute ( u8x16:: new (
2152
+ 0x02 , 0x03 , 0x06 , 0x07 , 0x0A , 0x0B , 0x0E , 0x0F , 0x12 , 0x13 , 0x16 , 0x17 , 0x1A , 0x1B ,
2153
+ 0x1E , 0x1F ,
2154
+ ) )
2155
+ } ;
2156
+
2157
+ transmute ( vec_perm ( a, b, pack_perm) )
2158
+ }
2159
+
2160
+ pub trait VectorPack < Other > {
2161
+ type Result ;
2162
+ unsafe fn vec_pack ( self , b : Other ) -> Self :: Result ;
2163
+ }
2164
+
2165
+ impl_vec_trait ! { [ VectorPack vec_pack] + vec_vpkuhum ( vector_signed_short, vector_signed_short) -> vector_signed_char }
2166
+ impl_vec_trait ! { [ VectorPack vec_pack] + vec_vpkuhum ( vector_unsigned_short, vector_unsigned_short) -> vector_unsigned_char }
2167
+ impl_vec_trait ! { [ VectorPack vec_pack] + vec_vpkuhum ( vector_bool_short, vector_bool_short) -> vector_bool_char }
2168
+ impl_vec_trait ! { [ VectorPack vec_pack] + vec_vpkuwum ( vector_signed_int, vector_signed_int) -> vector_signed_short }
2169
+ impl_vec_trait ! { [ VectorPack vec_pack] + vec_vpkuwum ( vector_unsigned_int, vector_unsigned_int) -> vector_unsigned_short }
2170
+ impl_vec_trait ! { [ VectorPack vec_pack] + vec_vpkuwum ( vector_bool_int, vector_bool_int) -> vector_bool_short }
2121
2171
}
2122
2172
2123
2173
/// Vector Merge Low
@@ -2140,6 +2190,16 @@ where
2140
2190
a. vec_mergeh ( b)
2141
2191
}
2142
2192
2193
+ /// Vector Pack
2194
+ #[ inline]
2195
+ #[ target_feature( enable = "altivec" ) ]
2196
+ pub unsafe fn vec_pack < T , U > ( a : T , b : U ) -> <T as sealed:: VectorPack < U > >:: Result
2197
+ where
2198
+ T : sealed:: VectorPack < U > ,
2199
+ {
2200
+ a. vec_pack ( b)
2201
+ }
2202
+
2143
2203
/// Vector Load Indexed.
2144
2204
#[ inline]
2145
2205
#[ target_feature( enable = "altivec" ) ]
0 commit comments