pr39543-2.c: Skip if ilp32 && pic.
[gcc.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 /* Event names. Keep in sync with plugin_event_name[]. */
24 enum plugin_event
25 {
26 PLUGIN_PASS_MANAGER_SETUP, /* To hook into pass manager. */
27 PLUGIN_FINISH_TYPE, /* After finishing parsing a type. */
28 PLUGIN_FINISH_UNIT, /* Useful for summary processing. */
29 PLUGIN_CXX_CP_PRE_GENERICIZE, /* Allows to see low level AST in C++ FE. */
30 PLUGIN_FINISH, /* Called before GCC exits. */
31 PLUGIN_INFO, /* Information about the plugin */
32 PLUGIN_EVENT_LAST /* Dummy event used for indexing callback
33 array. */
34 };
35
36 extern const char *plugin_event_name[];
37
38 struct plugin_argument
39 {
40 char *key; /* key of the argument. */
41 char *value; /* value is optional and can be NULL. */
42 };
43
44 enum pass_positioning_ops
45 {
46 PASS_POS_INSERT_AFTER, /* Insert after the reference pass. */
47 PASS_POS_INSERT_BEFORE, /* Insert before the reference pass. */
48 PASS_POS_REPLACE /* Replace the reference pass. */
49 };
50
51 struct plugin_pass
52 {
53 struct opt_pass *pass; /* New pass provided by the plugin. */
54 const char *reference_pass_name; /* Name of the reference pass for hooking
55 up the new pass. */
56 int ref_pass_instance_number; /* Insert the pass at the specified
57 instance number of the reference pass.
58 Do it for every instance if it is 0. */
59 enum pass_positioning_ops pos_op; /* how to insert the new pass. */
60 };
61
62 /* Additional information about the plugin. Used by --help and --version. */
63
64 struct plugin_info
65 {
66 const char *version;
67 const char *help;
68 };
69
70 /* Represents the gcc version. Used to avoid using an incompatible plugin. */
71
72 struct plugin_gcc_version
73 {
74 const char *basever;
75 const char *datestamp;
76 const char *devphase;
77 const char *revision;
78 const char *configuration_arguments;
79 };
80
81 /* The default version check. Compares every field in VERSION. */
82
83 extern bool plugin_default_version_check (struct plugin_gcc_version *,
84 struct plugin_gcc_version *);
85
86 /* Function type for the plugin initialization routine. Each plugin module
87 should define this as an externally-visible function with name
88 "plugin_init."
89
90 PLUGIN_NAME - name of the plugin (useful for error reporting)
91 VERSION - the plugin_gcc_version symbol of the plugin itself.
92 ARGC - the size of the ARGV array
93 ARGV - an array of key-value argument pair
94
95 Returns 0 if initialization finishes successfully. */
96
97 typedef int (*plugin_init_func) (const char *plugin_name,
98 struct plugin_gcc_version *version,
99 int argc, struct plugin_argument *argv);
100
101 /* Declaration for "plugin_init" function so that it doesn't need to be
102 duplicated in every plugin. */
103 extern int plugin_init (const char *, struct plugin_gcc_version *version,
104 int, struct plugin_argument *);
105
106 /* Function type for a plugin callback routine.
107
108 GCC_DATA - event-specific data provided by GCC
109 USER_DATA - plugin-specific data provided by the plugin */
110
111 typedef void (*plugin_callback_func) (void *gcc_data, void *user_data);
112
113 /* Called from the plugin's initialization code. Register a single callback.
114 This function can be called multiple times.
115
116 PLUGIN_NAME - display name for this plugin
117 EVENT - which event the callback is for
118 CALLBACK - the callback to be called at the event
119 USER_DATA - plugin-provided data */
120
121 extern void register_callback (const char *plugin_name,
122 enum plugin_event event,
123 plugin_callback_func callback,
124 void *user_data);
125
126 #endif /* GCC_PLUGIN_H */