openMSX
|
Utility class to optimize 64-bit divide/module by a 32-bit constant. More...
Classes | |
struct | Reduce0Result |
struct | Reduce1Result |
struct | Reduce2Result |
Functions | |
constexpr Reduce0Result | reduce0 (uint32_t divisor) |
constexpr Reduce1Result | reduce1 (uint64_t m, uint32_t s) |
constexpr Reduce2Result | reduce2 (uint128 m_low, uint128 m_high, uint32_t l) |
template<uint32_t DIVISOR> | |
constexpr auto | getAlgorithm () |
Utility class to optimize 64-bit divide/module by a 32-bit constant.
For 32-bit by 32-bit gcc already does this optimization (on 64-bit CPUs gcc also does it for 64-bit operands). This optimization especially helps on CPU without a HW division instruction (like ARM).
Usage: DivModByConst<123> dm; uint32_t d = dm.div(x); // equivalent to d = x / 123; uint32_t m = dm.mod(x); // equivalent to d = x % 123;
|
constexpr |
Definition at line 80 of file DivModByConst.hh.
|
constexpr |
Definition at line 25 of file DivModByConst.hh.
Referenced by getAlgorithm().
|
constexpr |
Definition at line 39 of file DivModByConst.hh.
Referenced by getAlgorithm().
|
constexpr |
Definition at line 52 of file DivModByConst.hh.
Referenced by getAlgorithm().