1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44
use int::Int; /// Counts the leading most significant bits set. /// /// When all bits of the operand are set it returns the size of the operand in /// bits. /// /// **Keywords**: count leading sign bits, count leading ones, count leading /// bits set. /// /// # Assembly Instructions /// /// - [`CLS`](http://infocenter.arm.com/help/index.jsp?topic=/com.arm.doc.ddi0487a.k_10775/index.html): /// - Description: Count leading sign bits. /// - Architecture: ARMv8. /// - Registers: 32/64 bits. /// /// # Example /// /// ``` /// use bitintr::arm::v8::*; /// /// let n = 0b1111_1111_1100_1010u16; /// /// assert_eq!(n.cls(), 10); /// assert_eq!(cls(0b1111_1111u8), 8); /// ``` #[inline] pub fn cls<T: Int>(x: T) -> T { T::leading_zeros(!x) } /// Method version of [`cls`](fn.cls.html). pub trait CLS { #[inline] fn cls(self) -> Self; } impl<T: Int> CLS for T { #[inline] fn cls(self) -> T { cls(self) } }