The first adjustment is to the documentation contained in the units,
which explains the implementation choices. The second adjustment is
to the size selection mechanism, which is better done on base types.

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

gcc/ada/

        * libgnat/a-tifiio.adb: Adjust documentation.
        (OK_Get_32): Compare the object size of the base type.
        (OK_Put_32): Likewise.
        (OK_Get_64): Likewise.
        (OK_Put_64): Likewise.
        * libgnat/a-tifiio__128.adb: Adjust documentation.
        (OK_Get_32): Compare the object size of the base type.
        (OK_Put_32): Likewise.
        (OK_Get_64): Likewise.
        (OK_Put_64): Likewise.
        (OK_Get_128): Likewise.
        (OK_Put_128): Likewise.
        * libgnat/a-wtfiio.adb (OK_Get_32): Likewise.
        (OK_Put_32): Likewise.
        (OK_Get_64): Likewise.
        (OK_Put_64): Likewise
        * libgnat/a-wtfiio__128.adb (OK_Get_32): Likewise.
        (OK_Put_32): Likewise.
        (OK_Get_64): Likewise.
        (OK_Put_64): Likewise.
        (OK_Get_128): Likewise.
        (OK_Put_128): Likewise.
        * libgnat/a-ztfiio.adb (OK_Get_32): Likewise.
        (OK_Put_32): Likewise.
        (OK_Get_64): Likewise.
        (OK_Put_64): Likewise
        * libgnat/a-ztfiio__128.adb (OK_Get_32): Likewise.
        (OK_Put_32): Likewise.
        (OK_Get_64): Likewise.
        (OK_Put_64): Likewise.
        (OK_Get_128): Likewise.
        (OK_Put_128): Likewise.
diff --git a/gcc/ada/libgnat/a-tifiio.adb b/gcc/ada/libgnat/a-tifiio.adb
--- a/gcc/ada/libgnat/a-tifiio.adb
+++ b/gcc/ada/libgnat/a-tifiio.adb
@@ -29,8 +29,9 @@
 --                                                                          --
 ------------------------------------------------------------------------------
 
---  Fixed point I/O
---  ---------------
+--  -------------------
+--  - Fixed point I/O -
+--  -------------------
 
 --  The following text documents implementation details of the fixed point
 --  input/output routines in the GNAT runtime. The first part describes the
@@ -40,7 +41,7 @@
 --  Subsequently these are reduced to implementation constraints and the impact
 --  of these constraints on a few possible approaches to input/output is given.
 --  Based on this analysis, a specific implementation is selected for use in
---  the GNAT runtime. Finally, the chosen algorithm is analyzed numerically in
+--  the GNAT runtime. Finally the chosen algorithms are analyzed numerically in
 --  order to provide user-level documentation on limits for range and precision
 --  of fixed point types as well as accuracy of input/output conversions.
 
@@ -68,7 +69,7 @@
 --  Operations
 --  ----------
 
---  'Image and 'Wide_Image (see RM 3.5(34))
+--  [Wide_[Wide_]]Image attribute (see RM 3.5(27.1/2))
 
 --          These attributes return a decimal real literal best approximating
 --          the value (rounded away from zero if halfway between) with a
@@ -88,7 +89,7 @@
 --          attributes, although it would be nice to be able to output more
 --          than S'Aft digits after the decimal point for values of subtype S.
 
---  'Value and 'Wide_Value attribute (RM 3.5(40-55))
+--  [Wide_[Wide_]]Value attribute (RM 3.5(39.1/2))
 
 --          Since the input can be given in any base in the range 2..16,
 --          accurate conversion to a fixed point number may require
@@ -121,7 +122,7 @@
 --  be less than 2.0**(-53).
 
 --  In GNAT, Fine_Delta is 2.0**(-63), and Duration for example is a 64-bit
---  type. This means that a floating-point type with 63 bits of mantissa needs
+--  type. This means that a floating-point type with 64 bits of mantissa needs
 --  to be used, which is only generally available on the x86 architecture. It
 --  would still be possible to use multi-precision floating point to perform
 --  calculations using longer mantissas, but this is a much harder approach.
@@ -137,9 +138,21 @@
 
 --  Fixed-precision integer arithmetic has the advantage of simplicity and
 --  speed. For the most common fixed point types this would be a perfect
---  solution. The downside however may be a too limited set of acceptable
+--  solution. The downside however may be a restricted set of acceptable
 --  fixed point types.
 
