diff options
author | Diego Novillo <dnovillo@gcc.gnu.org> | 2009-04-14 16:18:49 -0400 |
---|---|---|
committer | Diego Novillo <dnovillo@gcc.gnu.org> | 2009-04-14 16:18:49 -0400 |
commit | 68a607d8143693c8f4bc66bef001197ea4ff7c84 (patch) | |
tree | a65b40c88b9169d2d76f8139339fd3054612f224 /gcc/gcc-plugin.h | |
parent | 50617257085372785e4385d166b2fba4b634ee54 (diff) | |
download | gcc-68a607d8143693c8f4bc66bef001197ea4ff7c84.zip gcc-68a607d8143693c8f4bc66bef001197ea4ff7c84.tar.gz gcc-68a607d8143693c8f4bc66bef001197ea4ff7c84.tar.bz2 |
[multiple changes]
2009-04-14 Diego Novillo <dnovillo@google.com>
Le-Chun Wu <lcwu@google.com>
* configure.ac: Add --enable-plugin support.
Define ENABLE_PLUGIN and PLUGINLIBS when specified.
* Makefile.in (PLUGIN_H): Define.
Export ENABLE_PLUGIN and GMPINC to site.exp.
Add PLUGINLIBS to link command.
Add/modify dependencies for plugin.o and files including plugin.h.
(plugin.o): New.
* config.in: Regenerate.
* opts.c (common_handle_option): Handle OPT_fplugin_ and
OPT_fplugin_arg_.
2009-04-14 Le-Chun Wu <lcwu@google.com>
* tree-pass.h (register_one_dump_file): Add a prototype for
register_one_dump_file.
* toplev.c (compile_file): Call initialize_plugins.
(do_compile): Call invoke_plugin_callbacks.
(toplev_main): Call invoke_plugin_callbacks.
* common.opt: Add -fplugin= and -fplugin-arg-.
* gcc-plugin.h: New public header file for plugins to include.
* plugin.c: New source file.
* plugin.h: New internal header file.
* passes.c (register_one_dump_file): Make it external.
* c-parser.c (c_parser_declspecs): Call invoke_plugin_callbacks.
2009-04-14 Diego Novillo <dnovillo@google.com>
* doc/plugins.texi: New.
* doc/gccint.texi: Add reference to Plugins chapter.
* doc/invoke.texi: Document -fplugin and -fplugin-arg
* diagnostic.c (diagnostic_report_diagnostic): Warn about
loaded plugins, if any.
* timevar.def (TV_PLUGIN_INIT): Define.
(TV_PLUGIN_RUN): Define.
* plugin.c: Include timevar.h
(plugins_active_p): New.
(dump_active_plugins): New.
(debug_active_plugins): New.
cp/ChangeLog
2009-04-14 Le-Chun Wu <lcwu@google.com>
* Make-lang.in: Modify dependencies of files including plugin.h.
* decl.c (finish_function): Call invoke_plugin_callbacks.
* parser.c (cp_parser_type_specifier): Call invoke_plugin_callbacks.
From-SVN: r146059
Diffstat (limited to 'gcc/gcc-plugin.h')
-rw-r--r-- | gcc/gcc-plugin.h | 98 |
1 files changed, 98 insertions, 0 deletions
diff --git a/gcc/gcc-plugin.h b/gcc/gcc-plugin.h new file mode 100644 index 0000000..4a45c1e --- /dev/null +++ b/gcc/gcc-plugin.h @@ -0,0 +1,98 @@ +/* Public header file for plugins to include. + Copyright (C) 2009 Free Software Foundation, Inc. + +This file is part of GCC. + +GCC is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 3, or (at your option) +any later version. + +GCC is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with GCC; see the file COPYING3. If not see +<http://www.gnu.org/licenses/>. */ + +#ifndef GCC_PLUGIN_H +#define GCC_PLUGIN_H + +/* Event names. Keep in sync with plugin_event_name[]. */ +enum plugin_event +{ + PLUGIN_PASS_MANAGER_SETUP, /* To hook into pass manager. */ + PLUGIN_FINISH_TYPE, /* After finishing parsing a type. */ + PLUGIN_FINISH_UNIT, /* Useful for summary processing. */ + PLUGIN_CXX_CP_PRE_GENERICIZE, /* Allows to see low level AST in C++ FE. */ + PLUGIN_FINISH, /* Called before GCC exits. */ + PLUGIN_EVENT_LAST /* Dummy event used for indexing callback + array. */ +}; + +extern const char *plugin_event_name[]; + +struct plugin_argument +{ + char *key; /* key of the argument. */ + char *value; /* value is optional and can be NULL. */ +}; + +enum pass_positioning_ops +{ + PASS_POS_INSERT_AFTER, /* Insert after the reference pass. */ + PASS_POS_INSERT_BEFORE, /* Insert before the reference pass. */ + PASS_POS_REPLACE /* Replace the reference pass. */ +}; + +struct plugin_pass +{ + struct opt_pass *pass; /* New pass provided by the plugin. */ + const char *reference_pass_name; /* Name of the reference pass for hooking + up the new pass. */ + int ref_pass_instance_number; /* Insert the pass at the specified + instance number of the reference pass. + Do it for every instance if it is 0. */ + enum pass_positioning_ops pos_op; /* how to insert the new pass. */ +}; + +/* Function type for the plugin initialization routine. Each plugin module + should define this as an externally-visible function with name + "plugin_init." + + PLUGIN_NAME - name of the plugin (useful for error reporting) + ARGC - the size of the ARGV array + ARGV - an array of key-value argument pair + + Returns 0 if initialization finishes successfully. */ + +typedef int (*plugin_init_func) (const char *plugin_name, + int argc, struct plugin_argument *argv); + +/* Declaration for "plugin_init" function so that it doesn't need to be + duplicated in every plugin. */ +extern int plugin_init (const char *, int, struct plugin_argument *); + +/* Function type for a plugin callback routine. + + GCC_DATA - event-specific data provided by GCC + USER_DATA - plugin-specific data provided by the plugin */ + +typedef void (*plugin_callback_func) (void *gcc_data, void *user_data); + +/* Called from the plugin's initialization code. Register a single callback. + This function can be called multiple times. + + PLUGIN_NAME - display name for this plugin + EVENT - which event the callback is for + CALLBACK - the callback to be called at the event + USER_DATA - plugin-provided data */ + +extern void register_callback (const char *plugin_name, + enum plugin_event event, + plugin_callback_func callback, + void *user_data); + +#endif /* GCC_PLUGIN_H */ |