forked from OSchip/llvm-project
Move the smarts of AnalysisGroup registration into PassRegistry.
llvm-svn: 109019
This commit is contained in:
parent
34c85987fe
commit
845b14ef66
|
@ -58,9 +58,8 @@ public:
|
||||||
void unregisterPass(const PassInfo &PI);
|
void unregisterPass(const PassInfo &PI);
|
||||||
|
|
||||||
/// Analysis Group Mechanisms.
|
/// Analysis Group Mechanisms.
|
||||||
void registerAnalysisGroup(PassInfo *InterfaceInfo,
|
void registerAnalysisGroup(intptr_t InterfaceID, intptr_t PassID,
|
||||||
const PassInfo *ImplementationInfo,
|
PassInfo& Registeree, bool isDefault);
|
||||||
bool isDefault);
|
|
||||||
|
|
||||||
void enumerateWith(PassRegistrationListener *L);
|
void enumerateWith(PassRegistrationListener *L);
|
||||||
void addRegistrationListener(PassRegistrationListener* L);
|
void addRegistrationListener(PassRegistrationListener* L);
|
||||||
|
|
|
@ -264,30 +264,9 @@ Pass *PassInfo::createPass() const {
|
||||||
//
|
//
|
||||||
RegisterAGBase::RegisterAGBase(const char *Name, intptr_t InterfaceID,
|
RegisterAGBase::RegisterAGBase(const char *Name, intptr_t InterfaceID,
|
||||||
intptr_t PassID, bool isDefault)
|
intptr_t PassID, bool isDefault)
|
||||||
: PassInfo(Name, InterfaceID) {
|
: PassInfo(Name, InterfaceID) {
|
||||||
|
PassRegistry::getPassRegistry()->registerAnalysisGroup(InterfaceID, PassID,
|
||||||
PassInfo *InterfaceInfo =
|
*this, isDefault);
|
||||||
const_cast<PassInfo*>(Pass::lookupPassInfo(InterfaceID));
|
|
||||||
if (InterfaceInfo == 0) {
|
|
||||||
// First reference to Interface, register it now.
|
|
||||||
PassRegistry::getPassRegistry()->registerPass(*this);
|
|
||||||
InterfaceInfo = this;
|
|
||||||
}
|
|
||||||
assert(isAnalysisGroup() &&
|
|
||||||
"Trying to join an analysis group that is a normal pass!");
|
|
||||||
|
|
||||||
if (PassID) {
|
|
||||||
const PassInfo *ImplementationInfo = Pass::lookupPassInfo(PassID);
|
|
||||||
assert(ImplementationInfo &&
|
|
||||||
"Must register pass before adding to AnalysisGroup!");
|
|
||||||
|
|
||||||
// Make sure we keep track of the fact that the implementation implements
|
|
||||||
// the interface.
|
|
||||||
PassInfo *IIPI = const_cast<PassInfo*>(ImplementationInfo);
|
|
||||||
IIPI->addInterfaceImplemented(InterfaceInfo);
|
|
||||||
|
|
||||||
PassRegistry::getPassRegistry()->registerAnalysisGroup(InterfaceInfo, IIPI, isDefault);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -108,20 +108,40 @@ void PassRegistry::enumerateWith(PassRegistrationListener *L) {
|
||||||
|
|
||||||
|
|
||||||
/// Analysis Group Mechanisms.
|
/// Analysis Group Mechanisms.
|
||||||
void PassRegistry::registerAnalysisGroup(PassInfo *InterfaceInfo,
|
void PassRegistry::registerAnalysisGroup(intptr_t InterfaceID,
|
||||||
const PassInfo *ImplementationInfo,
|
intptr_t PassID,
|
||||||
|
PassInfo& Registeree,
|
||||||
bool isDefault) {
|
bool isDefault) {
|
||||||
sys::SmartScopedLock<true> Guard(Lock);
|
PassInfo *InterfaceInfo = const_cast<PassInfo*>(getPassInfo(InterfaceID));
|
||||||
AnalysisGroupInfo &AGI = AnalysisGroupInfoMap[InterfaceInfo];
|
if (InterfaceInfo == 0) {
|
||||||
assert(AGI.Implementations.count(ImplementationInfo) == 0 &&
|
// First reference to Interface, register it now.
|
||||||
"Cannot add a pass to the same analysis group more than once!");
|
registerPass(Registeree);
|
||||||
AGI.Implementations.insert(ImplementationInfo);
|
InterfaceInfo = &Registeree;
|
||||||
if (isDefault) {
|
}
|
||||||
assert(InterfaceInfo->getNormalCtor() == 0 &&
|
assert(Registeree.isAnalysisGroup() &&
|
||||||
"Default implementation for analysis group already specified!");
|
"Trying to join an analysis group that is a normal pass!");
|
||||||
assert(ImplementationInfo->getNormalCtor() &&
|
|
||||||
"Cannot specify pass as default if it does not have a default ctor");
|
if (PassID) {
|
||||||
InterfaceInfo->setNormalCtor(ImplementationInfo->getNormalCtor());
|
PassInfo *ImplementationInfo = const_cast<PassInfo*>(getPassInfo(PassID));
|
||||||
|
assert(ImplementationInfo &&
|
||||||
|
"Must register pass before adding to AnalysisGroup!");
|
||||||
|
|
||||||
|
// Make sure we keep track of the fact that the implementation implements
|
||||||
|
// the interface.
|
||||||
|
ImplementationInfo->addInterfaceImplemented(InterfaceInfo);
|
||||||
|
|
||||||
|
sys::SmartScopedLock<true> Guard(Lock);
|
||||||
|
AnalysisGroupInfo &AGI = AnalysisGroupInfoMap[InterfaceInfo];
|
||||||
|
assert(AGI.Implementations.count(ImplementationInfo) == 0 &&
|
||||||
|
"Cannot add a pass to the same analysis group more than once!");
|
||||||
|
AGI.Implementations.insert(ImplementationInfo);
|
||||||
|
if (isDefault) {
|
||||||
|
assert(InterfaceInfo->getNormalCtor() == 0 &&
|
||||||
|
"Default implementation for analysis group already specified!");
|
||||||
|
assert(ImplementationInfo->getNormalCtor() &&
|
||||||
|
"Cannot specify pass as default if it does not have a default ctor");
|
||||||
|
InterfaceInfo->setNormalCtor(ImplementationInfo->getNormalCtor());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue