From 69039e77309a5e1555797319c1c5f64af1b489c3 Mon Sep 17 00:00:00 2001 From: Craig Topper Date: Tue, 26 Jan 2021 19:41:52 -0800 Subject: [PATCH] [TableGen] Add isContradictoryImpl implementation to CheckCondCodeMatcher and CheckChild2CondCodeMatcher. This enables better pattern factoring in the RISCV ISel table. --- utils/TableGen/DAGISelMatcher.cpp | 12 ++++++++++++ utils/TableGen/DAGISelMatcher.h | 2 ++ 2 files changed, 14 insertions(+) diff --git a/utils/TableGen/DAGISelMatcher.cpp b/utils/TableGen/DAGISelMatcher.cpp index bebd205ad58..e436a931a9f 100644 --- a/utils/TableGen/DAGISelMatcher.cpp +++ b/utils/TableGen/DAGISelMatcher.cpp @@ -421,3 +421,15 @@ bool CheckImmAllZerosVMatcher::isContradictoryImpl(const Matcher *M) const { // AllOnes is contradictory. return isa(M); } + +bool CheckCondCodeMatcher::isContradictoryImpl(const Matcher *M) const { + if (const auto *CCCM = dyn_cast(M)) + return CCCM->getCondCodeName() != getCondCodeName(); + return false; +} + +bool CheckChild2CondCodeMatcher::isContradictoryImpl(const Matcher *M) const { + if (const auto *CCCCM = dyn_cast(M)) + return CCCCM->getCondCodeName() != getCondCodeName(); + return false; +} diff --git a/utils/TableGen/DAGISelMatcher.h b/utils/TableGen/DAGISelMatcher.h index ff9a0cb335d..77280acaf4c 100644 --- a/utils/TableGen/DAGISelMatcher.h +++ b/utils/TableGen/DAGISelMatcher.h @@ -635,6 +635,7 @@ private: bool isEqualImpl(const Matcher *M) const override { return cast(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(M)->CondCodeName == CondCodeName; } + bool isContradictoryImpl(const Matcher *M) const override; }; /// CheckValueTypeMatcher - This checks to see if the current node is a