[llvm] [TableGen] Emit OpName as an enum class instead of a namespace (PR #125313)
Craig Topper via llvm-commits
llvm-commits at lists.llvm.org
Mon Feb 3 21:43:34 PST 2025
================
@@ -282,20 +282,23 @@ void InstrInfoEmitter::emitOperandNameMappings(
OS << "#ifdef GET_INSTRINFO_OPERAND_ENUM\n";
OS << "#undef GET_INSTRINFO_OPERAND_ENUM\n";
- OS << "namespace llvm::" << Namespace << "::OpName {\n";
- OS << "enum {\n";
+ OS << "namespace llvm::" << Namespace << " {\n";
+ OS << "enum class OpName {\n";
for (const auto &[I, Op] : enumerate(OperandNameToID))
OS << " " << Op.first << " = " << I << ",\n";
- OS << " OPERAND_LAST = " << NumOperandNames << ",\n";
- OS << "};\n";
- OS << "} // end namespace llvm::" << Namespace << "::OpName\n";
+ OS << " NUM_OPERAND_NAMES = " << NumOperandNames << ",\n";
+ OS << "}; // enum class OpName\n\n";
+ OS << "LLVM_READONLY\n";
+ OS << "int16_t getNamedOperandIdx(uint16_t Opcode, OpName NamedIdx);\n";
----------------
topperc wrote:
`NamedIdx` is called `Name` when we emit the definition on line 300.
https://github.com/llvm/llvm-project/pull/125313
More information about the llvm-commits
mailing list