[PATCH] D144166: [RISCV] For rv32, accept constants like 0xfffff800 as a valid simm12.

Craig Topper via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Feb 16 00:35:36 PST 2023


craig.topper created this revision.
craig.topper added reviewers: asb, luismarques, jrtc27, kito-cheng, reames.
Herald added subscribers: luke, VincentWu, vkmr, frasercrmck, evandro, apazos, sameer.abuasal, s.egerton, Jim, benna, psnobl, jocewei, PkmX, the_o, brucehoult, MartinMosbeck, rogfer01, edward-jones, zzheng, shiva0217, niosHD, sabuasal, simoncook, johnrusso, rbar, hiraditya, arichardson.
Herald added a project: All.
craig.topper requested review of this revision.
Herald added subscribers: pcwang-thead, eopXD, MaskRay.
Herald added a project: LLVM.

Internally we store constants in int64_t after parsing, but this is
kind of an implementation detail. If we only supported rv32, we might
have chosen int32_t.

For rv32, I think it makes sense to accept the constants that we
would accept if int32_t was the internal type. In fact we already
do this for the `li` alias. This patch extends this to sign
extended constants for other instructions.

This matches the GNU assembler. The difference between LLVM and gcc
was previously noted here. https://github.com/riscv-non-isa/riscv-asm-manual/pull/71


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D144166

Files:
  llvm/lib/Target/RISCV/AsmParser/RISCVAsmParser.cpp
  llvm/test/MC/RISCV/rv32c-only-valid.s
  llvm/test/MC/RISCV/rv32i-only-valid.s
  llvm/test/MC/RISCV/rvv/rv32-immediate.s

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D144166.497913.patch
Type: text/x-patch
Size: 5750 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20230216/f5d0c694/attachment.bin>


More information about the llvm-commits mailing list