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]

adding a PLUGIN_PARSED_UNIT event


Hello All,

The attached patch, to trunk rev 152849, add a PLUGIN_PARSED_UNIT event,
invoked at start of cgraph_finalize_compilation_unit after all the compilation unit has been parsed.


My intuition is that we should better provide a little more hooks, especially at a such higher level. Doing everything only in passes is not practical (and was the reason to add stuff like PLUGIN_FINISH_UNIT

gcc/ChangeLog:

2009-10-15  Basile Starynkevitch  <basile@starynkevitch.net>
	* doc/plugins.texi (Plugin callbacks): added PLUGIN_PARSED_UNIT.
	* cgraphunit.c (cgraph_finalize_compilation_unit): Added
	invocation of PLUGIN_PARSED_UNIT callbacks.
	* gcc-plugin.h: Added PLUGIN_PARSED_UNIT.
	* plugin.c (plugin_event_name): Added PLUGIN_PARSED_UNIT.
	(invoke_plugin_callbacks): ditto.

I am bootstrapping it right now on x86_64-unknown-gnu-linux for c&c++

Comments are welcome.

I also believe that we should have plugin hooks for builtins.

Regards.
--
Basile STARYNKEVITCH         http://starynkevitch.net/Basile/
email: basile<at>starynkevitch<dot>net mobile: +33 6 8501 2359
8, rue de la Faiencerie, 92340 Bourg La Reine, France
*** opinions {are only mines, sont seulement les miennes} ***
Index: gcc/doc/plugins.texi
===================================================================
--- gcc/doc/plugins.texi	(revision 152849)
+++ gcc/doc/plugins.texi	(working copy)
@@ -136,6 +136,8 @@ enum plugin_event
   PLUGIN_REGISTER_GGC_CACHES,	/* Register an extra GGC cache table. */
   PLUGIN_ATTRIBUTES,            /* Called during attribute registration */
   PLUGIN_START_UNIT,            /* Called before processing a translation unit.  */
+  PLUGIN_PARSED_UNIT,           /* Called after a translation unit has
+				   been parsed.  */
   PLUGIN_EVENT_LAST             /* Dummy event used for indexing callback
                                    array.  */
 @};
Index: gcc/cgraphunit.c
===================================================================
--- gcc/cgraphunit.c	(revision 152849)
+++ gcc/cgraphunit.c	(working copy)
@@ -1052,6 +1052,9 @@ cgraph_finalize_compilation_unit (void)
 {
   timevar_push (TV_CGRAPH);
 
+  /* Invoke registered plugin callbacks.  */
+  invoke_plugin_callbacks (PLUGIN_PARSED_UNIT, NULL);
+  
   /* Do not skip analyzing the functions if there were errors, we
      miss diagnostics for following functions otherwise.  */
 
Index: gcc/gcc-plugin.h
===================================================================
--- gcc/gcc-plugin.h	(revision 152849)
+++ gcc/gcc-plugin.h	(working copy)
@@ -43,6 +43,8 @@ enum plugin_event
   PLUGIN_REGISTER_GGC_CACHES,	/* Register an extra GGC cache table. */
   PLUGIN_ATTRIBUTES,            /* Called during attribute registration.  */
   PLUGIN_START_UNIT,            /* Called before processing a translation unit.  */
+  PLUGIN_PARSED_UNIT,           /* Called after a translation unit has
+				   been parsed.  */
   PLUGIN_EVENT_LAST             /* Dummy event used for indexing callback
                                    array.  */
 };
Index: gcc/plugin.c
===================================================================
--- gcc/plugin.c	(revision 152849)
+++ gcc/plugin.c	(working copy)
@@ -58,7 +58,8 @@ const char *plugin_event_name[] =
   "PLUGIN_GGC_END",
   "PLUGIN_REGISTER_GGC_ROOTS",
   "PLUGIN_REGISTER_GGC_CACHES",
-  "PLUGIN_START_UNIT", 
+  "PLUGIN_START_UNIT",
+  "PLUGIN_PARSED_UNIT",
   "PLUGIN_EVENT_LAST"
 };
 
@@ -365,6 +366,7 @@ invoke_plugin_callbacks (enum plugin_event event,
     {
       case PLUGIN_FINISH_TYPE:
       case PLUGIN_START_UNIT:
+      case PLUGIN_PARSED_UNIT:
       case PLUGIN_FINISH_UNIT:
       case PLUGIN_CXX_CP_PRE_GENERICIZE:
       case PLUGIN_ATTRIBUTES:

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