OSDN Git Service

* optabs.h (enum optab_index): Add new OTI_significand.
[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_ATTRIBUTES,            /* Called during attribute registration.  */
44   PLUGIN_EVENT_LAST             /* Dummy event used for indexing callback
45                                    array.  */
46 };
47
48 extern const char *plugin_event_name[];
49
50 struct plugin_argument
51 {
52   char *key;    /* key of the argument.  */
53   char *value;  /* value is optional and can be NULL.  */
54 };
55
56 enum pass_positioning_ops
57 {
58   PASS_POS_INSERT_AFTER,  /* Insert after the reference pass.  */
59   PASS_POS_INSERT_BEFORE, /* Insert before the reference pass.  */
60   PASS_POS_REPLACE        /* Replace the reference pass.  */
61 };
62
63 struct plugin_pass
64 {
65   struct opt_pass *pass;            /* New pass provided by the plugin.  */
66   const char *reference_pass_name;  /* Name of the reference pass for hooking
67                                        up the new pass.  */
68   int ref_pass_instance_number;     /* Insert the pass at the specified
69                                        instance number of the reference pass.
70                                        Do it for every instance if it is 0.  */
71   enum pass_positioning_ops pos_op; /* how to insert the new pass.  */
72 };
73
74 /* Additional information about the plugin. Used by --help and --version. */
75
76 struct plugin_info
77 {
78   const char *version;
79   const char *help;
80 };
81
82 /* Represents the gcc version. Used to avoid using an incompatible plugin. */
83
84 struct plugin_gcc_version
85 {
86   const char *basever;
87   const char *datestamp;
88   const char *devphase;
89   const char *revision;
90   const char *configuration_arguments;
91 };
92
93 /* Object that keeps track of the plugin name and its arguments. */
94 struct plugin_name_args
95 {
96   char *base_name;              /* Short name of the plugin (filename without
97                                    .so suffix). */
98   const char *full_name;        /* Path to the plugin as specified with
99                                    -fplugin=. */
100   int argc;                     /* Number of arguments specified with
101                                    -fplugin-arg-... */
102   struct plugin_argument *argv; /* Array of ARGC key-value pairs. */
103   const char *version;          /* Version string provided by plugin. */
104   const char *help;             /* Help string provided by plugin. */
105 };
106
107 /* The default version check. Compares every field in VERSION. */
108
109 extern bool plugin_default_version_check (struct plugin_gcc_version *,
110                                           struct plugin_gcc_version *);
111
112 /* Function type for the plugin initialization routine. Each plugin module
113    should define this as an externally-visible function with name
114    "plugin_init."
115
116    PLUGIN_INFO - plugin invocation information.
117    VERSION     - the plugin_gcc_version symbol of GCC.
118
119    Returns 0 if initialization finishes successfully.  */
120
121 typedef int (*plugin_init_func) (struct plugin_name_args *plugin_info,
122                                  struct plugin_gcc_version *version);
123
124 /* Declaration for "plugin_init" function so that it doesn't need to be
125    duplicated in every plugin.  */
126 extern int plugin_init (struct plugin_name_args *plugin_info,
127                         struct plugin_gcc_version *version);
128
129 /* Function type for a plugin callback routine.
130
131    GCC_DATA  - event-specific data provided by GCC
132    USER_DATA - plugin-specific data provided by the plugin  */
133
134 typedef void (*plugin_callback_func) (void *gcc_data, void *user_data);
135
136 /* Called from the plugin's initialization code. Register a single callback.
137    This function can be called multiple times.
138
139    PLUGIN_NAME - display name for this plugin
140    EVENT       - which event the callback is for
141    CALLBACK    - the callback to be called at the event
142    USER_DATA   - plugin-provided data.
143 */
144
145 /* This is also called without a callback routine for the
146    PLUGIN_PASS_MANAGER_SETUP, PLUGIN_INFO, PLUGIN_REGISTER_GGC_ROOTS
147    pseudo-events, with a specific user_data.
148   */
149
150 extern void register_callback (const char *plugin_name,
151                                enum plugin_event event,
152                                plugin_callback_func callback,
153                                void *user_data);
154
155 #endif /* GCC_PLUGIN_H */