This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [v3 RFC] PATCH to memory asm ops in atomicity.h


On Thu, 18 Dec 2003 11:58:32 -0800, Richard Henderson <rth@redhat.com> wrote:

> On Thu, Dec 18, 2003 at 12:14:52PM -0500, Jason Merrill wrote:
>> Are you also agreeing that "+m" is converted into a matching restraint?
>
> Yes, it is.

OK, atomicity patch updated accordingly:

2003-12-16  Jason Merrill  <jason@redhat.com>

	* config/cpu/cris/atomicity.h: Remove memory clobbers.
	* config/cpu/mips/atomicity.h: Likewise.
	* config/cpu/i486/atomicity.h: Remove memory clobbers.
	Split up read-write memory operand.
	* config/cpu/m68k/atomicity.h: Likewise.
	* config/cpu/powerpc/atomicity.h: Make memory I/O explicit.
	* config/cpu/s390/atomicity.h: Likewise.
	* config/cpu/sparc/atomicity.h: Likewise.

*** ./cpu/cris/atomicity.h.~1~	2003-12-18 11:41:18.000000000 -0500
--- ./cpu/cris/atomicity.h	2003-12-18 15:24:33.000000000 -0500
*************** __exchange_and_add(_Atomic_word* __mem, 
*** 51,58 ****
  			" bwf 0b		\n"
  			" clearf		\n"
  			:  "=&r" (__result), "=m" (*__mem), "=&r" (__tmp)
! 			: "r" (__mem), "g" (__val), "m" (*__mem)
! 			: "memory");
  #else
    __asm__ __volatile__ (" move $ccr,$r9		\n"
  			" di			\n"
--- 51,57 ----
  			" bwf 0b		\n"
  			" clearf		\n"
  			:  "=&r" (__result), "=m" (*__mem), "=&r" (__tmp)
! 			: "r" (__mem), "g" (__val), "m" (*__mem));
  #else
    __asm__ __volatile__ (" move $ccr,$r9		\n"
  			" di			\n"
*************** __exchange_and_add(_Atomic_word* __mem, 
*** 63,69 ****
  			" move $r9,$ccr		\n"
  			:  "=&r" (__result), "=m" (*__mem), "=&r" (__tmp)
  			: "r" (__mem), "g" (__val), "m" (*__mem)
! 			: "memory", "r9");
  #endif
  
    return __result;
--- 62,68 ----
  			" move $r9,$ccr		\n"
  			:  "=&r" (__result), "=m" (*__mem), "=&r" (__tmp)
  			: "r" (__mem), "g" (__val), "m" (*__mem)
! 			: "r9");
  #endif
  
    return __result;
*** ./cpu/i486/atomicity.h.~1~	2003-12-18 11:41:18.000000000 -0500
--- ./cpu/i486/atomicity.h	2003-12-18 15:28:28.000000000 -0500
*************** __exchange_and_add(volatile _Atomic_word
*** 38,46 ****
  {
    register _Atomic_word __result;
    __asm__ __volatile__ ("lock; xadd{l} {%0,%1|%1,%0}"
! 			: "=r" (__result), "+m" (*__mem) 
!                         : "0" (__val)
!                         : "memory");
    return __result;
  }
  
--- 38,45 ----
  {
    register _Atomic_word __result;
    __asm__ __volatile__ ("lock; xadd{l} {%0,%1|%1,%0}"
! 			: "=r" (__result), "=m" (*__mem) 
! 			: "0" (__val), "m" (*__mem));
    return __result;
  }
  
*************** __attribute__ ((__unused__))
*** 49,55 ****
  __atomic_add(volatile _Atomic_word* __mem, int __val)
  {
    __asm__ __volatile__ ("lock; add{l} {%1,%0|%0,%1}"
! 			: "+m" (*__mem) : "ir" (__val) : "memory");
  }
  
  #endif /* atomicity.h */
--- 48,54 ----
  __atomic_add(volatile _Atomic_word* __mem, int __val)
  {
    __asm__ __volatile__ ("lock; add{l} {%1,%0|%0,%1}"
! 			: "=m" (*__mem) : "ir" (__val), "m" (*__mem));
  }
  
  #endif /* atomicity.h */
*** ./cpu/m68k/atomicity.h.~1~	2003-12-18 11:41:18.000000000 -0500
--- ./cpu/m68k/atomicity.h	2003-12-18 15:31:12.000000000 -0500
*************** __exchange_and_add(volatile _Atomic_word
*** 47,55 ****
  			"add%.l %3,%1\n\t"
  			"cas%.l %0,%1,%2\n\t"
  			"jne 1b"
! 			: "=d" (__result), "=&d" (__temp), "+m" (*__mem)
! 			: "d" (__val), "0" (__result)
! 			: "memory");
    return __result;
  }
  
