[PATCH] D142079: [TableGen] Support custom decoders for variable length instructions

Min-Yih Hsu via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Sat Jan 21 12:08:19 PST 2023


myhsu added inline comments.


================
Comment at: llvm/include/llvm/Target/Target.td:806-807
+/// doesn't matter.
+/// Note that currently we cannot assign different decoders in the same
+/// (instruction) operand.
 def encoder;
----------------
0x59616e wrote:
> Under what circumstances will we need different decoders for the same operand ?
I figure it's probably rare but for instance, the binary encoding of an operand was separated in two different places so the decoder has to puzzle them back.


================
Comment at: llvm/utils/TableGen/VarLenCodeEmitterGen.cpp:140-143
+    StringRef CustomEncoder, CustomDecoder;
     if (DI->getNumArgs() >= 3)
-      CustomEncoder = getCustomEncoderName(DI->getArg(2));
-    Segments.push_back(
-        {static_cast<unsigned>(NumBitsVal), OperandName, CustomEncoder});
+      std::tie(CustomEncoder, CustomDecoder) =
+          getCustomCoders(DI->getArgs().slice(2));
----------------
0x59616e wrote:
> nit: `getCustomCoders` will return empty `StringRef` automatically if `DI->getNumArgs()` == 2. So this if statement is unnecessary.
good catch, thanks!


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D142079/new/

https://reviews.llvm.org/D142079



More information about the llvm-commits mailing list