17static inline unsigned bitcount(
unsigned v) {
18#if defined(__GNUC__) || defined(__clang__)
19 unsigned rv = __builtin_popcount(v);
30static inline int floor_log2(
unsigned v) {
32#if defined(__GNUC__) || defined(__clang__)
33 if (v) rv = CHAR_BIT *
sizeof(unsigned) - __builtin_clz(v) - 1;
43static inline int ceil_log2(
unsigned v) {
return v ? floor_log2(v - 1) + 1 : -1; }
45static inline unsigned bitmask2bytemask(
const bitvec &a) {
46 int max = a.max().index();
47 if (max < 0)
return 0;
49 for (
unsigned i = 0; i <= max / 8U; i++)
50 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:13