From: Eric Botcazou <ebotca...@adacore.com> 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. Tested on x86_64-pc-linux-gnu, committed on master. --- gcc/ada/libgnat/s-carsi8.adb | 8 +++++--- gcc/ada/libgnat/s-carun8.adb | 8 +++++--- gcc/ada/libgnat/s-casi128.adb | 7 ++++--- gcc/ada/libgnat/s-casi16.adb | 11 +++++++---- gcc/ada/libgnat/s-casi32.adb | 7 ++++--- gcc/ada/libgnat/s-casi64.adb | 7 ++++--- gcc/ada/libgnat/s-caun128.adb | 7 ++++--- gcc/ada/libgnat/s-caun16.adb | 11 +++++++---- gcc/ada/libgnat/s-caun32.adb | 7 ++++--- gcc/ada/libgnat/s-caun64.adb | 7 ++++--- gcc/ada/libgnat/s-geveop.adb | 33 ++++++++++++++++----------------- 11 files changed, 64 insertions(+), 49 deletions(-) diff --git a/gcc/ada/libgnat/s-carsi8.adb b/gcc/ada/libgnat/s-carsi8.adb index 2a6c532d247..7eb545a2657 100644 --- a/gcc/ada/libgnat/s-carsi8.adb +++ b/gcc/ada/libgnat/s-carsi8.adb @@ -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; diff --git a/gcc/ada/libgnat/s-carun8.adb b/gcc/ada/libgnat/s-carun8.adb index 27422e5d728..e4cac204769 100644 --- a/gcc/ada/libgnat/s-carun8.adb +++ b/gcc/ada/libgnat/s-carun8.adb @@ -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; diff --git a/gcc/ada/libgnat/s-casi128.adb b/gcc/ada/libgnat/s-casi128.adb index 3d3614136a7..1b65c8c86ef 100644 --- a/gcc/ada/libgnat/s-casi128.adb +++ b/gcc/ada/libgnat/s-casi128.adb @@ -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 diff --git a/gcc/ada/libgnat/s-casi16.adb b/gcc/ada/libgnat/s-casi16.adb index 01771d1f8ff..e3411c978c5 100644 --- a/gcc/ada/libgnat/s-casi16.adb +++ b/gcc/ada/libgnat/s-casi16.adb @@ -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 diff --git a/gcc/ada/libgnat/s-casi32.adb b/gcc/ada/libgnat/s-casi32.adb index 24ad9ef90b9..43e47170606 100644 --- a/gcc/ada/libgnat/s-casi32.adb +++ b/gcc/ada/libgnat/s-casi32.adb @@ -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 diff --git a/gcc/ada/libgnat/s-casi64.adb b/gcc/ada/libgnat/s-casi64.adb index bcadea106c7..0625d1f5d74 100644 --- a/gcc/ada/libgnat/s-casi64.adb +++ b/gcc/ada/libgnat/s-casi64.adb @@ -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 diff --git a/gcc/ada/libgnat/s-caun128.adb b/gcc/ada/libgnat/s-caun128.adb index 113c4d4237b..f16f1348361 100644 --- a/gcc/ada/libgnat/s-caun128.adb +++ b/gcc/ada/libgnat/s-caun128.adb @@ -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 diff --git a/gcc/ada/libgnat/s-caun16.adb b/gcc/ada/libgnat/s-caun16.adb index 82f9d5b5afe..77a617ebb47 100644 --- a/gcc/ada/libgnat/s-caun16.adb +++ b/gcc/ada/libgnat/s-caun16.adb @@ -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 diff --git a/gcc/ada/libgnat/s-caun32.adb b/gcc/ada/libgnat/s-caun32.adb index 0be3a2ddc73..6bd31f59c98 100644 --- a/gcc/ada/libgnat/s-caun32.adb +++ b/gcc/ada/libgnat/s-caun32.adb @@ -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 diff --git a/gcc/ada/libgnat/s-caun64.adb b/gcc/ada/libgnat/s-caun64.adb index 92d7d13b1a8..1018cbe1343 100644 --- a/gcc/ada/libgnat/s-caun64.adb +++ b/gcc/ada/libgnat/s-caun64.adb @@ -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 diff --git a/gcc/ada/libgnat/s-geveop.adb b/gcc/ada/libgnat/s-geveop.adb index 2f679b4d244..ab8ac1e085a 100644 --- a/gcc/ada/libgnat/s-geveop.adb +++ b/gcc/ada/libgnat/s-geveop.adb @@ -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); -- 2.45.2