This series contains some minor big-endian RISC-V changes.

The common theme for most of these patches is selecting
the correct subword element on big-endian targets.

The second and the third patches are fixes pertaining to
atomic instructions on big-endian builds. The second patch
fixes issues with inline-atomics. The third should fix
libatomic for big-endian builds.

The patches were tested using QEMU modified
to support big-endian RISC-V targets [1]. We will be upstreaming this in the 
future.

Testing instructions can be found in individual patch descriptions.

[1] https://github.com/djtodoro/qemu/tree/riscvbe/current#

Changes in v3:
- Drop the patch that disabled RISC-V self-tests on big-endian builds.
- Link to v2: 
https://gcc.gnu.org/pipermail/gcc-patches/2026-January/705789.html 

Chao-ying Fu (3):
  RISC-V: Fix riscv_subword_address for big-endian targets.
  RISC-V: Use correct subreg in atomic_compare_and_swap
  RISC-V: libatomic: Fix the calculation of shift for the big-endian
    target.

 gcc/config/riscv/riscv.cc                            |  5 +++++
 gcc/config/riscv/sync.md                             |  3 ++-
 .../gcc.target/riscv/amo/big-endian-subword-amo-hi.c |  9 +++++++++
 .../gcc.target/riscv/amo/big-endian-subword-amo-qi.c |  9 +++++++++
 libatomic/cas_n.c                                    |  6 +++++-
 libatomic/exch_n.c                                   |  6 +++++-
 libatomic/fop_n.c                                    | 12 ++++++++++--
 libatomic/load_n.c                                   |  6 +++++-
 libatomic/store_n.c                                  |  6 +++++-
 libatomic/tas_n.c                                    |  6 +++++-
 10 files changed, 60 insertions(+), 8 deletions(-)
 create mode 100644 
gcc/testsuite/gcc.target/riscv/amo/big-endian-subword-amo-hi.c
 create mode 100644 
gcc/testsuite/gcc.target/riscv/amo/big-endian-subword-amo-qi.c

-- 
2.43.0

Reply via email to