[TableGen] Add isContradictoryImpl implementation to CheckCondCodeMatcher and CheckCh...
authorCraig Topper <craig.topper@sifive.com>
Wed, 27 Jan 2021 03:41:52 +0000 (19:41 -0800)
committerCraig Topper <craig.topper@sifive.com>
Wed, 27 Jan 2021 03:44:57 +0000 (19:44 -0800)
This enables better pattern factoring in the RISCV ISel table.

llvm/utils/TableGen/DAGISelMatcher.cpp
llvm/utils/TableGen/DAGISelMatcher.h

index bebd205..e436a93 100644 (file)
@@ -421,3 +421,15 @@ bool CheckImmAllZerosVMatcher::isContradictoryImpl(const Matcher *M) const {
   // AllOnes is contradictory.
   return isa<CheckImmAllOnesVMatcher>(M);
 }
+
+bool CheckCondCodeMatcher::isContradictoryImpl(const Matcher *M) const {
+  if (const auto *CCCM = dyn_cast<CheckCondCodeMatcher>(M))
+    return CCCM->getCondCodeName() != getCondCodeName();
+  return false;
+}
+
+bool CheckChild2CondCodeMatcher::isContradictoryImpl(const Matcher *M) const {
+  if (const auto *CCCCM = dyn_cast<CheckChild2CondCodeMatcher>(M))
+    return CCCCM->getCondCodeName() != getCondCodeName();
+  return false;
+}
index ff9a0cb..77280ac 100644 (file)
@@ -635,6 +635,7 @@ private:
   bool isEqualImpl(const Matcher *M) const override {
     return cast<CheckCondCodeMatcher>(M)->CondCodeName == CondCodeName;
   }
+  bool isContradictoryImpl(const Matcher *M) const override;
 };
 
 /// CheckChild2CondCodeMatcher - This checks to see if child 2 node is a
@@ -656,6 +657,7 @@ private:
   bool isEqualImpl(const Matcher *M) const override {
     return cast<CheckChild2CondCodeMatcher>(M)->CondCodeName == CondCodeName;
   }
+  bool isContradictoryImpl(const Matcher *M) const override;
 };
 
 /// CheckValueTypeMatcher - This checks to see if the current node is a