[llvm] [TableGen][NFC] Replace hardcoded opcode numbering. (PR #81065)
via llvm-commits
llvm-commits at lists.llvm.org
Wed Feb 7 16:45:17 PST 2024
llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-llvm-globalisel
Author: Jason Eckhardt (nvjle)
<details>
<summary>Changes</summary>
This patch uses the recently introduced CodeGenTarget::getInstrIntValue to replace hardcoded opcode enum value numbering in a few places.
---
Full diff: https://github.com/llvm/llvm-project/pull/81065.diff
2 Files Affected:
- (modified) llvm/utils/TableGen/GlobalISelMatchTable.cpp (+1-2)
- (modified) llvm/utils/TableGen/InstrInfoEmitter.cpp (+3-2)
``````````diff
diff --git a/llvm/utils/TableGen/GlobalISelMatchTable.cpp b/llvm/utils/TableGen/GlobalISelMatchTable.cpp
index 051c536f113f7..f7166ead9adc3 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 b2250c0cf9897..dbc5c22f23879 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";
``````````
</details>
https://github.com/llvm/llvm-project/pull/81065
More information about the llvm-commits
mailing list