[llvm] [TableGen] Change emitted comments for OPC_Scope to be more like OPC_SwitchType/Opcode. NFC (PR #175124)
via llvm-commits
llvm-commits at lists.llvm.org
Thu Jan 8 22:57:45 PST 2026
llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-llvm-selectiondag
Author: Craig Topper (topperc)
<details>
<summary>Changes</summary>
---
Full diff: https://github.com/llvm/llvm-project/pull/175124.diff
4 Files Affected:
- (modified) llvm/test/TableGen/CPtrWildcard.td (+2-2)
- (modified) llvm/test/TableGen/RegClassByHwMode.td (+4-4)
- (modified) llvm/test/TableGen/dag-isel-regclass-emit-enum.td (+1-1)
- (modified) llvm/utils/TableGen/DAGISelMatcherEmitter.cpp (+15-15)
``````````diff
diff --git a/llvm/test/TableGen/CPtrWildcard.td b/llvm/test/TableGen/CPtrWildcard.td
index 79efc42af9634..a19ae7fca2b84 100644
--- a/llvm/test/TableGen/CPtrWildcard.td
+++ b/llvm/test/TableGen/CPtrWildcard.td
@@ -7,13 +7,13 @@
// CHECK-NEXT: /* 0*/ OPC_CheckOpcode, TARGET_VAL(ISD::INTRINSIC_WO_CHAIN),
// CHECK-NEXT:/* 3*/ OPC_CheckChild0Integer, [[#]],
// CHECK-NEXT:/* 5*/ OPC_RecordChild1, // #0 = $src
-// CHECK-NEXT:/* 6*/ OPC_Scope, 9, /*->17*/ // 2 children in Scope
+// CHECK-NEXT:/* 6*/ OPC_Scope /*2 children */, 9, // ->17
// CHECK-NEXT:/* 8*/ OPC_CheckChild1Type, /*MVT::c64*/2|128,2/*258*/,
// CHECK-NEXT:/* 11*/ OPC_MorphNodeTo1None, TARGET_VAL(MyTarget::C64_TO_I64),
// CHECK-NEXT: /*MVT::i64*/8, 1/*#Ops*/, 0,
// CHECK-NEXT: // Src: (intrinsic_wo_chain:{ *:[i64] } [[#]]:{ *:[iPTR] }, c64:{ *:[c64] }:$src) - Complexity = 8
// CHECK-NEXT: // Dst: (C64_TO_I64:{ *:[i64] } ?:{ *:[c64] }:$src)
-// CHECK-NEXT:/* 17*/ /*Scope*/ 9, /*->27*/
+// CHECK-NEXT:/* 17*/ /*Scope*/ 9, // ->27
// CHECK-NEXT:/* 18*/ OPC_CheckChild1Type, /*MVT::c128*/3|128,2/*259*/,
// CHECK-NEXT:/* 21*/ OPC_MorphNodeTo1None, TARGET_VAL(MyTarget::C128_TO_I64),
// CHECK-NEXT: /*MVT::i64*/8, 1/*#Ops*/, 0,
diff --git a/llvm/test/TableGen/RegClassByHwMode.td b/llvm/test/TableGen/RegClassByHwMode.td
index 6c6d5ef9ecf85..2e5e6d08ddae6 100644
--- a/llvm/test/TableGen/RegClassByHwMode.td
+++ b/llvm/test/TableGen/RegClassByHwMode.td
@@ -207,11 +207,11 @@ include "Common/RegClassByHwModeCommon.td"
// ISEL-SDAG-NEXT: OPC_RecordChild1, // #1 = $val
// ISEL-SDAG-NEXT: OPC_CheckChild1TypeI64,
// ISEL-SDAG-NEXT: OPC_RecordChild2, // #2 = $src
-// ISEL-SDAG-NEXT: OPC_Scope, {{[0-9]+}}, /*->{{[0-9]+}}*/ // 2 children in Scope
+// ISEL-SDAG-NEXT: OPC_Scope /*2 children */, {{[0-9]+}}, // ->{{[0-9]+}}
// ISEL-SDAG-NEXT: OPC_CheckChild2TypeI32,
// ISEL-SDAG-NEXT: OPC_CheckPredicate0, // Predicate_unindexedstore
// ISEL-SDAG-NEXT: OPC_CheckPredicate1, // Predicate_store
-// ISEL-SDAG-NEXT: OPC_Scope, {{[0-9]+}}, /*->{{[0-9]+}}*/ // 3 children in Scope
+// ISEL-SDAG-NEXT: OPC_Scope /*3 children */, {{[0-9]+}}, // ->{{[0-9]+}}
// ISEL-SDAG-NEXT: OPC_CheckPatternPredicate0, // (Subtarget->hasAlignedRegisters())
// ISEL-SDAG-NEXT: OPC_EmitMergeInputChains1_0,
// ISEL-SDAG-NEXT: OPC_MorphNodeTo0, TARGET_VAL(MyTarget::MY_STORE), 0|OPFL_Chain|OPFL_MemRefs,
@@ -239,11 +239,11 @@ include "Common/RegClassByHwModeCommon.td"
// ISEL-SDAG-NEXT: OPC_RecordNode, // #0 = 'ld' chained node
// ISEL-SDAG-NEXT: OPC_RecordChild1, // #1 = $src
// ISEL-SDAG-NEXT: OPC_CheckTypeI64,
-// ISEL-SDAG-NEXT: OPC_Scope, {{[0-9]+}}, /*->{{[0-9]+}}*/ // 2 children in Scope
+// ISEL-SDAG-NEXT: OPC_Scope /*2 children */, {{[0-9]+}}, // ->{{[0-9]+}}
// ISEL-SDAG-NEXT: OPC_CheckChild1TypeI32,
// ISEL-SDAG-NEXT: OPC_CheckPredicate2, // Predicate_unindexedload
// ISEL-SDAG-NEXT: OPC_CheckPredicate3, // Predicate_load
-// ISEL-SDAG-NEXT: OPC_Scope, {{[0-9]+}}, /*->{{[0-9]+}}*/ // 3 children in Scope
+// ISEL-SDAG-NEXT: OPC_Scope /*3 children */, {{[0-9]+}}, // ->{{[0-9]+}}
// ISEL-SDAG-NEXT: OPC_CheckPatternPredicate0, // (Subtarget->hasAlignedRegisters())
// ISEL-SDAG-NEXT: OPC_EmitMergeInputChains1_0,
// ISEL-SDAG-NEXT: OPC_MorphNodeTo1, TARGET_VAL(MyTarget::MY_LOAD), 0|OPFL_Chain|OPFL_MemRefs,
diff --git a/llvm/test/TableGen/dag-isel-regclass-emit-enum.td b/llvm/test/TableGen/dag-isel-regclass-emit-enum.td
index f2858fc7504a4..da83c2bb5ed27 100644
--- a/llvm/test/TableGen/dag-isel-regclass-emit-enum.td
+++ b/llvm/test/TableGen/dag-isel-regclass-emit-enum.td
@@ -23,7 +23,7 @@ def GPRAbove127 : RegisterClass<"TestTarget", [i32], 32,
// CHECK: OPC_CheckOpcode, TARGET_VAL(ISD::ADD),
// CHECK-NEXT: OPC_RecordChild0, // #0 = $src
-// CHECK-NEXT: OPC_Scope, 12, /*->18*/ // 2 children in Scope
+// CHECK-NEXT: OPC_Scope /*2 children */, 12, // ->18
// CHECK-NEXT: OPC_CheckChild1Integer, 0,
// CHECK-NEXT: OPC_EmitIntegerI32, 0|128,1/*128*/, // #1 = TestNamespace::GPRAbove127RegClassID
// CHECK-NEXT: OPC_MorphNodeTo1None, TARGET_VAL(TargetOpcode::COPY_TO_REGCLASS),
diff --git a/llvm/utils/TableGen/DAGISelMatcherEmitter.cpp b/llvm/utils/TableGen/DAGISelMatcherEmitter.cpp
index 7877a1f36424f..f2f062f97cdbe 100644
--- a/llvm/utils/TableGen/DAGISelMatcherEmitter.cpp
+++ b/llvm/utils/TableGen/DAGISelMatcherEmitter.cpp
@@ -437,12 +437,15 @@ unsigned MatcherTableEmitter::EmitMatcher(const Matcher *N,
const ScopeMatcher *SM = cast<ScopeMatcher>(N);
unsigned StartIdx = CurrentIdx;
+ OS << "OPC_Scope";
+ if (!OmitComments)
+ OS << " /*" << SM->getNumChildren() << " children */";
+ OS << ", ";
+ ++CurrentIdx;
+
// Emit all of the children.
for (unsigned i = 0, e = SM->getNumChildren(); i != e; ++i) {
- if (i == 0) {
- OS << "OPC_Scope, ";
- ++CurrentIdx;
- } else {
+ if (i != 0) {
if (!OmitComments) {
OS << "/*" << format_decimal(CurrentIdx, IndexWidth) << "*/";
OS.indent(Indent) << "/*Scope*/ ";
@@ -451,20 +454,17 @@ unsigned MatcherTableEmitter::EmitMatcher(const Matcher *N,
}
}
- unsigned ChildSize = SM->getChild(i)->getSize();
- unsigned VBRSize = EmitVBRValue(ChildSize, OS);
- if (!OmitComments) {
- OS << " /*->" << CurrentIdx + VBRSize + ChildSize << "*/";
- if (i == 0)
- OS << " // " << SM->getNumChildren() << " children in Scope";
- }
+ const Matcher *Child = SM->getChild(i);
+ unsigned ChildSize = Child->getSize();
+ CurrentIdx += EmitVBRValue(ChildSize, OS);
+ if (!OmitComments)
+ OS << " // ->" << CurrentIdx + ChildSize;
OS << '\n';
- ChildSize = EmitMatcherList(SM->getChild(i), Indent + 1,
- CurrentIdx + VBRSize, OS);
- assert(ChildSize == SM->getChild(i)->getSize() &&
+ ChildSize = EmitMatcherList(Child, Indent + 1, CurrentIdx, OS);
+ assert(ChildSize == Child->getSize() &&
"Emitted child size does not match calculated size");
- CurrentIdx += VBRSize + ChildSize;
+ CurrentIdx += ChildSize;
}
// Emit a zero as a sentinel indicating end of 'Scope'.
``````````
</details>
https://github.com/llvm/llvm-project/pull/175124
More information about the llvm-commits
mailing list