]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
ada: Remove last uses of System.Address_Operations in runtime library
authorEric Botcazou <ebotcazou@adacore.com>
Wed, 12 Jun 2024 14:05:57 +0000 (16:05 +0200)
committerMarc Poulhiès <dkm@gcc.gnu.org>
Thu, 27 Jun 2024 08:19:13 +0000 (10:19 +0200)
This completes the switch from using System.Address_Operations to using only
System.Storage_Elements in the runtime library.  The remaining uses were for
simple optimizations that can be done by the optimizer alone.

gcc/ada/

* libgnat/s-carsi8.adb: Remove clauses for System.Address_Operations
and use only operations of System.Storage_Elements for addresses.
* libgnat/s-casi16.adb: Likewise.
* libgnat/s-casi32.adb: Likewise.
* libgnat/s-casi64.adb: Likewise.
* libgnat/s-casi128.adb: Likewise.
* libgnat/s-carun8.adb: Likewise.
* libgnat/s-caun16.adb: Likewise.
* libgnat/s-caun32.adb: Likewise.
* libgnat/s-caun64.adb: Likewise.
* libgnat/s-caun128.adb: Likewise.
* libgnat/s-geveop.adb: Likewise.

gcc/ada/libgnat/s-carsi8.adb
gcc/ada/libgnat/s-carun8.adb
gcc/ada/libgnat/s-casi128.adb
gcc/ada/libgnat/s-casi16.adb
gcc/ada/libgnat/s-casi32.adb
gcc/ada/libgnat/s-casi64.adb
gcc/ada/libgnat/s-caun128.adb
gcc/ada/libgnat/s-caun16.adb
gcc/ada/libgnat/s-caun32.adb
gcc/ada/libgnat/s-caun64.adb
gcc/ada/libgnat/s-geveop.adb

index 2a6c532d247e672b56cf0f11db7c3b07b21a7419..7eb545a26576acc84899bbf6a82605ae545ff1a4 100644 (file)
@@ -29,8 +29,7 @@
 --                                                                          --
 ------------------------------------------------------------------------------
 
-with System.Address_Operations; use System.Address_Operations;
-with System.Storage_Elements;   use System.Storage_Elements;
+with System.Storage_Elements; use System.Storage_Elements;
 
 with Ada.Unchecked_Conversion;
 
@@ -77,7 +76,10 @@ package body System.Compare_Array_Signed_8 is
    begin
       --  If operands are non-aligned, or length is too short, go by bytes
 
-      if ModA (OrA (Left, Right), 4) /= 0 or else Compare_Len < 4 then
+      if Left mod Storage_Offset (4) /= 0
+        or else Right mod Storage_Offset (4) /= 0
+        or else Compare_Len < 4
+      then
          return Compare_Array_S8_Unaligned (Left, Right, Left_Len, Right_Len);
       end if;
 
index 27422e5d72825f85089c4b46b7da3b96f0819fd6..e4cac204769ac54a57296b8d53ff44f0381c8ab7 100644 (file)
@@ -29,8 +29,7 @@
 --                                                                          --
 ------------------------------------------------------------------------------
 
-with System.Address_Operations; use System.Address_Operations;
-with System.Storage_Elements;   use System.Storage_Elements;
+with System.Storage_Elements; use System.Storage_Elements;
 
 with Ada.Unchecked_Conversion;
 
@@ -76,7 +75,10 @@ package body System.Compare_Array_Unsigned_8 is
    begin
       --  If operands are non-aligned, or length is too short, go by bytes
 
-      if ModA (OrA (Left, Right), 4) /= 0 or else Compare_Len < 4 then
+      if Left mod Storage_Offset (4) /= 0
+        or else Right mod Storage_Offset (4) /= 0
+        or else Compare_Len < 4
+      then
          return Compare_Array_U8_Unaligned (Left, Right, Left_Len, Right_Len);
       end if;
 
