]> git.ipfire.org Git - thirdparty/gcc.git/commit
[Ada] Correctly round Value attribute for floating point in more cases
authorEric Botcazou <ebotcazou@adacore.com>
Fri, 5 Aug 2022 07:42:58 +0000 (09:42 +0200)
committerMarc Poulhiès <poulhies@adacore.com>
Tue, 6 Sep 2022 07:14:20 +0000 (09:14 +0200)
commite9bac0faa1e55c6673296d7618df77044ef406ca
tree8195ca78c40c933033f8b833a0d7025ba76d2d2a
parent8b9bbdc362efe420633e43850092d01f467aa6d8
[Ada] Correctly round Value attribute for floating point in more cases

This provides correct rounding in the IEEE 754 sense for the Value attribute
of floating-point types in more cases, by switching from tables of powers of
10 to tables of powers of 5 for precomputed values, thus making it possible
to use a single divide for denormals and normalized numbers just above them.

Although this significantly increases the size of the tables, object files
for them are still quite small (1, 2 and 4 KB respectively on x86-64).

gcc/ada/

* libgnat/s-powflt.ads (Powfive): New constant array.
* libgnat/s-powlfl.ads (Powfive): Likewise.
(Powfive_100): New constant.
(Powfive_200): Likewise.
(Powfive_300): Likewise.
* libgnat/s-powllf.ads (Powfive): New constant array.
(Powfive_100): New constant.
(Powfive_200): Likewise.
(Powfive_300): Likewise.
* libgnat/s-valflt.ads (Impl): Replace Powten with Powfive and pass
Null_Address for the address of large constants.
* libgnat/s-vallfl.ads (Impl): Replace Powten with Powfive and pass
the address of large constants.
* libgnat/s-valllf.ads (Impl): Likewise.
* libgnat/s-valrea.ads (System.Val_Real): Replace Powten_Address
with Powfive_Address and add Powfive_{1,2,3}00_Address parameters.
* libgnat/s-valrea.adb (Is_Large_Type): New boolean constant.
(Is_Very_Large_Type): Likewise.
(Maxexp32): Change value of 10 to that of 5.
(Maxexp64): Likewise.
(Maxexp80): Likewise.
(Integer_to_Real): Use a combination of tables of powers of 5 and
scaling if the base is 10.
(Large_Powten): Rename into...
(Large_Powfive): ...this.  Add support for large constants.
(Large_Powfive): New overloaded function for very large exponents.
gcc/ada/libgnat/s-powflt.ads
gcc/ada/libgnat/s-powlfl.ads
gcc/ada/libgnat/s-powllf.ads
gcc/ada/libgnat/s-valflt.ads
gcc/ada/libgnat/s-vallfl.ads
gcc/ada/libgnat/s-valllf.ads
gcc/ada/libgnat/s-valrea.adb
gcc/ada/libgnat/s-valrea.ads