diff options
| author | Chris Lattner <sabre@nondot.org> | 2010-02-25 19:00:39 +0000 |
|---|---|---|
| committer | Chris Lattner <sabre@nondot.org> | 2010-02-25 19:00:39 +0000 |
| commit | f7fc2d8b8637a255e6bdcce18a56cc4dd79325d8 (patch) | |
| tree | 49e722b5d9edef02e4fe6011af91e203299aebae /llvm/utils/TableGen/DAGISelMatcher.h | |
| parent | e285f70a42c305d39ad54479c96a1c3b4c19b2a0 (diff) | |
| download | bcm5719-llvm-f7fc2d8b8637a255e6bdcce18a56cc4dd79325d8.tar.gz bcm5719-llvm-f7fc2d8b8637a255e6bdcce18a56cc4dd79325d8.zip | |
change the scope node to include a list of children to be checked
instead of to have a chained series of scope nodes. This makes
the generated table smaller, improves the efficiency of the
interpreter, and make the factoring optimization much more
reasonable to implement.
llvm-svn: 97160
Diffstat (limited to 'llvm/utils/TableGen/DAGISelMatcher.h')
| -rw-r--r-- | llvm/utils/TableGen/DAGISelMatcher.h | 35 |
1 files changed, 23 insertions, 12 deletions
diff --git a/llvm/utils/TableGen/DAGISelMatcher.h b/llvm/utils/TableGen/DAGISelMatcher.h index 0bc44e7473c..6599b21e934 100644 --- a/llvm/utils/TableGen/DAGISelMatcher.h +++ b/llvm/utils/TableGen/DAGISelMatcher.h @@ -111,21 +111,32 @@ protected: virtual unsigned getHashImpl() const = 0; }; -/// ScopeMatcher - This pushes a failure scope on the stack and evaluates -/// 'Check'. If 'Check' fails to match, it pops its scope and continues on to -/// 'Next'. +/// ScopeMatcher - This attempts to match each of its children to find the first +/// one that successfully matches. If one child fails, it tries the next child. +/// If none of the children match then this check fails. It never has a 'next'. class ScopeMatcher : public Matcher { - OwningPtr<Matcher> Check; + SmallVector<Matcher*, 4> Children; public: - ScopeMatcher(Matcher *check = 0, Matcher *next = 0) - : Matcher(Scope), Check(check) { - setNext(next); + ScopeMatcher(Matcher *const *children, unsigned numchildren) + : Matcher(Scope), Children(children, children+numchildren) { } + virtual ~ScopeMatcher(); - Matcher *getCheck() { return Check.get(); } - const Matcher *getCheck() const { return Check.get(); } - void setCheck(Matcher *N) { Check.reset(N); } - OwningPtr<Matcher> &getCheckPtr() { return Check; } + unsigned getNumChildren() const { return Children.size(); } + + Matcher *getChild(unsigned i) { return Children[i]; } + const Matcher *getChild(unsigned i) const { return Children[i]; } + + void resetChild(unsigned i, Matcher *N) { + delete Children[i]; + Children[i] = N; + } + + Matcher *takeChild(unsigned i) { + Matcher *Res = Children[i]; + Children[i] = 0; + return Res; + } static inline bool classof(const Matcher *N) { return N->getKind() == Scope; @@ -134,7 +145,7 @@ public: private: virtual void printImpl(raw_ostream &OS, unsigned indent) const; virtual bool isEqualImpl(const Matcher *M) const { return false; } - virtual unsigned getHashImpl() const { return 0; } + virtual unsigned getHashImpl() const { return 12312; } }; /// RecordMatcher - Save the current node in the operand list. |