--- 47,54 ----
  			"add%.l %3,%1\n\t"
  			"cas%.l %0,%1,%2\n\t"
  			"jne 1b"
! 			: "=d" (__result), "=&d" (__temp), "=m" (*__mem)
! 			: "d" (__val), "0" (__result), "m" (*__mem));
    return __result;
  }
  
*** ./cpu/mips/atomicity.h.~1~	2003-12-18 11:41:18.000000000 -0500
--- ./cpu/mips/atomicity.h	2003-12-16 17:32:45.000000000 -0500
*************** __exchange_and_add(volatile _Atomic_word
*** 52,59 ****
       "beqz	%1,1b\n\t"
       "/* End exchange & add */"
       : "=&r"(__result), "=&r"(__tmp), "=m"(*__mem)
!      : "m" (*__mem), "r"(__val)
!      : "memory");
  
    return __result;
  }
--- 52,58 ----
       "beqz	%1,1b\n\t"
       "/* End exchange & add */"
       : "=&r"(__result), "=&r"(__tmp), "=m"(*__mem)
!      : "m" (*__mem), "r"(__val));
  
    return __result;
  }
*************** __atomic_add(volatile _Atomic_word* __me
*** 78,85 ****
       "beqz	%0,1b\n\t"
       "/* End atomic add */"
       : "=&r"(__result), "=m"(*__mem)
!      : "m" (*__mem), "r"(__val)
!      : "memory");
  }
  
  #endif /* atomicity.h */
--- 77,83 ----
       "beqz	%0,1b\n\t"
       "/* End atomic add */"
       : "=&r"(__result), "=m"(*__mem)
!      : "m" (*__mem), "r"(__val));
  }
  
  #endif /* atomicity.h */
*** ./cpu/powerpc/atomicity.h.~1~	2003-12-18 11:41:18.000000000 -0500
--- ./cpu/powerpc/atomicity.h	2003-12-18 15:29:23.000000000 -0500
*************** __exchange_and_add(volatile _Atomic_word
*** 46,59 ****
    __asm__ __volatile__ (
  	"/* Inline exchange & add */\n"
  	"0:\t"
! 	"lwarx    %0,0,%2 \n\t"
! 	"add%I3   %1,%0,%3 \n\t"
! 	_STWCX "  %1,0,%2 \n\t"
  	"bne-     0b \n\t"
  	"/* End exchange & add */"
! 	: "=&b"(__res), "=&r"(__tmp)
! 	: "r" (__mem), "Ir"(__val)
! 	: "cr0", "memory");
    return __res;
  }
  
--- 46,59 ----
    __asm__ __volatile__ (
  	"/* Inline exchange & add */\n"
  	"0:\t"
! 	"lwarx    %0,0,%3 \n\t"
! 	"add%I3   %1,%0,%4 \n\t"
! 	_STWCX "  %1,0,%3 \n\t"
  	"bne-     0b \n\t"
  	"/* End exchange & add */"
! 	: "=&b"(__res), "=&r"(__tmp), "=m" (*__mem)
! 	: "r" (__mem), "Ir"(__val), "m" (*__mem)
! 	: "cr0");
    return __res;
  }
  
*************** __atomic_add(volatile _Atomic_word* __me
*** 65,78 ****
    __asm__ __volatile__ (
  	"/* Inline atomic add */\n"
  	"0:\t"
! 	"lwarx    %0,0,%1 \n\t"
! 	"add%I2   %0,%0,%2 \n\t"
! 	_STWCX "  %0,0,%1 \n\t"
  	"bne-     0b \n\t"
  	"/* End atomic add */"
! 	: "=&b"(__tmp)
! 	: "r" (__mem), "Ir"(__val)
! 	: "cr0", "memory");
  }
  
  #endif /* atomicity.h */
--- 65,78 ----
    __asm__ __volatile__ (
  	"/* Inline atomic add */\n"
  	"0:\t"
! 	"lwarx    %0,0,%2 \n\t"
! 	"add%I2   %0,%0,%3 \n\t"
! 	_STWCX "  %0,0,%2 \n\t"
  	"bne-     0b \n\t"
  	"/* End atomic add */"
! 	: "=&b"(__tmp), "=m" (*__mem)
! 	: "r" (__mem), "Ir"(__val), "m" (*__mem)
! 	: "cr0");
  }
  
  #endif /* atomicity.h */
