OSDN Git Service

* MAINTAINERS: Add myself as a maintainer for the RX port.
[pf3gnuchains/gcc-fork.git] / gcc / gcc-plugin.h
1 /* Public header file for plugins to include.
2    Copyright (C) 2009 Free Software Foundation, Inc.
3
4 This file is part of GCC.
5
6 GCC is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 3, or (at your option)
9 any later version.
10
11 GCC is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14 GNU General Public License for more details.
15
16 You should have received a copy of the GNU General Public License
17 along with GCC; see the file COPYING3.  If not see
18 <http://www.gnu.org/licenses/>.  */
19
20 #ifndef GCC_PLUGIN_H
21 #define GCC_PLUGIN_H
22
23 #ifndef IN_GCC
24 #define IN_GCC
25 #endif
26
27 #include "config.h"
28 #include "system.h"
29
30 /* Event names.  Keep in sync with plugin_event_name[].  */
31 enum plugin_event
32 {
33   PLUGIN_PASS_MANAGER_SETUP,    /* To hook into pass manager.  */
34   PLUGIN_FINISH_TYPE,           /* After finishing parsing a type.  */
35   PLUGIN_FINISH_UNIT,           /* Useful for summary processing.  */
36   PLUGIN_CXX_CP_PRE_GENERICIZE, /* Allows to see low level AST in C++ FE.  */
37   PLUGIN_FINISH,                /* Called before GCC exits.  */
38   PLUGIN_INFO,                  /* Information about the plugin. */
39   PLUGIN_GGC_START,             /* Called at start of GCC Garbage Collection. */
40   PLUGIN_GGC_MARKING,           /* Extend the GGC marking. */
41   PLUGIN_GGC_END,               /* Called at end of GGC. */
42   PLUGIN_REGISTER_GGC_ROOTS,    /* Register an extra GGC root table. */
43   PLUGIN_REGISTER_GGC_CACHES,   /* Register an extra GGC cache table. */
44   PLUGIN_ATTRIBUTES,            /* Called during attribute registration.  */
45   PLUGIN_START_UNIT,            /* Called before processing a translation unit.  */
46   PLUGIN_EVENT_LAST             /* Dummy event used for indexing callback
47                                    array.  */
48 };
49
50 extern const char *plugin_event_name[];
51
52 struct plugin_argument
53 {
54   char *key;    /* key of the argument.  */
55   char *value;  /* value is optional and can be NULL.  */
56 };
57
58 /* Additional information about the plugin. Used by --help and --version. */
59
60 struct plugin_info
61 {
62   const char *version;
63   const char *help;
64 };
65
66 /* Represents the gcc version. Used to avoid using an incompatible plugin. */
67
68 struct plugin_gcc_version
69 {
70   const char *basever;
71   const char *datestamp;
72   const char *devphase;
73   const char *revision;
74   const char *configuration_arguments;
75 };
76
77 /* Object that keeps track of the plugin name and its arguments. */
78 struct plugin_name_args
79 {
80   char *base_name;              /* Short name of the plugin (filename without
81                                    .so suffix). */
82   const char *full_name;        /* Path to the plugin as specified with
83                                    -fplugin=. */
84   int argc;                     /* Number of arguments specified with
85                                    -fplugin-arg-... */
86   struct plugin_argument *argv; /* Array of ARGC key-value pairs. */
87   const char *version;          /* Version string provided by plugin. */
88   const char *help;             /* Help string provided by plugin. */
89 };
90
91 /* The default version check. Compares every field in VERSION. */
92
93 extern bool plugin_default_version_check (struct plugin_gcc_version *,
94                                           struct plugin_gcc_version *);
95
96 /* Function type for the plugin initialization routine. Each plugin module
97    should define this as an externally-visible function with name
98    "plugin_init."
99
100    PLUGIN_INFO - plugin invocation information.
101    VERSION     - the plugin_gcc_version symbol of GCC.
102
103    Returns 0 if initialization finishes successfully.  */
104
105 typedef int (*plugin_init_func) (struct plugin_name_args *plugin_info,
106                                  struct plugin_gcc_version *version);
107
108 /* Declaration for "plugin_init" function so that it doesn't need to be
109    duplicated in every plugin.  */
110 extern int plugin_init (struct plugin_name_args *plugin_info,
111                         struct plugin_gcc_version *version);
112
113 /* Function type for a plugin callback routine.
114
115    GCC_DATA  - event-specific data provided by GCC
116    USER_DATA - plugin-specific data provided by the plugin  */
117
118 typedef void (*plugin_callback_func) (void *gcc_data, void *user_data);
119
120 /* Called from the plugin's initialization code. Register a single callback.
121    This function can be called multiple times.
122
123    PLUGIN_NAME - display name for this plugin
124    EVENT       - which event the callback is for
125    CALLBACK    - the callback to be called at the event
126    USER_DATA   - plugin-provided data.
127 */
128
129 /* This is also called without a callback routine for the
130    PLUGIN_PASS_MANAGER_SETUP, PLUGIN_INFO, PLUGIN_REGISTER_GGC_ROOTS and
131    PLUGIN_REGISTER_GGC_CACHES pseudo-events, with a specific user_data.
132   */
133
134 extern void register_callback (const char *plugin_name,
135                                enum plugin_event event,
136                                plugin_callback_func callback,
137                                void *user_data);
138
139 #endif /* GCC_PLUGIN_H */