46 struct PassRegistryImpl {
52 StringMapType PassInfoStringMap;
55 struct AnalysisGroupInfo {
60 std::vector<const PassInfo*> ToFree;
61 std::vector<PassRegistrationListener*> Listeners;
65 void *PassRegistry::getImpl()
const {
67 pImpl =
new PassRegistryImpl();
77 PassRegistryImpl *Impl =
static_cast<PassRegistryImpl*
>(pImpl);
79 for (std::vector<const PassInfo*>::iterator
I = Impl->ToFree.begin(),
80 E = Impl->ToFree.end();
I != E; ++
I)
89 PassRegistryImpl *Impl =
static_cast<PassRegistryImpl*
>(getImpl());
91 return I != Impl->PassInfoMap.end() ? I->second : 0;
96 PassRegistryImpl *Impl =
static_cast<PassRegistryImpl*
>(getImpl());
98 I = Impl->PassInfoStringMap.find(Arg);
99 return I != Impl->PassInfoStringMap.end() ? I->
second : 0;
108 PassRegistryImpl *Impl =
static_cast<PassRegistryImpl*
>(getImpl());
110 Impl->PassInfoMap.insert(std::make_pair(PI.
getTypeInfo(),&PI)).second;
111 assert(Inserted &&
"Pass registered multiple times!");
116 for (std::vector<PassRegistrationListener*>::iterator
117 I = Impl->Listeners.begin(), E = Impl->Listeners.end();
I != E; ++
I)
118 (*I)->passRegistered(&PI);
120 if (ShouldFree) Impl->ToFree.push_back(&PI);
125 PassRegistryImpl *Impl =
static_cast<PassRegistryImpl*
>(getImpl());
128 assert(I != Impl->PassInfoMap.end() &&
"Pass registered but not in map!");
131 Impl->PassInfoMap.erase(I);
137 PassRegistryImpl *Impl =
static_cast<PassRegistryImpl*
>(getImpl());
139 E = Impl->PassInfoMap.end();
I != E; ++
I)
151 if (InterfaceInfo == 0) {
154 InterfaceInfo = &Registeree;
157 "Trying to join an analysis group that is a normal pass!");
161 assert(ImplementationInfo &&
162 "Must register pass before adding to AnalysisGroup!");
170 PassRegistryImpl *Impl =
static_cast<PassRegistryImpl*
>(getImpl());
171 PassRegistryImpl::AnalysisGroupInfo &AGI =
172 Impl->AnalysisGroupInfoMap[InterfaceInfo];
173 assert(AGI.Implementations.count(ImplementationInfo) == 0 &&
174 "Cannot add a pass to the same analysis group more than once!");
175 AGI.Implementations.insert(ImplementationInfo);
178 "Default implementation for analysis group already specified!");
180 "Cannot specify pass as default if it does not have a default ctor");
185 PassRegistryImpl *Impl =
static_cast<PassRegistryImpl*
>(getImpl());
186 if (ShouldFree) Impl->ToFree.push_back(&Registeree);
191 PassRegistryImpl *Impl =
static_cast<PassRegistryImpl*
>(getImpl());
192 Impl->Listeners.push_back(L);
204 PassRegistryImpl *Impl =
static_cast<PassRegistryImpl*
>(getImpl());
205 std::vector<PassRegistrationListener*>::iterator
I =
206 std::find(Impl->Listeners.begin(), Impl->Listeners.end(), L);
207 assert(I != Impl->Listeners.end() &&
208 "PassRegistrationListener not registered!");
209 Impl->Listeners.erase(I);
void registerAnalysisGroup(const void *InterfaceID, const void *PassID, PassInfo &Registeree, bool isDefault, bool ShouldFree=false)
registerAnalysisGroup - Register an analysis group (or a pass implementing
static PassRegistry * getPassRegistry()
void setNormalCtor(NormalCtor_t Ctor)
void enumerateWith(PassRegistrationListener *L)
const void * getTypeInfo() const
void addInterfaceImplemented(const PassInfo *ItfPI)
bool isAnalysisGroup() const
void removeRegistrationListener(PassRegistrationListener *L)
ScopedReader - RAII acquisition of a reader lock.
ScopedWriter - RAII acquisition of a writer lock.
virtual void passEnumerate(const PassInfo *)
void unregisterPass(const PassInfo &PI)
NormalCtor_t getNormalCtor() const
static ManagedStatic< sys::SmartRWMutex< true > > Lock
void addRegistrationListener(PassRegistrationListener *L)
const char * getPassArgument() const
static ManagedStatic< PassRegistry > PassRegistryObj
const PassInfo * getPassInfo(const void *TI) const
void registerPass(const PassInfo &PI, bool ShouldFree=false)