This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Ada] Small front-end optimization


Tested on i686-linux, committed on trunk

This change is an optimization with no externally visible behaviour change.
When we need to obtain the unit id associated with a given source file,
we used to go through the unit table until we found a unit associated
with that source file. We now take advantage of cached unit information
from the source files table, allowing for more efficient determination of
that information. This optimization is interesting because Get_Code_Unit
and Get_Code_Unit are frequently called during compiler operation.

A new function Is_Keyword_Name that indicates if a name is a
reserved keyword is also created for the benefit of GPS.

2006-02-13  Thomas Quinot  <quinot@adacore.com>
	    Vincent Celier  <celier@adacore.com>
	    Robert Dewar  <dewar@adacore.com>

	* ali-util.adb (Get_File_Checksum): Update to account for change in
	profile of Initialize_Scanner.

	* gprep.adb (Gnatprep): Update to account for change in profile of
	Initialize_Scanner.
	(Process_One_File): Same.

	* lib.adb (Get_Code_Or_Source_Unit): New subprogram factoring the
	common code between Get_Code_Unit and Get_Source_Unit. Reimplement
	that behaviour using the new Unit information recorded in the source
	files table, rather than going through all units every time.
	(Get_Code_Unit): Reimplement in terms of Get_Code_Or_Source_Unit.
	(Get_Source_Unit): Same.

	* prepcomp.adb (Parse_Preprocessing_Data_File): Update to account for
	change in profile of Initialize_Scanner.
	(Prepare_To_Preprocess): Same.

	* lib.ads: Fix typo in comment (templace -> template).

	* prj-part.adb (Parse_Single_Project): Update to account for change in
	profile of Initialize_Scanner.

	* scn.adb (Initialize_Scanner): Account for change in profile of
	Scng.Initialize_Scanner: set Current_Source_Unit in Scn instead of Scng.
	Also record the association of the given Source_File_Index to the
	corresponding Unit_Number_Type.

	* scng.ads, scng.adb (Initialize_Scanner.Set_Reserved): Remove
	procedure.
	(Initialize_Scanner): Call Scans.Initialize_Ada_Keywords.
	Remove Unit formal for generic scanner: this formal
	is only relevant to Scn (the scanner instance used to parse Ada source
	files), not to other instances. Update comment accordingly.
	(Scan): Use new function Snames.Is_Keyword_Name.

	* sinfo-cn.adb: Fix typo in comment.

	* sinput.adb (Unit, Set_Unit): Accessors for new source file attribute
	Unit.

	* sinput.ads (Source_File_Record): New component Unit, used to capture
	the unit identifier (if any) associated to a source file.

	* sinput-c.adb, sinput-l.adb (Load_File): Initialize new component
	Unit in Source_File_Record.

	* sinput-p.adb (Source_File_Is_Subunit): Update to account for change
	in profile of Initialize_Scanner.

	* scans.adb (Initialize_Ada_Keywords): New procedure

	* scans.ads (Initialize_Ada_Keywords): New procedure to initialize the
	Ada keywords in the Namet table, without the need to call
	Initialize_Scanner.

	* snames.adb: Add pragma Ada_2005 (synonym for Ada_05)
	(Is_Keyword_Name): New function

	* snames.ads: Add subtype Configuration_Pragma_Names
	Add pragma Ada_2005 (synonym for Ada_05)
	(Is_Keyword_Name): New function

	* snames.h: Add pragma Ada_2005 (synonym for Ada_05)

Attachment: difs.12
Description: Text document


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]