index 3d3614136a7d83a80e3ff690b0ba8889662a30ae..1b65c8c86efcc00bb2c113f815d28a90989ffb72 100644 (file)
@@ -29,8 +29,7 @@
 --                                                                          --
 ------------------------------------------------------------------------------
 
-with System.Address_Operations; use System.Address_Operations;
-with System.Storage_Elements;   use System.Storage_Elements;
+with System.Storage_Elements; use System.Storage_Elements;
 
 with Ada.Unchecked_Conversion;
 
@@ -70,7 +69,9 @@ package body System.Compare_Array_Signed_128 is
    begin
       --  Case of going by aligned quadruple words
 
-      if ModA (OrA (Left, Right), 16) = 0 then
+      if Left mod Storage_Offset (16) = 0
+        and then Right mod Storage_Offset (16) = 0
+      then
          while Clen /= 0 loop
             if W (L).all /= W (R).all then
                if W (L).all > W (R).all then
index 01771d1f8ffb468ee7186113171272b856ebada2..e3411c978c534e4b73ccd37d5450d91ec95058e8 100644 (file)
@@ -29,8 +29,7 @@
 --                                                                          --
 ------------------------------------------------------------------------------
 
-with System.Address_Operations; use System.Address_Operations;
-with System.Storage_Elements;   use System.Storage_Elements;
+with System.Storage_Elements; use System.Storage_Elements;
 
 with Ada.Unchecked_Conversion;
 
@@ -78,7 +77,9 @@ package body System.Compare_Array_Signed_16 is
    begin
       --  Go by words if possible
 
-      if ModA (OrA (Left, Right), 4) = 0 then
+      if Left mod Storage_Offset (4) = 0
+        and then Right mod Storage_Offset (4) = 0
+      then
          while Clen > 1
            and then W (L).all = W (R).all
          loop
@@ -90,7 +91,9 @@ package body System.Compare_Array_Signed_16 is
 
       --  Case of going by aligned half words
 
-      if ModA (OrA (Left, Right), 2) = 0 then
+      if Left mod Storage_Offset (2) = 0
+        and then Right mod Storage_Offset (2) = 0
+      then
          while Clen /= 0 loop
             if H (L).all /= H (R).all then
                if H (L).all > H (R).all then
index 24ad9ef90b9d45226c86f465bcbd326dbaeea1cb..43e47170606c206d5417d8b818c50c22cdcc3c39 100644 (file)
@@ -29,8 +29,7 @@
 --                                                                          --
 ------------------------------------------------------------------------------
 
-with System.Address_Operations; use System.Address_Operations;
-with System.Storage_Elements;   use System.Storage_Elements;
+with System.Storage_Elements; use System.Storage_Elements;
 
 with Ada.Unchecked_Conversion;
 
@@ -73,7 +72,9 @@ package body System.Compare_Array_Signed_32 is
    begin
       --  Case of going by aligned words
 
-      if ModA (OrA (Left, Right), 4) = 0 then
+      if Left mod Storage_Offset (4) = 0
+        and then Right mod Storage_Offset (4) = 0
+      then
          while Clen /= 0 loop
             if W (L).all /= W (R).all then
                if W (L).all > W (R).all then
index bcadea106c7607219e2907c3cc9b9b4c86bde31e..0625d1f5d74adbff5fd034010c7f062a7c287bc5 100644 (file)
@@ -29,8 +29,7 @@
 --                                                                          --
 ------------------------------------------------------------------------------
 
-with System.Address_Operations; use System.Address_Operations;
-with System.Storage_Elements;   use System.Storage_Elements;
+with System.Storage_Elements; use System.Storage_Elements;
 
 with Ada.Unchecked_Conversion;
 
@@ -73,7 +72,9 @@ package body System.Compare_Array_Signed_64 is
    begin
       --  Case of going by aligned double words
 
