diff options
author | Dan Gohman <gohman@apple.com> | 2008-05-13 02:05:11 +0000 |
---|---|---|
committer | Dan Gohman <gohman@apple.com> | 2008-05-13 02:05:11 +0000 |
commit | 66a636e07c90c7270b673406f2bac1bfea81ea8b (patch) | |
tree | 02c986fdfaf2f67a232f705d77841290240c2f0b /lib/VMCore | |
parent | 285e2e4b303a2bd5d48eb4c27bf9405b17c129a4 (diff) | |
download | external_llvm-66a636e07c90c7270b673406f2bac1bfea81ea8b.zip external_llvm-66a636e07c90c7270b673406f2bac1bfea81ea8b.tar.gz external_llvm-66a636e07c90c7270b673406f2bac1bfea81ea8b.tar.bz2 |
Change class' public PassInfo variables to by initialized with the
address of the PassInfo directly instead of calling getPassInfo.
This eliminates a bunch of dynamic initializations of static data.
Also, fold RegisterPassBase into PassInfo, make a bunch of its
data members const, and rearrange some code to initialize data
members in constructors instead of using setter member functions.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@51022 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/VMCore')
-rw-r--r-- | lib/VMCore/Pass.cpp | 37 | ||||
-rw-r--r-- | lib/VMCore/Verifier.cpp | 2 |
2 files changed, 17 insertions, 22 deletions
diff --git a/lib/VMCore/Pass.cpp b/lib/VMCore/Pass.cpp index bd34883..e0fe622 100644 --- a/lib/VMCore/Pass.cpp +++ b/lib/VMCore/Pass.cpp @@ -122,7 +122,8 @@ namespace { class PassRegistrar { /// PassInfoMap - Keep track of the passinfo object for each registered llvm /// pass. - std::map<intptr_t, PassInfo*> PassInfoMap; + typedef std::map<intptr_t, const PassInfo*> MapType; + MapType PassInfoMap; /// AnalysisGroupInfo - Keep track of information for each analysis group. struct AnalysisGroupInfo { @@ -137,19 +138,18 @@ class PassRegistrar { public: const PassInfo *GetPassInfo(intptr_t TI) const { - std::map<intptr_t, PassInfo*>::const_iterator I = PassInfoMap.find(TI); + MapType::const_iterator I = PassInfoMap.find(TI); return I != PassInfoMap.end() ? I->second : 0; } - void RegisterPass(PassInfo &PI) { + void RegisterPass(const PassInfo &PI) { bool Inserted = PassInfoMap.insert(std::make_pair(PI.getTypeInfo(),&PI)).second; assert(Inserted && "Pass registered multiple times!"); } - void UnregisterPass(PassInfo &PI) { - std::map<intptr_t, PassInfo*>::iterator I = - PassInfoMap.find(PI.getTypeInfo()); + void UnregisterPass(const PassInfo &PI) { + MapType::iterator I = PassInfoMap.find(PI.getTypeInfo()); assert(I != PassInfoMap.end() && "Pass registered but not in map!"); // Remove pass from the map. @@ -157,7 +157,7 @@ public: } void EnumerateWith(PassRegistrationListener *L) { - for (std::map<intptr_t, PassInfo*>::const_iterator I = PassInfoMap.begin(), + for (MapType::const_iterator I = PassInfoMap.begin(), E = PassInfoMap.end(); I != E; ++I) L->passEnumerate(I->second); } @@ -206,18 +206,18 @@ const PassInfo *Pass::lookupPassInfo(intptr_t TI) { return getPassRegistrar()->GetPassInfo(TI); } -void RegisterPassBase::registerPass() { - getPassRegistrar()->RegisterPass(PIObj); +void PassInfo::registerPass() { + getPassRegistrar()->RegisterPass(*this); // Notify any listeners. if (Listeners) for (std::vector<PassRegistrationListener*>::iterator I = Listeners->begin(), E = Listeners->end(); I != E; ++I) - (*I)->passRegistered(&PIObj); + (*I)->passRegistered(this); } -void RegisterPassBase::unregisterPass() { - getPassRegistrar()->UnregisterPass(PIObj); +void PassInfo::unregisterPass() { + getPassRegistrar()->UnregisterPass(*this); } //===----------------------------------------------------------------------===// @@ -226,18 +226,18 @@ void RegisterPassBase::unregisterPass() { // RegisterAGBase implementation // -RegisterAGBase::RegisterAGBase(intptr_t InterfaceID, +RegisterAGBase::RegisterAGBase(const char *Name, intptr_t InterfaceID, intptr_t PassID, bool isDefault) - : RegisterPassBase(InterfaceID), + : PassInfo(Name, InterfaceID), ImplementationInfo(0), isDefaultImplementation(isDefault) { InterfaceInfo = const_cast<PassInfo*>(Pass::lookupPassInfo(InterfaceID)); if (InterfaceInfo == 0) { // First reference to Interface, register it now. registerPass(); - InterfaceInfo = &PIObj; + InterfaceInfo = this; } - assert(PIObj.isAnalysisGroup() && + assert(isAnalysisGroup() && "Trying to join an analysis group that is a normal pass!"); if (PassID) { @@ -254,11 +254,6 @@ RegisterAGBase::RegisterAGBase(intptr_t InterfaceID, } } -void RegisterAGBase::setGroupName(const char *Name) { - assert(InterfaceInfo->getPassName()[0] == 0 && "Interface Name already set!"); - InterfaceInfo->setPassName(Name); -} - //===----------------------------------------------------------------------===// // PassRegistrationListener implementation diff --git a/lib/VMCore/Verifier.cpp b/lib/VMCore/Verifier.cpp index 4c6f9e0..86aff9b 100644 --- a/lib/VMCore/Verifier.cpp +++ b/lib/VMCore/Verifier.cpp @@ -97,7 +97,7 @@ namespace { // Anonymous namespace for class char PreVerifier::ID = 0; static RegisterPass<PreVerifier> PreVer("preverify", "Preliminary module verification"); -static const PassInfo *PreVerifyID = PreVer.getPassInfo(); +static const PassInfo *PreVerifyID = &PreVer; namespace { struct VISIBILITY_HIDDEN |