diff mbox series

[COMMITTED,01/30] ada: Remove obsolete workaround

Message ID 20240801151738.400796-1-poulhies@adacore.com
State New
Headers show
Series [COMMITTED,01/30] ada: Remove obsolete workaround | expand

Commit Message

Marc Poulhiès Aug. 1, 2024, 3:17 p.m. UTC
From: Eric Botcazou <ebotcazou@adacore.com>

It is possible to call the "+" operator of System.Storage_Elements directly
as done for example in Expand_Interface_Thunk.

gcc/ada/

	* exp_ch7.adb (Make_Address_For_Finalize): Generate a direct call
	to the "+" operator of System.Storage_Elements.
	(Make_Finalize_Address_Stmts): Likewise.
	* rtsfind.ads (RE_Id): Remove RE_Add_Offset_To_Address.
	(RE_Unit_Table): Remove entry for RE_Add_Offset_To_Address.
	* libgnat/s-finpri.ads (Add_Offset_To_Address): Delete.
	* libgnat/s-finpri.adb (Add_Offset_To_Address): Likewise.

Tested on x86_64-pc-linux-gnu, committed on master.

---
 gcc/ada/exp_ch7.adb          | 37 ++++++++++++++++++++----------------
 gcc/ada/libgnat/s-finpri.adb | 12 ------------
 gcc/ada/libgnat/s-finpri.ads |  7 -------
 gcc/ada/rtsfind.ads          |  2 --
 4 files changed, 21 insertions(+), 37 deletions(-)
diff mbox series

Patch

diff --git a/gcc/ada/exp_ch7.adb b/gcc/ada/exp_ch7.adb
index f4a707034c1..454f74507f4 100644
--- a/gcc/ada/exp_ch7.adb
+++ b/gcc/ada/exp_ch7.adb
@@ -5351,23 +5351,25 @@  package body Exp_Ch7 is
 
          --    V - (Obj_Typ'Descriptor_Size / Storage_Unit)
 
-         --  Note that this is done through a wrapper routine as  RTSfind
-         --  cannot retrieve operations with string name of the form "+".
-
          Obj_Addr :=
            Make_Function_Call (Loc,
              Name                   =>
-               New_Occurrence_Of (RTE (RE_Add_Offset_To_Address), Loc),
+               Make_Expanded_Name (Loc,
+                 Chars => Name_Op_Subtract,
+                 Prefix =>
+                   New_Occurrence_Of
+                     (RTU_Entity (System_Storage_Elements), Loc),
+                 Selector_Name =>
+                   Make_Identifier (Loc, Name_Op_Subtract)),
              Parameter_Associations => New_List (
                Obj_Addr,
-               Make_Op_Minus (Loc,
-                 Make_Op_Divide (Loc,
-                   Left_Opnd  =>
-                     Make_Attribute_Reference (Loc,
-                       Prefix         => New_Occurrence_Of (Obj_Typ, Loc),
-                       Attribute_Name => Name_Descriptor_Size),
-                   Right_Opnd =>
-                     Make_Integer_Literal (Loc, System_Storage_Unit)))));
+               Make_Op_Divide (Loc,
+                 Left_Opnd  =>
+                   Make_Attribute_Reference (Loc,
+                     Prefix         => New_Occurrence_Of (Obj_Typ, Loc),
+                     Attribute_Name => Name_Descriptor_Size),
+                 Right_Opnd =>
+                   Make_Integer_Literal (Loc, System_Storage_Unit))));
       end if;
 
       return Obj_Addr;
@@ -8105,14 +8107,17 @@  package body Exp_Ch7 is
             --  start of the elements:
             --
             --    V + Dnn
-            --
-            --  Note that this is done through a wrapper routine since RTSfind
-            --  cannot retrieve operations with string names of the form "+".
 
             Obj_Expr :=
               Make_Function_Call (Loc,
                 Name                   =>
-                  New_Occurrence_Of (RTE (RE_Add_Offset_To_Address), Loc),
+                  Make_Expanded_Name (Loc,
+                    Chars => Name_Op_Add,
+                    Prefix =>
+                      New_Occurrence_Of
+                        (RTU_Entity (System_Storage_Elements), Loc),
+                    Selector_Name =>
+                      Make_Identifier (Loc, Name_Op_Add)),
                 Parameter_Associations => New_List (
                   Obj_Expr,
                   New_Occurrence_Of (Dope_Id, Loc)));
diff --git a/gcc/ada/libgnat/s-finpri.adb b/gcc/ada/libgnat/s-finpri.adb
index bc90fe23ac9..9767090cb4a 100644
--- a/gcc/ada/libgnat/s-finpri.adb
+++ b/gcc/ada/libgnat/s-finpri.adb
@@ -60,18 +60,6 @@  package body System.Finalization_Primitives is
    --  Unlock the finalization collection, i.e. relinquish ownership of the
    --  lock to the collection.
 
-   ---------------------------
-   -- Add_Offset_To_Address --
-   ---------------------------
-
-   function Add_Offset_To_Address
-     (Addr   : System.Address;
-      Offset : System.Storage_Elements.Storage_Offset) return System.Address
-   is
-   begin
-      return System.Storage_Elements."+" (Addr, Offset);
-   end Add_Offset_To_Address;
-
    ---------------------------------
    -- Attach_Object_To_Collection --
    ---------------------------------
diff --git a/gcc/ada/libgnat/s-finpri.ads b/gcc/ada/libgnat/s-finpri.ads
index a821f1db657..851917b5924 100644
--- a/gcc/ada/libgnat/s-finpri.ads
+++ b/gcc/ada/libgnat/s-finpri.ads
@@ -171,13 +171,6 @@  package System.Finalization_Primitives with Preelaborate is
 
 private
 
-   --  Since RTSfind cannot contain names of the form RE_"+", the following
-   --  routine serves as a wrapper around System.Storage_Elements."+".
-
-   function Add_Offset_To_Address
-     (Addr   : System.Address;
-      Offset : System.Storage_Elements.Storage_Offset) return System.Address;
-
    --  Finalization masters:
 
    --  Master node type structure. Finalize_Address comes first because it is
diff --git a/gcc/ada/rtsfind.ads b/gcc/ada/rtsfind.ads
index f4566b4846f..8c0c9045360 100644
--- a/gcc/ada/rtsfind.ads
+++ b/gcc/ada/rtsfind.ads
@@ -919,7 +919,6 @@  package Rtsfind is
 
      RE_Attr_Long_Long_Float,            -- System.Fat_LLF
 
-     RE_Add_Offset_To_Address,           -- System.Finalization_Primitives
      RE_Attach_Object_To_Collection,     -- System.Finalization_Primitives
      RE_Attach_Object_To_Master,         -- System.Finalization_Primitives
      RE_Attach_Object_To_Node,           -- System.Finalization_Primitives
@@ -2571,7 +2570,6 @@  package Rtsfind is
 
      RE_Attr_Long_Long_Float             => System_Fat_LLF,
 
-     RE_Add_Offset_To_Address            => System_Finalization_Primitives,
      RE_Attach_Object_To_Collection      => System_Finalization_Primitives,
      RE_Attach_Object_To_Master          => System_Finalization_Primitives,
      RE_Attach_Object_To_Node            => System_Finalization_Primitives,