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 | d6c84720df0b63e34081e0c7890f3074d8b110b9 (patch) | |
tree | f46552db5b37742ed3f49f1084681468b7222756 /utils/TableGen/DAGISelMatcher.h | |
parent | 2333655ed04637ffd049b9299685a0752aab8e8d (diff) | |
download | llvm-d6c84720df0b63e34081e0c7890f3074d8b110b9.tar.gz llvm-d6c84720df0b63e34081e0c7890f3074d8b110b9.tar.bz2 llvm-d6c84720df0b63e34081e0c7890f3074d8b110b9.tar.xz |
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.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@97160 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'utils/TableGen/DAGISelMatcher.h')
-rw-r--r-- | utils/TableGen/DAGISelMatcher.h | 35 |
1 files changed, 23 insertions, 12 deletions
diff --git a/utils/TableGen/DAGISelMatcher.h b/utils/TableGen/DAGISelMatcher.h index 0bc44e7473..6599b21e93 100644 --- a/utils/TableGen/DAGISelMatcher.h +++ b/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. |