26static inline unsigned bitcount(
unsigned v) {
27#if defined(__GNUC__) || defined(__clang__)
28 unsigned rv = __builtin_popcount(v);
39static inline int floor_log2(
unsigned v) {
41#if defined(__GNUC__) || defined(__clang__)
42 if (v) rv = CHAR_BIT *
sizeof(unsigned) - __builtin_clz(v) - 1;
52static inline int ceil_log2(
unsigned v) {
return v ? floor_log2(v - 1) + 1 : -1; }
54static inline unsigned bitmask2bytemask(
const bitvec &a) {
55 int max = a.max().index();
56 if (max < 0)
return 0;
58 for (
unsigned i = 0; i <= max / 8U; i++)
59 if (a.getrange(i * 8, 8)) rv |= 1 << i;
TODO: this is not really specific to BMV2, it should reside somewhere else.
Definition applyOptionsPragmas.cpp:24