]> granicus.if.org Git - llvm/commit
[RISCV] Add Custom Parser for Atomic Memory Operands
authorSam Elliott <selliott@lowrisc.org>
Thu, 1 Aug 2019 12:42:31 +0000 (12:42 +0000)
committerSam Elliott <selliott@lowrisc.org>
Thu, 1 Aug 2019 12:42:31 +0000 (12:42 +0000)
commit08a44c9adc342f7db0df92fd1f3713be3f5575c6
treea0ad0318c65d292f27464bfd8757a766ef332040
parent2f4e7f099b6c9f7c712375874be31d549404efa7
[RISCV] Add Custom Parser for Atomic Memory Operands

Summary:
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)`.

Reviewers: asb, lewis-revill

Reviewed By: asb

Subscribers: s.egerton, hiraditya, rbar, johnrusso, simoncook, apazos, sabuasal, niosHD, kito-cheng, shiva0217, jrtc27, MaskRay, zzheng, edward-jones, rogfer01, MartinMosbeck, brucehoult, the_o, rkruppe, jfb, PkmX, jocewei, psnobl, benna, Jim, llvm-commits

Tags: #llvm

Differential Revision: https://reviews.llvm.org/D65205

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@367553 91177308-0d34-0410-b5e6-96231b3b80d8
lib/Target/RISCV/AsmParser/RISCVAsmParser.cpp
lib/Target/RISCV/MCTargetDesc/RISCVInstPrinter.cpp
lib/Target/RISCV/MCTargetDesc/RISCVInstPrinter.h
lib/Target/RISCV/RISCVInstrInfoA.td
test/MC/RISCV/rv32a-invalid.s
test/MC/RISCV/rv64a-aliases-valid.s [new file with mode: 0644]
test/MC/RISCV/rv64a-invalid.s
test/MC/RISCV/rva-aliases-invalid.s [new file with mode: 0644]
test/MC/RISCV/rva-aliases-valid.s [new file with mode: 0644]