2 * Generator for GIMPLE pass related boilerplate code/data
8 * 1. before inclusion define PASS_NAME
9 * 2. before inclusion define NO_* for unimplemented callbacks
12 * 3. before inclusion define PROPERTIES_* and TODO_FLAGS_* to override
13 * the default 0 values
14 * 4. for convenience, all the above will be undefined after inclusion!
15 * 5. the only exported name is make_PASS_NAME_pass() to register with gcc
19 #error at least PASS_NAME must be defined
21 #define __GCC_PLUGIN_STRINGIFY(n) #n
22 #define _GCC_PLUGIN_STRINGIFY(n) __GCC_PLUGIN_STRINGIFY(n)
23 #define _GCC_PLUGIN_CONCAT2(x, y) x ## y
24 #define _GCC_PLUGIN_CONCAT3(x, y, z) x ## y ## z
26 #define __PASS_NAME_PASS_DATA(n) _GCC_PLUGIN_CONCAT2(n, _pass_data)
27 #define _PASS_NAME_PASS_DATA __PASS_NAME_PASS_DATA(PASS_NAME)
29 #define __PASS_NAME_PASS(n) _GCC_PLUGIN_CONCAT2(n, _pass)
30 #define _PASS_NAME_PASS __PASS_NAME_PASS(PASS_NAME)
32 #define _PASS_NAME_NAME _GCC_PLUGIN_STRINGIFY(PASS_NAME)
34 #define __MAKE_PASS_NAME_PASS(n) _GCC_PLUGIN_CONCAT3(make_, n, _pass)
35 #define _MAKE_PASS_NAME_PASS __MAKE_PASS_NAME_PASS(PASS_NAME)
39 #define _HAS_GATE false
41 #define __GATE(n) _GCC_PLUGIN_CONCAT2(n, _gate)
42 #define _GATE __GATE(PASS_NAME)
43 #define _HAS_GATE true
48 #define _HAS_EXECUTE false
50 #define __EXECUTE(n) _GCC_PLUGIN_CONCAT2(n, _execute)
51 #define _EXECUTE __EXECUTE(PASS_NAME)
52 #define _HAS_EXECUTE true
55 #ifndef PROPERTIES_REQUIRED
56 #define PROPERTIES_REQUIRED 0
59 #ifndef PROPERTIES_PROVIDED
60 #define PROPERTIES_PROVIDED 0
63 #ifndef PROPERTIES_DESTROYED
64 #define PROPERTIES_DESTROYED 0
67 #ifndef TODO_FLAGS_START
68 #define TODO_FLAGS_START 0
71 #ifndef TODO_FLAGS_FINISH
72 #define TODO_FLAGS_FINISH 0
75 #if BUILDING_GCC_VERSION >= 4009
77 static const pass_data _PASS_NAME_PASS_DATA
= {
79 static struct gimple_opt_pass _PASS_NAME_PASS
= {
83 .name
= _PASS_NAME_NAME
,
84 #if BUILDING_GCC_VERSION >= 4008
85 .optinfo_flags
= OPTGROUP_NONE
,
87 #if BUILDING_GCC_VERSION >= 5000
88 #elif BUILDING_GCC_VERSION == 4009
89 .has_gate
= _HAS_GATE
,
90 .has_execute
= _HAS_EXECUTE
,
96 .static_pass_number
= 0,
99 .properties_required
= PROPERTIES_REQUIRED
,
100 .properties_provided
= PROPERTIES_PROVIDED
,
101 .properties_destroyed
= PROPERTIES_DESTROYED
,
102 .todo_flags_start
= TODO_FLAGS_START
,
103 .todo_flags_finish
= TODO_FLAGS_FINISH
,
104 #if BUILDING_GCC_VERSION < 4009
109 #if BUILDING_GCC_VERSION >= 4009
110 class _PASS_NAME_PASS
: public gimple_opt_pass
{
112 _PASS_NAME_PASS() : gimple_opt_pass(_PASS_NAME_PASS_DATA
, g
) {}
115 #if BUILDING_GCC_VERSION >= 5000
116 virtual bool gate(function
*) { return _GATE(); }
118 virtual bool gate(void) { return _GATE(); }
122 virtual opt_pass
* clone () { return new _PASS_NAME_PASS(); }
125 #if BUILDING_GCC_VERSION >= 5000
126 virtual unsigned int execute(function
*) { return _EXECUTE(); }
128 virtual unsigned int execute(void) { return _EXECUTE(); }
134 opt_pass
*_MAKE_PASS_NAME_PASS(void)
136 return new _PASS_NAME_PASS();
139 struct opt_pass
*_MAKE_PASS_NAME_PASS(void)
141 return &_PASS_NAME_PASS
.pass
;
145 /* clean up user provided defines */
150 #undef PROPERTIES_DESTROYED
151 #undef PROPERTIES_PROVIDED
152 #undef PROPERTIES_REQUIRED
153 #undef TODO_FLAGS_FINISH
154 #undef TODO_FLAGS_START
156 /* clean up generated defines */
161 #undef _GCC_PLUGIN_CONCAT2
162 #undef _GCC_PLUGIN_CONCAT3
163 #undef _GCC_PLUGIN_STRINGIFY
164 #undef __GCC_PLUGIN_STRINGIFY
167 #undef _MAKE_PASS_NAME_PASS
168 #undef __MAKE_PASS_NAME_PASS
169 #undef _PASS_NAME_NAME
170 #undef _PASS_NAME_PASS
171 #undef __PASS_NAME_PASS
172 #undef _PASS_NAME_PASS_DATA
173 #undef __PASS_NAME_PASS_DATA
175 #endif /* PASS_NAME */