summaryrefslogtreecommitdiffstats
path: root/llvm/lib/VMCore/Pass.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'llvm/lib/VMCore/Pass.cpp')
-rw-r--r--llvm/lib/VMCore/Pass.cpp14
1 files changed, 14 insertions, 0 deletions
diff --git a/llvm/lib/VMCore/Pass.cpp b/llvm/lib/VMCore/Pass.cpp
index 1278074ef53..a2831d34345 100644
--- a/llvm/lib/VMCore/Pass.cpp
+++ b/llvm/lib/VMCore/Pass.cpp
@@ -129,6 +129,9 @@ class PassRegistrar {
/// pass.
typedef std::map<intptr_t, const PassInfo*> MapType;
MapType PassInfoMap;
+
+ typedef StringMap<const PassInfo*> StringMapType;
+ StringMapType PassInfoStringMap;
/// AnalysisGroupInfo - Keep track of information for each analysis group.
struct AnalysisGroupInfo {
@@ -145,10 +148,16 @@ public:
return I != PassInfoMap.end() ? I->second : 0;
}
+ const PassInfo *GetPassInfo(const StringRef &Arg) const {
+ StringMapType::const_iterator I = PassInfoStringMap.find(Arg);
+ return I != PassInfoStringMap.end() ? I->second : 0;
+ }
+
void RegisterPass(const PassInfo &PI) {
bool Inserted =
PassInfoMap.insert(std::make_pair(PI.getTypeInfo(),&PI)).second;
assert(Inserted && "Pass registered multiple times!"); Inserted=Inserted;
+ PassInfoStringMap[PI.getPassArgument()] = &PI;
}
void UnregisterPass(const PassInfo &PI) {
@@ -157,6 +166,7 @@ public:
// Remove pass from the map.
PassInfoMap.erase(I);
+ PassInfoStringMap.erase(PI.getPassArgument());
}
void EnumerateWith(PassRegistrationListener *L) {
@@ -227,6 +237,10 @@ const PassInfo *Pass::lookupPassInfo(intptr_t TI) {
return getPassRegistrar()->GetPassInfo(TI);
}
+const PassInfo *Pass::lookupPassInfo(const StringRef &Arg) {
+ return getPassRegistrar()->GetPassInfo(Arg);
+}
+
void PassInfo::registerPass() {
getPassRegistrar()->RegisterPass(*this);
OpenPOWER on IntegriCloud