This patch is preliminary work in preparation for changing the node
structure so that nodes and entities can be of different sizes depending
on the Node_Kind or Entity_Kind.

This is cleanup/simplification combined with efficiency improvements.

We rearrange the subranges of the various union types in types.ads to
allow for more Node_Ids. Node_Id is now most of the nonnegative range.
The other ranges remain the same length (100 million, except for Uint),
but are now negative numbers. Fix various places that assumed the
numbers are positive.

Note that -gnaten switch is currently undocumented, and might
be removed.

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

gcc/ada/

        * atree.ads: Make Default_Node a constant.  Remove the
        modification of Comes_From_Source, and use a separate flag for
        that.  Change Sloc to 0; it always overwritten, and never left
        as the No_Location value.
        (Print_Statistics): Move to spec so we can call it from
        gnat1drv.
        (Num_Nodes): Rename to clarify that this is approximate.
        Correct comment: nodes and entities are never deleted, the count
        is never decremented, and this is not used by Xref.
        (Initialize): Correct comment: Error_List is not created here.
        Other minor naming and comment changes.
        * atree.adb (Extend_Node, New_Copy, New_Entity, New_Node):
        Streamline these. Simplify and improve efficiency.  Move code
        from Allocate_Initialize_Node to these, where it can be executed
        unconditionally.  Take advantage of automatic zeroing of the
        Nodes table.
        (Allocate_Initialize_Node): Remove this. It was an efficiency
        bottleneck, and somewhat complicated, because it was called from
        4 places, and had all sorts of conditionals to check where it
        was called from. Better to move most of that code to the call
        sites, where it can be executed (or not) unconditionally.
        (Allocate_New_Node): New procedure to partly replace
        Allocate_Initialize_Node (called from just 2 of those 4 places).
        (Comes_From_Source_Default): New flag written/read by
        Set_Comes_From_Source_Default/Get_Comes_From_Source_Default.
        This allows us to make Default_Node into a constant with
        all-zeros value.
        (Set_Paren_Count_Of_Copy): New procedure to avoid duplicated
        code.
        (Report): New procedure to encapsulate the call to the reporting
        procedure.
        (Atree_Private_Part): We now need a body for this package, to
        contain package body Nodes.
        (Approx_Num_Nodes_And_Entities): Was Num_Nodes.  For efficiency,
        compute the answer from Nodes.Last. That way we don't need to
        increment a counter on every node creation. Other minor naming
        and comment changes.
        * gnat1drv.adb: Call Atree.Print_Statistics if -gnatd.A switch
        was given.  Add comment documenting the new order dependency (we
        must process the command line before calling Atree.Initialize).
        * debug.adb: Document -gnatd.A.
        * einfo.adb, sinfo.adb: Remove useless Style_Checks pragmas.
        * nlists.ads (Allocate_List_Tables): Inline makes node creation
        a little faster.
        * nlists.adb (Initialize): Remove local constant E, which didn't
        seem to add clarity.
        * treepr.adb (Print_Init): Use renamed
        Approx_Num_Nodes_And_Entities function.
        * types.ads: Change the Low and High bounds as described above.
        * types.h: Change Low and High bounds to match types.ads.
        * sem_ch8.adb, namet.adb, namet.ads: Move the computation of
        Last_Name_Id from sem_ch8 to namet, and correct it to not assume
        Name_Ids are positive.
        * ali.adb, ali-util.adb, bindo-writers.adb, exp_dist.adb,
        fmap.adb, fname-uf.adb, osint.adb: Fix various hash functions to
        avoid assuming the various ranges are positive. Note that "mod"
        returns a nonnegative result when the second operand is
        positive. "rem" can return negative values in that case (in
        particular, if the first operand is negative, which it now is).
        * switch-c.adb: Allow switch -gnaten to control the value of
        Nodes_Size_In_Meg.
        * doc/gnat_ugn/building_executable_programs_with_gnat.rst:
        Remove traling whitespaces.
        * opt.ads (Nodes_Size_In_Meg): New Variable.

Attachment: patch.diff.gz
Description: application/gzip

Reply via email to