aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorEric Botcazou <ebotcazou@adacore.com>2019-09-19 08:13:38 +0000
committerPierre-Marie de Rodat <pmderodat@gcc.gnu.org>2019-09-19 08:13:38 +0000
commitd8ec2787e0ba7b508c968c330b04575d2cbf97d7 (patch)
treec3c07f4f98ae46537abb0ec4383ef8b1d9b17fef /gcc
parent143df1f9aa4e829907d4e300a0006783fcbba71b (diff)
downloadgcc-d8ec2787e0ba7b508c968c330b04575d2cbf97d7.zip
gcc-d8ec2787e0ba7b508c968c330b04575d2cbf97d7.tar.gz
gcc-d8ec2787e0ba7b508c968c330b04575d2cbf97d7.tar.bz2
[Ada] Implement Machine_Rounding attribute in line when possible
GNAT implements Machine_Rounding as an alias for Rounding but, whereas the implementation of the latter is in line when possible, that of the former is always out of line, which is not aligned with the intent of the Ada RM. This changes the compiler to using for Machine_Rounding the same in line implementation as Rounding when possible. Running these commands: gcc -c f.adb -gnatD grep system f.adb.dg On the following sources: function F (Val : Float) return Integer is begin return Integer (Float'Machine_Rounding (Val)); end; Should execute silently. 2019-09-19 Eric Botcazou <ebotcazou@adacore.com> gcc/ada/ * exp_attr.adb (Is_Inline_Floating_Point_Attribute): Treat Machine_Rounding as an alias for Rounding. * sem_res.adb (Simplify_Type_Conversion): Likewise. From-SVN: r275943
Diffstat (limited to 'gcc')
-rw-r--r--gcc/ada/ChangeLog6
-rw-r--r--gcc/ada/exp_attr.adb12
-rw-r--r--gcc/ada/sem_res.adb4
3 files changed, 15 insertions, 7 deletions
diff --git a/gcc/ada/ChangeLog b/gcc/ada/ChangeLog
index 86e9f07..289213e 100644
--- a/gcc/ada/ChangeLog
+++ b/gcc/ada/ChangeLog
@@ -1,3 +1,9 @@
+2019-09-19 Eric Botcazou <ebotcazou@adacore.com>
+
+ * exp_attr.adb (Is_Inline_Floating_Point_Attribute): Treat
+ Machine_Rounding as an alias for Rounding.
+ * sem_res.adb (Simplify_Type_Conversion): Likewise.
+
2019-09-19 Gary Dismukes <dismukes@adacore.com>
* exp_unst.adb (Unnest_Subprogram): Bypass the transformation of
diff --git a/gcc/ada/exp_attr.adb b/gcc/ada/exp_attr.adb
index a8e68bb..817e7ef 100644
--- a/gcc/ada/exp_attr.adb
+++ b/gcc/ada/exp_attr.adb
@@ -8360,13 +8360,13 @@ package body Exp_Attr is
return False;
end if;
- -- Here we are in the integer conversion context
+ -- Here we are in the integer conversion context. We reuse Rounding for
+ -- Machine_Rounding as System.Fat_Gen, which is a permissible behavior.
- -- Very probably we should also recognize the cases of Machine_Rounding
- -- and unbiased rounding in this conversion context, but the back end is
- -- not yet prepared to handle these cases ???
-
- return Id = Attribute_Rounding or else Id = Attribute_Truncation;
+ return
+ Id = Attribute_Rounding
+ or else Id = Attribute_Machine_Rounding
+ or else Id = Attribute_Truncation;
end Is_Inline_Floating_Point_Attribute;
end Exp_Attr;
diff --git a/gcc/ada/sem_res.adb b/gcc/ada/sem_res.adb
index 38de57d..28d1352 100644
--- a/gcc/ada/sem_res.adb
+++ b/gcc/ada/sem_res.adb
@@ -12439,7 +12439,8 @@ package body Sem_Res is
-- ityp (x)
-- with the Float_Truncate flag set to False or True respectively,
- -- which is more efficient.
+ -- which is more efficient. We reuse Rounding for Machine_Rounding
+ -- as System.Fat_Gen, which is a permissible behavior.
if Is_Floating_Point_Type (Opnd_Typ)
and then
@@ -12448,6 +12449,7 @@ package body Sem_Res is
and then Conversion_OK (N)))
and then Nkind (Operand) = N_Attribute_Reference
and then Nam_In (Attribute_Name (Operand), Name_Rounding,
+ Name_Machine_Rounding,
Name_Truncation)
then
declare