public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: Pierre-Marie de Rodat <derodat@adacore.com>
To: gcc-patches@gcc.gnu.org
Subject: [Ada] Factor out many fields in entities
Date: Wed, 30 Jun 2021 05:30:45 -0400	[thread overview]
Message-ID: <20210630093045.GA147310@adacore.com> (raw)

[-- Attachment #1: Type: text/plain, Size: 377 bytes --]

Also minor reformatting nearby.

Tested on x86_64-pc-linux-gnu, committed on trunk

gcc/ada/

	* gen_il-gen-gen_entities.adb (Record_Field_Kind,
	Allocatable_Kind): Add new abstract kinds.
	(Constant_Or_Variable_Kind): Likewise.
	(E_Constant, E_Variable, E_Loop_Parameter): Use them.
	(E_Discriminant, E_Component): Likewise.
	* gen_il-types.ads (type Opt_Type_Enum): Add them.

[-- Attachment #2: patch.diff --]
[-- Type: text/x-diff, Size: 9043 bytes --]

diff --git a/gcc/ada/gen_il-gen-gen_entities.adb b/gcc/ada/gen_il-gen-gen_entities.adb
--- a/gcc/ada/gen_il-gen-gen_entities.adb
+++ b/gcc/ada/gen_il-gen-gen_entities.adb
@@ -242,8 +242,8 @@ begin -- Gen_IL.Gen.Gen_Entities
        --  The initial Ekind value for a newly created entity. Also used as the
        --  Ekind for Standard_Void_Type, a type entity in Standard used as a
        --  dummy type for the return type of a procedure (the reason we create
-       --  this type is to share the circuits for performing overload resolution
-       --  on calls).
+       --  this type is to share the circuits for performing overload
+       --  resolution on calls).
        (Sm (Alignment, Uint),
         Sm (Contract, Node_Id),
         Sm (Is_Elaboration_Warnings_OK_Id, Flag),
@@ -254,7 +254,9 @@ begin -- Gen_IL.Gen.Gen_Entities
         Sm (Current_Value, Node_Id), -- setter only
         Sm (Has_Predicates, Flag), -- setter only
         Sm (Initialization_Statements, Node_Id), -- setter only
-        Sm (Is_Param_Block_Component_Type, Flag, Base_Type_Only), -- setter only
+        Sm (Is_Param_Block_Component_Type, Flag, Base_Type_Only),
+        -- setter only
+
         Sm (Package_Instantiation, Node_Id), -- setter only
         Sm (Related_Expression, Node_Id), -- setter only
 
@@ -302,17 +304,10 @@ begin -- Gen_IL.Gen.Gen_Entities
        (Sm (Current_Value, Node_Id),
         Sm (Renamed_Or_Alias, Node_Id)));
 
-   Cc (E_Component, Object_Kind,
-       --  Components of a record declaration, private declarations of
-       --  protected objects.
+   Ab (Record_Field_Kind, Object_Kind,
        (Sm (Component_Bit_Offset, Uint),
         Sm (Component_Clause, Node_Id),
         Sm (Corresponding_Record_Component, Node_Id),
-        Sm (Discriminant_Checking_Func, Node_Id),
-        Sm (DT_Entry_Count, Uint,
-            Pre => "Is_Tag (N)"),
-        Sm (DT_Offset_To_Top_Func, Node_Id,
-            Pre => "Is_Tag (N)"),
         Sm (Entry_Formal, Node_Id),
         Sm (Esize, Uint),
         Sm (Interface_Name, Node_Id),
@@ -320,114 +315,80 @@ begin -- Gen_IL.Gen.Gen_Entities
         Sm (Normalized_First_Bit, Uint),
         Sm (Normalized_Position, Uint),
         Sm (Normalized_Position_Max, Uint),
-        Sm (Original_Record_Component, Node_Id),
+        Sm (Original_Record_Component, Node_Id)));
+
+   Cc (E_Component, Record_Field_Kind,
+       --  Components of a record declaration, private declarations of
+       --  protected objects.
+       (Sm (Discriminant_Checking_Func, Node_Id),
+        Sm (DT_Entry_Count, Uint,
+            Pre => "Is_Tag (N)"),
+        Sm (DT_Offset_To_Top_Func, Node_Id,
+            Pre => "Is_Tag (N)"),
         Sm (Prival, Node_Id,
             Pre => "Is_Protected_Component (N)"),
         Sm (Related_Type, Node_Id)));
 
-   Cc (E_Constant, Object_Kind,
-       --  Constants created by an object declaration with a constant keyword
+   Ab (Allocatable_Kind, Object_Kind,
        (Sm (Activation_Record_Component, Node_Id),
-        Sm (Actual_Subtype, Node_Id),
         Sm (Alignment, Uint),
+        Sm (Esize, Uint),
+        Sm (Interface_Name, Node_Id),
+        Sm (Is_Finalized_Transient, Flag),
+        Sm (Is_Ignored_Transient, Flag),
+        Sm (Linker_Section_Pragma, Node_Id),
+        Sm (Related_Expression, Node_Id),
+        Sm (Status_Flag_Or_Transient_Decl, Node_Id)));
+
+   Ab (Constant_Or_Variable_Kind, Allocatable_Kind,
+       (Sm (Actual_Subtype, Node_Id),
         Sm (BIP_Initialization_Call, Node_Id),
         Sm (Contract, Node_Id),
         Sm (Discriminal_Link, Node_Id),
         Sm (Encapsulating_State, Node_Id),
-        Sm (Esize, Uint),
         Sm (Extra_Accessibility, Node_Id),
-        Sm (Full_View, Node_Id),
         Sm (Initialization_Statements, Node_Id),
-        Sm (Interface_Name, Node_Id),
         Sm (Is_Elaboration_Checks_OK_Id, Flag),
         Sm (Is_Elaboration_Warnings_OK_Id, Flag),
-        Sm (Is_Finalized_Transient, Flag),
-        Sm (Is_Ignored_Transient, Flag),
         Sm (Last_Aggregate_Assignment, Node_Id),
-        Sm (Linker_Section_Pragma, Node_Id),
         Sm (Optimize_Alignment_Space, Flag),
         Sm (Optimize_Alignment_Time, Flag),
         Sm (Prival_Link, Node_Id),
-        Sm (Related_Expression, Node_Id),
         Sm (Related_Type, Node_Id),
         Sm (Return_Statement, Node_Id),
         Sm (Size_Check_Code, Node_Id),
         Sm (SPARK_Pragma, Node_Id),
-        Sm (SPARK_Pragma_Inherited, Flag),
-        Sm (Status_Flag_Or_Transient_Decl, Node_Id)));
+        Sm (SPARK_Pragma_Inherited, Flag)));
+
+   Cc (E_Constant, Constant_Or_Variable_Kind,
+       --  Constants created by an object declaration with a constant keyword
+       (Sm (Full_View, Node_Id)));
 
-   Cc (E_Discriminant, Object_Kind,
+   Cc (E_Discriminant, Record_Field_Kind,
        --  A discriminant, created by the use of a discriminant in a type
        --  declaration.
-       (Sm (Component_Bit_Offset, Uint),
-        Sm (Component_Clause, Node_Id),
-        Sm (Corresponding_Discriminant, Node_Id),
-        Sm (Corresponding_Record_Component, Node_Id),
+       (Sm (Corresponding_Discriminant, Node_Id),
         Sm (CR_Discriminant, Node_Id),
         Sm (Discriminal, Node_Id),
         Sm (Discriminant_Default_Value, Node_Id),
         Sm (Discriminant_Number, Uint),
-        Sm (Entry_Formal, Node_Id),
-        Sm (Esize, Uint),
-        Sm (Interface_Name, Node_Id),
-        Sm (Is_Completely_Hidden, Flag),
-        Sm (Linker_Section_Pragma, Node_Id),
-        Sm (Normalized_First_Bit, Uint),
-        Sm (Normalized_Position, Uint),
-        Sm (Normalized_Position_Max, Uint),
-        Sm (Original_Record_Component, Node_Id)));
+        Sm (Is_Completely_Hidden, Flag)));
 
-   Cc (E_Loop_Parameter, Object_Kind,
-       --  A loop parameter created by a for loop
-       (Sm (Activation_Record_Component, Node_Id),
-        Sm (Alignment, Uint),
-        Sm (Esize, Uint),
-        Sm (Interface_Name, Node_Id),
-        Sm (Is_Finalized_Transient, Flag),
-        Sm (Is_Ignored_Transient, Flag),
-        Sm (Linker_Section_Pragma, Node_Id),
-        Sm (Related_Expression, Node_Id),
-        Sm (Status_Flag_Or_Transient_Decl, Node_Id)));
+   Cc (E_Loop_Parameter, Allocatable_Kind);
+   --  A loop parameter created by a for loop
 
-   Cc (E_Variable, Object_Kind,
+   Cc (E_Variable, Constant_Or_Variable_Kind,
        --  Variables created by an object declaration with no constant keyword
-       (Sm (Activation_Record_Component, Node_Id),
-        Sm (Actual_Subtype, Node_Id),
-        Sm (Alignment, Uint),
-        Sm (Anonymous_Designated_Type, Node_Id),
-        Sm (BIP_Initialization_Call, Node_Id),
-        Sm (Contract, Node_Id),
+       (Sm (Anonymous_Designated_Type, Node_Id),
         Sm (Debug_Renaming_Link, Node_Id),
-        Sm (Discriminal_Link, Node_Id),
-        Sm (Encapsulating_State, Node_Id),
-        Sm (Esize, Uint),
-        Sm (Extra_Accessibility, Node_Id),
         Sm (Extra_Constrained, Node_Id),
         Sm (Has_Initial_Value, Flag),
         Sm (Hiding_Loop_Variable, Node_Id),
-        Sm (Initialization_Statements, Node_Id),
-        Sm (Interface_Name, Node_Id),
-        Sm (Is_Elaboration_Checks_OK_Id, Flag),
-        Sm (Is_Elaboration_Warnings_OK_Id, Flag),
-        Sm (Is_Finalized_Transient, Flag),
-        Sm (Is_Ignored_Transient, Flag),
-        Sm (Last_Aggregate_Assignment, Node_Id),
         Sm (Last_Assignment, Node_Id),
-        Sm (Linker_Section_Pragma, Node_Id),
         Sm (OK_To_Rename, Flag),
-        Sm (Optimize_Alignment_Space, Flag),
-        Sm (Optimize_Alignment_Time, Flag),
         Sm (Part_Of_Constituents, Elist_Id),
         Sm (Part_Of_References, Elist_Id),
-        Sm (Prival_Link, Node_Id),
-        Sm (Related_Expression, Node_Id),
-        Sm (Related_Type, Node_Id),
-        Sm (Return_Statement, Node_Id),
         Sm (Shared_Var_Procs_Instance, Node_Id),
-        Sm (Size_Check_Code, Node_Id),
-        Sm (SPARK_Pragma, Node_Id),
-        Sm (SPARK_Pragma_Inherited, Flag),
-        Sm (Status_Flag_Or_Transient_Decl, Node_Id),
         Sm (Suppress_Initialization, Flag),
         Sm (Unset_Reference, Node_Id),
         Sm (Validated_Object, Node_Id)));


diff --git a/gcc/ada/gen_il-types.ads b/gcc/ada/gen_il-types.ads
--- a/gcc/ada/gen_il-types.ads
+++ b/gcc/ada/gen_il-types.ads
@@ -124,6 +124,7 @@ package Gen_IL.Types is
       Access_Subprogram_Kind,
       Access_Protected_Kind,
       Aggregate_Kind,
+      Allocatable_Kind,
       Anonymous_Access_Kind,
       Array_Kind,
       Assignable_Kind,
@@ -131,6 +132,7 @@ package Gen_IL.Types is
       Composite_Kind,
       Concurrent_Kind,
       Concurrent_Body_Kind,
+      Constant_Or_Variable_Kind,
       Decimal_Fixed_Point_Kind,
       Digits_Kind,
       Discrete_Kind,
@@ -158,6 +160,7 @@ package Gen_IL.Types is
       Protected_Kind,
       Real_Kind,
       Record_Kind,
+      Record_Field_Kind,
       Scalar_Kind,
       Subprogram_Kind,
       Signed_Integer_Kind,



                 reply	other threads:[~2021-06-30  9:30 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20210630093045.GA147310@adacore.com \
    --to=derodat@adacore.com \
    --cc=gcc-patches@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).