2 * Generator for IPA pass related boilerplate code/data
8 * 1. before inclusion define PASS_NAME
9 * 2. before inclusion define NO_* for unimplemented callbacks
13 * NO_READ_OPTIMIZATION_SUMMARY
14 * NO_WRITE_OPTIMIZATION_SUMMARY
16 * NO_FUNCTION_TRANSFORM
17 * NO_VARIABLE_TRANSFORM
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
27 #error at least PASS_NAME must be defined
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
48 #define __GENERATE_SUMMARY(n) _GCC_PLUGIN_CONCAT2(n, _generate_summary)
49 #define _GENERATE_SUMMARY __GENERATE_SUMMARY(PASS_NAME)
52 #ifdef NO_READ_SUMMARY
53 #define _READ_SUMMARY NULL
55 #define __READ_SUMMARY(n) _GCC_PLUGIN_CONCAT2(n, _read_summary)
56 #define _READ_SUMMARY __READ_SUMMARY(PASS_NAME)
59 #ifdef NO_WRITE_SUMMARY
60 #define _WRITE_SUMMARY NULL
62 #define __WRITE_SUMMARY(n) _GCC_PLUGIN_CONCAT2(n, _write_summary)
63 #define _WRITE_SUMMARY __WRITE_SUMMARY(PASS_NAME)
66 #ifdef NO_READ_OPTIMIZATION_SUMMARY
67 #define _READ_OPTIMIZATION_SUMMARY NULL
69 #define __READ_OPTIMIZATION_SUMMARY(n) _GCC_PLUGIN_CONCAT2(n, _read_optimization_summary)
70 #define _READ_OPTIMIZATION_SUMMARY __READ_OPTIMIZATION_SUMMARY(PASS_NAME)
73 #ifdef NO_WRITE_OPTIMIZATION_SUMMARY
74 #define _WRITE_OPTIMIZATION_SUMMARY NULL
76 #define __WRITE_OPTIMIZATION_SUMMARY(n) _GCC_PLUGIN_CONCAT2(n, _write_optimization_summary)
77 #define _WRITE_OPTIMIZATION_SUMMARY __WRITE_OPTIMIZATION_SUMMARY(PASS_NAME)
81 #define _STMT_FIXUP NULL
83 #define __STMT_FIXUP(n) _GCC_PLUGIN_CONCAT2(n, _stmt_fixup)
84 #define _STMT_FIXUP __STMT_FIXUP(PASS_NAME)
87 #ifdef NO_FUNCTION_TRANSFORM
88 #define _FUNCTION_TRANSFORM NULL
90 #define __FUNCTION_TRANSFORM(n) _GCC_PLUGIN_CONCAT2(n, _function_transform)
91 #define _FUNCTION_TRANSFORM __FUNCTION_TRANSFORM(PASS_NAME)
94 #ifdef NO_VARIABLE_TRANSFORM
95 #define _VARIABLE_TRANSFORM NULL
97 #define __VARIABLE_TRANSFORM(n) _GCC_PLUGIN_CONCAT2(n, _variable_transform)
98 #define _VARIABLE_TRANSFORM __VARIABLE_TRANSFORM(PASS_NAME)
103 #define _HAS_GATE false
105 #define __GATE(n) _GCC_PLUGIN_CONCAT2(n, _gate)
106 #define _GATE __GATE(PASS_NAME)
107 #define _HAS_GATE true
111 #define _EXECUTE NULL
112 #define _HAS_EXECUTE false
114 #define __EXECUTE(n) _GCC_PLUGIN_CONCAT2(n, _execute)
115 #define _EXECUTE __EXECUTE(PASS_NAME)
116 #define _HAS_EXECUTE true
119 #ifndef PROPERTIES_REQUIRED
120 #define PROPERTIES_REQUIRED 0
123 #ifndef PROPERTIES_PROVIDED
124 #define PROPERTIES_PROVIDED 0
127 #ifndef PROPERTIES_DESTROYED
128 #define PROPERTIES_DESTROYED 0
131 #ifndef TODO_FLAGS_START
132 #define TODO_FLAGS_START 0
135 #ifndef TODO_FLAGS_FINISH
136 #define TODO_FLAGS_FINISH 0
139 #ifndef FUNCTION_TRANSFORM_TODO_FLAGS_START
140 #define FUNCTION_TRANSFORM_TODO_FLAGS_START 0
143 #if BUILDING_GCC_VERSION >= 4009
145 static const pass_data _PASS_NAME_PASS_DATA
= {
147 static struct ipa_opt_pass_d _PASS_NAME_PASS
= {
151 .name
= _PASS_NAME_NAME
,
152 #if BUILDING_GCC_VERSION >= 4008
153 .optinfo_flags
= OPTGROUP_NONE
,
155 #if BUILDING_GCC_VERSION >= 5000
156 #elif BUILDING_GCC_VERSION == 4009
157 .has_gate
= _HAS_GATE
,
158 .has_execute
= _HAS_EXECUTE
,
164 .static_pass_number
= 0,
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
,
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
,
188 #if BUILDING_GCC_VERSION >= 4009
189 class _PASS_NAME_PASS
: public ipa_opt_pass_d
{
191 _PASS_NAME_PASS() : ipa_opt_pass_d(_PASS_NAME_PASS_DATA
,
196 _WRITE_OPTIMIZATION_SUMMARY
,
197 _READ_OPTIMIZATION_SUMMARY
,
199 FUNCTION_TRANSFORM_TODO_FLAGS_START
,
201 _VARIABLE_TRANSFORM
) {}
204 #if BUILDING_GCC_VERSION >= 5000
205 virtual bool gate(function
*) { return _GATE(); }
207 virtual bool gate(void) { return _GATE(); }
211 virtual opt_pass
*clone() { return new _PASS_NAME_PASS(); }
214 #if BUILDING_GCC_VERSION >= 5000
215 virtual unsigned int execute(function
*) { return _EXECUTE(); }
217 virtual unsigned int execute(void) { return _EXECUTE(); }
223 opt_pass
*_MAKE_PASS_NAME_PASS(void)
225 return new _PASS_NAME_PASS();
228 struct opt_pass
*_MAKE_PASS_NAME_PASS(void)
230 return &_PASS_NAME_PASS
.pass
;
234 /* clean up user provided defines */
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
242 #undef NO_FUNCTION_TRANSFORM
243 #undef NO_VARIABLE_TRANSFORM
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 */
257 #undef _FUNCTION_TRANSFORM
258 #undef __FUNCTION_TRANSFORM
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
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
279 #undef __READ_SUMMARY
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 */