summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDavid Greene <greened@obbligato.org>2007-08-20 19:54:01 +0000
committerDavid Greene <greened@obbligato.org>2007-08-20 19:54:01 +0000
commit8766c1684080d3b64e19ea5cf639cbf3cf8d632d (patch)
treec41c7125eb18f39d5da6d63138ab2e93a0e64f85
parent54a187ea8b1de779a4963fd36493ac16e58d3b13 (diff)
downloadbcm5719-llvm-8766c1684080d3b64e19ea5cf639cbf3cf8d632d.tar.gz
bcm5719-llvm-8766c1684080d3b64e19ea5cf639cbf3cf8d632d.zip
Add FilteredPassNameParser along with PassArgFilter to filter passes
based on their Arg members. llvm-svn: 41192
-rw-r--r--llvm/include/llvm/Support/PassNameParser.h42
1 files changed, 40 insertions, 2 deletions
diff --git a/llvm/include/llvm/Support/PassNameParser.h b/llvm/include/llvm/Support/PassNameParser.h
index e87e16a21bb..37f07972713 100644
--- a/llvm/include/llvm/Support/PassNameParser.h
+++ b/llvm/include/llvm/Support/PassNameParser.h
@@ -24,9 +24,9 @@
#define LLVM_SUPPORT_PASS_NAME_PARSER_H
#include "llvm/Support/CommandLine.h"
-#include "llvm/Support/Debug.h"
#include "llvm/Pass.h"
#include <algorithm>
+#include <cstring>
namespace llvm {
@@ -89,6 +89,44 @@ public:
}
};
-} // End llvm namespace
+//===----------------------------------------------------------------------===//
+// FilteredPassNameParser class - Make use of the pass registration
+// mechanism to automatically add a command line argument to opt for
+// each pass that satisfies a filter criteria. Filter should return
+// true for passes to be registered as command-line options.
+//
+template<typename Filter>
+class FilteredPassNameParser : public PassNameParser {
+private:
+ Filter filter;
+public:
+ bool ignorablePassImpl(const PassInfo *P) const { return !filter(*P); }
+};
+
+//===----------------------------------------------------------------------===//
+// PassArgFilter - A filter for use with PassNameFilterParser that only
+// accepts a Pass whose Arg matches certain strings.
+//
+// Use like this:
+//
+// extern const char AllowedPassArgs[] = "-anders_aa -dse";
+//
+// static cl::list<
+// const PassInfo*,
+// bool,
+// FilteredPassNameParser<PassArgFilter<AllowedPassArgs> > >
+// PassList(cl::desc("LLVM optimizations available:"));
+//
+// Only the -anders_aa and -dse options will be available to the user.
+//
+template<const char *Args>
+class PassArgFilter {
+public:
+ bool operator()(const PassInfo &P) const {
+ return(std::strstr(Args, P.getPassArgument()));
+ }
+};
+
+} // End llvm namespace
#endif
OpenPOWER on IntegriCloud