@@ -377,6 +377,13 @@ extern "C" {
377
377
fn vslv ( a : vector_unsigned_char , b : vector_unsigned_char ) -> vector_unsigned_char ;
378
378
#[ link_name = "llvm.ppc.altivec.srv" ]
379
379
fn vsrv ( a : vector_unsigned_char , b : vector_unsigned_char ) -> vector_unsigned_char ;
380
+
381
+ #[ link_name = "llvm.ctlz.v16i8" ]
382
+ fn vclzb ( a : vector_signed_char ) -> vector_signed_char ;
383
+ #[ link_name = "llvm.ctlz.v8i16" ]
384
+ fn vclzh ( a : vector_signed_short ) -> vector_signed_short ;
385
+ #[ link_name = "llvm.ctlz.v4i32" ]
386
+ fn vclzw ( a : vector_signed_int ) -> vector_signed_int ;
380
387
}
381
388
382
389
macro_rules! s_t_l {
@@ -3090,6 +3097,35 @@ mod sealed {
3090
3097
}
3091
3098
3092
3099
impl_vec_shift_octect ! { [ VectorSro vec_sro] ( vsro) }
3100
+
3101
+ test_impl ! { vec_vcntlzb( a: vector_signed_char) -> vector_signed_char [ vclzb, vclzb] }
3102
+ test_impl ! { vec_vcntlzh( a: vector_signed_short) -> vector_signed_short [ vclzh, vclzh] }
3103
+ test_impl ! { vec_vcntlzw( a: vector_signed_int) -> vector_signed_int [ vclzw, vclzw] }
3104
+
3105
+ #[ unstable( feature = "stdarch_powerpc" , issue = "111145" ) ]
3106
+ pub trait VectorCntlz {
3107
+ unsafe fn vec_cntlz ( self ) -> Self ;
3108
+ }
3109
+
3110
+ macro_rules! impl_vec_cntlz {
3111
+ ( $fun: ident ( $a: ty) ) => {
3112
+ #[ unstable( feature = "stdarch_powerpc" , issue = "111145" ) ]
3113
+ impl VectorCntlz for $a {
3114
+ #[ inline]
3115
+ #[ target_feature( enable = "altivec" ) ]
3116
+ unsafe fn vec_cntlz( self ) -> Self {
3117
+ transmute( $fun( transmute( self ) ) )
3118
+ }
3119
+ }
3120
+ } ;
3121
+ }
3122
+
3123
+ impl_vec_cntlz ! { vec_vcntlzb( vector_signed_char) }
3124
+ impl_vec_cntlz ! { vec_vcntlzb( vector_unsigned_char) }
3125
+ impl_vec_cntlz ! { vec_vcntlzh( vector_signed_short) }
3126
+ impl_vec_cntlz ! { vec_vcntlzh( vector_unsigned_short) }
3127
+ impl_vec_cntlz ! { vec_vcntlzw( vector_signed_int) }
3128
+ impl_vec_cntlz ! { vec_vcntlzw( vector_unsigned_int) }
3093
3129
}
3094
3130
3095
3131
/// Vector Merge Low
@@ -4219,6 +4255,25 @@ pub unsafe fn vec_any_numeric(a: vector_float) -> bool {
4219
4255
vcmpgefp_p ( 1 , a, a) != 0
4220
4256
}
4221
4257
4258
+ /// Vector Count Leading Zeros
4259
+ ///
4260
+ /// ## Purpose
4261
+ /// Returns a vector containing the number of most-significant bits equal to zero of each
4262
+ /// corresponding element of the source vector.
4263
+ ///
4264
+ /// ## Result value
4265
+ /// The value of each element of r is set to the number of leading zeros of the
4266
+ /// corresponding element of a.
4267
+ #[ inline]
4268
+ #[ target_feature( enable = "altivec" ) ]
4269
+ #[ unstable( feature = "stdarch_powerpc" , issue = "111145" ) ]
4270
+ pub unsafe fn vec_cntlz < T > ( a : T ) -> T
4271
+ where
4272
+ T : sealed:: VectorCntlz ,
4273
+ {
4274
+ a. vec_cntlz ( )
4275
+ }
4276
+
4222
4277
/// Any Element Out of Bounds
4223
4278
#[ inline]
4224
4279
#[ target_feature( enable = "altivec" ) ]
0 commit comments