[0/1] RISC-V: Add support for 'Zacas' atomic CAS

Message ID cover.1697857915.git.research_trasio@irq.a4lg.com
Headers
Series RISC-V: Add support for 'Zacas' atomic CAS |

Message

Tsukasa OI Oct. 21, 2023, 3:12 a.m. UTC
  Hi,

This patch adds support for now frozen (and being ratification) 'Zacas'
extension, containing atomic CAS instructions.

There are two patch sets by other people:

By Gianluca Guida (in 2023 May; RFC PATCH v2 at that time):
<https://sourceware.org/pipermail/binutils/2023-May/127700.html>
By Jiawei (in 2023 July; withdrawn):
<https://sourceware.org/pipermail/binutils/2023-July/128556.html>

... but independently developed.


Note that, this is one of the extensions that require the concept of
register pairs or register groups because it contains 2*XLEN-width
(double-word) CAS instructions.

We are better to reject invalid encodings considering the consensus after
the discussion of RISC-V GNU Toolchain meeting at 2022-10-06 (the feedback
of my proposal itself wasn't positive but we agreed that we are better to
detect invalid encodings as early as possible [I mean, in the assembler])
and the feedback to Gianluca's first RFC PATCH by Jan:
<https://sourceware.org/pipermail/binutils/2023-May/127407.html>


Differences to Gianluka's:
1.  Correct data size (INSN_DREF|INSN_*_BYTE) we are handling
2.  Make register pair matching function to be template
    to enable reusing this framework for upcoming P and existing Zdinx and
    V (many V cases are invalid only on certain runtime configuration and
    "always invalid" detectable cases are rare, but not zero).

Differences to Jiawei's:
1.  Correct support for register groups (fixed in Gianluka's RFC PATCH v2).


Thanks,
Tsukasa




Tsukasa OI (1):
  RISC-V: Add support for 'Zacas' atomic CAS

 bfd/elfxx-riscv.c                       |  6 +++++
 gas/testsuite/gas/riscv/zacas-32-fail.d |  2 ++
 gas/testsuite/gas/riscv/zacas-32-fail.l |  9 +++++++
 gas/testsuite/gas/riscv/zacas-32-fail.s | 10 +++++++
 gas/testsuite/gas/riscv/zacas-32.d      | 17 ++++++++++++
 gas/testsuite/gas/riscv/zacas-32.s      |  9 +++++++
 gas/testsuite/gas/riscv/zacas-64-fail.d |  2 ++
 gas/testsuite/gas/riscv/zacas-64-fail.l |  9 +++++++
 gas/testsuite/gas/riscv/zacas-64-fail.s | 10 +++++++
 gas/testsuite/gas/riscv/zacas-64.d      | 17 ++++++++++++
 gas/testsuite/gas/riscv/zacas-64.s      |  9 +++++++
 include/opcode/riscv-opc.h              | 11 ++++++++
 include/opcode/riscv.h                  |  1 +
 opcodes/riscv-opc.c                     | 36 +++++++++++++++++++++++++
 14 files changed, 148 insertions(+)
 create mode 100644 gas/testsuite/gas/riscv/zacas-32-fail.d
 create mode 100644 gas/testsuite/gas/riscv/zacas-32-fail.l
 create mode 100644 gas/testsuite/gas/riscv/zacas-32-fail.s
 create mode 100644 gas/testsuite/gas/riscv/zacas-32.d
 create mode 100644 gas/testsuite/gas/riscv/zacas-32.s
 create mode 100644 gas/testsuite/gas/riscv/zacas-64-fail.d
 create mode 100644 gas/testsuite/gas/riscv/zacas-64-fail.l
 create mode 100644 gas/testsuite/gas/riscv/zacas-64-fail.s
 create mode 100644 gas/testsuite/gas/riscv/zacas-64.d
 create mode 100644 gas/testsuite/gas/riscv/zacas-64.s


base-commit: 0e17d3fc080f543d81e6c2520ba0bd8046ea3a95
  

Comments

Gianluca Guida Dec. 6, 2023, 6:39 p.m. UTC | #1
Hi Tsukasa,

I somehow missed this thread completely, as I wasn't in CC. Catching up now.

On Sat, Oct 21, 2023 at 4:12 AM Tsukasa OI <research_trasio@irq.a4lg.com> wrote:
>
> Differences to Gianluka's:
> 1.  Correct data size (INSN_DREF|INSN_*_BYTE) we are handling
Correct, that was in fact fixed in my patch on my current tree.
Surprised didn't catch that earlier.

> 2.  Make register pair matching function to be template
>     to enable reusing this framework for upcoming P and existing Zdinx and
>     V (many V cases are invalid only on certain runtime configuration and
>     "always invalid" detectable cases are rare, but not zero).

Sure, I wondered about other generalising support for pair of
registers, but I was expecting some kind of discussion on the review,
so I went for the simplest patch possible, when I implemented that in
the v2.

I don't have any strong opinion on which patch to use.

Gianluca.