Skip to content

Commit 494ac2a

Browse files
committed
[TableGen] Add isContradictoryImpl implementation to CheckCondCodeMatcher and CheckChild2CondCodeMatcher.
This enables better pattern factoring in the RISCV ISel table.
1 parent 5369517 commit 494ac2a

File tree

2 files changed

+14
-0
lines changed

2 files changed

+14
-0
lines changed

llvm/utils/TableGen/DAGISelMatcher.cpp

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -421,3 +421,15 @@ bool CheckImmAllZerosVMatcher::isContradictoryImpl(const Matcher *M) const {
421421
// AllOnes is contradictory.
422422
return isa<CheckImmAllOnesVMatcher>(M);
423423
}
424+
425+
bool CheckCondCodeMatcher::isContradictoryImpl(const Matcher *M) const {
426+
if (const auto *CCCM = dyn_cast<CheckCondCodeMatcher>(M))
427+
return CCCM->getCondCodeName() != getCondCodeName();
428+
return false;
429+
}
430+
431+
bool CheckChild2CondCodeMatcher::isContradictoryImpl(const Matcher *M) const {
432+
if (const auto *CCCCM = dyn_cast<CheckChild2CondCodeMatcher>(M))
433+
return CCCCM->getCondCodeName() != getCondCodeName();
434+
return false;
435+
}

llvm/utils/TableGen/DAGISelMatcher.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -635,6 +635,7 @@ class CheckCondCodeMatcher : public Matcher {
635635
bool isEqualImpl(const Matcher *M) const override {
636636
return cast<CheckCondCodeMatcher>(M)->CondCodeName == CondCodeName;
637637
}
638+
bool isContradictoryImpl(const Matcher *M) const override;
638639
};
639640

640641
/// CheckChild2CondCodeMatcher - This checks to see if child 2 node is a
@@ -656,6 +657,7 @@ class CheckChild2CondCodeMatcher : public Matcher {
656657
bool isEqualImpl(const Matcher *M) const override {
657658
return cast<CheckChild2CondCodeMatcher>(M)->CondCodeName == CondCodeName;
658659
}
660+
bool isContradictoryImpl(const Matcher *M) const override;
659661
};
660662

661663
/// CheckValueTypeMatcher - This checks to see if the current node is a

0 commit comments

Comments
 (0)