[llvm] [TableGen][DecoderEmitter] Add option to emit type-specialized `decodeToMCInst` (PR #146593)
Rahul Joshi via llvm-commits
llvm-commits at lists.llvm.org
Thu Jul 3 09:06:55 PDT 2025
jurahul wrote:
> > Can we store the type in the Instruction class in the .td files like the bitwidth instead of introducing a complex command line argument?
>
> +1 for this.
>
> > we will still need to validate for example that for all instructions with a particular size, the type string is same
>
> Why can't they be different?
For all targets today, the same C++ type is used as a payload for all insts of a given size. For example, all 32-bit insts might use uint32_t. So if the type is specified on each *instance* of the instruction, we may run into the case of `Inst1 { Size = 4, CPPType = "uint32_t"}` and `Inst2 { Size = 4, CPPType = "uint64_t"}`. I am assuming we do not want to support something like this (we can, but then all 32-bit decoders will be replicated into the 64-bit InstType code, which is the thing this PR avoids). so we will need additional sanity check that all insts of a given size use the *same* CPPType for their payload. But with the interface being proposed, we are avoiding that as this info is now in `InstrInfo` class and not replicated per instruction instance.
https://github.com/llvm/llvm-project/pull/146593
More information about the llvm-commits
mailing list