2015-05-01 Paolo Carlini <paolo.carlini@oracle.com>
[official-gcc.git] / gcc / gcc-plugin.h
blob3dd52ee316aa03101108e4dda9449c27224f0f72
1 /* Public header file for plugins to include.
2 Copyright (C) 2009-2015 Free Software Foundation, Inc.
4 This file is part of GCC.
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.
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.
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/>. */
20 #ifndef GCC_PLUGIN_H
21 #define GCC_PLUGIN_H
23 #ifndef IN_GCC
24 #define IN_GCC
25 #endif
27 #include "config.h"
28 #include "system.h"
29 #include "coretypes.h"
30 #include "highlev-plugin-common.h"
31 #include "tm.h"
32 #include "hashtab.h"
33 #include "hash-set.h"
34 #include "vec.h"
35 #include "machmode.h"
36 #include "hard-reg-set.h"
37 #include "input.h"
38 #include "function.h"
39 #include "predict.h"
40 #include "dominance.h"
41 #include "cfg.h"
42 #include "cfgrtl.h"
43 #include "cfganal.h"
44 #include "lcm.h"
45 #include "cfgbuild.h"
46 #include "cfgcleanup.h"
47 #include "hash-map.h"
48 #include "is-a.h"
49 #include "plugin-api.h"
50 #include "ipa-ref.h"
51 #include "statistics.h"
52 #include "double-int.h"
53 #include "real.h"
54 #include "fixed-value.h"
55 #include "alias.h"
56 #include "flags.h"
57 #include "symtab.h"
58 #include "tree-core.h"
59 #include "hash-set.h"
60 #include "wide-int.h"
61 #include "inchash.h"
62 #include "fold-const.h"
63 #include "tree-check.h"
65 /* Event names. */
66 enum plugin_event
68 # define DEFEVENT(NAME) NAME,
69 # include "plugin.def"
70 # undef DEFEVENT
71 PLUGIN_EVENT_FIRST_DYNAMIC
74 /* All globals declared here have C linkage to reduce link compatibility
75 issues with implementation language choice and mangling. */
76 #ifdef __cplusplus
77 extern "C" {
78 #endif
80 extern const char **plugin_event_name;
82 struct plugin_argument
84 char *key; /* key of the argument. */
85 char *value; /* value is optional and can be NULL. */
88 /* Additional information about the plugin. Used by --help and --version. */
90 struct plugin_info
92 const char *version;
93 const char *help;
96 /* Represents the gcc version. Used to avoid using an incompatible plugin. */
98 struct plugin_gcc_version
100 const char *basever;
101 const char *datestamp;
102 const char *devphase;
103 const char *revision;
104 const char *configuration_arguments;
107 /* Object that keeps track of the plugin name and its arguments. */
108 struct plugin_name_args
110 char *base_name; /* Short name of the plugin (filename without
111 .so suffix). */
112 const char *full_name; /* Path to the plugin as specified with
113 -fplugin=. */
114 int argc; /* Number of arguments specified with
115 -fplugin-arg-... */
116 struct plugin_argument *argv; /* Array of ARGC key-value pairs. */
117 const char *version; /* Version string provided by plugin. */
118 const char *help; /* Help string provided by plugin. */
121 /* The default version check. Compares every field in VERSION. */
123 extern bool plugin_default_version_check (struct plugin_gcc_version *,
124 struct plugin_gcc_version *);
126 /* Function type for the plugin initialization routine. Each plugin module
127 should define this as an externally-visible function with name
128 "plugin_init."
130 PLUGIN_INFO - plugin invocation information.
131 VERSION - the plugin_gcc_version symbol of GCC.
133 Returns 0 if initialization finishes successfully. */
135 typedef int (*plugin_init_func) (struct plugin_name_args *plugin_info,
136 struct plugin_gcc_version *version);
138 /* Declaration for "plugin_init" function so that it doesn't need to be
139 duplicated in every plugin. */
140 extern int plugin_init (struct plugin_name_args *plugin_info,
141 struct plugin_gcc_version *version);
143 /* Function type for a plugin callback routine.
145 GCC_DATA - event-specific data provided by GCC
146 USER_DATA - plugin-specific data provided by the plugin */
148 typedef void (*plugin_callback_func) (void *gcc_data, void *user_data);
150 /* Called from the plugin's initialization code. Register a single callback.
151 This function can be called multiple times.
153 PLUGIN_NAME - display name for this plugin
154 EVENT - which event the callback is for
155 CALLBACK - the callback to be called at the event
156 USER_DATA - plugin-provided data.
159 /* Number of event ids / names registered so far. */
161 extern int get_event_last (void);
163 int get_named_event_id (const char *name, enum insert_option insert);
165 /* This is also called without a callback routine for the
166 PLUGIN_PASS_MANAGER_SETUP, PLUGIN_INFO and PLUGIN_REGISTER_GGC_ROOTS
167 pseudo-events, with a specific user_data.
170 extern void register_callback (const char *plugin_name,
171 int event,
172 plugin_callback_func callback,
173 void *user_data);
175 extern int unregister_callback (const char *plugin_name, int event);
178 /* Retrieve the plugin directory name, as returned by the
179 -fprint-file-name=plugin argument to the gcc program, which is the
180 -iplugindir program argument to cc1. */
181 extern const char* default_plugin_dir_name (void);
183 #ifdef __cplusplus
185 #endif
187 /* In case the C++ compiler does name mangling for globals, declare
188 plugin_is_GPL_compatible extern "C" so that a later definition
189 in a plugin file will have this linkage. */
190 #ifdef __cplusplus
191 extern "C" {
192 #endif
193 extern int plugin_is_GPL_compatible;
194 #ifdef __cplusplus
196 #endif
198 #endif /* GCC_PLUGIN_H */