[clang] [llvm] [RISCV] Add experimental support of Zaamo and Zalrsc (PR #77424)

James Y Knight via cfe-commits cfe-commits at lists.llvm.org
Wed Jan 17 09:03:19 PST 2024


jyknight wrote:

There's two sets of atomic functions:
`__atomic_*` are provided by libatomic, and might use locking, or not.
`__sync_*` should always be lock-free. These are only used on certain architectures where it's guaranteed that the operation _can_ be implemented lock-free, but it's desirable for whatever reason to not do so inline.

For this patch, I think the correct behavior is:
- If Zalrsc is present, but Zaamo is not, you may either emit an LR/SC loop (what I'd recommend), or emit an out-of-line call to `__sync_*` (which needs to be implemented with that LR/SC loop.)
- If Zaamo is present, but neither Zalrsc nor Zacas are present, I think there's no way to implement a cmpxchg operation. This means lock-free atomics cannot be supported, so it should `setMaxAtomicSizeInBitsSupported(0)`.

https://github.com/llvm/llvm-project/pull/77424


More information about the cfe-commits mailing list