llvm.org GIT mirror llvm / d86b052
Run clang-format over PassSupport.h, mostly to get the macros all formatted fancily. I'm working on rewriting these macros to use the new call_once stuff, but really want to have clang-format work on the edits, so just re-baselining the entire file here. No changes other than clang-format. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@271635 91177308-0d34-0410-b5e6-96231b3b80d8 Chandler Carruth 4 years ago
1 changed file(s) with 113 addition(s) and 122 deletion(s). Raw diff Collapse all Expand all
3030
3131 class TargetMachine;
3232
33 #define CALL_ONCE_INITIALIZATION(function) \
34 static volatile sys::cas_flag initialized = 0; \
35 sys::cas_flag old_val = sys::CompareAndSwap(&initialized, 1, 0); \
36 if (old_val == 0) { \
37 function(Registry); \
38 sys::MemoryFence(); \
39 TsanIgnoreWritesBegin(); \
40 TsanHappensBefore(&initialized); \
41 initialized = 2; \
42 TsanIgnoreWritesEnd(); \
43 } else { \
44 sys::cas_flag tmp = initialized; \
45 sys::MemoryFence(); \
46 while (tmp != 2) { \
47 tmp = initialized; \
48 sys::MemoryFence(); \
49 } \
50 } \
33 #define CALL_ONCE_INITIALIZATION(function) \
34 static volatile sys::cas_flag initialized = 0; \
35 sys::cas_flag old_val = sys::CompareAndSwap(&initialized, 1, 0); \
36 if (old_val == 0) { \
37 function(Registry); \
38 sys::MemoryFence(); \
39 TsanIgnoreWritesBegin(); \
40 TsanHappensBefore(&initialized); \
41 initialized = 2; \
42 TsanIgnoreWritesEnd(); \
43 } else { \
44 sys::cas_flag tmp = initialized; \
45 sys::MemoryFence(); \
46 while (tmp != 2) { \
47 tmp = initialized; \
48 sys::MemoryFence(); \
49 } \
50 } \
5151 TsanHappensAfter(&initialized);
5252
53 #define INITIALIZE_PASS(passName, arg, name, cfg, analysis) \
54 static void* initialize##passName##PassOnce(PassRegistry &Registry) { \
55 PassInfo *PI = new PassInfo(name, arg, & passName ::ID, \
56 PassInfo::NormalCtor_t(callDefaultCtor< passName >), cfg, analysis); \
57 Registry.registerPass(*PI, true); \
58 return PI; \
59 } \
60 void llvm::initialize##passName##Pass(PassRegistry &Registry) { \
61 CALL_ONCE_INITIALIZATION(initialize##passName##PassOnce) \
62 }
63
64 #define INITIALIZE_PASS_BEGIN(passName, arg, name, cfg, analysis) \
65 static void* initialize##passName##PassOnce(PassRegistry &Registry) {
66
67 #define INITIALIZE_PASS_DEPENDENCY(depName) \
68 initialize##depName##Pass(Registry);
69 #define INITIALIZE_AG_DEPENDENCY(depName) \
70 initialize##depName##AnalysisGroup(Registry);
71
72 #define INITIALIZE_PASS_END(passName, arg, name, cfg, analysis) \
73 PassInfo *PI = new PassInfo(name, arg, & passName ::ID, \
74 PassInfo::NormalCtor_t(callDefaultCtor< passName >), cfg, analysis); \
75 Registry.registerPass(*PI, true); \
76 return PI; \
77 } \
78 void llvm::initialize##passName##Pass(PassRegistry &Registry) { \
79 CALL_ONCE_INITIALIZATION(initialize##passName##PassOnce) \
80 }
81
82 #define INITIALIZE_PASS_WITH_OPTIONS(PassName, Arg, Name, Cfg, Analysis) \
83 INITIALIZE_PASS_BEGIN(PassName, Arg, Name, Cfg, Analysis) \
84 PassName::registerOptions(); \
53 #define INITIALIZE_PASS(passName, arg, name, cfg, analysis) \
54 static void *initialize##passName##PassOnce(PassRegistry &Registry) { \
55 PassInfo *PI = new PassInfo( \
56 name, arg, &passName::ID, \
57 PassInfo::NormalCtor_t(callDefaultCtor), cfg, analysis); \
58 Registry.registerPass(*PI, true); \
59 return PI; \
60 } \
61 void llvm::initialize##passName##Pass(PassRegistry &Registry) { \
62 CALL_ONCE_INITIALIZATION(initialize##passName##PassOnce) \
63 }
64
65 #define INITIALIZE_PASS_BEGIN(passName, arg, name, cfg, analysis) \
66 static void *initialize##passName##PassOnce(PassRegistry &Registry) {
67
68 #define INITIALIZE_PASS_DEPENDENCY(depName) initialize##depName##Pass(Registry);
69 #define INITIALIZE_AG_DEPENDENCY(depName) \
70 initialize##depName##AnalysisGroup(Registry);
71
72 #define INITIALIZE_PASS_END(passName, arg, name, cfg, analysis) \
73 PassInfo *PI = new PassInfo( \
74 name, arg, &passName::ID, \
75 PassInfo::NormalCtor_t(callDefaultCtor), cfg, analysis); \
76 Registry.registerPass(*PI, true); \
77 return PI; \
78 } \
79 void llvm::initialize##passName##Pass(PassRegistry &Registry) { \
80 CALL_ONCE_INITIALIZATION(initialize##passName##PassOnce) \
81 }
82
83 #define INITIALIZE_PASS_WITH_OPTIONS(PassName, Arg, Name, Cfg, Analysis) \
84 INITIALIZE_PASS_BEGIN(PassName, Arg, Name, Cfg, Analysis) \
85 PassName::registerOptions(); \
8586 INITIALIZE_PASS_END(PassName, Arg, Name, Cfg, Analysis)
8687
8788 #define INITIALIZE_PASS_WITH_OPTIONS_BEGIN(PassName, Arg, Name, Cfg, Analysis) \
88 INITIALIZE_PASS_BEGIN(PassName, Arg, Name, Cfg, Analysis) \
89 PassName::registerOptions(); \
90
91 template
92 Pass *callDefaultCtor() { return new PassName(); }
89 INITIALIZE_PASS_BEGIN(PassName, Arg, Name, Cfg, Analysis) \
90 PassName::registerOptions();
91
92 template Pass *callDefaultCtor() { return new PassName(); }
9393
9494 template Pass *callTargetMachineCtor(TargetMachine *TM) {
9595 return new PassName(TM);
112112 ///
113113 /// static RegisterPass tmp("passopt", "My Name");
114114 ///
115 template
116 struct RegisterPass : public PassInfo {
117
115 template struct RegisterPass : public PassInfo {
118116 // Register Pass using default constructor...
119117 RegisterPass(const char *PassArg, const char *Name, bool CFGOnly = false,
120118 bool is_analysis = false)
121 : PassInfo(Name, PassArg, &passName::ID,
122 PassInfo::NormalCtor_t(callDefaultCtor),
123 CFGOnly, is_analysis) {
119 : PassInfo(Name, PassArg, &passName::ID,
120 PassInfo::NormalCtor_t(callDefaultCtor), CFGOnly,
121 is_analysis) {
124122 PassRegistry::getPassRegistry()->registerPass(*this);
125123 }
126124 };
127
128125
129126 /// RegisterAnalysisGroup - Register a Pass as a member of an analysis _group_.
130127 /// Analysis groups are used to define an interface (which need not derive from
147144 ///
148145 class RegisterAGBase : public PassInfo {
149146 public:
150 RegisterAGBase(const char *Name,
151 const void *InterfaceID,
152 const void *PassID = nullptr,
153 bool isDefault = false);
154 };
155
156 template
147 RegisterAGBase(const char *Name, const void *InterfaceID,
148 const void *PassID = nullptr, bool isDefault = false);
149 };
150
151 template
157152 struct RegisterAnalysisGroup : public RegisterAGBase {
158153 explicit RegisterAnalysisGroup(PassInfo &RPB)
159 : RegisterAGBase(RPB.getPassName(),
160 &Interface::ID, RPB.getTypeInfo(),
161 Default) {
162 }
154 : RegisterAGBase(RPB.getPassName(), &Interface::ID, RPB.getTypeInfo(),
155 Default) {}
163156
164157 explicit RegisterAnalysisGroup(const char *Name)
165 : RegisterAGBase(Name, &Interface::ID) {
166 }
167 };
168
169 #define INITIALIZE_ANALYSIS_GROUP(agName, name, defaultPass) \
170 static void* initialize##agName##AnalysisGroupOnce(PassRegistry &Registry) { \
171 initialize##defaultPass##Pass(Registry); \
172 PassInfo *AI = new PassInfo(name, & agName :: ID); \
173 Registry.registerAnalysisGroup(& agName ::ID, 0, *AI, false, true); \
174 return AI; \
175 } \
176 void llvm::initialize##agName##AnalysisGroup(PassRegistry &Registry) { \
177 CALL_ONCE_INITIALIZATION(initialize##agName##AnalysisGroupOnce) \
178 }
179
180
181 #define INITIALIZE_AG_PASS(passName, agName, arg, name, cfg, analysis, def) \
182 static void* initialize##passName##PassOnce(PassRegistry &Registry) { \
183 if (!def) initialize##agName##AnalysisGroup(Registry); \
184 PassInfo *PI = new PassInfo(name, arg, & passName ::ID, \
185 PassInfo::NormalCtor_t(callDefaultCtor< passName >), cfg, analysis); \
186 Registry.registerPass(*PI, true); \
187 \
188 PassInfo *AI = new PassInfo(name, & agName :: ID); \
189 Registry.registerAnalysisGroup(& agName ::ID, & passName ::ID, \
190 *AI, def, true); \
191 return AI; \
192 } \
193 void llvm::initialize##passName##Pass(PassRegistry &Registry) { \
194 CALL_ONCE_INITIALIZATION(initialize##passName##PassOnce) \
195 }
196
158 : RegisterAGBase(Name, &Interface::ID) {}
159 };
160
161 #define INITIALIZE_ANALYSIS_GROUP(agName, name, defaultPass) \
162 static void *initialize##agName##AnalysisGroupOnce(PassRegistry &Registry) { \
163 initialize##defaultPass##Pass(Registry); \
164 PassInfo *AI = new PassInfo(name, &agName::ID); \
165 Registry.registerAnalysisGroup(&agName::ID, 0, *AI, false, true); \
166 return AI; \
167 } \
168 void llvm::initialize##agName##AnalysisGroup(PassRegistry &Registry) { \
169 CALL_ONCE_INITIALIZATION(initialize##agName##AnalysisGroupOnce) \
170 }
171
172 #define INITIALIZE_AG_PASS(passName, agName, arg, name, cfg, analysis, def) \
173 static void *initialize##passName##PassOnce(PassRegistry &Registry) { \
174 if (!def) \
175 initialize##agName##AnalysisGroup(Registry); \
176 PassInfo *PI = new PassInfo( \
177 name, arg, &passName::ID, \
178 PassInfo::NormalCtor_t(callDefaultCtor), cfg, analysis); \
179 Registry.registerPass(*PI, true); \
180 \
181 PassInfo *AI = new PassInfo(name, &agName::ID); \
182 Registry.registerAnalysisGroup(&agName::ID, &passName::ID, *AI, def, \
183 true); \
184 return AI; \
185 } \
186 void llvm::initialize##passName##Pass(PassRegistry &Registry) { \
187 CALL_ONCE_INITIALIZATION(initialize##passName##PassOnce) \
188 }
197189
198190 #define INITIALIZE_AG_PASS_BEGIN(passName, agName, arg, n, cfg, analysis, def) \
199 static void* initialize##passName##PassOnce(PassRegistry &Registry) { \
200 if (!def) initialize##agName##AnalysisGroup(Registry);
201
202 #define INITIALIZE_AG_PASS_END(passName, agName, arg, n, cfg, analysis, def) \
203 PassInfo *PI = new PassInfo(n, arg, & passName ::ID, \
204 PassInfo::NormalCtor_t(callDefaultCtor< passName >), cfg, analysis); \
205 Registry.registerPass(*PI, true); \
206 \
207 PassInfo *AI = new PassInfo(n, & agName :: ID); \
208 Registry.registerAnalysisGroup(& agName ::ID, & passName ::ID, \
209 *AI, def, true); \
210 return AI; \
211 } \
212 void llvm::initialize##passName##Pass(PassRegistry &Registry) { \
213 CALL_ONCE_INITIALIZATION(initialize##passName##PassOnce) \
191 static void *initialize##passName##PassOnce(PassRegistry &Registry) { \
192 if (!def) \
193 initialize##agName##AnalysisGroup(Registry);
194
195 #define INITIALIZE_AG_PASS_END(passName, agName, arg, n, cfg, analysis, def) \
196 PassInfo *PI = new PassInfo( \
197 n, arg, &passName::ID, \
198 PassInfo::NormalCtor_t(callDefaultCtor), cfg, analysis); \
199 Registry.registerPass(*PI, true); \
200 \
201 PassInfo *AI = new PassInfo(n, &agName::ID); \
202 Registry.registerAnalysisGroup(&agName::ID, &passName::ID, *AI, def, true); \
203 return AI; \
204 } \
205 void llvm::initialize##passName##Pass(PassRegistry &Registry) { \
206 CALL_ONCE_INITIALIZATION(initialize##passName##PassOnce) \
214207 }
215208
216209 //===---------------------------------------------------------------------------
221214 /// loaded).
222215 ///
223216 struct PassRegistrationListener {
224
225217 PassRegistrationListener() {}
226218 virtual ~PassRegistrationListener() {}
227219
241233 virtual void passEnumerate(const PassInfo *) {}
242234 };
243235
244
245236 } // End llvm namespace
246237
247238 #endif