8#ifndef LIB_BIG_INT_UTIL_H_
9#define LIB_BIG_INT_UTIL_H_
19big_int ripBits(big_int &value,
int bits);
28BitRange findOnes(
const big_int &value);
30big_int cvtInt(
const char *s,
unsigned base);
31big_int shift_left(
const big_int &v,
unsigned bits);
32big_int shift_right(
const big_int &v,
unsigned bits);
34big_int maskFromSlice(
unsigned m,
unsigned l);
35big_int mask(
unsigned bits);
37inline unsigned scan0_positive(
const boost::multiprecision::cpp_int &val,
unsigned pos) {
38 while (boost::multiprecision::bit_test(val, pos)) ++pos;
41inline unsigned scan1_positive(
const boost::multiprecision::cpp_int &val,
unsigned pos) {
42 if (val == 0 || pos > boost::multiprecision::msb(val))
return ~0U;
43 unsigned lsb = boost::multiprecision::lsb(val);
44 if (lsb >= pos)
return lsb;
45 while (!boost::multiprecision::bit_test(val, pos)) ++pos;
48inline unsigned scan0(
const boost::multiprecision::cpp_int &val,
unsigned pos) {
49 if (val < 0)
return scan1_positive(-val - 1, pos);
50 return scan0_positive(val, pos);
52inline unsigned scan1(
const boost::multiprecision::cpp_int &val,
unsigned pos) {
53 if (val < 0)
return scan0_positive(-val - 1, pos);
54 return scan1_positive(val, pos);
61static inline unsigned bitcount(big_int v) {
62 if (v < 0)
return ~0U;
71static inline int ffs(big_int v) {
72 if (v <= 0)
return -1;
73 return boost::multiprecision::lsb(v);
76static inline int floor_log2(big_int v) {
85static inline int ceil_log2(big_int v) {
return v ? floor_log2(v - 1) + 1 : -1; }
TODO: this is not really specific to BMV2, it should reside somewhere else.
Definition applyOptionsPragmas.cpp:13
Definition big_int_util.h:21