Fix support for atomic loads and stores on hppa.
commitcf467fb93b7b92330ddcb9c8fe7c93df45ce8e40
authorJohn David Anglin <danglin@gcc.gnu.org>
Fri, 13 Jan 2023 19:22:49 +0000 (13 19:22 +0000)
committerJohn David Anglin <danglin@gcc.gnu.org>
Fri, 13 Jan 2023 19:24:15 +0000 (13 19:24 +0000)
tree821c49d285046168caf441f057bb2ab1e499b87c
parent733a1b777f16cd397b43a242d9c31761f66d3da8
Fix support for atomic loads and stores on hppa.

This change updates the atomic libcall support to fix the following
issues:

1) A internal compiler error with -fno-sync-libcalls.
2) When sync libcalls are disabled, we don't generate libcalls for
   libatomic.
3) There is no sync libcall support for targets other than linux.
   As a result, non-atomic stores are silently emitted for types
   smaller or equal to the word size.  There are now a few atomic
   libcalls in the libgcc code, so we need sync support on all
   targets.

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

gcc/ChangeLog:

* config/pa/pa-linux.h (TARGET_SYNC_LIBCALL): Delete define.
* config/pa/pa.cc (pa_init_libfuncs): Use MAX_SYNC_LIBFUNC_SIZE
define.
* config/pa/pa.h (TARGET_SYNC_LIBCALLS): Use flag_sync_libcalls.
(MAX_SYNC_LIBFUNC_SIZE): Define.
(TARGET_CPU_CPP_BUILTINS): Define __SOFTFP__ when soft float is
enabled.
* config/pa/pa.md (atomic_storeqi): Emit __atomic_exchange_1
libcall when sync libcalls are disabled.
(atomic_storehi, atomic_storesi, atomic_storedi): Likewise.
(atomic_loaddi): Emit __atomic_load_8 libcall when sync libcalls
are disabled on 32-bit target.
* config/pa/pa.opt (matomic-libcalls): New option.
* doc/invoke.texi (HPPA Options): Update.

libgcc/ChangeLog:

* config.host (hppa*64*-*-linux*): Adjust tmake_file to use
pa/t-pa64-linux.
(hppa*64*-*-hpux11*): Adjust tmake_file to use pa/t-pa64-hpux
instead of pa/t-hpux and pa/t-pa64.
* config/pa/linux-atomic.c: Define u32 type.
(ATOMIC_LOAD): Define new macro to implement atomic_load_1,
atomic_load_2, atomic_load_4 and atomic_load_8.  Update sync
defines to use atomic_load calls for type.
(SYNC_LOCK_LOAD_2): New macro to implement __sync_lock_load_8.
* config/pa/sync-libfuncs.c: New file.
* config/pa/t-netbsd (LIB2ADD_ST): Define.
* config/pa/t-openbsd (LIB2ADD_ST): Define.
* config/pa/t-pa64-hpux: New file.
* config/pa/t-pa64-linux: New file.
13 files changed:
gcc/config/pa/pa-linux.h
gcc/config/pa/pa.cc
gcc/config/pa/pa.h
gcc/config/pa/pa.md
gcc/config/pa/pa.opt
gcc/doc/invoke.texi
libgcc/config.host
libgcc/config/pa/linux-atomic.c
libgcc/config/pa/sync-libfuncs.c [new file with mode: 0644]
libgcc/config/pa/t-netbsd
libgcc/config/pa/t-openbsd
libgcc/config/pa/t-pa64-hpux [new file with mode: 0644]
libgcc/config/pa/t-pa64-linux [new file with mode: 0644]