Fix atomic operations on PA-RISC 2.0 processors.
commit9807c31af91326988d083436483f9577296e1f9a
authorJohn David Anglin <danglin@gcc.gnu.org>
Thu, 5 Jan 2023 18:15:18 +0000 (5 18:15 +0000)
committerJohn David Anglin <danglin@gcc.gnu.org>
Thu, 5 Jan 2023 18:15:18 +0000 (5 18:15 +0000)
tree309a400a027d826d8a5c5769255e5d50eec47b57
parent4413365616e8c6024d1ff4e23309e5012ee33b9f
Fix atomic operations on PA-RISC 2.0 processors.

PA-RISC 2.0 supports out-of-order execution for loads and stores.
Thus, we need to synchonize memory accesses.

This change revises the lock releases in __exchange_and_add and
__atomic_add to use an ordered store with release semantics.  We
also use an ordered load in the inner spin loop.

We use the "ldcw,co" instruction instead of "ldcw" when compiled
for PA 2.0.  Most PA 2.0 processors are coherent and can execute
the ldcw instruction in cache for improved performance.

Finally, the inner spin loop is revised to immediately branch to
the ldcw instruction when it detects the lock is free.

2023-01-05  John David Anglin  <danglin@gcc.gnu.org>

libstdc++-v3/ChangeLog:

* config/cpu/hppa/atomicity.h (_PA_LDCW_INSN): Define.
(__exchange_and_add): Use _PA_LDCW_INSN.  Use ordered store for
lock release.  Revise loop.
(__atomic_add): Likewise.
libstdc++-v3/config/cpu/hppa/atomicity.h