summaryrefslogtreecommitdiff
path: root/lib/VMCore/Pass.cpp
diff options
context:
space:
mode:
authorDan Gohman <gohman@apple.com>2009-10-08 17:00:02 +0000
committerDan Gohman <gohman@apple.com>2009-10-08 17:00:02 +0000
commit8a261e44f71a433b7d9af373c3e3dfa6fea67146 (patch)
tree0f0a78c5c187f1764a43d34439e7cbaecbb9323b /lib/VMCore/Pass.cpp
parentd4a537be0574460e9369152ca482456ccabac776 (diff)
downloadllvm-8a261e44f71a433b7d9af373c3e3dfa6fea67146.tar.gz
llvm-8a261e44f71a433b7d9af373c3e3dfa6fea67146.tar.bz2
llvm-8a261e44f71a433b7d9af373c3e3dfa6fea67146.tar.xz
Add a form of addPreserved which takes a string argument, to allow passes
to declare that they preserve other passes without needing to pull in additional header file or library dependencies. Convert MachineFunctionPass and CodeGenLICM to make use of this. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@83555 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/VMCore/Pass.cpp')
-rw-r--r--lib/VMCore/Pass.cpp14
1 files changed, 14 insertions, 0 deletions
diff --git a/lib/VMCore/Pass.cpp b/lib/VMCore/Pass.cpp
index 1278074ef5..a2831d3434 100644
--- a/lib/VMCore/Pass.cpp
+++ b/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);