comparison gcc/gcc-plugin.h @ 111:04ced10e8804

gcc 7
author kono
date Fri, 27 Oct 2017 22:46:09 +0900
parents f6334be47118
children 84e7813d76e9
comparison
equal deleted inserted replaced
68:561a7518be6b 111:04ced10e8804
1 /* Public header file for plugins to include. 1 /* Public header file for plugins to include.
2 Copyright (C) 2009, 2010 Free Software Foundation, Inc. 2 Copyright (C) 2009-2017 Free Software Foundation, Inc.
3 3
4 This file is part of GCC. 4 This file is part of GCC.
5 5
6 GCC is free software; you can redistribute it and/or modify 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 7 it under the terms of the GNU General Public License as published by
25 #endif 25 #endif
26 26
27 #include "config.h" 27 #include "config.h"
28 #include "system.h" 28 #include "system.h"
29 #include "coretypes.h" 29 #include "coretypes.h"
30 #include "highlev-plugin-common.h" 30 #include "backend.h"
31 #include "hashtab.h" 31 #include "cfghooks.h"
32 32 #include "hard-reg-set.h"
33 /* Event names. */ 33 #include "cfgrtl.h"
34 enum plugin_event 34 #include "cfganal.h"
35 { 35 #include "lcm.h"
36 # define DEFEVENT(NAME) NAME, 36 #include "cfgbuild.h"
37 # include "plugin.def" 37 #include "cfgcleanup.h"
38 # undef DEFEVENT 38 #include "plugin-api.h"
39 PLUGIN_EVENT_FIRST_DYNAMIC 39 #include "ipa-ref.h"
40 }; 40 #include "alias.h"
41 41 #include "flags.h"
42 /* All globals declared here have C linkage to reduce link compatibility 42 #include "tree-core.h"
43 issues with implementation language choice and mangling. */ 43 #include "fold-const.h"
44 #ifdef __cplusplus 44 #include "tree-check.h"
45 extern "C" { 45 #include "plugin.h"
46 #endif
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 /* Additional information about the plugin. Used by --help and --version. */
57
58 struct plugin_info
59 {
60 const char *version;
61 const char *help;
62 };
63
64 /* Represents the gcc version. Used to avoid using an incompatible plugin. */
65
66 struct plugin_gcc_version
67 {
68 const char *basever;
69 const char *datestamp;
70 const char *devphase;
71 const char *revision;
72 const char *configuration_arguments;
73 };
74
75 /* Object that keeps track of the plugin name and its arguments. */
76 struct plugin_name_args
77 {
78 char *base_name; /* Short name of the plugin (filename without
79 .so suffix). */
80 const char *full_name; /* Path to the plugin as specified with
81 -fplugin=. */
82 int argc; /* Number of arguments specified with
83 -fplugin-arg-... */
84 struct plugin_argument *argv; /* Array of ARGC key-value pairs. */
85 const char *version; /* Version string provided by plugin. */
86 const char *help; /* Help string provided by plugin. */
87 };
88
89 /* The default version check. Compares every field in VERSION. */
90
91 extern bool plugin_default_version_check (struct plugin_gcc_version *,
92 struct plugin_gcc_version *);
93
94 /* Function type for the plugin initialization routine. Each plugin module
95 should define this as an externally-visible function with name
96 "plugin_init."
97
98 PLUGIN_INFO - plugin invocation information.
99 VERSION - the plugin_gcc_version symbol of GCC.
100
101 Returns 0 if initialization finishes successfully. */
102
103 typedef int (*plugin_init_func) (struct plugin_name_args *plugin_info,
104 struct plugin_gcc_version *version);
105
106 /* Declaration for "plugin_init" function so that it doesn't need to be
107 duplicated in every plugin. */
108 extern int plugin_init (struct plugin_name_args *plugin_info,
109 struct plugin_gcc_version *version);
110
111 /* Function type for a plugin callback routine.
112
113 GCC_DATA - event-specific data provided by GCC
114 USER_DATA - plugin-specific data provided by the plugin */
115
116 typedef void (*plugin_callback_func) (void *gcc_data, void *user_data);
117
118 /* Called from the plugin's initialization code. Register a single callback.
119 This function can be called multiple times.
120
121 PLUGIN_NAME - display name for this plugin
122 EVENT - which event the callback is for
123 CALLBACK - the callback to be called at the event
124 USER_DATA - plugin-provided data.
125 */
126
127 /* Number of event ids / names registered so far. */
128
129 extern int get_event_last (void);
130
131 int get_named_event_id (const char *name, enum insert_option insert);
132
133 /* This is also called without a callback routine for the
134 PLUGIN_PASS_MANAGER_SETUP, PLUGIN_INFO, PLUGIN_REGISTER_GGC_ROOTS and
135 PLUGIN_REGISTER_GGC_CACHES pseudo-events, with a specific user_data.
136 */
137
138 extern void register_callback (const char *plugin_name,
139 int event,
140 plugin_callback_func callback,
141 void *user_data);
142
143 extern int unregister_callback (const char *plugin_name, int event);
144
145
146 /* Retrieve the plugin directory name, as returned by the
147 -fprint-file-name=plugin argument to the gcc program, which is the
148 -iplugindir program argument to cc1. */
149 extern const char* default_plugin_dir_name (void);
150
151 #ifdef __cplusplus
152 }
153 #endif
154
155 /* In case the C++ compiler does name mangling for globals, declare
156 plugin_is_GPL_compatible extern "C" so that a later definition
157 in a plugin file will have this linkage. */
158 #ifdef __cplusplus
159 extern "C" {
160 #endif
161 extern int plugin_is_GPL_compatible;
162 #ifdef __cplusplus
163 }
164 #endif
165 46
166 #endif /* GCC_PLUGIN_H */ 47 #endif /* GCC_PLUGIN_H */