@@ -377,6 +377,13 @@ extern "C" {
377377 fn vslv ( a : vector_unsigned_char , b : vector_unsigned_char ) -> vector_unsigned_char ;
378378 #[ link_name = "llvm.ppc.altivec.srv" ]
379379 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 ;
380387}
381388
382389macro_rules! s_t_l {
@@ -3090,6 +3097,35 @@ mod sealed {
30903097 }
30913098
30923099 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) }
30933129}
30943130
30953131/// Vector Merge Low
@@ -4219,6 +4255,25 @@ pub unsafe fn vec_any_numeric(a: vector_float) -> bool {
42194255 vcmpgefp_p ( 1 , a, a) != 0
42204256}
42214257
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+
42224277/// Any Element Out of Bounds
42234278#[ inline]
42244279#[ target_feature( enable = "altivec" ) ]
0 commit comments