aboutsummaryrefslogtreecommitdiff
path: root/gcc/ada/sinfo.ads
diff options
context:
space:
mode:
authorEric Botcazou <ebotcazou@adacore.com>2023-03-29 12:52:57 +0200
committerMarc Poulhiès <poulhies@adacore.com>2023-05-26 09:29:19 +0200
commit18a72d68c9daf72a5690be652fd1b0eb217035a2 (patch)
treed007b549010909ef0f5ac6d41ad927f53fc137d0 /gcc/ada/sinfo.ads
parent3e62561d5ffbb07fa97a4dddfd729fceb7cfce75 (diff)
downloadgcc-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/sinfo.ads')
-rw-r--r--gcc/ada/sinfo.ads5
1 files changed, 3 insertions, 2 deletions
diff --git a/gcc/ada/sinfo.ads b/gcc/ada/sinfo.ads
index e4fd679..0f698cd 100644
--- a/gcc/ada/sinfo.ads
+++ b/gcc/ada/sinfo.ads
@@ -1329,8 +1329,9 @@ package Sinfo is
-- to the entity for the first subtype.
-- Float_Truncate
- -- A flag present in type conversion nodes. This is used for float to
- -- integer conversions where truncation is required rather than rounding.
+ -- A flag present in type conversion nodes. It is used for floating-point
+ -- to fixed-point or integer conversions, where truncation is required
+ -- rather than rounding.
-- Forwards_OK
-- A flag present in the N_Assignment_Statement node. It is used only