Files
clang-p2996/libc/utils/FPUtil/generic
Hedin Garca a5a337e55e [libc] Capture floating point encoding and arrange it sequentially in memory
Redefined FPBits.h and LongDoubleBitsX86 so its implementation works for the Windows
and Linux platform while maintaining a packed memory alignment of the precision floating
point numbers. For its size in memory to be the same as the data type of the float point number.
This change was necessary because the previous attribute((packed)) specification in the struct was not working
for Windows like it was for Linux and consequently static_asserts in the FPBits.h file were failing.

Reviewed By: aeubanks, sivachandra

Differential Revision: https://reviews.llvm.org/D105561
2021-07-13 20:43:54 +00:00
..

This directory contains machine independent implementations of floating point operations. The implementations are nested in the namespace __llvm_libc::fputil::generic. This is to facilitate calling these generic implementations from machine dependent implementations. Consider the example of the fuse-multiply-add operation (FMA). The C standard library requires three different flavors, fma which operates double precsion numbers, fmaf which operates on single precision numbers, and fmal which operates on lond double numbers. On Aarch64, there are hardware instructions which implement the single and double precision flavors but not the long double flavor. For such targets, we want to be able to call the generic long double implementation from the long double flavor. By putting the generic implementations in a separate nested namespace, we will be to call them as follows:

namespace __llvm_libc {
namespace fputil {

long double fmal(long double x, long double y, long double z) {
  return generic::fmal(x, y, z);
}

} // namespace fputil
} // namespace __llvm_libc

Note that actual code might not be as straightforward as above (for example, we might want to prevent implicit type promotions by using some template facilities). But, the general idea is very similar.