21 #ifndef LLVM_PASSSUPPORT_H
22 #define LLVM_PASSSUPPORT_H
36 #define INITIALIZE_PASS(passName, arg, name, cfg, analysis) \
37 static void *initialize##passName##PassOnce(PassRegistry &Registry) { \
38 PassInfo *PI = new PassInfo( \
39 name, arg, &passName::ID, \
40 PassInfo::NormalCtor_t(callDefaultCtor<passName>), cfg, analysis); \
41 Registry.registerPass(*PI, true); \
44 LLVM_DEFINE_ONCE_FLAG(Initialize##passName##PassFlag); \
45 void llvm::initialize##passName##Pass(PassRegistry &Registry) { \
46 llvm::call_once(Initialize##passName##PassFlag, \
47 initialize##passName##PassOnce, std::ref(Registry)); \
50 #define INITIALIZE_PASS_BEGIN(passName, arg, name, cfg, analysis) \
51 static void *initialize##passName##PassOnce(PassRegistry &Registry) {
53 #define INITIALIZE_PASS_DEPENDENCY(depName) initialize##depName##Pass(Registry);
54 #define INITIALIZE_AG_DEPENDENCY(depName) \
55 initialize##depName##AnalysisGroup(Registry);
57 #define INITIALIZE_PASS_END(passName, arg, name, cfg, analysis) \
58 PassInfo *PI = new PassInfo( \
59 name, arg, &passName::ID, \
60 PassInfo::NormalCtor_t(callDefaultCtor<passName>), cfg, analysis); \
61 Registry.registerPass(*PI, true); \
64 LLVM_DEFINE_ONCE_FLAG(Initialize##passName##PassFlag); \
65 void llvm::initialize##passName##Pass(PassRegistry &Registry) { \
66 llvm::call_once(Initialize##passName##PassFlag, \
67 initialize##passName##PassOnce, std::ref(Registry)); \
70 #define INITIALIZE_PASS_WITH_OPTIONS(PassName, Arg, Name, Cfg, Analysis) \
71 INITIALIZE_PASS_BEGIN(PassName, Arg, Name, Cfg, Analysis) \
72 PassName::registerOptions(); \
73 INITIALIZE_PASS_END(PassName, Arg, Name, Cfg, Analysis)
75 #define INITIALIZE_PASS_WITH_OPTIONS_BEGIN(PassName, Arg, Name, Cfg, Analysis) \
76 INITIALIZE_PASS_BEGIN(PassName, Arg, Name, Cfg, Analysis) \
77 PassName::registerOptions();
82 return new PassName(TM);
105 bool is_analysis =
false)
135 const void *PassID =
nullptr,
bool isDefault =
false);
138 template <
typename Interface,
bool Default = false>
148 #define INITIALIZE_ANALYSIS_GROUP(agName, name, defaultPass) \
149 static void *initialize##agName##AnalysisGroupOnce(PassRegistry &Registry) { \
150 initialize##defaultPass##Pass(Registry); \
151 PassInfo *AI = new PassInfo(name, &agName::ID); \
152 Registry.registerAnalysisGroup(&agName::ID, 0, *AI, false, true); \
155 LLVM_DEFINE_ONCE_FLAG(Initialize##agName##AnalysisGroupFlag); \
156 void llvm::initialize##agName##AnalysisGroup(PassRegistry &Registry) { \
157 llvm::call_once(Initialize##agName##AnalysisGroupFlag, \
158 initialize##agName##AnalysisGroupOnce, \
159 std::ref(Registry)); \
162 #define INITIALIZE_AG_PASS(passName, agName, arg, name, cfg, analysis, def) \
163 static void *initialize##passName##PassOnce(PassRegistry &Registry) { \
165 initialize##agName##AnalysisGroup(Registry); \
166 PassInfo *PI = new PassInfo( \
167 name, arg, &passName::ID, \
168 PassInfo::NormalCtor_t(callDefaultCtor<passName>), cfg, analysis); \
169 Registry.registerPass(*PI, true); \
171 PassInfo *AI = new PassInfo(name, &agName::ID); \
172 Registry.registerAnalysisGroup(&agName::ID, &passName::ID, *AI, def, \
176 LLVM_DEFINE_ONCE_FLAG(Initialize##passName##PassFlag); \
177 void llvm::initialize##passName##Pass(PassRegistry &Registry) { \
178 llvm::call_once(Initialize##passName##PassFlag, \
179 initialize##passName##PassOnce, std::ref(Registry)); \
182 #define INITIALIZE_AG_PASS_BEGIN(passName, agName, arg, n, cfg, analysis, def) \
183 static void *initialize##passName##PassOnce(PassRegistry &Registry) { \
185 initialize##agName##AnalysisGroup(Registry);
187 #define INITIALIZE_AG_PASS_END(passName, agName, arg, n, cfg, analysis, def) \
188 PassInfo *PI = new PassInfo( \
189 n, arg, &passName::ID, \
190 PassInfo::NormalCtor_t(callDefaultCtor<passName>), cfg, analysis); \
191 Registry.registerPass(*PI, true); \
193 PassInfo *AI = new PassInfo(n, &agName::ID); \
194 Registry.registerAnalysisGroup(&agName::ID, &passName::ID, *AI, def, true); \
197 LLVM_DEFINE_ONCE_FLAG(Initialize##passName##PassFlag); \
198 void llvm::initialize##passName##Pass(PassRegistry &Registry) { \
199 llvm::call_once(Initialize##passName##PassFlag, \
200 initialize##passName##PassOnce, std::ref(Registry)); \
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...
Pass * callTargetMachineCtor(TargetMachine *TM)
const void * getTypeInfo() const
getTypeInfo - Return the id object for the pass...
RegisterPass(StringRef PassArg, StringRef Name, bool CFGOnly=false, bool is_analysis=false)
RegisterAGBase(StringRef 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...
StringRef getPassName() const
getPassName - Return the friendly name for the pass, never returns null
Primary interface to the complete machine description for the target machine.
StringRef - Represent a constant reference to a string, i.e.
void registerPass(const PassInfo &PI, bool ShouldFree=false)
registerPass - Register a pass (by means of its PassInfo) with the registry.
RegisterAnalysisGroup(PassInfo &RPB)