[llvm] b2f29ad - [TableGen] Reduce code duplication. NFC
Craig Topper via llvm-commits
llvm-commits at lists.llvm.org
Fri Mar 31 23:07:26 PDT 2023
Author: Craig Topper
Date: 2023-03-31T22:54:15-07:00
New Revision: b2f29adb24a578bb8b4b0e4b4f5e136fb4f0f34a
URL: https://github.com/llvm/llvm-project/commit/b2f29adb24a578bb8b4b0e4b4f5e136fb4f0f34a
DIFF: https://github.com/llvm/llvm-project/commit/b2f29adb24a578bb8b4b0e4b4f5e136fb4f0f34a.diff
LOG: [TableGen] Reduce code duplication. NFC
Added:
Modified:
llvm/utils/TableGen/DAGISelMatcherGen.cpp
Removed:
################################################################################
diff --git a/llvm/utils/TableGen/DAGISelMatcherGen.cpp b/llvm/utils/TableGen/DAGISelMatcherGen.cpp
index ac45de8be4c5a..ab75181d3244f 100644
--- a/llvm/utils/TableGen/DAGISelMatcherGen.cpp
+++ b/llvm/utils/TableGen/DAGISelMatcherGen.cpp
@@ -281,7 +281,8 @@ void MatcherGen::EmitLeafMatchCode(const TreePatternNode *N) {
return;
}
- if (LeafRec->getName() == "immAllOnesV") {
+ if (LeafRec->getName() == "immAllOnesV" ||
+ LeafRec->getName() == "immAllZerosV") {
// If this is the root of the dag we're matching, we emit a redundant opcode
// check to ensure that this gets folded into the normal top-level
// OpcodeSwitch.
@@ -291,19 +292,11 @@ void MatcherGen::EmitLeafMatchCode(const TreePatternNode *N) {
const SDNodeInfo &NI = CGP.getSDNodeInfo(CGP.getSDNodeNamed(Name));
AddMatcher(new CheckOpcodeMatcher(NI));
}
- return AddMatcher(new CheckImmAllOnesVMatcher());
- }
- if (LeafRec->getName() == "immAllZerosV") {
- // If this is the root of the dag we're matching, we emit a redundant opcode
- // check to ensure that this gets folded into the normal top-level
- // OpcodeSwitch.
- if (N == Pattern.getSrcPattern()) {
- MVT VT = N->getSimpleType(0);
- StringRef Name = VT.isScalableVector() ? "splat_vector" : "build_vector";
- const SDNodeInfo &NI = CGP.getSDNodeInfo(CGP.getSDNodeNamed(Name));
- AddMatcher(new CheckOpcodeMatcher(NI));
- }
- return AddMatcher(new CheckImmAllZerosVMatcher());
+ if (LeafRec->getName() == "immAllOnesV")
+ AddMatcher(new CheckImmAllOnesVMatcher());
+ else
+ AddMatcher(new CheckImmAllZerosVMatcher());
+ return;
}
errs() << "Unknown leaf kind: " << *N << "\n";
More information about the llvm-commits
mailing list