From: Basile STARYNKEVITCH <basile@starynkevitch.net>
To: gcc-patches <gcc-patches@gcc.gnu.org>
Subject: adding a PLUGIN_PARSED_UNIT event
Date: Thu, 15 Oct 2009 17:08:00 -0000 [thread overview]
Message-ID: <4AD74D96.60205@starynkevitch.net> (raw)
[-- Attachment #1: Type: text/plain, Size: 1194 bytes --]
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} ***
[-- Attachment #2: plugin_parsed_unit-patch-rev_152849.diff --]
[-- Type: text/x-patch, Size: 2507 bytes --]
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:
next reply other threads:[~2009-10-15 16:27 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-10-15 17:08 Basile STARYNKEVITCH [this message]
2009-11-19 16:59 ` Diego Novillo
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=4AD74D96.60205@starynkevitch.net \
--to=basile@starynkevitch.net \
--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).