diff options
author | Craig Topper <craig.topper@gmail.com> | 2013-10-04 05:22:20 +0000 |
---|---|---|
committer | Craig Topper <craig.topper@gmail.com> | 2013-10-04 05:22:20 +0000 |
commit | a2efe9ebc68457bbff97c9e38665f2ac4813d87c (patch) | |
tree | 747d37b58fbe5f837751c8e275345f316613d5f3 /llvm/utils/TableGen/DAGISelMatcher.h | |
parent | 309ffe40165f29c09e535716984fa082c6b7ac70 (diff) | |
download | bcm5719-llvm-a2efe9ebc68457bbff97c9e38665f2ac4813d87c.tar.gz bcm5719-llvm-a2efe9ebc68457bbff97c9e38665f2ac4813d87c.zip |
Add OPC_CheckChildSame0-3 to the DAG isel matcher. This replaces sequences of MoveChild, CheckSame, MoveParent. Saves 846 bytes from the X86 DAG isel matcher, ~300 from ARM, ~840 from Hexagon.
llvm-svn: 191940
Diffstat (limited to 'llvm/utils/TableGen/DAGISelMatcher.h')
-rw-r--r-- | llvm/utils/TableGen/DAGISelMatcher.h | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/llvm/utils/TableGen/DAGISelMatcher.h b/llvm/utils/TableGen/DAGISelMatcher.h index ebac7902de4..70031fa6d3b 100644 --- a/llvm/utils/TableGen/DAGISelMatcher.h +++ b/llvm/utils/TableGen/DAGISelMatcher.h @@ -55,6 +55,7 @@ public: // Predicate checking. CheckSame, // Fail if not same as prev match. + CheckChildSame, // Fail if child not same as prev match. CheckPatternPredicate, CheckPredicate, // Fail if node predicate fails. CheckOpcode, // Fail if not opcode. @@ -122,6 +123,7 @@ public: switch (getKind()) { default: return false; case CheckSame: + case CheckChildSame: case CheckPatternPredicate: case CheckPredicate: case CheckOpcode: @@ -392,6 +394,34 @@ private: virtual unsigned getHashImpl() const { return getMatchNumber(); } }; +/// CheckChildSameMatcher - This checks to see if child node is exactly the same +/// node as the specified match that was recorded with 'Record'. This is used +/// when patterns have the same name in them, like '(mul GPR:$in, GPR:$in)'. +class CheckChildSameMatcher : public Matcher { + unsigned ChildNo; + unsigned MatchNumber; +public: + CheckChildSameMatcher(unsigned childno, unsigned matchnumber) + : Matcher(CheckChildSame), ChildNo(childno), MatchNumber(matchnumber) {} + + unsigned getChildNo() const { return ChildNo; } + unsigned getMatchNumber() const { return MatchNumber; } + + static inline bool classof(const Matcher *N) { + return N->getKind() == CheckChildSame; + } + + virtual bool isSafeToReorderWithPatternPredicate() const { return true; } + +private: + virtual void printImpl(raw_ostream &OS, unsigned indent) const; + virtual bool isEqualImpl(const Matcher *M) const { + return cast<CheckChildSameMatcher>(M)->ChildNo == ChildNo && + cast<CheckChildSameMatcher>(M)->MatchNumber == MatchNumber; + } + virtual unsigned getHashImpl() const { return (MatchNumber << 2) | ChildNo; } +}; + /// CheckPatternPredicateMatcher - This checks the target-specific predicate /// to see if the entire pattern is capable of matching. This predicate does /// not take a node as input. This is used for subtarget feature checks etc. |