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