Skip to content

Commit 9337344

Browse files
authored
[TableGen] Don't print the instruction enum value in multiple comments in GenInstrInfo.inc. (llvm#156960)
The name is most interesting and if you really need the number you can use the name to find the entry in the enum or use the first field of the table row.
1 parent 2498f0b commit 9337344

File tree

2 files changed

+7
-7
lines changed

2 files changed

+7
-7
lines changed

llvm/test/TableGen/def-multiple-operands.td

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ def Reg3Opnd : Operand<OtherVT> {
2424
// CHECK: archInstrTable {{.* = \{}}
2525
// CHECK: {{\{}}
2626
// CHECK: {{\{}} [[ID:[0-9]+]], 4, 3, 13, {{.+\}, \/\/}}
27-
// CHECK-SAME: Inst #[[ID]] = InstA
27+
// CHECK-SAME: InstA
2828
def InstA : Instruction {
2929
let Namespace = "MyNS";
3030
let Size = 13;

llvm/utils/TableGen/InstrInfoEmitter.cpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -760,8 +760,9 @@ void InstrInfoEmitter::emitFeatureVerifier(raw_ostream &OS,
760760
OS << " };\n"
761761
<< " static constexpr " << getMinimalTypeForRange(FeatureBitsets.size())
762762
<< " RequiredFeaturesRefs[] = {\n";
763-
unsigned InstIdx = 0;
764-
for (const CodeGenInstruction *Inst : Target.getInstructions()) {
763+
ArrayRef<const CodeGenInstruction *> NumberedInstructions =
764+
Target.getInstructions();
765+
for (const CodeGenInstruction *Inst : NumberedInstructions) {
765766
OS << " CEFBS";
766767
unsigned NumPredicates = 0;
767768
for (const Record *Predicate :
@@ -774,11 +775,10 @@ void InstrInfoEmitter::emitFeatureVerifier(raw_ostream &OS,
774775
}
775776
if (!NumPredicates)
776777
OS << "_None";
777-
OS << ", // " << Inst->TheDef->getName() << " = " << InstIdx << '\n';
778-
InstIdx++;
778+
OS << ", // " << Inst->TheDef->getName() << '\n';
779779
}
780780
OS << " };\n\n"
781-
<< " assert(Opcode < " << InstIdx << ");\n"
781+
<< " assert(Opcode < " << NumberedInstructions.size() << ");\n"
782782
<< " return FeatureBitsets[RequiredFeaturesRefs[Opcode]];\n"
783783
<< "}\n\n";
784784

@@ -1284,7 +1284,7 @@ void InstrInfoEmitter::emitRecord(
12841284
OS.write_hex(Value);
12851285
OS << "ULL";
12861286

1287-
OS << " }, // Inst #" << Num << " = " << Inst.TheDef->getName() << '\n';
1287+
OS << " }, // " << Inst.TheDef->getName() << '\n';
12881288
}
12891289

12901290
// emitEnums - Print out enum values for all of the instructions.

0 commit comments

Comments
 (0)