diff options
author | Chris Lattner <sabre@nondot.org> | 2010-02-27 07:49:13 +0000 |
---|---|---|
committer | Chris Lattner <sabre@nondot.org> | 2010-02-27 07:49:13 +0000 |
commit | 82781b938af4057df90b5fa4035781ddc4aa681a (patch) | |
tree | 7e741bb5cf98cf25ac5ffa32d1467eb16642277f /utils/TableGen/DAGISelMatcher.h | |
parent | 2c755ba12a79e0bb2899c0bde00b2f7ea2c975a0 (diff) |
Teach the grouper some simple tricks about looking contradictory
predicates. For example if we have:
Scope:
CheckType i32
ABC
CheckType f32
DEF
CheckType i32
GHI
Then we know that we can transform this into:
Scope:
CheckType i32
Scope
ABC
GHI
CheckType f32
DEF
This reorders the check for the 'GHI' predicate above
the check for the 'DEF' predidate. However it is safe to do this
in this situation because we know that a node cannot have both an
i32 and f32 type.
We're now doing more factoring that the old isel did.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@97312 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'utils/TableGen/DAGISelMatcher.h')
-rw-r--r-- | utils/TableGen/DAGISelMatcher.h | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/utils/TableGen/DAGISelMatcher.h b/utils/TableGen/DAGISelMatcher.h index 9af98f77f3..b4de0e4fcf 100644 --- a/utils/TableGen/DAGISelMatcher.h +++ b/utils/TableGen/DAGISelMatcher.h @@ -110,12 +110,26 @@ public: return false; } + /// isContradictory - Return true of these two matchers could never match on + /// the same node. + bool isContradictory(const Matcher *Other) const { + // Since this predicate is reflexive, we canonicalize the ordering so that + // we always match a node against nodes with kinds that are greater or equal + // to them. For example, we'll pass in a CheckType node as an argument to + // the CheckOpcode method, not the other way around. + if (getKind() < Other->getKind()) + return isContradictoryImpl(Other); + return Other->isContradictoryImpl(this); + } + void print(raw_ostream &OS, unsigned indent = 0) const; + void printOne(raw_ostream &OS) const; void dump() const; protected: virtual void printImpl(raw_ostream &OS, unsigned indent) const = 0; virtual bool isEqualImpl(const Matcher *M) const = 0; virtual unsigned getHashImpl() const = 0; + virtual bool isContradictoryImpl(const Matcher *M) const { return false; } }; /// ScopeMatcher - This attempts to match each of its children to find the first @@ -391,6 +405,7 @@ private: return cast<CheckOpcodeMatcher>(M)->OpcodeName == OpcodeName; } virtual unsigned getHashImpl() const; + virtual bool isContradictoryImpl(const Matcher *M) const; }; /// CheckMultiOpcodeMatcher - This checks to see if the current node has one @@ -442,6 +457,7 @@ private: return cast<CheckTypeMatcher>(M)->Type == Type; } virtual unsigned getHashImpl() const { return Type; } + virtual bool isContradictoryImpl(const Matcher *M) const; }; /// CheckChildTypeMatcher - This checks to see if a child node has the @@ -469,6 +485,7 @@ private: cast<CheckChildTypeMatcher>(M)->Type == Type; } virtual unsigned getHashImpl() const { return (Type << 3) | ChildNo; } + virtual bool isContradictoryImpl(const Matcher *M) const; }; |