X-Git-Url: http://git.sourceforge.jp/view?p=pf3gnuchains%2Fgcc-fork.git;a=blobdiff_plain;f=gcc%2Fgcc-plugin.h;h=948c4397570c65a51bfda95ff97fb186aba62603;hp=4a45c1e2c4819387b112aa0eb55d10a25c4af6b5;hb=c445c8dabaa2550c4c9e2093e6bf438999d5b946;hpb=9227b6fcb5d57341e64daf1dfd153f38df20694c diff --git a/gcc/gcc-plugin.h b/gcc/gcc-plugin.h index 4a45c1e2c48..948c4397570 100644 --- a/gcc/gcc-plugin.h +++ b/gcc/gcc-plugin.h @@ -1,5 +1,5 @@ /* Public header file for plugins to include. - Copyright (C) 2009 Free Software Foundation, Inc. + Copyright (C) 2009, 2010 Free Software Foundation, Inc. This file is part of GCC. @@ -20,19 +20,25 @@ along with GCC; see the file COPYING3. If not see #ifndef GCC_PLUGIN_H #define GCC_PLUGIN_H -/* Event names. Keep in sync with plugin_event_name[]. */ +#ifndef IN_GCC +#define IN_GCC +#endif + +#include "config.h" +#include "system.h" +#include "highlev-plugin-common.h" +#include "hashtab.h" + +/* Event names. */ 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. */ +# define DEFEVENT(NAME) NAME, +# include "plugin.def" +# undef DEFEVENT + PLUGIN_EVENT_FIRST_DYNAMIC }; -extern const char *plugin_event_name[]; +extern const char **plugin_event_name; struct plugin_argument { @@ -40,40 +46,66 @@ struct plugin_argument char *value; /* value is optional and can be NULL. */ }; -enum pass_positioning_ops +/* Additional information about the plugin. Used by --help and --version. */ + +struct plugin_info +{ + const char *version; + const char *help; +}; + +/* Represents the gcc version. Used to avoid using an incompatible plugin. */ + +struct plugin_gcc_version { - 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. */ + const char *basever; + const char *datestamp; + const char *devphase; + const char *revision; + const char *configuration_arguments; }; -struct plugin_pass +/* Object that keeps track of the plugin name and its arguments. */ +struct plugin_name_args { - 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. */ + char *base_name; /* Short name of the plugin (filename without + .so suffix). */ + const char *full_name; /* Path to the plugin as specified with + -fplugin=. */ + int argc; /* Number of arguments specified with + -fplugin-arg-... */ + struct plugin_argument *argv; /* Array of ARGC key-value pairs. */ + const char *version; /* Version string provided by plugin. */ + const char *help; /* Help string provided by plugin. */ }; +/* The default version check. Compares every field in VERSION. */ + +extern bool plugin_default_version_check (struct plugin_gcc_version *, + struct plugin_gcc_version *); + /* 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 + PLUGIN_INFO - plugin invocation information. + VERSION - the plugin_gcc_version symbol of GCC. Returns 0 if initialization finishes successfully. */ -typedef int (*plugin_init_func) (const char *plugin_name, - int argc, struct plugin_argument *argv); +typedef int (*plugin_init_func) (struct plugin_name_args *plugin_info, + struct plugin_gcc_version *version); +#ifdef __cplusplus +extern "C" { +#endif /* 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 *); +extern int plugin_init (struct plugin_name_args *plugin_info, + struct plugin_gcc_version *version); +#ifdef __cplusplus +} +#endif /* Function type for a plugin callback routine. @@ -88,11 +120,31 @@ typedef void (*plugin_callback_func) (void *gcc_data, void *user_data); 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 */ + USER_DATA - plugin-provided data. +*/ + +/* Number of event ids / names registered so far. */ + +extern int get_event_last (void); + +int get_named_event_id (const char *name, enum insert_option insert); + +/* This is also called without a callback routine for the + PLUGIN_PASS_MANAGER_SETUP, PLUGIN_INFO, PLUGIN_REGISTER_GGC_ROOTS and + PLUGIN_REGISTER_GGC_CACHES pseudo-events, with a specific user_data. + */ extern void register_callback (const char *plugin_name, - enum plugin_event event, + int event, plugin_callback_func callback, void *user_data); +extern int unregister_callback (const char *plugin_name, int event); + + +/* Retrieve the plugin directory name, as returned by the + -fprint-file-name=plugin argument to the gcc program, which is the + -iplugindir program argument to cc1. */ +extern const char* default_plugin_dir_name (void); + #endif /* GCC_PLUGIN_H */