Go to the documentation of this file.
29 #ifndef __BASE_INTMATH_HH__
30 #define __BASE_INTMATH_HH__
34 #include <type_traits>
46 uint64_t component =
n;
48 uint64_t last = result;
51 warn_if(result < last,
"power() overflowed!");
53 component *= component;
62 inline typename std::enable_if<std::is_integral<T>::value,
int>
::type
71 constexpr
auto ts =
sizeof(T);
73 if (
ts >= 8 && (
ux &
ULL(0xffffffff00000000))) { y += 32;
ux >>= 32; }
74 if (
ts >= 4 && (
ux &
ULL(0x00000000ffff0000))) { y += 16;
ux >>= 16; }
75 if (
ts >= 2 && (
ux &
ULL(0x000000000000ff00))) { y += 8;
ux >>= 8; }
76 if (
ux &
ULL(0x00000000000000f0)) { y += 4;
ux >>= 4; }
77 if (
ux &
ULL(0x000000000000000c)) { y += 2;
ux >>= 2; }
78 if (
ux &
ULL(0x0000000000000002)) { y += 1; }
106 return n && !(
n & (
n - 1));
112 template <
class T,
class U>
116 return (
a +
b - 1) /
b;
129 template <
class T,
class U>
148 template <
class T,
class U>
157 #endif // __BASE_INTMATH_HH__
T roundDown(const T &val, const U &align)
This function is used to align addresses in memory.
std::enable_if< std::is_integral< T >::value, int >::type floorLog2(T x)
void align(const scfx_rep &lhs, const scfx_rep &rhs, int &new_wp, int &len_mant, scfx_mant_ref &lhs_mant, scfx_mant_ref &rhs_mant)
T divCeil(const T &a, const U &b)
#define warn_if(cond,...)
Conditional warning macro that checks the supplied condition and only prints a warning if the conditi...
T roundUp(const T &val, const U &align)
This function is used to align addresses in memory.
uint64_t power(uint32_t n, uint32_t e)
bool isPowerOf2(const T &n)
#define ULL(N)
uint64_t constant
Generated on Wed Sep 30 2020 14:02:07 for gem5 by doxygen 1.8.17