[COMMITTED] hppa: Use optab_libfunc to access sync_lock_test_and_set libfunc

Message ID YdHZKFRLH2cikt3j@mx3210.localdomain
State Committed
Commit 4759c16beec2a7a4ed56608adcf932f9a6acbdc7
Headers
Series [COMMITTED] hppa: Use optab_libfunc to access sync_lock_test_and_set libfunc |

Commit Message

John David Anglin Jan. 2, 2022, 4:56 p.m. UTC
  This patch revises the atomic store code for hppa-linux to use optab_libfunc
to access the sync_lock_test_and_set libfunc. We now call
convert_memory_address() to convert the memory address to Pmode. This
should handle more memory addresses.

Tested on hppa-unknown-linux-gnu. Committed to trunk and gcc-11 branch.

Dave
---

Use optab_libfunc to access sync_lock_test_and_set libfunc on hppa-linux.

2022-01-02  John David Anglin  <danglin@gcc.gnu.org>

gcc/ChangeLog:

	* config/pa/pa.md (atomic_storeq): Use optab_libfunc to access
	sync_lock_test_and_set libfunc. Call convert_memory_address to
	convert memory address to Pmode.
	(atomic_storehi, atomic_storesi, atomic_storedi): Likewise.
  

Patch

diff --git a/gcc/config/pa/pa.md b/gcc/config/pa/pa.md
index af5449a9ea3..31e3b1bff80 100644
--- a/gcc/config/pa/pa.md
+++ b/gcc/config/pa/pa.md
@@ -10366,10 +10366,10 @@  add,l %2,%3,%3\;bv,n %%r0(%3)"
 {
   if (TARGET_SYNC_LIBCALL)
     {
-      rtx libfunc = init_one_libfunc ("__sync_lock_test_and_set_1");
+      rtx libfunc = optab_libfunc (sync_lock_test_and_set_optab, QImode);
+      rtx addr = convert_memory_address (Pmode, XEXP (operands[0], 0));
 
-      emit_library_call (libfunc, LCT_NORMAL, VOIDmode,
-			 XEXP (operands[0], 0), Pmode,
+      emit_library_call (libfunc, LCT_NORMAL, VOIDmode, addr, Pmode,
 			 operands[1], QImode);
       DONE;
     }
@@ -10386,10 +10386,10 @@  add,l %2,%3,%3\;bv,n %%r0(%3)"
 {
   if (TARGET_SYNC_LIBCALL)
     {
-      rtx libfunc = init_one_libfunc ("__sync_lock_test_and_set_2");
+      rtx libfunc = optab_libfunc (sync_lock_test_and_set_optab, HImode);
+      rtx addr = convert_memory_address (Pmode, XEXP (operands[0], 0));
 
-      emit_library_call (libfunc, LCT_NORMAL, VOIDmode,
-			 XEXP (operands[0], 0), Pmode,
+      emit_library_call (libfunc, LCT_NORMAL, VOIDmode, addr, Pmode,
 			 operands[1], HImode);
       DONE;
     }
@@ -10406,10 +10406,10 @@  add,l %2,%3,%3\;bv,n %%r0(%3)"
 {
   if (TARGET_SYNC_LIBCALL)
     {
-      rtx libfunc = init_one_libfunc ("__sync_lock_test_and_set_4");
+      rtx libfunc = optab_libfunc (sync_lock_test_and_set_optab, SImode);
+      rtx addr = convert_memory_address (Pmode, XEXP (operands[0], 0));
 
-      emit_library_call (libfunc, LCT_NORMAL, VOIDmode,
-			 XEXP (operands[0], 0), Pmode,
+      emit_library_call (libfunc, LCT_NORMAL, VOIDmode, addr, Pmode,
 			 operands[1], SImode);
       DONE;
     }
@@ -10459,10 +10459,10 @@  add,l %2,%3,%3\;bv,n %%r0(%3)"
 
   if (TARGET_SYNC_LIBCALL)
     {
-      rtx libfunc = init_one_libfunc ("__sync_lock_test_and_set_8");
+      rtx libfunc = optab_libfunc (sync_lock_test_and_set_optab, DImode);
+      rtx addr = convert_memory_address (Pmode, XEXP (operands[0], 0));
 
-      emit_library_call (libfunc, LCT_NORMAL, VOIDmode,
-			 XEXP (operands[0], 0), Pmode,
+      emit_library_call (libfunc, LCT_NORMAL, VOIDmode, addr, Pmode,
 			 operands[1], DImode);
       DONE;
     }