From 3fbf81a252d7599b4e99b7c969ff164a2330bdb5 Mon Sep 17 00:00:00 2001 From: Arnaud Charlet Date: Fri, 12 Feb 2021 02:54:07 -0500 Subject: [PATCH] [Ada] Remove unused subprograms (continued) gcc/ada/ * repinfo.ads, repinfo.adb (*SO_Ref*): Restore. --- gcc/ada/repinfo.adb | 49 ++++++++++++++++++++++++++++++++++++++ gcc/ada/repinfo.ads | 58 +++++++++++++++++++++++++++++++++++++++++---- 2 files changed, 103 insertions(+), 4 deletions(-) diff --git a/gcc/ada/repinfo.adb b/gcc/ada/repinfo.adb index 61912ef92c9..bfb8af3756c 100644 --- a/gcc/ada/repinfo.adb +++ b/gcc/ada/repinfo.adb @@ -92,6 +92,18 @@ package body Repinfo is Table_Increment => Alloc.Rep_Table_Increment, Table_Name => "BE_Rep_Table"); + -------------------------------------------------------------- + -- Representation of Front-End Dynamic Size/Offset Entities -- + -------------------------------------------------------------- + + package Dynamic_SO_Entity_Table is new Table.Table ( + Table_Component_Type => Entity_Id, + Table_Index_Type => Nat, + Table_Low_Bound => 1, + Table_Initial => Alloc.Rep_Table_Initial, + Table_Increment => Alloc.Rep_Table_Increment, + Table_Name => "FE_Rep_Table"); + Unit_Casing : Casing_Type; -- Identifier casing for current unit. This is set by List_Rep_Info for -- each unit, before calling subprograms which may read it. @@ -212,6 +224,16 @@ package body Repinfo is Op1 => Discriminant_Number (Discr)); end Create_Discrim_Ref; + --------------------------- + -- Create_Dynamic_SO_Ref -- + --------------------------- + + function Create_Dynamic_SO_Ref (E : Entity_Id) return Dynamic_SO_Ref is + begin + Dynamic_SO_Entity_Table.Append (E); + return UI_From_Int (-Dynamic_SO_Entity_Table.Last); + end Create_Dynamic_SO_Ref; + ----------------- -- Create_Node -- ----------------- @@ -240,6 +262,33 @@ package body Repinfo is return Entity_Header_Num (Id mod Relevant_Entities_Size); end Entity_Hash; + --------------------------- + -- Get_Dynamic_SO_Entity -- + --------------------------- + + function Get_Dynamic_SO_Entity (U : Dynamic_SO_Ref) return Entity_Id is + begin + return Dynamic_SO_Entity_Table.Table (-UI_To_Int (U)); + end Get_Dynamic_SO_Entity; + + ----------------------- + -- Is_Dynamic_SO_Ref -- + ----------------------- + + function Is_Dynamic_SO_Ref (U : SO_Ref) return Boolean is + begin + return U < Uint_0; + end Is_Dynamic_SO_Ref; + + ---------------------- + -- Is_Static_SO_Ref -- + ---------------------- + + function Is_Static_SO_Ref (U : SO_Ref) return Boolean is + begin + return U >= Uint_0; + end Is_Static_SO_Ref; + --------- -- lgx -- --------- diff --git a/gcc/ada/repinfo.ads b/gcc/ada/repinfo.ads index f730c538b14..a2ab8325ce3 100644 --- a/gcc/ada/repinfo.ads +++ b/gcc/ada/repinfo.ads @@ -51,10 +51,10 @@ package Repinfo is -- for example in the case where representation clauses or -- pragmas specify the values. - -- 2. Otherwise the backend is responsible for layout of all types and - -- objects not laid out by the front end. This includes all dynamic - -- values, and also static values (e.g. record sizes) when not set by - -- the front end. + -- 2. The backend is responsible for layout of all types and objects + -- not laid out by the front end. This includes all dynamic values, + -- and also static values (e.g. record sizes) when not set by the + -- front end. ----------------------------- -- Back Annotation by Gigi -- @@ -291,6 +291,56 @@ package Repinfo is function Create_Discrim_Ref (Discr : Entity_Id) return Node_Ref; -- Creates a reference to the discriminant whose entity is Discr + -------------------------------------------------------- + -- Front-End Interface for Dynamic Size/Offset Values -- + -------------------------------------------------------- + + -- This interface is used by GNAT LLVM to deal with all dynamic size and + -- offset fields. + + -- The interface here allows these created entities to be referenced + -- using negative Unit values, so that they can be stored in the + -- appropriate size and offset fields in the tree. + + -- In the case of components, if the location of the component is static, + -- then all four fields (Component_Bit_Offset, Normalized_Position, Esize, + -- and Normalized_First_Bit) are set to appropriate values. In the case of + -- a non-static component location, Component_Bit_Offset is not used and + -- is left set to Unknown. Normalized_Position and Normalized_First_Bit + -- are set appropriately. + + subtype SO_Ref is Uint; + -- Type used to represent a Uint value that represents a static or + -- dynamic size/offset value (non-negative if static, negative if + -- the size value is dynamic). + + subtype Dynamic_SO_Ref is Uint; + -- Type used to represent a negative Uint value used to store + -- a dynamic size/offset value. + + function Is_Dynamic_SO_Ref (U : SO_Ref) return Boolean; + pragma Inline (Is_Dynamic_SO_Ref); + -- Given a SO_Ref (Uint) value, returns True iff the SO_Ref value + -- represents a dynamic Size/Offset value (i.e. it is negative). + + function Is_Static_SO_Ref (U : SO_Ref) return Boolean; + pragma Inline (Is_Static_SO_Ref); + -- Given a SO_Ref (Uint) value, returns True iff the SO_Ref value + -- represents a static Size/Offset value (i.e. it is non-negative). + + function Create_Dynamic_SO_Ref (E : Entity_Id) return Dynamic_SO_Ref; + -- Given the Entity_Id for a constant (case 1), the Node_Id for an + -- expression (case 2), or the Entity_Id for a function (case 3), + -- this function returns a (negative) Uint value that can be used + -- to retrieve the entity or expression for later use. + + function Get_Dynamic_SO_Entity (U : Dynamic_SO_Ref) return Entity_Id; + -- Retrieve the Node_Id or Entity_Id stored by a previous call to + -- Create_Dynamic_SO_Ref. The approach is that the front end makes + -- the necessary Create_Dynamic_SO_Ref calls to associate the node + -- and entity id values and the back end makes Get_Dynamic_SO_Ref + -- calls to retrieve them. + ------------------------------ -- External tools Interface -- ------------------------------ -- 2.30.2