diff options
author | Owen Anderson <resistor@mac.com> | 2010-07-20 23:41:56 +0000 |
---|---|---|
committer | Owen Anderson <resistor@mac.com> | 2010-07-20 23:41:56 +0000 |
commit | 7fc9fe755356634bfd52aef1ab0961ad9b63dbf7 (patch) | |
tree | b637f7e7042ee662dea14e2fd602ce044abdc4b3 /llvm/lib/VMCore/PassRegistry.cpp | |
parent | 1d1806641146f60f10e6269c7ec66f9ed1e5e88a (diff) | |
download | bcm5719-llvm-7fc9fe755356634bfd52aef1ab0961ad9b63dbf7.tar.gz bcm5719-llvm-7fc9fe755356634bfd52aef1ab0961ad9b63dbf7.zip |
Move the handling of PassRegistrationListener's to PassRegistry.
llvm-svn: 108966
Diffstat (limited to 'llvm/lib/VMCore/PassRegistry.cpp')
-rw-r--r-- | llvm/lib/VMCore/PassRegistry.cpp | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/llvm/lib/VMCore/PassRegistry.cpp b/llvm/lib/VMCore/PassRegistry.cpp index 18a8cca56fc..140719e12b3 100644 --- a/llvm/lib/VMCore/PassRegistry.cpp +++ b/llvm/lib/VMCore/PassRegistry.cpp @@ -13,9 +13,12 @@ //===----------------------------------------------------------------------===// #include "llvm/PassRegistry.h" +#include "llvm/PassSupport.h" #include "llvm/Support/Compiler.h" #include "llvm/Support/ManagedStatic.h" +using namespace llvm; + static PassRegistry *PassRegistryObj = 0; PassRegistry *PassRegistry::getPassRegistry() { // Use double-checked locking to safely initialize the registrar when @@ -69,12 +72,21 @@ const PassInfo *PassRegistry::getPassInfo(StringRef Arg) const { return I != PassInfoStringMap.end() ? I->second : 0; } +//===----------------------------------------------------------------------===// +// Pass Registration mechanism +// + void PassRegistry::registerPass(const PassInfo &PI) { sys::SmartScopedLock<true> Guard(Lock); bool Inserted = PassInfoMap.insert(std::make_pair(PI.getTypeInfo(),&PI)).second; assert(Inserted && "Pass registered multiple times!"); Inserted=Inserted; PassInfoStringMap[PI.getPassArgument()] = &PI; + + // Notify any listeners. + for (std::vector<PassRegistrationListener*>::iterator + I = Listeners.begin(), E = Listeners.end(); I != E; ++I) + (*I)->passRegistered(&PI); } void PassRegistry::unregisterPass(const PassInfo &PI) { @@ -112,3 +124,16 @@ void PassRegistry::registerAnalysisGroup(PassInfo *InterfaceInfo, InterfaceInfo->setNormalCtor(ImplementationInfo->getNormalCtor()); } } + +void PassRegistry::addRegistrationListener(PassRegistrationListener *L) { + sys::SmartScopedLock<true> Guard(Lock); + Listeners.push_back(L); +} + +void PassRegistry::removeRegistrationListener(PassRegistrationListener *L) { + sys::SmartScopedLock<true> Guard(Lock); + std::vector<PassRegistrationListener*>::iterator I = + std::find(Listeners.begin(), Listeners.end(), L); + assert(I != Listeners.end() && "PassRegistrationListener not registered!"); + Listeners.erase(I); +} |