1 /* SPDX-License-Identifier: GPL-2.0 */
3 * Generator for GIMPLE pass related boilerplate code/data
9 * 1. before inclusion define PASS_NAME
10 * 2. before inclusion define NO_* for unimplemented callbacks
13 * 3. before inclusion define PROPERTIES_* and TODO_FLAGS_* to override
14 * the default 0 values
15 * 4. for convenience, all the above will be undefined after inclusion!
16 * 5. the only exported name is make_PASS_NAME_pass() to register with gcc
20 #error at least PASS_NAME must be defined
22 #define __GCC_PLUGIN_STRINGIFY(n) #n
23 #define _GCC_PLUGIN_STRINGIFY(n) __GCC_PLUGIN_STRINGIFY(n)
24 #define _GCC_PLUGIN_CONCAT2(x, y) x ## y
25 #define _GCC_PLUGIN_CONCAT3(x, y, z) x ## y ## z
27 #define __PASS_NAME_PASS_DATA(n) _GCC_PLUGIN_CONCAT2(n, _pass_data)
28 #define _PASS_NAME_PASS_DATA __PASS_NAME_PASS_DATA(PASS_NAME)
30 #define __PASS_NAME_PASS(n) _GCC_PLUGIN_CONCAT2(n, _pass)
31 #define _PASS_NAME_PASS __PASS_NAME_PASS(PASS_NAME)
33 #define _PASS_NAME_NAME _GCC_PLUGIN_STRINGIFY(PASS_NAME)
35 #define __MAKE_PASS_NAME_PASS(n) _GCC_PLUGIN_CONCAT3(make_, n, _pass)
36 #define _MAKE_PASS_NAME_PASS __MAKE_PASS_NAME_PASS(PASS_NAME)
40 #define _HAS_GATE false
42 #define __GATE(n) _GCC_PLUGIN_CONCAT2(n, _gate)
43 #define _GATE __GATE(PASS_NAME)
44 #define _HAS_GATE true
49 #define _HAS_EXECUTE false
51 #define __EXECUTE(n) _GCC_PLUGIN_CONCAT2(n, _execute)
52 #define _EXECUTE __EXECUTE(PASS_NAME)
53 #define _HAS_EXECUTE true
56 #ifndef PROPERTIES_REQUIRED
57 #define PROPERTIES_REQUIRED 0
60 #ifndef PROPERTIES_PROVIDED
61 #define PROPERTIES_PROVIDED 0
64 #ifndef PROPERTIES_DESTROYED
65 #define PROPERTIES_DESTROYED 0
68 #ifndef TODO_FLAGS_START
69 #define TODO_FLAGS_START 0
72 #ifndef TODO_FLAGS_FINISH
73 #define TODO_FLAGS_FINISH 0
77 static const pass_data _PASS_NAME_PASS_DATA
= {
79 .name
= _PASS_NAME_NAME
,
80 .optinfo_flags
= OPTGROUP_NONE
,
81 #if BUILDING_GCC_VERSION >= 5000
82 #elif BUILDING_GCC_VERSION == 4009
83 .has_gate
= _HAS_GATE
,
84 .has_execute
= _HAS_EXECUTE
,
90 .static_pass_number
= 0,
93 .properties_required
= PROPERTIES_REQUIRED
,
94 .properties_provided
= PROPERTIES_PROVIDED
,
95 .properties_destroyed
= PROPERTIES_DESTROYED
,
96 .todo_flags_start
= TODO_FLAGS_START
,
97 .todo_flags_finish
= TODO_FLAGS_FINISH
,
100 class _PASS_NAME_PASS
: public gimple_opt_pass
{
102 _PASS_NAME_PASS() : gimple_opt_pass(_PASS_NAME_PASS_DATA
, g
) {}
105 #if BUILDING_GCC_VERSION >= 5000
106 virtual bool gate(function
*) { return _GATE(); }
108 virtual bool gate(void) { return _GATE(); }
112 virtual opt_pass
* clone () { return new _PASS_NAME_PASS(); }
115 #if BUILDING_GCC_VERSION >= 5000
116 virtual unsigned int execute(function
*) { return _EXECUTE(); }
118 virtual unsigned int execute(void) { return _EXECUTE(); }
123 opt_pass
*_MAKE_PASS_NAME_PASS(void)
125 return new _PASS_NAME_PASS();
128 struct opt_pass
*_MAKE_PASS_NAME_PASS(void)
130 return &_PASS_NAME_PASS
.pass
;
134 /* clean up user provided defines */
139 #undef PROPERTIES_DESTROYED
140 #undef PROPERTIES_PROVIDED
141 #undef PROPERTIES_REQUIRED
142 #undef TODO_FLAGS_FINISH
143 #undef TODO_FLAGS_START
145 /* clean up generated defines */
150 #undef _GCC_PLUGIN_CONCAT2
151 #undef _GCC_PLUGIN_CONCAT3
152 #undef _GCC_PLUGIN_STRINGIFY
153 #undef __GCC_PLUGIN_STRINGIFY
156 #undef _MAKE_PASS_NAME_PASS
157 #undef __MAKE_PASS_NAME_PASS
158 #undef _PASS_NAME_NAME
159 #undef _PASS_NAME_PASS
160 #undef __PASS_NAME_PASS
161 #undef _PASS_NAME_PASS_DATA
162 #undef __PASS_NAME_PASS_DATA
164 #endif /* PASS_NAME */