[llvm] [NFC][TableGen] Adopt CodeGenHelpers in InstrInfoEmitter (PR #166442)
Rahul Joshi via llvm-commits
llvm-commits at lists.llvm.org
Wed Nov 5 11:14:00 PST 2025
================
@@ -383,38 +383,35 @@ void InstrInfoEmitter::emitOperandNameMappings(
const size_t NumOperandNames = OperandNameToID.size();
const unsigned MaxNumOperands = MaxOperandNo + 1;
- OS << "#ifdef GET_INSTRINFO_OPERAND_ENUM\n";
- OS << "#undef GET_INSTRINFO_OPERAND_ENUM\n";
- OS << "namespace llvm::" << Namespace << " {\n";
-
- assert(NumOperandNames <= UINT16_MAX &&
- "Too many operands for the operand index -> name table");
- StringRef EnumType = getMinimalTypeForRange(NumOperandNames);
- OS << "enum class OpName : " << EnumType << " {\n";
- for (const auto &[Op, I] : OperandNameToID)
- OS << " " << Op << " = " << I << ",\n";
- OS << " NUM_OPERAND_NAMES = " << NumOperandNames << ",\n";
- OS << "}; // enum class OpName\n\n";
-
- OS << "LLVM_READONLY int16_t getNamedOperandIdx(uint16_t Opcode, OpName "
- "Name);\n";
- OS << "LLVM_READONLY OpName getOperandIdxName(uint16_t Opcode, int16_t "
- "Idx);\n";
- OS << "} // end namespace llvm::" << Namespace << '\n';
- OS << "#endif //GET_INSTRINFO_OPERAND_ENUM\n\n";
-
- OS << "#ifdef GET_INSTRINFO_NAMED_OPS\n";
- OS << "#undef GET_INSTRINFO_NAMED_OPS\n";
- OS << "namespace llvm::" << Namespace << " {\n";
-
- emitGetInstructionIndexForOpLookup(OS, OperandMap, InstructionIndex);
+ const std::string LlvmNamespace = ("llvm::" + Namespace).str();
----------------
jurahul wrote:
Done. SmallString has a constructor that does concatenation, so used that instead of building a Twine and then calling .str() on it
https://github.com/llvm/llvm-project/pull/166442
More information about the llvm-commits
mailing list