From: Eric Botcazou Date: Thu, 19 Sep 2019 08:13:38 +0000 (+0000) Subject: [Ada] Implement Machine_Rounding attribute in line when possible X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=d8ec2787e0ba7b508c968c330b04575d2cbf97d7;p=gcc.git [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 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 --- diff --git a/gcc/ada/ChangeLog b/gcc/ada/ChangeLog index 86e9f07353f..289213e914a 100644 --- a/gcc/ada/ChangeLog +++ b/gcc/ada/ChangeLog @@ -1,3 +1,9 @@ +2019-09-19 Eric Botcazou + + * 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 * exp_unst.adb (Unnest_Subprogram): Bypass the transformation of diff --git a/gcc/ada/exp_attr.adb b/gcc/ada/exp_attr.adb index a8e68bbb033..817e7ef4cab 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 38de57d6cf5..28d1352afb3 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