mirror of
https://github.com/fastfloat/fast_float.git
synced 2025-12-06 16:56:57 +08:00
reduce register pressure.
This commit is contained in:
parent
a133b72fa8
commit
b121f53316
@ -37,10 +37,10 @@ constexpr size_t bigint_limbs = bigint_bits / limb_bits;
|
|||||||
|
|
||||||
// vector-like type that is allocated on the stack. the entire
|
// vector-like type that is allocated on the stack. the entire
|
||||||
// buffer is pre-allocated, and only the length changes.
|
// buffer is pre-allocated, and only the length changes.
|
||||||
template <uint16_t size> struct stackvec {
|
template <uint8_t size> struct stackvec {
|
||||||
limb data[size];
|
limb data[size];
|
||||||
// we never need more than 150 limbs
|
// we never need more than 150 limbs
|
||||||
uint16_t length{0};
|
uint8_t length{0};
|
||||||
|
|
||||||
FASTFLOAT_CONSTEXPR20 stackvec() noexcept = default;
|
FASTFLOAT_CONSTEXPR20 stackvec() noexcept = default;
|
||||||
stackvec(stackvec const &) = delete;
|
stackvec(stackvec const &) = delete;
|
||||||
@ -72,14 +72,14 @@ template <uint16_t size> struct stackvec {
|
|||||||
|
|
||||||
// set the length, without bounds checking.
|
// set the length, without bounds checking.
|
||||||
FASTFLOAT_CONSTEXPR14 void set_len(size_t len) noexcept {
|
FASTFLOAT_CONSTEXPR14 void set_len(size_t len) noexcept {
|
||||||
length = uint16_t(len);
|
length = uint8_t(len);
|
||||||
}
|
}
|
||||||
|
|
||||||
constexpr size_t len() const noexcept { return length; }
|
constexpr uint8_t len() const noexcept { return length; }
|
||||||
|
|
||||||
constexpr bool is_empty() const noexcept { return length == 0; }
|
constexpr bool is_empty() const noexcept { return length == 0; }
|
||||||
|
|
||||||
constexpr size_t capacity() const noexcept { return size; }
|
constexpr uint8_t capacity() const noexcept { return size; }
|
||||||
|
|
||||||
// append item to vector, without bounds checking
|
// append item to vector, without bounds checking
|
||||||
FASTFLOAT_CONSTEXPR14 void push_unchecked(limb value) noexcept {
|
FASTFLOAT_CONSTEXPR14 void push_unchecked(limb value) noexcept {
|
||||||
@ -375,7 +375,7 @@ FASTFLOAT_CONSTEXPR20 bool large_mul(stackvec<size> &x, limb_span y) noexcept {
|
|||||||
}
|
}
|
||||||
|
|
||||||
template <typename = void> struct pow5_tables {
|
template <typename = void> struct pow5_tables {
|
||||||
static constexpr uint32_t large_step = 135;
|
static constexpr uint8_t large_step = 135;
|
||||||
static constexpr uint64_t small_power_of_5[] = {
|
static constexpr uint64_t small_power_of_5[] = {
|
||||||
1UL,
|
1UL,
|
||||||
5UL,
|
5UL,
|
||||||
@ -419,7 +419,7 @@ template <typename = void> struct pow5_tables {
|
|||||||
|
|
||||||
#if FASTFLOAT_DETAIL_MUST_DEFINE_CONSTEXPR_VARIABLE
|
#if FASTFLOAT_DETAIL_MUST_DEFINE_CONSTEXPR_VARIABLE
|
||||||
|
|
||||||
template <typename T> constexpr uint32_t pow5_tables<T>::large_step;
|
template <typename T> constexpr uint8_t pow5_tables<T>::large_step;
|
||||||
|
|
||||||
template <typename T> constexpr uint64_t pow5_tables<T>::small_power_of_5[];
|
template <typename T> constexpr uint64_t pow5_tables<T>::small_power_of_5[];
|
||||||
|
|
||||||
@ -605,10 +605,10 @@ struct bigint : pow5_tables<> {
|
|||||||
exp -= large_step;
|
exp -= large_step;
|
||||||
}
|
}
|
||||||
#ifdef FASTFLOAT_64BIT_LIMB
|
#ifdef FASTFLOAT_64BIT_LIMB
|
||||||
uint32_t small_step = 27;
|
uint8_t small_step = 27;
|
||||||
limb max_native = 7450580596923828125UL;
|
limb max_native = 7450580596923828125UL;
|
||||||
#else
|
#else
|
||||||
uint32_t small_step = 13;
|
uint8_t small_step = 13;
|
||||||
limb max_native = 1220703125U;
|
limb max_native = 1220703125U;
|
||||||
#endif
|
#endif
|
||||||
while (exp >= small_step) {
|
while (exp >= small_step) {
|
||||||
|
|||||||
@ -17,7 +17,7 @@ namespace fast_float {
|
|||||||
// most significant bits and the low part corresponding to the least significant
|
// most significant bits and the low part corresponding to the least significant
|
||||||
// bits.
|
// bits.
|
||||||
//
|
//
|
||||||
template <int bit_precision>
|
template <uint8_t bit_precision>
|
||||||
fastfloat_really_inline FASTFLOAT_CONSTEXPR20 value128
|
fastfloat_really_inline FASTFLOAT_CONSTEXPR20 value128
|
||||||
compute_product_approximation(int64_t q, uint64_t w) noexcept {
|
compute_product_approximation(int64_t q, uint64_t w) noexcept {
|
||||||
int const index = 2 * int(q - powers::smallest_power_of_five);
|
int const index = 2 * int(q - powers::smallest_power_of_five);
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user