Current implementations of single precision and double precision
floating point operations operate on bits of the integer type of
same size. The code made use of magic masks which were listed as
literal integer values. This is not possible in the case of long
double type as the mantissa of quad-precision long double type used
on non-x86 architectures is wider that the widest integer type for
which we can list literal values. So, in this patch, to avoid
using magic masks specified with literal values, we use packed
bit-field struct types and let the compiler generate the masks.
This new scheme allows us to implement long double flavors of the
various floating point operations. To keep the size of the patch
small, only the implementations of fabs and trunc have been
switched to the new scheme. In following patches, all exisiting
implementations will be switched to the new scheme.
Details
Diff Detail
- Repository
- rG LLVM Github Monorepo
Event Timeline
Increase mpfr precision. This allows to to enable fabsl and
truncl for aarch64 as well.
Clang-tidy went completely crazy, or those warnings are expected?
Have you tested it in Visual Studio?
libc/test/src/math/fabsl_test.cpp | ||
---|---|---|
30 | fabsl(NaN) == NaN test would be handy. | |
libc/test/src/math/truncl_test.cpp | ||
29 | truncl(NaN) == NaN test | |
38 | Add some test where truncl(x) != x, e.g. truncl(2.5) == 2.0. | |
libc/utils/FPUtil/FPBits.h | ||
35 | This should be moved to MantissaWidth<long double> (10 lines below) if for visual studio long double and double are equivalent. You can hardly have 15 bytes for exponent and 52 bits for mantissa. |
Address comments.
libc/utils/FPUtil/FPBits.h | ||
---|---|---|
35 | When we start adding MSVC support, we will have to enclose this in separate #define and friends. Without MSVC support, this is correct as is because all architectures use 15 bit exponent for long double. |
fabsl(NaN) == NaN test would be handy.