+--  Implementation Choices
+--  ----------------------
+
+--  The current implementation in the GNAT runtime uses fixed-precision integer
+--  arithmetic for fixed point types whose Small is the ratio of two integers
+--  whose magnitude is bounded relatively to the size of the mantissa, with a
+--  two-tiered approach for 32-bit and 64-bit fixed point types. For the other
+--  fixed point types, the implementation uses floating-point arithmetic.
+
+--  The exact requirements of the algorithms are analyzed and documented along
+--  with the implementation in their respective units.
+
 with Interfaces;
 with Ada.Text_IO.Fixed_Aux;
 with Ada.Text_IO.Float_Aux;
@@ -171,7 +184,7 @@ package body Ada.Text_IO.Fixed_IO is
    --  static (although it is not a static expressions in the RM sense).
 
    OK_Get_32 : constant Boolean :=
-     Num'Object_Size <= 32
+     Num'Base'Object_Size <= 32
        and then
          ((Num'Small_Numerator = 1 and then Num'Small_Denominator <= 2**31)
            or else
@@ -182,7 +195,7 @@ package body Ada.Text_IO.Fixed_IO is
    --  These conditions are derived from the prerequisites of System.Value_F
 
    OK_Put_32 : constant Boolean :=
-     Num'Object_Size <= 32
+     Num'Base'Object_Size <= 32
        and then
          ((Num'Small_Numerator = 1 and then Num'Small_Denominator <= 2**31)
            or else
@@ -196,7 +209,7 @@ package body Ada.Text_IO.Fixed_IO is
    --  These conditions are derived from the prerequisites of System.Image_F
 
    OK_Get_64 : constant Boolean :=
-     Num'Object_Size <= 64
+     Num'Base'Object_Size <= 64
        and then
          ((Num'Small_Numerator = 1 and then Num'Small_Denominator <= 2**63)
            or else
@@ -207,7 +220,7 @@ package body Ada.Text_IO.Fixed_IO is
    --  These conditions are derived from the prerequisites of System.Value_F
 
    OK_Put_64 : constant Boolean :=
-     Num'Object_Size <= 64
+     Num'Base'Object_Size <= 64
        and then
          ((Num'Small_Numerator = 1 and then Num'Small_Denominator <= 2**63)
            or else


diff --git a/gcc/ada/libgnat/a-tifiio__128.adb b/gcc/ada/libgnat/a-tifiio__128.adb
--- a/gcc/ada/libgnat/a-tifiio__128.adb
+++ b/gcc/ada/libgnat/a-tifiio__128.adb
@@ -29,8 +29,9 @@
 --                                                                          --
 ------------------------------------------------------------------------------
 
---  Fixed point I/O
---  ---------------
+--  -------------------
+--  - Fixed point I/O -
+--  -------------------
 
 --  The following text documents implementation details of the fixed point
 --  input/output routines in the GNAT runtime. The first part describes the
@@ -40,7 +41,7 @@
 --  Subsequently these are reduced to implementation constraints and the impact
 --  of these constraints on a few possible approaches to input/output is given.
 --  Based on this analysis, a specific implementation is selected for use in
---  the GNAT runtime. Finally, the chosen algorithm is analyzed numerically in
+--  the GNAT runtime. Finally the chosen algorithms are analyzed numerically in
 --  order to provide user-level documentation on limits for range and precision
 --  of fixed point types as well as accuracy of input/output conversions.
 
@@ -68,7 +69,7 @@
 --  Operations
 --  ----------
 
---  'Image and 'Wide_Image (see RM 3.5(34))
+--  [Wide_[Wide_]]Image attribute (see RM 3.5(27.1/2))
 
 --          These attributes return a decimal real literal best approximating
 --          the value (rounded away from zero if halfway between) with a
@@ -88,7 +89,7 @@
 --          attributes, although it would be nice to be able to output more
 --          than S'Aft digits after the decimal point for values of subtype S.
 
---  'Value and 'Wide_Value attribute (RM 3.5(40-55))
+--  [Wide_[Wide_]]Value attribute (RM 3.5(39.1/2))
 
 --          Since the input can be given in any base in the range 2..16,
 --          accurate conversion to a fixed point number may require
@@ -120,9 +121,9 @@
 --  available has 53 bits of mantissa. This means that Fine_Delta cannot
 --  be less than 2.0**(-53).
 
---  In GNAT, Fine_Delta is 2.0**(-63), and Duration for example is a 64-bit
---  type. This means that a floating-point type with 63 bits of mantissa needs
---  to be used, which is only generally available on the x86 architecture. It
+--  In GNAT, Fine_Delta is 2.0**(-127), and Duration for example is a 64-bit
+--  type. This means that a floating-point type with 128 bits of mantissa needs
+--  to be used, which currently does not exist in any common architecture. It
 --  would still be possible to use multi-precision floating point to perform
 --  calculations using longer mantissas, but this is a much harder approach.
 
@@ -137,9 +138,21 @@
 
 --  Fixed-precision integer arithmetic has the advantage of simplicity and
 --  speed. For the most common fixed point types this would be a perfect
---  solution. The downside however may be a too limited set of acceptable
+--  solution. The downside however may be a restricted set of acceptable
 --  fixed point types.
 
+--  Implementation Choices
+--  ----------------------
+
+--  The current implementation in the GNAT runtime uses fixed-precision integer
+--  arithmetic for fixed point types whose Small is the ratio of two integers
+--  whose magnitude is bounded relatively to the size of the mantissa, with a
+--  three-tiered approach for 32-bit, 64-bit and 128-bit fixed point types. For
+--  other fixed point types, the implementation uses floating-point arithmetic.
+
+--  The exact requirements of the algorithms are analyzed and documented along
+--  with the implementation in their respective units.
+
 with Interfaces;
 with Ada.Text_IO.Fixed_Aux;
 with Ada.Text_IO.Float_Aux;
@@ -178,7 +191,7 @@ package body Ada.Text_IO.Fixed_IO is
    --  in the RM sense).
 
    OK_Get_32 : constant Boolean :=
-     Num'Object_Size <= 32
+     Num'Base'Object_Size <= 32
        and then
          ((Num'Small_Numerator = 1 and then Num'Small_Denominator <= 2**31)
            or else
@@ -189,7 +202,7 @@ package body Ada.Text_IO.Fixed_IO is
    --  These conditions are derived from the prerequisites of System.Value_F
 
    OK_Put_32 : constant Boolean :=
-     Num'Object_Size <= 32
+     Num'Base'Object_Size <= 32
        and then
          ((Num'Small_Numerator = 1 and then Num'Small_Denominator <= 2**31)
            or else
@@ -203,7 +216,7 @@ package body Ada.Text_IO.Fixed_IO is
    --  These conditions are derived from the prerequisites of System.Image_F
 
    OK_Get_64 : constant Boolean :=
-     Num'Object_Size <= 64
+     Num'Base'Object_Size <= 64
        and then
          ((Num'Small_Numerator = 1 and then Num'Small_Denominator <= 2**63)
            or else
@@ -214,7 +227,7 @@ package body Ada.Text_IO.Fixed_IO is
    --  These conditions are derived from the prerequisites of System.Value_F
 
    OK_Put_64 : constant Boolean :=
-     Num'Object_Size <= 64
+     Num'Base'Object_Size <= 64
        and then
          ((Num'Small_Numerator = 1 and then Num'Small_Denominator <= 2**63)
            or else
@@ -228,7 +241,7 @@ package body Ada.Text_IO.Fixed_IO is
    --  These conditions are derived from the prerequisites of System.Image_F
 
    OK_Get_128 : constant Boolean :=
-     Num'Object_Size <= 128
+     Num'Base'Object_Size <= 128
        and then
          ((Num'Small_Numerator = 1 and then Num'Small_Denominator <= 2**127)
            or else
@@ -239,7 +252,7 @@ package body Ada.Text_IO.Fixed_IO is
    --  These conditions are derived from the prerequisites of System.Value_F
 
    OK_Put_128 : constant Boolean :=
-     Num'Object_Size <= 128
+     Num'Base'Object_Size <= 128
        and then
          ((Num'Small_Numerator = 1 and then Num'Small_Denominator <= 2**127)
            or else


diff --git a/gcc/ada/libgnat/a-wtfiio.adb b/gcc/ada/libgnat/a-wtfiio.adb
--- a/gcc/ada/libgnat/a-wtfiio.adb
+++ b/gcc/ada/libgnat/a-wtfiio.adb
@@ -62,7 +62,7 @@ package body Ada.Wide_Text_IO.Fixed_IO is
    --  static (although it is not a static expressions in the RM sense).
 
    OK_Get_32 : constant Boolean :=
-     Num'Object_Size <= 32
+     Num'Base'Object_Size <= 32
        and then
          ((Num'Small_Numerator = 1 and then Num'Small_Denominator <= 2**31)
            or else
@@ -73,7 +73,7 @@ package body Ada.Wide_Text_IO.Fixed_IO is
    --  These conditions are derived from the prerequisites of System.Value_F
 
    OK_Put_32 : constant Boolean :=
-     Num'Object_Size <= 32
+     Num'Base'Object_Size <= 32
        and then
          ((Num'Small_Numerator = 1 and then Num'Small_Denominator <= 2**31)
            or else
@@ -87,7 +87,7 @@ package body Ada.Wide_Text_IO.Fixed_IO is
    --  These conditions are derived from the prerequisites of System.Image_F
 
    OK_Get_64 : constant Boolean :=
-     Num'Object_Size <= 64
+     Num'Base'Object_Size <= 64
        and then
          ((Num'Small_Numerator = 1 and then Num'Small_Denominator <= 2**63)
            or else
@@ -98,7 +98,7 @@ package body Ada.Wide_Text_IO.Fixed_IO is
    --  These conditions are derived from the prerequisites of System.Value_F
 
    OK_Put_64 : constant Boolean :=
-     Num'Object_Size <= 64
+     Num'Base'Object_Size <= 64
        and then
          ((Num'Small_Numerator = 1 and then Num'Small_Denominator <= 2**63)
            or else


diff --git a/gcc/ada/libgnat/a-wtfiio__128.adb b/gcc/ada/libgnat/a-wtfiio__128.adb
--- a/gcc/ada/libgnat/a-wtfiio__128.adb
+++ b/gcc/ada/libgnat/a-wtfiio__128.adb
@@ -69,7 +69,7 @@ package body Ada.Wide_Text_IO.Fixed_IO is
    --  in the RM sense).
 
    OK_Get_32 : constant Boolean :=
-     Num'Object_Size <= 32
+     Num'Base'Object_Size <= 32
        and then
          ((Num'Small_Numerator = 1 and then Num'Small_Denominator <= 2**31)
            or else
@@ -80,7 +80,7 @@ package body Ada.Wide_Text_IO.Fixed_IO is
    --  These conditions are derived from the prerequisites of System.Value_F
 
    OK_Put_32 : constant Boolean :=
-     Num'Object_Size <= 32
+     Num'Base'Object_Size <= 32
        and then
          ((Num'Small_Numerator = 1 and then Num'Small_Denominator <= 2**31)
            or else
@@ -94,7 +94,7 @@ package body Ada.Wide_Text_IO.Fixed_IO is
    --  These conditions are derived from the prerequisites of System.Image_F
 
    OK_Get_64 : constant Boolean :=
-     Num'Object_Size <= 64
+     Num'Base'Object_Size <= 64
        and then
          ((Num'Small_Numerator = 1 and then Num'Small_Denominator <= 2**63)
            or else
@@ -105,7 +105,7 @@ package body Ada.Wide_Text_IO.Fixed_IO is
    --  These conditions are derived from the prerequisites of System.Value_F
 
    OK_Put_64 : constant Boolean :=
-     Num'Object_Size <= 64
+     Num'Base'Object_Size <= 64
        and then
          ((Num'Small_Numerator = 1 and then Num'Small_Denominator <= 2**63)
            or else
@@ -119,7 +119,7 @@ package body Ada.Wide_Text_IO.Fixed_IO is
    --  These conditions are derived from the prerequisites of System.Image_F
 
    OK_Get_128 : constant Boolean :=
-     Num'Object_Size <= 128
+     Num'Base'Object_Size <= 128
        and then
          ((Num'Small_Numerator = 1 and then Num'Small_Denominator <= 2**127)
            or else
@@ -130,7 +130,7 @@ package body Ada.Wide_Text_IO.Fixed_IO is
    --  These conditions are derived from the prerequisites of System.Value_F
 
    OK_Put_128 : constant Boolean :=
-     Num'Object_Size <= 128
+     Num'Base'Object_Size <= 128
        and then
          ((Num'Small_Numerator = 1 and then Num'Small_Denominator <= 2**127)
            or else


diff --git a/gcc/ada/libgnat/a-ztfiio.adb b/gcc/ada/libgnat/a-ztfiio.adb
--- a/gcc/ada/libgnat/a-ztfiio.adb
+++ b/gcc/ada/libgnat/a-ztfiio.adb
@@ -62,7 +62,7 @@ package body Ada.Wide_Wide_Text_IO.Fixed_IO is
    --  static (although it is not a static expressions in the RM sense).
 
    OK_Get_32 : constant Boolean :=
-     Num'Object_Size <= 32
+     Num'Base'Object_Size <= 32
        and then
          ((Num'Small_Numerator = 1 and then Num'Small_Denominator <= 2**31)
            or else
@@ -73,7 +73,7 @@ package body Ada.Wide_Wide_Text_IO.Fixed_IO is
    --  These conditions are derived from the prerequisites of System.Value_F
 
    OK_Put_32 : constant Boolean :=
-     Num'Object_Size <= 32
+     Num'Base'Object_Size <= 32
        and then
          ((Num'Small_Numerator = 1 and then Num'Small_Denominator <= 2**31)
            or else
@@ -87,7 +87,7 @@ package body Ada.Wide_Wide_Text_IO.Fixed_IO is
    --  These conditions are derived from the prerequisites of System.Image_F
 
    OK_Get_64 : constant Boolean :=
-     Num'Object_Size <= 64
+     Num'Base'Object_Size <= 64
        and then
          ((Num'Small_Numerator = 1 and then Num'Small_Denominator <= 2**63)
            or else
@@ -98,7 +98,7 @@ package body Ada.Wide_Wide_Text_IO.Fixed_IO is
    --  These conditions are derived from the prerequisites of System.Value_F
 
    OK_Put_64 : constant Boolean :=
-     Num'Object_Size <= 64
+     Num'Base'Object_Size <= 64
        and then
          ((Num'Small_Numerator = 1 and then Num'Small_Denominator <= 2**63)
            or else


diff --git a/gcc/ada/libgnat/a-ztfiio__128.adb b/gcc/ada/libgnat/a-ztfiio__128.adb
--- a/gcc/ada/libgnat/a-ztfiio__128.adb
+++ b/gcc/ada/libgnat/a-ztfiio__128.adb
@@ -70,7 +70,7 @@ package body Ada.Wide_Wide_Text_IO.Fixed_IO is
    --  in the RM sense).
 
    OK_Get_32 : constant Boolean :=
-     Num'Object_Size <= 32
+     Num'Base'Object_Size <= 32
        and then
          ((Num'Small_Numerator = 1 and then Num'Small_Denominator <= 2**31)
            or else
@@ -81,7 +81,7 @@ package body Ada.Wide_Wide_Text_IO.Fixed_IO is
    --  These conditions are derived from the prerequisites of System.Value_F
 
    OK_Put_32 : constant Boolean :=
-     Num'Object_Size <= 32
+     Num'Base'Object_Size <= 32
        and then
          ((Num'Small_Numerator = 1 and then Num'Small_Denominator <= 2**31)
            or else
@@ -95,7 +95,7 @@ package body Ada.Wide_Wide_Text_IO.Fixed_IO is
    --  These conditions are derived from the prerequisites of System.Image_F
 
    OK_Get_64 : constant Boolean :=
-     Num'Object_Size <= 64
+     Num'Base'Object_Size <= 64
        and then
          ((Num'Small_Numerator = 1 and then Num'Small_Denominator <= 2**63)
            or else
@@ -106,7 +106,7 @@ package body Ada.Wide_Wide_Text_IO.Fixed_IO is
    --  These conditions are derived from the prerequisites of System.Value_F
 
    OK_Put_64 : constant Boolean :=
-     Num'Object_Size <= 64
+     Num'Base'Object_Size <= 64
        and then
          ((Num'Small_Numerator = 1 and then Num'Small_Denominator <= 2**63)
            or else
@@ -120,7 +120,7 @@ package body Ada.Wide_Wide_Text_IO.Fixed_IO is
    --  These conditions are derived from the prerequisites of System.Image_F
 
    OK_Get_128 : constant Boolean :=
-     Num'Object_Size <= 128
+     Num'Base'Object_Size <= 128
        and then
          ((Num'Small_Numerator = 1 and then Num'Small_Denominator <= 2**127)
            or else
@@ -131,7 +131,7 @@ package body Ada.Wide_Wide_Text_IO.Fixed_IO is
    --  These conditions are derived from the prerequisites of System.Value_F
 
    OK_Put_128 : constant Boolean :=
-     Num'Object_Size <= 128
+     Num'Base'Object_Size <= 128
        and then
          ((Num'Small_Numerator = 1 and then Num'Small_Denominator <= 2**127)
            or else


Reply via email to