The current intx 0.5 has "recursive" design, i.e. uint<N> types is composed of two (high and low) parts of uint<N/2> types. This was inspired by LLVM type legalization, but it turned out to have number of limitations and issues:
the performance depends heavily on compiler inlining and is unpredictable which procedures are going to stay not inlined,
it seems it would be better to have a loop over words instead of procedure calling some other big procedures,
only power-of-two bit lengths are supported (no uint384),
arbitrary length procedures cannot be reused (needed for division).
We propose to change the internal structure of intx types to simple array of 64-bit words uint64_t[K]. This makes this types being very close to std::array<uint64_t, K> although we will not use std::array directly — we want freedom to define other constructors and conversion operators.
An alternative was also considered:
Union of uint64_t[K} and two parts uint<N/2> hi, lo. This would allow two different style of access to the data, but it is quite complex and requires very obscure hackery to have constexpr support. In lo/hi access is needed it is probably much easier and cleaner to provide hi() and lo() helpers (methods or free functions).
The current intx 0.5 has "recursive" design, i.e.
uint<N>
types is composed of two (high and low) parts ofuint<N/2>
types. This was inspired by LLVM type legalization, but it turned out to have number of limitations and issues:We propose to change the internal structure of intx types to simple array of 64-bit words
uint64_t[K]
. This makes this types being very close tostd::array<uint64_t, K>
although we will not usestd::array
directly — we want freedom to define other constructors and conversion operators.An alternative was also considered:
uint64_t[K}
and two partsuint<N/2> hi, lo
. This would allow two different style of access to the data, but it is quite complex and requires very obscure hackery to have constexpr support. In lo/hi access is needed it is probably much easier and cleaner to providehi()
andlo()
helpers (methods or free functions).