[PATCH] D156432: [RISCV][NFC] Use !format to simplify some code
Craig Topper via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Mon Jul 31 12:47:32 PDT 2023
craig.topper added inline comments.
================
Comment at: llvm/lib/Target/RISCV/RISCVInstrInfo.td:192
-def uimm1 : Operand<XLenVT>, ImmLeaf<XLenVT, [{return isUInt<1>(Imm);}]> {
- let ParserMatchClass = UImmAsmOperand<1>;
- let DecoderMethod = "decodeUImmOperand<1>";
- let OperandType = "OPERAND_UIMM1";
- let OperandNamespace = "RISCVOp";
+foreach i = [1, 5] in {
+ def uimm # i : Operand<XLenVT>, ImmLeaf<XLenVT, !format([{return isUInt<{0}>(Imm);}], i)> {
----------------
Instead of a foreach, can we have a class or two that takes the number of bits as a parameter?
Then we can have something like
```
uimm1 : UImmOperand<1>, UImmLeaf<1>;
uimm5 : UImmOperand<5>, UImmLeaf<5>;
```
That would make it much easier to find whether uimm1 or uimm5 already exist with a grep when we need them.
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D156432/new/
https://reviews.llvm.org/D156432
More information about the llvm-commits
mailing list