Lines Matching defs:bits

22 namespace bits {
24 // CountPopulation(value) returns the number of bits set in |value|.
39 // Start with 64 buckets of 1 bits, holding values from [0,1].
41 // Having 32 buckets of 2 bits, holding values from [0,2] now.
43 // Having 16 buckets of 4 bits, holding values from [0,4] now.
45 // Having 8 buckets of 8 bits, holding values from [0,8] now.
46 // From this point on, the buckets are bigger than the number of bits
51 // Having 4 buckets of 16 bits, holding values from [0,16] now.
53 // Having 2 buckets of 32 bits, holding values from [0,32] now.
55 // Having 1 buckets of 64 bits, holding values from [0,64] now.
73 // CountLeadingZeros(value) returns the number of zero bits following the most
76 template <typename T, unsigned bits = sizeof(T) * 8>
81 static_assert(bits > 0, "invalid instantiation");
84 ? bits
85 : bits == 64
87 : __builtin_clz(static_cast<uint32_t>(value)) - (32 - bits);
91 if (bits == 1) return static_cast<unsigned>(value) ^ 1;
92 T upper_half = value >> (bits / 2);
94 unsigned add = upper_half != 0 ? 0 : bits / 2;
95 constexpr unsigned next_bits = bits == 1 ? 1 : bits / 2;
107 // CountTrailingZeros(value) returns the number of zero bits preceding the
112 template <typename T, unsigned bits = sizeof(T) * 8>
118 return value == 0 ? bits
119 : bits == 64 ? __builtin_ctzll(static_cast<uint64_t>(value))
138 // CountTrailingZerosNonZero(value) returns the number of zero bits preceding
142 template <typename T, unsigned bits = sizeof(T) * 8>
149 return bits == 64 ? __builtin_ctzll(static_cast<uint64_t>(value))
152 return CountTrailingZeros<T, bits>(value);
286 // |rhs|, extracts the most significant 32 bits of the result, and returns
291 // |lhs| and |rhs|, extracts the most significant 32 bits of the result, and
351 } // namespace bits