]> git.ipfire.org Git - thirdparty/gcc.git/commit
RISC-V: Implement -m{,no}fence-tso
authorPalmer Dabbelt <palmer@rivosinc.com>
Sat, 18 May 2024 21:15:09 +0000 (15:15 -0600)
committerJeff Law <jlaw@ventanamicro.com>
Sat, 18 May 2024 21:16:45 +0000 (15:16 -0600)
commita6114c2a691112f9cf5b072c21685d2e43c76d81
tree30775e9894e5d387f4c591bd1428b8dd2277834c
parent3c9c52a1c0fa7af22f769a2116b28a0b7ea18129
RISC-V: Implement -m{,no}fence-tso

Some processors from T-Head don't implement the `fence.tso` instruction
natively and instead trap to firmware.  This breaks some users who
haven't yet updated the firmware and one could imagine it breaking users
who are trying to build firmware if they're using the C memory model.

So just add an option to disable emitting it, in a similar fashion to
how we allow users to forbid other instructions.

Link: https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=1070959
---
I've just smoke tested this one, but

    void func(void) { __atomic_thread_fence(__ATOMIC_ACQ_REL); }

generates `fence.tso` without the argument and `fence rw,rw` with
`-mno-fence-tso`, so it seems to be at least mostly there.  I figured
I'd just send it up for comments before putting together the DG bits:
it's kind of a pain to carry around these workarounds for unimplemented
instructions, but it's in HW so there's not much we can do about that.

gcc/ChangeLog:

* config/riscv/riscv.opt: Add -mno-fence-tso.
* config/riscv/sync-rvwmo.md (mem_thread_fence_rvwmo): Respect
-mno-fence-tso.
* doc/invoke.texi (RISC-V): Document -mno-fence-tso.
gcc/config/riscv/riscv.opt
gcc/config/riscv/sync-rvwmo.md
gcc/doc/invoke.texi