libgcc: Add support for HF mode (aka _Float16) in libbid
authorChristophe Lyon <christophe.lyon@arm.com>
Wed, 4 May 2022 15:13:35 +0000 (16:13 +0100)
committerChristophe Lyon <christophe.lyon@arm.com>
Fri, 20 May 2022 07:35:54 +0000 (09:35 +0200)
commit308a0af4f913243023ee52332f7cc513745c9203
tree3aa44acaea135b1843150f55178c87208f9c3f54
parent46c6976da146fbd52c088c1530f25e8b8f56c648
libgcc: Add support for HF mode (aka _Float16) in libbid

This patch adds support for trunc and extend operations between HF
mode (_Float16) and Decimal Floating Point formats (_Decimal32,
_Decimal64 and _Decimal128).

For simplicity we rely on the implicit conversions inserted by the
compiler between HF and SD/DF/TF modes.  The existing bid*_to_binary*
and binary*_to_bid* functions are non-trivial and at this stage it is
not clear if there is a performance-critical use case involving _Float16
and _Decimal* formats.

The patch also adds two executable tests, to make sure the right
functions are called, available (link phase) and functional.

Tested on aarch64 and x86_64. The number of symbol matches in the
testcases includes the .global XXX to avoid having to match different
call instructions for different targets.

2022-05-04  Christophe Lyon  <christophe.lyon@arm.com>

libgcc/ChangeLog:

* Makefile.in (D32PBIT_FUNCS): Add _hf_to_sd and _sd_to_hf.
(D64PBIT_FUNCS): Add _hf_to_dd and _dd_to_hf.
(D128PBIT_FUNCS): Add _hf_to_td _td_to_hf.

libgcc/config/libbid/ChangeLog:

* bid_gcc_intrinsics.h (LIBGCC2_HAS_HF_MODE): Define according to
__LIBGCC_HAS_HF_MODE__.
(BID_HAS_HF_MODE): Define.
(HFtype): Define.
(__bid_extendhfsd): New prototype.
(__bid_extendhfdd): Likewise.
(__bid_extendhftd): Likewise.
(__bid_truncsdhf): Likewise.
(__bid_truncddhf): Likewise.
(__bid_trunctdhf): Likewise.
* _dd_to_hf.c: New file.
* _hf_to_dd.c: New file.
* _hf_to_sd.c: New file.
* _hf_to_td.c: New file.
* _sd_to_hf.c: New file.
* _td_to_hf.c: New file.

gcc/testsuite/ChangeLog:

* gcc.dg/torture/convert-dfp-2.c: New test.
* gcc.dg/torture/convert-dfp.c: New test.
gcc/testsuite/gcc.dg/torture/convert-dfp-2.c [new file with mode: 0644]
gcc/testsuite/gcc.dg/torture/convert-dfp.c [new file with mode: 0644]
libgcc/Makefile.in
libgcc/config/libbid/_dd_to_hf.c [new file with mode: 0644]
libgcc/config/libbid/_hf_to_dd.c [new file with mode: 0644]
libgcc/config/libbid/_hf_to_sd.c [new file with mode: 0644]
libgcc/config/libbid/_hf_to_td.c [new file with mode: 0644]
libgcc/config/libbid/_sd_to_hf.c [new file with mode: 0644]
libgcc/config/libbid/_td_to_hf.c [new file with mode: 0644]
libgcc/config/libbid/bid_gcc_intrinsics.h