-      if ModA (OrA (Left, Right), 8) = 0 then
+      if Left mod Storage_Offset (8) = 0
+        and then Right mod Storage_Offset (8) = 0
+      then
          while Clen /= 0 loop
             if W (L).all /= W (R).all then
                if W (L).all > W (R).all then
index 113c4d4237b2d363afe2654dbdc1f7e9a91eff20..f16f1348361b4afe724f49ce69dc95d38714603a 100644 (file)
@@ -29,8 +29,7 @@
 --                                                                          --
 ------------------------------------------------------------------------------
 
-with System.Address_Operations; use System.Address_Operations;
-with System.Storage_Elements;   use System.Storage_Elements;
+with System.Storage_Elements; use System.Storage_Elements;
 
 with Ada.Unchecked_Conversion;
 
@@ -69,7 +68,9 @@ package body System.Compare_Array_Unsigned_128 is
    begin
       --  Case of going by aligned quadruple words
 
-      if ModA (OrA (Left, Right), 16) = 0 then
+      if Left mod Storage_Offset (16) = 0
+        and then Right mod Storage_Offset (16) = 0
+      then
          while Clen /= 0 loop
             if W (L).all /= W (R).all then
                if W (L).all > W (R).all then
index 82f9d5b5afe1cc45ed5c1d709d9adc86c7dc896d..77a617ebb476fa24507fd8cf45ae022ab93b221c 100644 (file)
@@ -29,8 +29,7 @@
 --                                                                          --
 ------------------------------------------------------------------------------
 
-with System.Address_Operations; use System.Address_Operations;
-with System.Storage_Elements;   use System.Storage_Elements;
+with System.Storage_Elements; use System.Storage_Elements;
 
 with Ada.Unchecked_Conversion;
 
@@ -78,7 +77,9 @@ package body System.Compare_Array_Unsigned_16 is
    begin
       --  Go by words if possible
 
-      if ModA (OrA (Left, Right), 4) = 0 then
+      if Left mod Storage_Offset (4) = 0
+        and then Right mod Storage_Offset (4) = 0
+      then
          while Clen > 1
            and then W (L).all = W (R).all
          loop
@@ -90,7 +91,9 @@ package body System.Compare_Array_Unsigned_16 is
 
       --  Case of going by aligned half words
 
-      if ModA (OrA (Left, Right), 2) = 0 then
+      if Left mod Storage_Offset (2) = 0
+        and then Right mod Storage_Offset (2) = 0
+      then
          while Clen /= 0 loop
             if H (L).all /= H (R).all then
                if H (L).all > H (R).all then
index 0be3a2ddc73139220e77ca5182b40bae4e01d9ae..6bd31f59c98fa4d83b565aee0d258f7cf90892a7 100644 (file)
@@ -29,8 +29,7 @@
 --                                                                          --
 ------------------------------------------------------------------------------
 
-with System.Address_Operations; use System.Address_Operations;
-with System.Storage_Elements;   use System.Storage_Elements;
+with System.Storage_Elements; use System.Storage_Elements;
 
 with Ada.Unchecked_Conversion;
 
@@ -73,7 +72,9 @@ package body System.Compare_Array_Unsigned_32 is
    begin
       --  Case of going by aligned words
 
-      if ModA (OrA (Left, Right), 4) = 0 then
+      if Left mod Storage_Offset (4) = 0
+        and then Right mod Storage_Offset (4) = 0
+      then
          while Clen /= 0 loop
             if W (L).all /= W (R).all then
                if W (L).all > W (R).all then
index 92d7d13b1a8849a72d15999074d21b0f459d84c1..1018cbe1343ca15529485aee01c4c1d19af6bb5f 100644 (file)
@@ -29,8 +29,7 @@
 --                                                                          --
 ------------------------------------------------------------------------------
 
