This is the mail archive of the gcc@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: matching constraints in asm operands question


>> Ugh, in the hopes of simplifying the example, I made it somewhat trivial...
>> 
>> static __inline__ void atomic_add(atomic_t *v, int i)
>> {
>> 	__asm__ __volatile__("addl %2,%0" : "=m" (*v) : "m" (*v), "d" (i));
>> }
>> 
>> Is that correct?  And if so, then isn't the documentation wrong?
>
>This is correct, as is a version using "+m" (*v) : "d"(i),
>though of course the %2 gets moved to %1 in that case.

If I try:

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?

-- 
Peter Barada
peter@the-baradas.com


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