[llvm] 567d304 - [TableGen][NFC] Replace hardcoded opcode numbering. (#81065)
via llvm-commits
llvm-commits at lists.llvm.org
Wed Feb 7 19:04:18 PST 2024
Author: Jason Eckhardt
Date: 2024-02-07T19:04:14-08:00
New Revision: 567d304e5344dfb408f2453390886fc229c09481
URL: https://github.com/llvm/llvm-project/commit/567d304e5344dfb408f2453390886fc229c09481
DIFF: https://github.com/llvm/llvm-project/commit/567d304e5344dfb408f2453390886fc229c09481.diff
LOG: [TableGen][NFC] Replace hardcoded opcode numbering. (#81065)
This patch uses the recently introduced CodeGenTarget::getInstrIntValue
to replace hardcoded opcode enum value numbering in a few places.
Added:
Modified:
llvm/utils/TableGen/GlobalISelMatchTable.cpp
llvm/utils/TableGen/InstrInfoEmitter.cpp
Removed:
################################################################################
diff --git a/llvm/utils/TableGen/GlobalISelMatchTable.cpp b/llvm/utils/TableGen/GlobalISelMatchTable.cpp
index 051c536f113f7b..f7166ead9adc3d 100644
--- a/llvm/utils/TableGen/GlobalISelMatchTable.cpp
+++ b/llvm/utils/TableGen/GlobalISelMatchTable.cpp
@@ -1399,9 +1399,8 @@ void InstructionOpcodeMatcher::initOpcodeValuesMap(
const CodeGenTarget &Target) {
OpcodeValues.clear();
- unsigned OpcodeValue = 0;
for (const CodeGenInstruction *I : Target.getInstructionsByEnumValue())
- OpcodeValues[I] = OpcodeValue++;
+ OpcodeValues[I] = Target.getInstrIntValue(I->TheDef);
}
MatchTableRecord InstructionOpcodeMatcher::getValue() const {
diff --git a/llvm/utils/TableGen/InstrInfoEmitter.cpp b/llvm/utils/TableGen/InstrInfoEmitter.cpp
index b2250c0cf9897c..dbc5c22f238793 100644
--- a/llvm/utils/TableGen/InstrInfoEmitter.cpp
+++ b/llvm/utils/TableGen/InstrInfoEmitter.cpp
@@ -1284,8 +1284,9 @@ void InstrInfoEmitter::emitEnums(raw_ostream &OS) {
OS << " enum {\n";
unsigned Num = 0;
for (const CodeGenInstruction *Inst : Target.getInstructionsByEnumValue())
- OS << " " << Inst->TheDef->getName() << "\t= " << Num++ << ",\n";
- OS << " INSTRUCTION_LIST_END = " << Num << "\n";
+ OS << " " << Inst->TheDef->getName()
+ << "\t= " << (Num = Target.getInstrIntValue(Inst->TheDef)) << ",\n";
+ OS << " INSTRUCTION_LIST_END = " << Num + 1 << "\n";
OS << " };\n\n";
OS << "} // end namespace " << Namespace << "\n";
OS << "} // end namespace llvm\n";
More information about the llvm-commits
mailing list