summaryrefslogtreecommitdiff
path: root/utils/TableGen/CodeGenDAGPatterns.h
diff options
context:
space:
mode:
authorDan Gohman <gohman@apple.com>2008-10-15 06:17:21 +0000
committerDan Gohman <gohman@apple.com>2008-10-15 06:17:21 +0000
commit0540e17788f0d09d784fb9bd9b354e02f1c5e4a4 (patch)
tree8051040c19507c9fe7a77c99bfa4ca712115a869 /utils/TableGen/CodeGenDAGPatterns.h
parent740e709d0df1ffc234be28039502442745c82de7 (diff)
downloadllvm-0540e17788f0d09d784fb9bd9b354e02f1c5e4a4.tar.gz
llvm-0540e17788f0d09d784fb9bd9b354e02f1c5e4a4.tar.bz2
llvm-0540e17788f0d09d784fb9bd9b354e02f1c5e4a4.tar.xz
Add support for having multiple predicates on a TreePatternNode.
This will allow predicates to be composed, which will allow the predicate definitions to become less redundant, and eventually will allow DAGISelEmitter.cpp to emit less redundant code. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@57562 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'utils/TableGen/CodeGenDAGPatterns.h')
-rw-r--r--utils/TableGen/CodeGenDAGPatterns.h22
1 files changed, 17 insertions, 5 deletions
diff --git a/utils/TableGen/CodeGenDAGPatterns.h b/utils/TableGen/CodeGenDAGPatterns.h
index 4d7ea58b06..977f75569f 100644
--- a/utils/TableGen/CodeGenDAGPatterns.h
+++ b/utils/TableGen/CodeGenDAGPatterns.h
@@ -16,6 +16,8 @@
#define CODEGEN_DAGPATTERNS_H
#include <set>
+#include <algorithm>
+#include <vector>
#include "CodeGenTarget.h"
#include "CodeGenIntrinsics.h"
@@ -158,9 +160,9 @@ class TreePatternNode {
///
std::string Name;
- /// PredicateFn - The predicate function to execute on this node to check
- /// for a match. If this string is empty, no predicate is involved.
- std::string PredicateFn;
+ /// PredicateFns - The predicate functions to execute on this node to check
+ /// for a match. If this list is empty, no predicate is involved.
+ std::vector<std::string> PredicateFns;
/// TransformFn - The transformation function to execute on this node before
/// it can be substituted into the resulting instruction on a pattern match.
@@ -213,8 +215,18 @@ public:
Children[i] = N;
}
- const std::string &getPredicateFn() const { return PredicateFn; }
- void setPredicateFn(const std::string &Fn) { PredicateFn = Fn; }
+ const std::vector<std::string> &getPredicateFns() const { return PredicateFns; }
+ void clearPredicateFns() { PredicateFns.clear(); }
+ void setPredicateFns(const std::vector<std::string> &Fns) {
+ assert(PredicateFns.empty() && "Overwriting non-empty predicate list!");
+ PredicateFns = Fns;
+ }
+ void addPredicateFn(const std::string &Fn) {
+ assert(!Fn.empty() && "Empty predicate string!");
+ if (std::find(PredicateFns.begin(), PredicateFns.end(), Fn) ==
+ PredicateFns.end())
+ PredicateFns.push_back(Fn);
+ }
Record *getTransformFn() const { return TransformFn; }
void setTransformFn(Record *Fn) { TransformFn = Fn; }