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]

matching constraints in asm operands question


I'm trying to improve atomic operations for ColdFir ein a 2.4 kernel, and
I tried the following following the current online manual at:
http://gcc.gnu.org/onlinedocs/gcc-3.4.3/gcc/Extended-Asm.html#Extended-Asm

static __inline__ void atomic_inc(atomic_t *v)
{
	__asm__ __volatile__("addql #1,%0" : "=m" (*v) : "0" (*v));
}

but that genreates *lots* of warning messages about "matching
contstaint doesn't allow a register".  The manual states that if I
*don't* use "0", then the compiler may have the input and output
operand in seperate locations, and predicts unkown bad things can
happen.

Searching the archives I see that people are using:

static __inline__ void atomic_inc(atomic_t *v)
{
	__asm__ __volatile__("addql #1,%0" : "=m" (*v) : "m" (*v));
}

which seems to work, but I'm really concerned about the manuals
warning of the input and output operads being in seperate places.

Which form is correct?

-- 
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]