[llvm] [TableGen] Improvements to Named operands in InstrInfoEmitter (PR #124960)
Rahul Joshi via llvm-commits
llvm-commits at lists.llvm.org
Fri Jan 31 14:41:31 PST 2025
jurahul wrote:
> > > > Hi @jurahul ,
> > > > My downstream backend uses sentinel `OPERAND_LAST` (perhaps others do as well). It seems best to restore that line. It is pretty common for TableGen to emit sentinels in enums like this, and they can be useful.
> > >
> > >
> > > Can you say more about what you use it for? If I understand correctly the value wasn't guaranteed to be a value that wasn't used elsewhere in the enum.
> >
> >
> > Really as a sentinel value, for example. to indicate that the enum value is not present. For example, a function that returns OpName can return OPERAND_LAST to indicate that it did not find the operand it was looking for. We could also instead use `std::optional<OpName>` but as @nvjle said its best to restore it as other downstream backends may be using this as well.
>
> It's not named the same way most enums in LLVM are. "LAST" usually refers a value that is inclusive in the range. See LAST_FCMP_PREDICATE, LAST_MEMORY_OPCODE, LAST_*_INST. There are other exceptions to this, but that seemed to be the general pattern. enum values one past the end of the range are usually labeled END or NUM like NUM_TARGET_REGS or INSTRUCTION_LIST_END.
Makes sense. We can add a NUM_OPERAND_NAMES alias to start with and remove OPERAND_LAST once all other users (downstream) migrate to it.
https://github.com/llvm/llvm-project/pull/124960
More information about the llvm-commits
mailing list