diff options
author | Craig Topper <craig.topper@gmail.com> | 2014-02-05 05:44:28 +0000 |
---|---|---|
committer | Craig Topper <craig.topper@gmail.com> | 2014-02-05 05:44:28 +0000 |
commit | 3211c86b969a0de8e7b42c32df2756da4dbc0a3e (patch) | |
tree | b6bb2ff7ad252f78e886d873416b3f173dc517bb /utils | |
parent | deb0ab53b5b28e2c2601a594a9b2a6baad9e456e (diff) | |
download | llvm-3211c86b969a0de8e7b42c32df2756da4dbc0a3e.tar.gz llvm-3211c86b969a0de8e7b42c32df2756da4dbc0a3e.tar.bz2 llvm-3211c86b969a0de8e7b42c32df2756da4dbc0a3e.tar.xz |
Add CheckChildInteger to ISelMatcher operations. Removes nearly 2000 bytes from X86 matcher table.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@200821 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'utils')
-rw-r--r-- | utils/TableGen/DAGISelMatcher.cpp | 17 | ||||
-rw-r--r-- | utils/TableGen/DAGISelMatcher.h | 30 | ||||
-rw-r--r-- | utils/TableGen/DAGISelMatcherEmitter.cpp | 9 | ||||
-rw-r--r-- | utils/TableGen/DAGISelMatcherOpt.cpp | 6 |
4 files changed, 61 insertions, 1 deletions
diff --git a/utils/TableGen/DAGISelMatcher.cpp b/utils/TableGen/DAGISelMatcher.cpp index 64764bdb92..2557bb6eea 100644 --- a/utils/TableGen/DAGISelMatcher.cpp +++ b/utils/TableGen/DAGISelMatcher.cpp @@ -194,6 +194,11 @@ void CheckIntegerMatcher::printImpl(raw_ostream &OS, unsigned indent) const { OS.indent(indent) << "CheckInteger " << Value << '\n'; } +void CheckChildIntegerMatcher::printImpl(raw_ostream &OS, + unsigned indent) const { + OS.indent(indent) << "CheckChildInteger " << ChildNo << " " << Value << '\n'; +} + void CheckCondCodeMatcher::printImpl(raw_ostream &OS, unsigned indent) const { OS.indent(indent) << "CheckCondCode ISD::" << CondCodeName << '\n'; } @@ -420,6 +425,18 @@ bool CheckIntegerMatcher::isContradictoryImpl(const Matcher *M) const { return false; } +bool CheckChildIntegerMatcher::isContradictoryImpl(const Matcher *M) const { + if (const CheckChildIntegerMatcher *CCIM = dyn_cast<CheckChildIntegerMatcher>(M)) { + // If the two checks are about different nodes, we don't know if they + // conflict! + if (CCIM->getChildNo() != getChildNo()) + return false; + + return CCIM->getValue() != getValue(); + } + return false; +} + bool CheckValueTypeMatcher::isContradictoryImpl(const Matcher *M) const { if (const CheckValueTypeMatcher *CVT = dyn_cast<CheckValueTypeMatcher>(M)) return CVT->getTypeName() != getTypeName(); diff --git a/utils/TableGen/DAGISelMatcher.h b/utils/TableGen/DAGISelMatcher.h index 4a07df8f9d..97b81e54be 100644 --- a/utils/TableGen/DAGISelMatcher.h +++ b/utils/TableGen/DAGISelMatcher.h @@ -65,6 +65,7 @@ public: SwitchType, // Dispatch based on type. CheckChildType, // Fail if child has wrong type. CheckInteger, // Fail if wrong val. + CheckChildInteger, // Fail if child is wrong val. CheckCondCode, // Fail if not condcode. CheckValueType, CheckComplexPat, @@ -131,6 +132,7 @@ public: case CheckType: case CheckChildType: case CheckInteger: + case CheckChildInteger: case CheckCondCode: case CheckValueType: case CheckAndImm: @@ -632,6 +634,34 @@ private: virtual bool isContradictoryImpl(const Matcher *M) const; }; +/// CheckChildIntegerMatcher - This checks to see if the child node is a +/// ConstantSDNode with a specified integer value, if not it fails to match. +class CheckChildIntegerMatcher : public Matcher { + unsigned ChildNo; + int64_t Value; +public: + CheckChildIntegerMatcher(unsigned childno, int64_t value) + : Matcher(CheckChildInteger), ChildNo(childno), Value(value) {} + + unsigned getChildNo() const { return ChildNo; } + int64_t getValue() const { return Value; } + + static inline bool classof(const Matcher *N) { + return N->getKind() == CheckChildInteger; + } + + 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<CheckChildIntegerMatcher>(M)->ChildNo == ChildNo && + cast<CheckChildIntegerMatcher>(M)->Value == Value; + } + virtual unsigned getHashImpl() const { return (Value << 3) | ChildNo; } + virtual bool isContradictoryImpl(const Matcher *M) const; +}; + /// CheckCondCodeMatcher - This checks to see if the current node is a /// CondCodeSDNode with the specified condition, if not it fails to match. class CheckCondCodeMatcher : public Matcher { diff --git a/utils/TableGen/DAGISelMatcherEmitter.cpp b/utils/TableGen/DAGISelMatcherEmitter.cpp index cceec9f691..41db5c56e9 100644 --- a/utils/TableGen/DAGISelMatcherEmitter.cpp +++ b/utils/TableGen/DAGISelMatcherEmitter.cpp @@ -378,6 +378,14 @@ EmitMatcher(const Matcher *N, unsigned Indent, unsigned CurrentIdx, OS << '\n'; return Bytes; } + case Matcher::CheckChildInteger: { + OS << "OPC_CheckChild" << cast<CheckChildIntegerMatcher>(N)->getChildNo() + << "Integer, "; + unsigned Bytes=1+EmitVBRValue(cast<CheckChildIntegerMatcher>(N)->getValue(), + OS); + OS << '\n'; + return Bytes; + } case Matcher::CheckCondCode: OS << "OPC_CheckCondCode, ISD::" << cast<CheckCondCodeMatcher>(N)->getCondCodeName() << ",\n"; @@ -768,6 +776,7 @@ void MatcherTableEmitter::EmitHistogram(const Matcher *M, case Matcher::SwitchType: OS << "OPC_SwitchType"; break; case Matcher::CheckChildType: OS << "OPC_CheckChildType"; break; case Matcher::CheckInteger: OS << "OPC_CheckInteger"; break; + case Matcher::CheckChildInteger: OS << "OPC_CheckChildInteger"; break; case Matcher::CheckCondCode: OS << "OPC_CheckCondCode"; break; case Matcher::CheckValueType: OS << "OPC_CheckValueType"; break; case Matcher::CheckComplexPat: OS << "OPC_CheckComplexPat"; break; diff --git a/utils/TableGen/DAGISelMatcherOpt.cpp b/utils/TableGen/DAGISelMatcherOpt.cpp index 8fde8ce5bc..682b27c097 100644 --- a/utils/TableGen/DAGISelMatcherOpt.cpp +++ b/utils/TableGen/DAGISelMatcherOpt.cpp @@ -46,7 +46,7 @@ static void ContractNodes(OwningPtr<Matcher> &MatcherPtr, if (MC->getChildNo() < 8) // Only have RecordChild0...7 New = new RecordChildMatcher(MC->getChildNo(), RM->getWhatFor(), RM->getResultNo()); - + if (CheckTypeMatcher *CT = dyn_cast<CheckTypeMatcher>(MC->getNext())) if (MC->getChildNo() < 8 && // Only have CheckChildType0...7 CT->getResNo() == 0) // CheckChildType checks res #0 @@ -56,6 +56,10 @@ static void ContractNodes(OwningPtr<Matcher> &MatcherPtr, if (MC->getChildNo() < 4) // Only have CheckChildSame0...3 New = new CheckChildSameMatcher(MC->getChildNo(), CS->getMatchNumber()); + if (CheckIntegerMatcher *CS = dyn_cast<CheckIntegerMatcher>(MC->getNext())) + if (MC->getChildNo() < 5) // Only have CheckChildInteger0...4 + New = new CheckChildIntegerMatcher(MC->getChildNo(), CS->getValue()); + if (New) { // Insert the new node. New->setNext(MatcherPtr.take()); |