[llvm] [TableGen] Improvements to Named operands in InstrInfoEmitter (PR #124960)
Rahul Joshi via llvm-commits
llvm-commits at lists.llvm.org
Wed Jan 29 17:48:24 PST 2025
================
@@ -307,28 +295,30 @@ void InstrInfoEmitter::emitOperandNameMappings(
OS << "namespace llvm::" << Namespace << " {\n";
OS << "LLVM_READONLY\n";
OS << "int16_t getNamedOperandIdx(uint16_t Opcode, uint16_t NamedIdx) {\n";
- if (!Operands.empty()) {
- OS << " static const int16_t OperandMap [][" << Operands.size()
+ if (NumOperandNames != 0) {
+ assert(MaxOperandNo <= INT16_MAX &&
+ "Too many operands for the operand name -> index table");
+ StringRef Type = MaxOperandNo <= INT8_MAX ? "int8_t" : "int16_t";
+ OS << " static constexpr " << Type << " OperandMap[][" << NumOperandNames
<< "] = {\n";
for (const auto &Entry : OperandMap) {
const std::map<unsigned, unsigned> &OpList = Entry.first;
- OS << "{";
-
- // Emit a row of the OperandMap table
- for (unsigned i = 0, e = Operands.size(); i != e; ++i)
- OS << (OpList.count(i) == 0 ? -1 : (int)OpList.find(i)->second) << ", ";
+ // Emit a row of the OperandMap table.
+ OS << " {";
+ for (int i = 0; i < static_cast<int>(NumOperandNames); ++i) {
+ unsigned ID = OperandEnumToID[i];
+ OS << (OpList.count(ID) ? (int)OpList.find(ID)->second : -1) << ", ";
----------------
jurahul wrote:
Will do
https://github.com/llvm/llvm-project/pull/124960
More information about the llvm-commits
mailing list