]> gcc.gnu.org Git - gcc.git/commitdiff
[Ada] Minor comment cleanups
authorBob Duff <duff@adacore.com>
Tue, 23 Mar 2021 20:00:03 +0000 (16:00 -0400)
committerPierre-Marie de Rodat <derodat@adacore.com>
Fri, 18 Jun 2021 08:36:54 +0000 (04:36 -0400)
gcc/ada/

* gen_il-gen.adb: Improve comments.
* snames.ads-tmpl (Convention_Id): Remove "--  Plenty of space
for expansion", because that's irrelevant now that we are no
longer laying out node fields by hand.

gcc/ada/gen_il-gen.adb
gcc/ada/snames.ads-tmpl

index 61d464c9ce0a20a684d3198dcad3c9ff26fd2fbd..7ef285ee458f37889cc94d2434c340997772b2c3 100644 (file)
@@ -837,20 +837,24 @@ package body Gen_IL.Gen is
 
           when Node_Kind_Type | Entity_Kind_Type | Convention_Id => 8,
 
-           when Mechanism_Type
-              | List_Id
-              | Elist_Id
-              | Name_Id
-              | String_Id
-              | Uint
-              | Ureal
-              | Source_Ptr
-              | Union_Id
-              | Node_Id
-              | Node_Or_Entity_Type => 32,
+          when Mechanism_Type
+             | List_Id
+             | Elist_Id
+             | Name_Id
+             | String_Id
+             | Uint
+             | Ureal
+             | Source_Ptr
+             | Union_Id
+             | Node_Id
+             | Node_Or_Entity_Type => 32,
 
          when Between_Special_And_Abstract_Node_Types => -- can't happen
            Bit_Offset'Last);
+         --  Size in bits of a a field of type T. It must be a power of 2, and
+         --  must match the size of the type in GNAT, which sometimes requires
+         --  a Size clause in GNAT.
+         --
          --  Note that this is not the same as Type_Bit_Size of the field's
          --  type. For one thing, Type_Bit_Size only covers concrete node and
          --  entity types, which does not include most of the above. For
@@ -1012,11 +1016,20 @@ package body Gen_IL.Gen is
          end loop;
 
          --  Sort All_Fields based on how many concrete types have the field.
+         --  This is for efficiency; we want to choose the offsets of the most
+         --  common fields first, so they get low numbers.
 
          Sorting.Sort (All_Fields);
 
          --  Go through all the fields, and choose the lowest offset that is
-         --  free in all types that have the field.
+         --  free in all types that have the field. This is basically a
+         --  graph-coloring algorithm on the interference graph. The
+         --  interference graph is an undirected graph with the fields being
+         --  nodes (not nodes in the compiler!) in the graph, and an edge
+         --  between a pair of fields if they appear in the same node in the
+         --  compiler. The "colors" are fields offsets, except that a
+         --  complication compared to standard graph coloring is that fields
+         --  are different sizes.
 
          for F of All_Fields loop
             Field_Table (F).Offset := Choose_Offset (F);
index e5a019fc08713e7b38fd300b68d3b48314bcb1f2..2611541dd7809a826f44c960aec566e6bb314b05 100644 (file)
@@ -1700,7 +1700,6 @@ package Snames is
       --  in Sem_Prag.
 
    for Convention_Id'Size use 8;
-   --  Plenty of space for expansion
 
    subtype Convention_C_Family is Convention_Id
      range Convention_C .. Convention_CPP;
This page took 0.066634 seconds and 5 git commands to generate.