[PATCH] D65291: [RISCV] Add Custom Parser for Atomic Memory Operands

James Clarke via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Jul 25 09:31:09 PDT 2019


jrtc27 created this revision.
jrtc27 added reviewers: asb, lewis-revill, lenary.
Herald added subscribers: llvm-commits, s.egerton, Jim, benna, psnobl, jocewei, PkmX, jfb, rkruppe, the_o, brucehoult, MartinMosbeck, rogfer01, edward-jones, zzheng, MaskRay, shiva0217, kito-cheng, niosHD, sabuasal, apazos, simoncook, johnrusso, rbar, hiraditya.
Herald added a project: LLVM.

GCC Accepts both (reg) and 0(reg) for atomic instruction memory
operands. These instructions do not allow for an offset in their
encoding, so in the latter case, the 0 is silently dropped.

Due to how we have structured the RISCVAsmParser, the easiest way to add
support for parsing this offset is to add a custom AsmOperand and
parser. This parser drops all the parens, and just keeps the register.

This commit also adds a custom printer for these operands, which matches
the GCC canonical printer, printing both `(a0)` and `0(a0)` as `(a0)`.

Based on D65205 <https://reviews.llvm.org/D65205> by Sam Elliott.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D65291

Files:
  llvm/lib/Target/RISCV/AsmParser/RISCVAsmParser.cpp
  llvm/lib/Target/RISCV/MCTargetDesc/RISCVInstPrinter.cpp
  llvm/lib/Target/RISCV/MCTargetDesc/RISCVInstPrinter.h
  llvm/lib/Target/RISCV/RISCVInstrInfoA.td
  llvm/test/MC/RISCV/rv32a-invalid.s
  llvm/test/MC/RISCV/rv64a-aliases-valid.s
  llvm/test/MC/RISCV/rv64a-invalid.s
  llvm/test/MC/RISCV/rva-aliases-invalid.s
  llvm/test/MC/RISCV/rva-aliases-valid.s

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D65291.211780.patch
Type: text/x-patch
Size: 36363 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20190725/8128b01c/attachment-0001.bin>


More information about the llvm-commits mailing list