Lines Matching refs:x

47 constexpr int CLZ(T x) {  in CLZ()  argument
53 DCHECK_NE(x, 0u); in CLZ()
57 return is_64_bit ? __builtin_clzll(x) : __builtin_clz(x) - adjustment; in CLZ()
62 constexpr int JAVASTYLE_CLZ(T x) { in JAVASTYLE_CLZ() argument
65 return (x == 0) ? BitSizeOf<T>() : CLZ(static_cast<unsigned_type>(x)); in JAVASTYLE_CLZ()
69 constexpr int CTZ(T x) { in CTZ() argument
75 DCHECK_NE(x, static_cast<T>(0)); in CTZ()
76 return (sizeof(T) == sizeof(uint64_t)) ? __builtin_ctzll(x) : __builtin_ctz(x); in CTZ()
81 constexpr int JAVASTYLE_CTZ(T x) { in JAVASTYLE_CTZ() argument
84 return (x == 0) ? BitSizeOf<T>() : CTZ(static_cast<unsigned_type>(x)); in JAVASTYLE_CTZ()
89 constexpr int POPCOUNT(T x) { in POPCOUNT() argument
90 return (sizeof(T) == sizeof(uint32_t)) ? __builtin_popcount(x) : __builtin_popcountll(x); in POPCOUNT()
95 constexpr T BSWAP(T x) { in BSWAP() argument
97 return __builtin_bswap16(x); in BSWAP()
99 return __builtin_bswap32(x); in BSWAP()
101 return __builtin_bswap64(x); in BSWAP()
129 constexpr T RoundUpToPowerOfTwo(T x) { in RoundUpToPowerOfTwo() argument
133 return (x < 2u) ? x : static_cast<T>(1u) << (std::numeric_limits<T>::digits - CLZ(x - 1u)); in RoundUpToPowerOfTwo()
145 constexpr bool IsPowerOfTwo(T x) { in IsPowerOfTwo() argument
148 return (x & (x - 1)) == 0; in IsPowerOfTwo()
152 constexpr int WhichPowerOf2(T x) { in WhichPowerOf2() argument
155 DCHECK((x != 0) && IsPowerOfTwo(x)); in WhichPowerOf2()
156 return CTZ(x); in WhichPowerOf2()
162 constexpr T RoundDown(T x, typename Identity<T>::type n) WARN_UNUSED;
165 constexpr T RoundDown(T x, typename Identity<T>::type n) { in RoundDown() argument
167 return (x & -n); in RoundDown()
171 constexpr T RoundUp(T x, typename std::remove_reference<T>::type n) WARN_UNUSED;
174 constexpr T RoundUp(T x, typename std::remove_reference<T>::type n) { in RoundUp() argument
175 return RoundDown(x + n - 1, n); in RoundUp()
180 inline T* AlignDown(T* x, uintptr_t n) WARN_UNUSED;
183 inline T* AlignDown(T* x, uintptr_t n) { in AlignDown() argument
184 return reinterpret_cast<T*>(RoundDown(reinterpret_cast<uintptr_t>(x), n)); in AlignDown()
188 inline T* AlignUp(T* x, uintptr_t n) WARN_UNUSED;
191 inline T* AlignUp(T* x, uintptr_t n) { in AlignUp() argument
192 return reinterpret_cast<T*>(RoundUp(reinterpret_cast<uintptr_t>(x), n)); in AlignUp()
196 constexpr bool IsAligned(T x) { in IsAligned() argument
198 return (x & (n - 1)) == 0; in IsAligned()
202 inline bool IsAligned(T* x) { in IsAligned() argument
203 return IsAligned<n>(reinterpret_cast<const uintptr_t>(x)); in IsAligned()
207 inline bool IsAlignedParam(T x, int n) { in IsAlignedParam() argument
208 return (x & (n - 1)) == 0; in IsAlignedParam()
212 inline bool IsAlignedParam(T* x, int n) { in IsAlignedParam() argument
213 return IsAlignedParam(reinterpret_cast<const uintptr_t>(x), n); in IsAlignedParam()