This commit adresses the discussions from patch D152575. From previous discussions, we agreed that __builtin math functions should be used as
long as they would compile to NVPTX and AMD-GCN/AMD-HSA targets. I found that the __builtin functions compiled to GPU code in all cases. That was tested in the following way:
bash clang++ -O3 -pthread -fno-dwarf2-cfi-asm -fno-asynchronous-unwind-tables -mcpu=gfx1100 --target=amdgcn-amd-amdhsa -nogpulib -I../llvm-project/libc -fno-pie -emit-llvm -S <file>.cpp -o <file>.ll llvm-as <file>.ll -o <file>.bc llc -mcpu=gfx1100 -filetype=obj -relocation-model=pic <file>.bc -o <file>.o
However, I have not tested if the code performed well on the GPU target or if it compiles to NVPTX.
__builtin Functions
The following __builtin functions were added.
- Added modf and modff.
- Added nearbyint and nearbyintf.
- Added nextafter and nextafterf.
- Added remainder and remainderf.
- Added remquo and remquof.
- Added rint and rintf.
- Added scalbn and scalbnf.
- Added sinh and sinhf.
- Added sqrt and sqrtf.
- Added tan and tanf.
- Added tanh and tanhf.
- Added trunc and truncf.
Vendor Functions
The following vendor functions were added, because the __builtin versions do not exist in the LLVM project, as far as I am aware.
- Added sincos and sincosf.
libc Header Files
The following header files were introduced to libc:
- sinh.
- tanh.
According to @arsenm these aren't correct now so we should proabably use the vendor versions for now.