8#ifndef LIB_BIG_INT_UTIL_H_
9#define LIB_BIG_INT_UTIL_H_
11#include <boost/version.hpp>
13#if BOOST_VERSION < 106700
14#include <boost/functional/hash.hpp>
25big_int ripBits(big_int &value,
int bits);
34BitRange findOnes(
const big_int &value);
36big_int cvtInt(
const char *s,
unsigned base);
37big_int shift_left(
const big_int &v,
unsigned bits);
38big_int shift_right(
const big_int &v,
unsigned bits);
40big_int maskFromSlice(
unsigned m,
unsigned l);
41big_int mask(
unsigned bits);
43inline unsigned scan0_positive(
const boost::multiprecision::cpp_int &val,
unsigned pos) {
44 while (boost::multiprecision::bit_test(val, pos)) ++pos;
47inline unsigned scan1_positive(
const boost::multiprecision::cpp_int &val,
unsigned pos) {
48 if (val == 0 || pos > boost::multiprecision::msb(val))
return ~0U;
49 unsigned lsb = boost::multiprecision::lsb(val);
50 if (lsb >= pos)
return lsb;
51 while (!boost::multiprecision::bit_test(val, pos)) ++pos;
54inline unsigned scan0(
const boost::multiprecision::cpp_int &val,
unsigned pos) {
55 if (val < 0)
return scan1_positive(-val - 1, pos);
56 return scan0_positive(val, pos);
58inline unsigned scan1(
const boost::multiprecision::cpp_int &val,
unsigned pos) {
59 if (val < 0)
return scan0_positive(-val - 1, pos);
60 return scan1_positive(val, pos);
67static inline unsigned bitcount(big_int v) {
68 if (v < 0)
return ~0U;
77static inline int ffs(big_int v) {
78 if (v <= 0)
return -1;
79 return boost::multiprecision::lsb(v);
82static inline int floor_log2(big_int v) {
91static 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:27