From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 1914) id 302F13887036; Mon, 14 Dec 2020 15:54:24 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 302F13887036 MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset="utf-8" From: Pierre-Marie de Rodat To: gcc-cvs@gcc.gnu.org Subject: [gcc r11-6014] [Ada] Adjust again previous change to System.Fat_Gen X-Act-Checkin: gcc X-Git-Author: Eric Botcazou X-Git-Refname: refs/heads/master X-Git-Oldrev: a36a291399fbcf24d5ea237850b862921ebdec95 X-Git-Newrev: b97b4e6f71da62cae325d1f41610cfb43870a4a1 Message-Id: <20201214155424.302F13887036@sourceware.org> Date: Mon, 14 Dec 2020 15:54:24 +0000 (GMT) X-BeenThere: gcc-cvs@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-cvs mailing list List-Unsubscribe: , List-Archive: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 14 Dec 2020 15:54:24 -0000 https://gcc.gnu.org/g:b97b4e6f71da62cae325d1f41610cfb43870a4a1 commit r11-6014-gb97b4e6f71da62cae325d1f41610cfb43870a4a1 Author: Eric Botcazou Date: Sun Nov 22 00:54:18 2020 +0100 [Ada] Adjust again previous change to System.Fat_Gen gcc/ada/ * libgnat/s-fatgen.adb: Add with clause for Interfaces and use type clause for Interfaces.Unsigned_64. (Small): Comment out. (Tiny): Likewise. (Tiny16): New integer constant. (Tiny32): Likewise. (Tiny64): Likewise. (Tiny80): New integer array constant. (Pred): Declare a local overlay for Tiny. (Succ): Likewise. Diff: --- gcc/ada/libgnat/s-fatgen.adb | 32 +++++++++++++++++++++++++++++--- 1 file changed, 29 insertions(+), 3 deletions(-) diff --git a/gcc/ada/libgnat/s-fatgen.adb b/gcc/ada/libgnat/s-fatgen.adb index 64234b436f5..d297451d99c 100644 --- a/gcc/ada/libgnat/s-fatgen.adb +++ b/gcc/ada/libgnat/s-fatgen.adb @@ -35,12 +35,15 @@ -- floating-point implementations. with Ada.Unchecked_Conversion; +with Interfaces; with System.Unsigned_Types; pragma Warnings (Off, "non-static constant in preelaborated unit"); -- Every constant is static given our instantiation model package body System.Fat_Gen is + use type Interfaces.Unsigned_64; + pragma Assert (T'Machine_Radix = 2); -- This version does not handle radix 16 @@ -53,13 +56,22 @@ package body System.Fat_Gen is Invrad : constant T := 1.0 / Rad; -- Smallest positive mantissa in the canonical form (RM A.5.3(4)) - Small : constant T := Rad ** (T'Machine_Emin - 1); - pragma Unreferenced (Small); + -- Small : constant T := Rad ** (T'Machine_Emin - 1); -- Smallest positive normalized number - Tiny : constant T := Rad ** (T'Machine_Emin - Mantissa); + -- Tiny : constant T := Rad ** (T'Machine_Emin - Mantissa); -- Smallest positive denormalized number + Tiny16 : constant Interfaces.Unsigned_16 := 1; + Tiny32 : constant Interfaces.Unsigned_32 := 1; + Tiny64 : constant Interfaces.Unsigned_64 := 1; + Tiny80 : constant array (1 .. 2) of Interfaces.Unsigned_64 := + (1 * Standard'Default_Bit_Order, + 2**48 * (1 - Standard'Default_Bit_Order)); + -- We cannot use the direct declaration because it cannot be translated + -- into C90, as the hexadecimal floating constants were introduced in C99. + -- So we work around this by using an overlay of the integer constant. + RM1 : constant T := Rad ** (Mantissa - 1); -- Smallest positive member of the large consecutive integers. It is equal -- to the ratio Small / Tiny, which means that multiplying by it normalizes @@ -411,6 +423,13 @@ package body System.Fat_Gen is ---------- function Pred (X : T) return T is + Tiny : constant T; + pragma Import (Ada, Tiny); + for Tiny'Address use (if T'Size = 16 then Tiny16'Address + elsif T'Size = 32 then Tiny32'Address + elsif T'Size = 64 then Tiny64'Address + elsif Mantissa = 64 then Tiny80'Address + else raise Program_Error); X_Frac : T; X_Exp : UI; @@ -676,6 +695,13 @@ package body System.Fat_Gen is ---------- function Succ (X : T) return T is + Tiny : constant T; + pragma Import (Ada, Tiny); + for Tiny'Address use (if T'Size = 16 then Tiny16'Address + elsif T'Size = 32 then Tiny32'Address + elsif T'Size = 64 then Tiny64'Address + elsif Mantissa = 64 then Tiny80'Address + else raise Program_Error); X_Frac : T; X_Exp : UI;