diff options
author | Eric Botcazou <ebotcazou@adacore.com> | 2023-03-29 12:52:57 +0200 |
---|---|---|
committer | Marc Poulhiès <poulhies@adacore.com> | 2023-05-26 09:29:19 +0200 |
commit | 18a72d68c9daf72a5690be652fd1b0eb217035a2 (patch) | |
tree | d007b549010909ef0f5ac6d41ad927f53fc137d0 /gcc/ada/debug.adb | |
parent | 3e62561d5ffbb07fa97a4dddfd729fceb7cfce75 (diff) | |
download | gcc-18a72d68c9daf72a5690be652fd1b0eb217035a2.zip gcc-18a72d68c9daf72a5690be652fd1b0eb217035a2.tar.gz gcc-18a72d68c9daf72a5690be652fd1b0eb217035a2.tar.bz2 |
ada: Use truncation for dynamic conversions from floating point to fixed point
This changes the implementation of dynamic conversions from floating-point
to ordinary fixed-point types, from rounding (to the nearest number) to
truncation (toward zero), so as to make them consistent with both static
conversions between these types and also the value of the Machine_Rounds
attribute, which is False for all fixed-point types with GNAT.
The rounding is still available under the debug switch -gnatd.N for the
sake of backward compatibility with the previous implementation.
gcc/ada/
* debug.adb (d.N): Document new usage.
* exp_ch4.adb (Expand_N_Type_Conversion): Copy the Float_Truncate
flag when rewriting a floating-point to fixed-point conversion as
a floating-point to integer conversion.
* exp_fixd.adb: Add with and use clauses for Debug.
(Expand_Convert_Fixed_To_Fixed): Generate a truncation in all cases
except if the result is explicitly rounded.
(Expand_Convert_Integer_To_Fixed): Likewise.
(Expand_Convert_Float_To_Fixed): Generate a truncation for all kind
of fixed-point types, except if the result is explicitly rounded, or
-gnatd.N is specified and the type is an ordinary fixed-point type.
* sinfo.ads (Float_Truncate): Document usage for floating-point to
fixed-point conversions.
Diffstat (limited to 'gcc/ada/debug.adb')
-rw-r--r-- | gcc/ada/debug.adb | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/gcc/ada/debug.adb b/gcc/ada/debug.adb index 9566e09..fd94203 100644 --- a/gcc/ada/debug.adb +++ b/gcc/ada/debug.adb @@ -125,7 +125,7 @@ package body Debug is -- d.K Do not reject components in extensions overlapping with parent -- d.L Depend on back end for limited types in if and case expressions -- d.M Relaxed RM semantics - -- d.N + -- d.N Use rounding when converting from floating point to fixed point -- d.O Dump internal SCO tables -- d.P Previous (non-optimized) handling of length comparisons -- d.Q Previous (incomplete) style check for binary operators @@ -906,6 +906,10 @@ package body Debug is -- d.M Relaxed RM semantics. This flag sets Opt.Relaxed_RM_Semantics -- See Opt.Relaxed_RM_Semantics for more details. + -- d.N Use rounding instead of truncation when dynamically converting from + -- a floating-point type to an ordinary fixed-point type, for the sake + -- of compatibility with earlier versions of the compiler. + -- d.O Dump internal SCO tables. Before outputting the SCO information to -- the ALI file, the internal SCO tables (SCO_Table/SCO_Unit_Table) -- are dumped for debugging purposes. |