[compiler-rt] [builtins] Support conversion between fp16 and fp128
authorAdhemerval Zanella <adhemerval.zanella@linaro.org>
Tue, 8 Dec 2020 13:26:18 +0000 (10:26 -0300)
committerAdhemerval Zanella <adhemerval.zanella@linaro.org>
Tue, 8 Dec 2020 14:51:55 +0000 (11:51 -0300)
commitdb61b1844e11f29a06d6dc4aab87ebb4f0aabfdd
treea881cd0e743368241fdc6e5e0d776b6e8df5b908
parente22259fafe5e2f5e0219366ff92bba15ec70ff56
[compiler-rt] [builtins] Support conversion between fp16 and fp128

This patch adds both extendhftf2 and trunctfhf2 to support
conversion between half-precision and quad-precision floating-point
values. They are built iff the compiler supports _Float16.

Some notes on ARM plaforms: while fp16 is supported on all
architectures, _Float16 is supported only for 32-bit ARM, 64-bit ARM,
and SPIR (as indicated by clang/docs/LanguageExtensions.rst). Also,
fp16 is a storage format and 64-bit ARM supports floating-point
convert precision to half as base armv8-a instruction.

This patch does not change the ABI for 32-bit ARM, it will continue
to pass _Float16 as uint16.

This re-enabled revert done by https://reviews.llvm.org/rGb534beabeed3ba1777cd0ff9ce552d077e496726

Differential Revision: https://reviews.llvm.org/D92242
compiler-rt/lib/builtins/CMakeLists.txt
compiler-rt/lib/builtins/extendhftf2.c [new file with mode: 0644]
compiler-rt/lib/builtins/trunctfhf2.c [new file with mode: 0644]
compiler-rt/test/builtins/Unit/extendhftf2_test.c [new file with mode: 0644]
compiler-rt/test/builtins/Unit/trunctfhf2_test.c [new file with mode: 0644]