[Ada] Fix inconsistent usage of Machine in s-fatgen.adb

Message ID 20171215094453.GA130850@adacore.com
State New
Headers show
Series
  • [Ada] Fix inconsistent usage of Machine in s-fatgen.adb
Related show

Commit Message

Pierre-Marie de Rodat Dec. 15, 2017, 9:44 a.m.
System.Fat_Gen is a generic unit implementing support routines for floating-
point attributes, for example the 'Machine attribute.  These routines make
themselves use of the 'Machine attribute, some of them by calling the
Machine support routine directly, some others by using the attribute.

Consistency dictates that a single idiom be used and the latter is to be
preferred, since it generates better code for targets without excessive
precision issues, i.e. all of them except for x86 and x86-64.

No functional changes.

Tested on x86_64-pc-linux-gnu, committed on trunk

2017-12-15  Eric Botcazou  <ebotcazou@adacore.com>

	* exp_attr.adb (Is_Inline_Floating_Point_Attribute): Fix comment.
	* libgnat/s-fatgen.adb (Model): Use Machine attribute.
	(Truncation): Likewise.

Patch

Index: libgnat/s-fatgen.adb
===================================================================
--- libgnat/s-fatgen.adb	(revision 255678)
+++ libgnat/s-fatgen.adb	(working copy)
@@ -394,7 +394,7 @@ 
 
    function Model (X : T) return T is
    begin
-      return Machine (X);
+      return T'Machine (X);
    end Model;
 
    ----------
@@ -739,10 +739,11 @@ 
       Result := abs X;
 
       if Result >= Radix_To_M_Minus_1 then
-         return Machine (X);
+         return T'Machine (X);
 
       else
-         Result := Machine (Radix_To_M_Minus_1 + Result) - Radix_To_M_Minus_1;
+         Result :=
+           T'Machine (Radix_To_M_Minus_1 + Result) - Radix_To_M_Minus_1;
 
          if Result > abs X then
             Result := Result - 1.0;
Index: exp_attr.adb
===================================================================
--- exp_attr.adb	(revision 255678)
+++ exp_attr.adb	(working copy)
@@ -8274,7 +8274,7 @@ 
    --  Start of processing for Is_Inline_Floating_Point_Attribute
 
    begin
-      --  Machine and Model can be expanded by the GCC and AAMP back ends only
+      --  Machine and Model can be expanded by the GCC back end only
 
       if Id = Attribute_Machine or else Id = Attribute_Model then
          return Is_GCC_Target;