[PATCH] D120958: [TableGen] Add support for variable length instruction in decoder generator

Sheng via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Mar 3 18:30:55 PST 2022


0x59616e created this revision.
Herald added a project: All.
0x59616e requested review of this revision.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

I want to share my thoughts with you by answering these question:

1. How do you fit variable length instruction into fixed length instruction decoder generator ?

I think of variable length instruction as fixed length instruction with the "maximum length". For example, if there're three instructions with 2, 6 and 9 bytes, we can fit them into the algorithm by treating them all have 9 bytes.

2. So every time you decode, you have to give 9 bytes to the decoder even it isn't that long ?

No, we don't need to. Take a look at `decodeInstruction` and `fieldFromInstruction`, there is a function object with type `void(APInt &, uint64_t)` in the parameter list. We can use this function to supply the bits the decoder needs.

Also, a `InstrLenTable` is added to let the decoder know how long the instruction is.


https://reviews.llvm.org/D120958

Files:
  llvm/test/TableGen/VarLenEncoder.td
  llvm/utils/TableGen/FixedLenDecoderEmitter.cpp
  llvm/utils/TableGen/VarLenCodeEmitterGen.cpp
  llvm/utils/TableGen/VarLenCodeEmitterGen.h

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D120958.412884.patch
Type: text/x-patch
Size: 31595 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20220304/5daa270b/attachment-0001.bin>


More information about the llvm-commits mailing list