x86/tsc: Limit the adjust value further
[linux/fpc-iii.git] / scripts / gcc-plugins / gcc-generate-ipa-pass.h
blob9bd926e072f0d3b19ccf639012956359ab9b65d9
1 /*
2 * Generator for IPA pass related boilerplate code/data
4 * Supports gcc 4.5-6
6 * Usage:
8 * 1. before inclusion define PASS_NAME
9 * 2. before inclusion define NO_* for unimplemented callbacks
10 * NO_GENERATE_SUMMARY
11 * NO_READ_SUMMARY
12 * NO_WRITE_SUMMARY
13 * NO_READ_OPTIMIZATION_SUMMARY
14 * NO_WRITE_OPTIMIZATION_SUMMARY
15 * NO_STMT_FIXUP
16 * NO_FUNCTION_TRANSFORM
17 * NO_VARIABLE_TRANSFORM
18 * NO_GATE
19 * NO_EXECUTE
20 * 3. before inclusion define PROPERTIES_* and *TODO_FLAGS_* to override
21 * the default 0 values
22 * 4. for convenience, all the above will be undefined after inclusion!
23 * 5. the only exported name is make_PASS_NAME_pass() to register with gcc
26 #ifndef PASS_NAME
27 #error at least PASS_NAME must be defined
28 #else
29 #define __GCC_PLUGIN_STRINGIFY(n) #n
30 #define _GCC_PLUGIN_STRINGIFY(n) __GCC_PLUGIN_STRINGIFY(n)
31 #define _GCC_PLUGIN_CONCAT2(x, y) x ## y
32 #define _GCC_PLUGIN_CONCAT3(x, y, z) x ## y ## z
34 #define __PASS_NAME_PASS_DATA(n) _GCC_PLUGIN_CONCAT2(n, _pass_data)
35 #define _PASS_NAME_PASS_DATA __PASS_NAME_PASS_DATA(PASS_NAME)
37 #define __PASS_NAME_PASS(n) _GCC_PLUGIN_CONCAT2(n, _pass)
38 #define _PASS_NAME_PASS __PASS_NAME_PASS(PASS_NAME)
40 #define _PASS_NAME_NAME _GCC_PLUGIN_STRINGIFY(PASS_NAME)
42 #define __MAKE_PASS_NAME_PASS(n) _GCC_PLUGIN_CONCAT3(make_, n, _pass)
43 #define _MAKE_PASS_NAME_PASS __MAKE_PASS_NAME_PASS(PASS_NAME)
45 #ifdef NO_GENERATE_SUMMARY
46 #define _GENERATE_SUMMARY NULL
47 #else
48 #define __GENERATE_SUMMARY(n) _GCC_PLUGIN_CONCAT2(n, _generate_summary)
49 #define _GENERATE_SUMMARY __GENERATE_SUMMARY(PASS_NAME)
50 #endif
52 #ifdef NO_READ_SUMMARY
53 #define _READ_SUMMARY NULL
54 #else
55 #define __READ_SUMMARY(n) _GCC_PLUGIN_CONCAT2(n, _read_summary)
56 #define _READ_SUMMARY __READ_SUMMARY(PASS_NAME)
57 #endif
59 #ifdef NO_WRITE_SUMMARY
60 #define _WRITE_SUMMARY NULL
61 #else
62 #define __WRITE_SUMMARY(n) _GCC_PLUGIN_CONCAT2(n, _write_summary)
63 #define _WRITE_SUMMARY __WRITE_SUMMARY(PASS_NAME)
64 #endif
66 #ifdef NO_READ_OPTIMIZATION_SUMMARY
67 #define _READ_OPTIMIZATION_SUMMARY NULL
68 #else
69 #define __READ_OPTIMIZATION_SUMMARY(n) _GCC_PLUGIN_CONCAT2(n, _read_optimization_summary)
70 #define _READ_OPTIMIZATION_SUMMARY __READ_OPTIMIZATION_SUMMARY(PASS_NAME)
71 #endif
73 #ifdef NO_WRITE_OPTIMIZATION_SUMMARY
74 #define _WRITE_OPTIMIZATION_SUMMARY NULL
75 #else
76 #define __WRITE_OPTIMIZATION_SUMMARY(n) _GCC_PLUGIN_CONCAT2(n, _write_optimization_summary)
77 #define _WRITE_OPTIMIZATION_SUMMARY __WRITE_OPTIMIZATION_SUMMARY(PASS_NAME)
78 #endif
80 #ifdef NO_STMT_FIXUP
81 #define _STMT_FIXUP NULL
82 #else
83 #define __STMT_FIXUP(n) _GCC_PLUGIN_CONCAT2(n, _stmt_fixup)
84 #define _STMT_FIXUP __STMT_FIXUP(PASS_NAME)
85 #endif
87 #ifdef NO_FUNCTION_TRANSFORM
88 #define _FUNCTION_TRANSFORM NULL
89 #else
90 #define __FUNCTION_TRANSFORM(n) _GCC_PLUGIN_CONCAT2(n, _function_transform)
91 #define _FUNCTION_TRANSFORM __FUNCTION_TRANSFORM(PASS_NAME)
92 #endif
94 #ifdef NO_VARIABLE_TRANSFORM
95 #define _VARIABLE_TRANSFORM NULL
96 #else
97 #define __VARIABLE_TRANSFORM(n) _GCC_PLUGIN_CONCAT2(n, _variable_transform)
98 #define _VARIABLE_TRANSFORM __VARIABLE_TRANSFORM(PASS_NAME)
99 #endif
101 #ifdef NO_GATE
102 #define _GATE NULL
103 #define _HAS_GATE false
104 #else
105 #define __GATE(n) _GCC_PLUGIN_CONCAT2(n, _gate)
106 #define _GATE __GATE(PASS_NAME)
107 #define _HAS_GATE true
108 #endif
110 #ifdef NO_EXECUTE
111 #define _EXECUTE NULL
112 #define _HAS_EXECUTE false
113 #else
114 #define __EXECUTE(n) _GCC_PLUGIN_CONCAT2(n, _execute)
115 #define _EXECUTE __EXECUTE(PASS_NAME)
116 #define _HAS_EXECUTE true
117 #endif
119 #ifndef PROPERTIES_REQUIRED
120 #define PROPERTIES_REQUIRED 0
121 #endif
123 #ifndef PROPERTIES_PROVIDED
124 #define PROPERTIES_PROVIDED 0
125 #endif
127 #ifndef PROPERTIES_DESTROYED
128 #define PROPERTIES_DESTROYED 0
129 #endif
131 #ifndef TODO_FLAGS_START
132 #define TODO_FLAGS_START 0
133 #endif
135 #ifndef TODO_FLAGS_FINISH
136 #define TODO_FLAGS_FINISH 0
137 #endif
139 #ifndef FUNCTION_TRANSFORM_TODO_FLAGS_START
140 #define FUNCTION_TRANSFORM_TODO_FLAGS_START 0
141 #endif
143 #if BUILDING_GCC_VERSION >= 4009
144 namespace {
145 static const pass_data _PASS_NAME_PASS_DATA = {
146 #else
147 static struct ipa_opt_pass_d _PASS_NAME_PASS = {
148 .pass = {
149 #endif
150 .type = IPA_PASS,
151 .name = _PASS_NAME_NAME,
152 #if BUILDING_GCC_VERSION >= 4008
153 .optinfo_flags = OPTGROUP_NONE,
154 #endif
155 #if BUILDING_GCC_VERSION >= 5000
156 #elif BUILDING_GCC_VERSION == 4009
157 .has_gate = _HAS_GATE,
158 .has_execute = _HAS_EXECUTE,
159 #else
160 .gate = _GATE,
161 .execute = _EXECUTE,
162 .sub = NULL,
163 .next = NULL,
164 .static_pass_number = 0,
165 #endif
166 .tv_id = TV_NONE,
167 .properties_required = PROPERTIES_REQUIRED,
168 .properties_provided = PROPERTIES_PROVIDED,
169 .properties_destroyed = PROPERTIES_DESTROYED,
170 .todo_flags_start = TODO_FLAGS_START,
171 .todo_flags_finish = TODO_FLAGS_FINISH,
172 #if BUILDING_GCC_VERSION < 4009
174 .generate_summary = _GENERATE_SUMMARY,
175 .write_summary = _WRITE_SUMMARY,
176 .read_summary = _READ_SUMMARY,
177 #if BUILDING_GCC_VERSION >= 4006
178 .write_optimization_summary = _WRITE_OPTIMIZATION_SUMMARY,
179 .read_optimization_summary = _READ_OPTIMIZATION_SUMMARY,
180 #endif
181 .stmt_fixup = _STMT_FIXUP,
182 .function_transform_todo_flags_start = FUNCTION_TRANSFORM_TODO_FLAGS_START,
183 .function_transform = _FUNCTION_TRANSFORM,
184 .variable_transform = _VARIABLE_TRANSFORM,
185 #endif
188 #if BUILDING_GCC_VERSION >= 4009
189 class _PASS_NAME_PASS : public ipa_opt_pass_d {
190 public:
191 _PASS_NAME_PASS() : ipa_opt_pass_d(_PASS_NAME_PASS_DATA,
193 _GENERATE_SUMMARY,
194 _WRITE_SUMMARY,
195 _READ_SUMMARY,
196 _WRITE_OPTIMIZATION_SUMMARY,
197 _READ_OPTIMIZATION_SUMMARY,
198 _STMT_FIXUP,
199 FUNCTION_TRANSFORM_TODO_FLAGS_START,
200 _FUNCTION_TRANSFORM,
201 _VARIABLE_TRANSFORM) {}
203 #ifndef NO_GATE
204 #if BUILDING_GCC_VERSION >= 5000
205 virtual bool gate(function *) { return _GATE(); }
206 #else
207 virtual bool gate(void) { return _GATE(); }
208 #endif
209 #endif
211 virtual opt_pass *clone() { return new _PASS_NAME_PASS(); }
213 #ifndef NO_EXECUTE
214 #if BUILDING_GCC_VERSION >= 5000
215 virtual unsigned int execute(function *) { return _EXECUTE(); }
216 #else
217 virtual unsigned int execute(void) { return _EXECUTE(); }
218 #endif
219 #endif
223 opt_pass *_MAKE_PASS_NAME_PASS(void)
225 return new _PASS_NAME_PASS();
227 #else
228 struct opt_pass *_MAKE_PASS_NAME_PASS(void)
230 return &_PASS_NAME_PASS.pass;
232 #endif
234 /* clean up user provided defines */
235 #undef PASS_NAME
236 #undef NO_GENERATE_SUMMARY
237 #undef NO_WRITE_SUMMARY
238 #undef NO_READ_SUMMARY
239 #undef NO_WRITE_OPTIMIZATION_SUMMARY
240 #undef NO_READ_OPTIMIZATION_SUMMARY
241 #undef NO_STMT_FIXUP
242 #undef NO_FUNCTION_TRANSFORM
243 #undef NO_VARIABLE_TRANSFORM
244 #undef NO_GATE
245 #undef NO_EXECUTE
247 #undef FUNCTION_TRANSFORM_TODO_FLAGS_START
248 #undef PROPERTIES_DESTROYED
249 #undef PROPERTIES_PROVIDED
250 #undef PROPERTIES_REQUIRED
251 #undef TODO_FLAGS_FINISH
252 #undef TODO_FLAGS_START
254 /* clean up generated defines */
255 #undef _EXECUTE
256 #undef __EXECUTE
257 #undef _FUNCTION_TRANSFORM
258 #undef __FUNCTION_TRANSFORM
259 #undef _GATE
260 #undef __GATE
261 #undef _GCC_PLUGIN_CONCAT2
262 #undef _GCC_PLUGIN_CONCAT3
263 #undef _GCC_PLUGIN_STRINGIFY
264 #undef __GCC_PLUGIN_STRINGIFY
265 #undef _GENERATE_SUMMARY
266 #undef __GENERATE_SUMMARY
267 #undef _HAS_EXECUTE
268 #undef _HAS_GATE
269 #undef _MAKE_PASS_NAME_PASS
270 #undef __MAKE_PASS_NAME_PASS
271 #undef _PASS_NAME_NAME
272 #undef _PASS_NAME_PASS
273 #undef __PASS_NAME_PASS
274 #undef _PASS_NAME_PASS_DATA
275 #undef __PASS_NAME_PASS_DATA
276 #undef _READ_OPTIMIZATION_SUMMARY
277 #undef __READ_OPTIMIZATION_SUMMARY
278 #undef _READ_SUMMARY
279 #undef __READ_SUMMARY
280 #undef _STMT_FIXUP
281 #undef __STMT_FIXUP
282 #undef _VARIABLE_TRANSFORM
283 #undef __VARIABLE_TRANSFORM
284 #undef _WRITE_OPTIMIZATION_SUMMARY
285 #undef __WRITE_OPTIMIZATION_SUMMARY
286 #undef _WRITE_SUMMARY
287 #undef __WRITE_SUMMARY
289 #endif /* PASS_NAME */