plugin hooks

Basile STARYNKEVITCH basile@starynkevitch.net
Tue Oct 27 15:39:00 GMT 2009


Ian Lance Taylor wrote:
> 
> For something like PLUGIN_ADD_CPP_MACROS, the need is clear, but I
> think it's an open question we should add a hook or whether the plugin
> should just call cpp_define.  A hook means that we promise to always
> have a way to do this in case cpp_define changes.  How do we decide
> when to add that kind of thing to the plugin interface and when to
> simply require the plugin to invoke gcc functions directly?

I (Basile) don't know much of libcpp. If a plugin can just call 
cpp_define, this is ok for me. But then, we perhaps should document how 
can that be called, and when (at plugin initialization, at 
PLUGIN_START_UNIT? I don't know!)

I don't claim that a PLUGIN_ADD_CPP_MACROS is needed, I just think that 
we should be able to declare additional builtin CPP macros [like 
__DATE__ is, or perhaps like defined inside CPP is] from plugins.

I am not familiar enough with libcpp to understand if calling cpp_define 
from a plugin is enough.

As a matter of fact, there are several *.def files which seems to be 
#include-d to fill some constant arrays. For these kind of things, I 
would suppose that perhaps some registration facility is needed, 
probably as an addition register_plugin_XXXX function. Of course, not 
every *.def fits into that scheme: I don't claim that plugin should 
register a new kind of GIMPLE or TREE node (even if a file like 
gcc/gimple.def or gcc/tree.def exists). [*] But the files 
gcc/builtins.def & gcc/builtin-types.def seems to suggest a vector of 
extra plugin-registered builtins & builtin-types and perhaps a 
register_plugin_builtin function etc...

Regards.

(*) Half-joking note about adding GIMPLE node in plugins. Of course, if 
all GCC was in C++, plugins could register extra GIMPLE nodes :-) 
provided the GIMPLE node would be implemented as an abstract class (with 
many virtual method slots).
-- 
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} ***



More information about the Gcc mailing list