21 #ifndef LLVM_PASSSUPPORT_H
22 #define LLVM_PASSSUPPORT_H
36 #define CALL_ONCE_INITIALIZATION(function) \
37 static volatile sys::cas_flag initialized = 0; \
38 sys::cas_flag old_val = sys::CompareAndSwap(&initialized, 1, 0); \
42 TsanIgnoreWritesBegin(); \
43 TsanHappensBefore(&initialized); \
45 TsanIgnoreWritesEnd(); \
47 sys::cas_flag tmp = initialized; \
54 TsanHappensAfter(&initialized);
56 #define INITIALIZE_PASS(passName, arg, name, cfg, analysis) \
57 static void* initialize##passName##PassOnce(PassRegistry &Registry) { \
58 PassInfo *PI = new PassInfo(name, arg, & passName ::ID, \
59 PassInfo::NormalCtor_t(callDefaultCtor< passName >), cfg, analysis); \
60 Registry.registerPass(*PI, true); \
63 void llvm::initialize##passName##Pass(PassRegistry &Registry) { \
64 CALL_ONCE_INITIALIZATION(initialize##passName##PassOnce) \
67 #define INITIALIZE_PASS_BEGIN(passName, arg, name, cfg, analysis) \
68 static void* initialize##passName##PassOnce(PassRegistry &Registry) {
70 #define INITIALIZE_PASS_DEPENDENCY(depName) \
71 initialize##depName##Pass(Registry);
72 #define INITIALIZE_AG_DEPENDENCY(depName) \
73 initialize##depName##AnalysisGroup(Registry);
75 #define INITIALIZE_PASS_END(passName, arg, name, cfg, analysis) \
76 PassInfo *PI = new PassInfo(name, arg, & passName ::ID, \
77 PassInfo::NormalCtor_t(callDefaultCtor< passName >), cfg, analysis); \
78 Registry.registerPass(*PI, true); \
81 void llvm::initialize##passName##Pass(PassRegistry &Registry) { \
82 CALL_ONCE_INITIALIZATION(initialize##passName##PassOnce) \
85 #define INITIALIZE_PASS_WITH_OPTIONS(PassName, Arg, Name, Cfg, Analysis) \
86 INITIALIZE_PASS_BEGIN(PassName, Arg, Name, Cfg, Analysis) \
87 PassName::registerOptions(); \
88 INITIALIZE_PASS_END(PassName, Arg, Name, Cfg, Analysis)
90 #define INITIALIZE_PASS_WITH_OPTIONS_BEGIN(PassName, Arg, Name, Cfg, Analysis) \
91 INITIALIZE_PASS_BEGIN(PassName, Arg, Name, Cfg, Analysis) \
92 PassName::registerOptions(); \
94 template<
typename PassName>
98 return new PassName(TM);
118 template<
typename passName>
123 bool is_analysis =
false)
126 CFGOnly, is_analysis) {
154 const void *InterfaceID,
155 const void *PassID =
nullptr,
156 bool isDefault =
false);
159 template<
typename Interface,
bool Default = false>
172 #define INITIALIZE_ANALYSIS_GROUP(agName, name, defaultPass) \
173 static void* initialize##agName##AnalysisGroupOnce(PassRegistry &Registry) { \
174 initialize##defaultPass##Pass(Registry); \
175 PassInfo *AI = new PassInfo(name, & agName :: ID); \
176 Registry.registerAnalysisGroup(& agName ::ID, 0, *AI, false, true); \
179 void llvm::initialize##agName##AnalysisGroup(PassRegistry &Registry) { \
180 CALL_ONCE_INITIALIZATION(initialize##agName##AnalysisGroupOnce) \
184 #define INITIALIZE_AG_PASS(passName, agName, arg, name, cfg, analysis, def) \
185 static void* initialize##passName##PassOnce(PassRegistry &Registry) { \
186 if (!def) initialize##agName##AnalysisGroup(Registry); \
187 PassInfo *PI = new PassInfo(name, arg, & passName ::ID, \
188 PassInfo::NormalCtor_t(callDefaultCtor< passName >), cfg, analysis); \
189 Registry.registerPass(*PI, true); \
191 PassInfo *AI = new PassInfo(name, & agName :: ID); \
192 Registry.registerAnalysisGroup(& agName ::ID, & passName ::ID, \
196 void llvm::initialize##passName##Pass(PassRegistry &Registry) { \
197 CALL_ONCE_INITIALIZATION(initialize##passName##PassOnce) \
201 #define INITIALIZE_AG_PASS_BEGIN(passName, agName, arg, n, cfg, analysis, def) \
202 static void* initialize##passName##PassOnce(PassRegistry &Registry) { \
203 if (!def) initialize##agName##AnalysisGroup(Registry);
205 #define INITIALIZE_AG_PASS_END(passName, agName, arg, n, cfg, analysis, def) \
206 PassInfo *PI = new PassInfo(n, arg, & passName ::ID, \
207 PassInfo::NormalCtor_t(callDefaultCtor< passName >), cfg, analysis); \
208 Registry.registerPass(*PI, true); \
210 PassInfo *AI = new PassInfo(n, & agName :: ID); \
211 Registry.registerAnalysisGroup(& agName ::ID, & passName ::ID, \
215 void llvm::initialize##passName##Pass(PassRegistry &Registry) { \
216 CALL_ONCE_INITIALIZATION(initialize##passName##PassOnce) \
Pass interface - Implemented by all 'passes'.
void enumeratePasses()
enumeratePasses - Iterate over the registered passes, calling the passEnumerate callback on each Pass...
RegisterPass<t> template - This template class is used to notify the system that a Pass is available ...
static PassRegistry * getPassRegistry()
getPassRegistry - Access the global registry object, which is automatically initialized at applicatio...
const char * getPassName() const
getPassName - Return the friendly name for the pass, never returns null
Pass * callTargetMachineCtor(TargetMachine *TM)
const void * getTypeInfo() const
getTypeInfo - Return the id object for the pass...
RegisterAGBase(const char *Name, const void *InterfaceID, const void *PassID=nullptr, bool isDefault=false)
RegisterAnalysisGroup(const char *Name)
virtual void passRegistered(const PassInfo *)
Callback functions - These functions are invoked whenever a pass is loaded or removed from the curren...
virtual ~PassRegistrationListener()
virtual void passEnumerate(const PassInfo *)
passEnumerate - Callback function invoked when someone calls enumeratePasses on this PassRegistration...
PassInfo class - An instance of this class exists for every pass known by the system, and can be obtained from a live Pass by calling its getPassInfo() method.
PassRegistrationListener()
RegisterAnalysisGroup - Register a Pass as a member of an analysis group.
PassRegistrationListener class - This class is meant to be derived from by clients that are intereste...
Primary interface to the complete machine description for the target machine.
RegisterPass(const char *PassArg, const char *Name, bool CFGOnly=false, bool is_analysis=false)
void registerPass(const PassInfo &PI, bool ShouldFree=false)
registerPass - Register a pass (by means of its PassInfo) with the registry.
RegisterAnalysisGroup(PassInfo &RPB)