diff options
| author | Dan Gohman <gohman@apple.com> | 2008-10-15 06:17:21 +0000 |
|---|---|---|
| committer | Dan Gohman <gohman@apple.com> | 2008-10-15 06:17:21 +0000 |
| commit | 6e979020cdaf41789c0f57d88d2d128def54ab23 (patch) | |
| tree | 63a7c6e3185f85889e4740bd2e2fb56cffc5a5b6 /llvm/utils/TableGen/CodeGenDAGPatterns.h | |
| parent | 3f399451cde268c6452c23b6bbfb1e63e99a53e0 (diff) | |
| download | bcm5719-llvm-6e979020cdaf41789c0f57d88d2d128def54ab23.tar.gz bcm5719-llvm-6e979020cdaf41789c0f57d88d2d128def54ab23.zip | |
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.
llvm-svn: 57562
Diffstat (limited to 'llvm/utils/TableGen/CodeGenDAGPatterns.h')
| -rw-r--r-- | llvm/utils/TableGen/CodeGenDAGPatterns.h | 22 |
1 files changed, 17 insertions, 5 deletions
diff --git a/llvm/utils/TableGen/CodeGenDAGPatterns.h b/llvm/utils/TableGen/CodeGenDAGPatterns.h index 4d7ea58b06b..977f75569fd 100644 --- a/llvm/utils/TableGen/CodeGenDAGPatterns.h +++ b/llvm/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; } |