-with System.Address_Operations; use System.Address_Operations;
-with System.Storage_Elements;   use System.Storage_Elements;
+with System.Storage_Elements; use System.Storage_Elements;
 
 with Ada.Unchecked_Conversion;
 
@@ -72,7 +71,9 @@ package body System.Compare_Array_Unsigned_64 is
    begin
       --  Case of going by aligned double words
 
-      if ModA (OrA (Left, Right), 8) = 0 then
+      if Left mod Storage_Offset (8) = 0
+        and then Right mod Storage_Offset (8) = 0
+      then
          while Clen /= 0 loop
             if W (L).all /= W (R).all then
                if W (L).all > W (R).all then
index 2f679b4d2449636766173e218af4910d55eb8588..ab8ac1e085ab08660582796ce5bd288279b183a9 100644 (file)
@@ -29,8 +29,7 @@
 --                                                                          --
 ------------------------------------------------------------------------------
 
-with System.Address_Operations; use System.Address_Operations;
-with System.Storage_Elements;   use System.Storage_Elements;
+with System.Storage_Elements; use System.Storage_Elements;
 
 with Ada.Unchecked_Conversion;
 
@@ -49,15 +48,10 @@ package body System.Generic_Vector_Operations is
      (R, X, Y : System.Address;
       Length  : System.Storage_Elements.Storage_Count)
    is
-      RA : Address := R;
-      XA : Address := X;
-      YA : Address := Y;
-      --  Address of next element to process in R, X and Y
-
       VI : constant Integer_Address := Integer_Address (VU);
 
       Unaligned : constant Integer_Address :=
-                    Boolean'Pos (OrA (OrA (RA, XA), YA) mod VU /= 0) - 1;
+        (if R mod VU /= 0 or X mod VU /= 0 or Y mod VU /= 0 then 0 else -1);
       --  Zero iff one or more argument addresses is not aligned, else all 1's
 
       type Vector_Ptr is access all Vectors.Vector;
@@ -74,10 +68,15 @@ package body System.Generic_Vector_Operations is
       --  Vector'Size > Storage_Unit
       --  VI > 0
       SA : constant Address :=
-             XA + Storage_Offset
-                    ((Integer_Address (Length) / VI * VI) and Unaligned);
+             X + Storage_Offset
+                   ((Integer_Address (Length) / VI * VI) and Unaligned);
       --  First address of argument X to start serial processing
 
+      RA : Address := R;
+      XA : Address := X;
+      YA : Address := Y;
+      --  Address of next element to process in R, X and Y
+
    begin
       while XA < SA loop
          VP (RA).all := Vector_Op (VP (XA).all, VP (YA).all);
@@ -102,14 +101,10 @@ package body System.Generic_Vector_Operations is
      (R, X    : System.Address;
       Length  : System.Storage_Elements.Storage_Count)
    is
-      RA : Address := R;
-      XA : Address := X;
-      --  Address of next element to process in R and X
-
       VI : constant Integer_Address := Integer_Address (VU);
 
       Unaligned : constant Integer_Address :=
-                    Boolean'Pos (OrA (RA, XA) mod VU /= 0) - 1;
+        (if R mod VU /= 0 or X mod VU /= 0 then 0 else -1);
       --  Zero iff one or more argument addresses is not aligned, else all 1's
 
       type Vector_Ptr is access all Vectors.Vector;
@@ -126,10 +121,14 @@ package body System.Generic_Vector_Operations is
       --  Vector'Size > Storage_Unit
       --  VI > 0
       SA : constant Address :=
-             XA + Storage_Offset
-                    ((Integer_Address (Length) / VI * VI) and Unaligned);
+             X + Storage_Offset
+                   ((Integer_Address (Length) / VI * VI) and Unaligned);
       --  First address of argument X to start serial processing
 
+      RA : Address := R;
+      XA : Address := X;
+      --  Address of next element to process in R and X
+
    begin
       while XA < SA loop
          VP (RA).all := Vector_Op (VP (XA).all);