*** ./cpu/s390/atomicity.h.~1~	2003-12-18 11:41:18.000000000 -0500
--- ./cpu/s390/atomicity.h	2003-12-18 15:29:42.000000000 -0500
*************** __exchange_and_add(volatile _Atomic_word
*** 38,50 ****
  {
    register _Atomic_word __old_val, __new_val;
  
!   __asm__ __volatile__ ("   l     %0,0(%2)\n"
                          "0: lr    %1,%0\n"
!                         "   ar    %1,%3\n"
!                         "   cs    %0,%1,0(%2)\n"
                          "   jl    0b"
!                         : "=&d" (__old_val), "=&d" (__new_val)
!                         : "a" (__mem), "d" (__val) : "cc", "memory" );
    return __old_val;
  }
  
--- 38,50 ----
  {
    register _Atomic_word __old_val, __new_val;
  
!   __asm__ __volatile__ ("   l     %0,0(%3)\n"
                          "0: lr    %1,%0\n"
!                         "   ar    %1,%4\n"
!                         "   cs    %0,%1,0(%3)\n"
                          "   jl    0b"
!                         : "=&d" (__old_val), "=&d" (__new_val), "=m" (*__mem)
!                         : "a" (__mem), "d" (__val), "m" (*__mem) : "cc");
    return __old_val;
  }
  
*** ./cpu/sparc/atomicity.h.~1~	2003-12-18 11:41:18.000000000 -0500
--- ./cpu/sparc/atomicity.h	2003-12-18 15:30:36.000000000 -0500
*************** __exchange_and_add(volatile _Atomic_word
*** 41,55 ****
    _Atomic_word __tmp1, __tmp2;
    _Atomic_word __val_extended = __val;
  
!   __asm__ __volatile__("1:	ldx	[%2], %0\n\t"
! 		       "	add	%0, %3, %1\n\t"
! 		       "	casx	[%2], %0, %1\n\t"
  		       "	sub	%0, %1, %0\n\t"
  		       "	brnz,pn	%0, 1b\n\t"
  		       "	 nop"
! 		       : "=&r" (__tmp1), "=&r" (__tmp2)
! 		       : "r" (__mem), "r" (__val_extended)
! 		       : "memory");
    return __tmp2;
  }
  
--- 41,54 ----
    _Atomic_word __tmp1, __tmp2;
    _Atomic_word __val_extended = __val;
  
!   __asm__ __volatile__("1:	ldx	[%3], %0\n\t"
! 		       "	add	%0, %4, %1\n\t"
! 		       "	casx	[%3], %0, %1\n\t"
  		       "	sub	%0, %1, %0\n\t"
  		       "	brnz,pn	%0, 1b\n\t"
  		       "	 nop"
! 		       : "=&r" (__tmp1), "=&r" (__tmp2), "=m" (*__mem)
! 		       : "r" (__mem), "r" (__val_extended), "m" (*__mem));
    return __tmp2;
  }
  
*************** __atomic_add(volatile _Atomic_word* __me
*** 60,74 ****
    _Atomic_word __tmp1, __tmp2;
    _Atomic_word __val_extended = __val;
  
!   __asm__ __volatile__("1:	ldx	[%2], %0\n\t"
! 		       "	add	%0, %3, %1\n\t"
! 		       "	casx	[%2], %0, %1\n\t"
  		       "	sub	%0, %1, %0\n\t"
  		       "	brnz,pn	%0, 1b\n\t"
  		       "	 nop"
! 		       : "=&r" (__tmp1), "=&r" (__tmp2)
! 		       : "r" (__mem), "r" (__val_extended)
! 		       : "memory");
  }
  
  #else /* __arch32__ */
--- 59,72 ----
    _Atomic_word __tmp1, __tmp2;
    _Atomic_word __val_extended = __val;
  
!   __asm__ __volatile__("1:	ldx	[%3], %0\n\t"
! 		       "	add	%0, %4, %1\n\t"
! 		       "	casx	[%3], %0, %1\n\t"
  		       "	sub	%0, %1, %0\n\t"
  		       "	brnz,pn	%0, 1b\n\t"
  		       "	 nop"
! 		       : "=&r" (__tmp1), "=&r" (__tmp2), "=m" (*__mem)
! 		       : "r" (__mem), "r" (__val_extended), "m" (*__mem));
  }
  
  #else /* __arch32__ */

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]