This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: matching constraints in asm operands question
- From: Jason Merrill <jason at redhat dot com>
- To: amylaar at spamcop dot net
- Cc: Peter Barada <peter at the-baradas dot com>, rth at redhat dot com, pinskia at physics dot uc dot edu, gcc at gcc dot gnu dot org
- Date: Sat, 05 Mar 2005 09:41:09 -0500
- Subject: Re: matching constraints in asm operands question
- References: <20050305002410.e9ew4c0400kwkwso@webmail.spamcop.net>
On Sat, 5 Mar 2005 00:24:10 -0500, amylaar@spamcop.net wrote:
>> static __inline__ void atomic_add(atomic_t *v, int i)
>> {
>> __asm__ __volatile__("addl %1,%0" : "+m" (*v) : "d" (i));
>> }
>>
>> Then the compiler complains with:
>>
>> /asm/atomic.h:33: warning: read-write constraint does not allow a register
>>
>> So is the warning wrong?
>
> Yes, the warning is wrong, and the text in the manual about '+' is also
> nonsense. Support for '+' is asms was specifically introduced to make
> it safe to have read-write memory operands. Jason, the point of using '+'
> is that the matched parts start out as the same, and the compiler is
> supposed to keep them the same.
Well, I assumed the same thing when I started poking at that code, but then
someone pointed out that it didn't actually work that way, and as I recall
the code does in fact assume a register. I certainly would not object to
making '+' work properly for memory operands, but simply asserting that it
already does is wrong.
Jason