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: amylaar at spamcop dot net
- To: Peter Barada <peter at the-baradas dot com>, jason at redhat dot com
- Cc: rth at redhat dot com, pinskia at physics dot uc dot edu, gcc at gcc dot gnu dot org
- Date: Sat, 5 Mar 2005 00:24:10 -0500
- Subject: Re: matching constraints in asm operands question
> 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. We initially did this with shared rtl,
but IIRC we changed cse since, but still the same premise holds: the
compiler is supposed to keep both parts of the match in sync. We
can guarantee this for '+', but we can't for matching constraints,
and this was documented properly till you till you changed extend.texi
in December 2003.