supression of 'matching constraint does not allow a register' warning
Andrew Haley
aph@redhat.com
Fri Apr 30 17:23:00 GMT 2004
Peter Barada writes:
>
> In the Linux-2.4.x kernel for m68k, the atomic operations use the
> addql/subql instructions for incrementing/decrementing atomic
> variables, and force the variables to memory to make the operation
> truly atomic. The definition from linux-2.4.x/include/asm-m68k/atomic.h:
>
> static __inline__ void atomic_inc(volatile atomic_t *v)
> {
> __asm__ __volatile__("addql #1,%0" : "=m" (*v): "0" (*v));
> }
>
> static __inline__ void atomic_dec(volatile atomic_t *v)
> {
> __asm__ __volatile__("subql #1,%0" : "=m" (*v): "0" (*v));
> }
>
> Unfortunately when used they generate the following warning from
> parse_input_contstraint in gcc/stmt.c:
>
> if (saw_match && !*allows_reg)
> warning ("matching constraint does not allow a register");
>
>
> Since atomic_inc/atomic_dec are defined that way to enforce an
> atomic operation to memory, when building the kernel, *lots* of
> warnings are generated making it hard to wade through the log looking
> for other warnings/errors.
>
> I'd like to add a flag to suppress this warning, and was wondering if
> a patch for this would be accepted, and what best to call the flag.
I don't think gcc supports what you want to do. That's what the
warning means.
In glibc, these matching constraints were removed some time ago.
glibc changed to use
#define atomic_increment_and_test(mem) \
...
__asm __volatile ("addq%.l %#1,%1; seq %0" \
: "=dm" (__result), "=m" (*(mem)) \
: "m" (*(mem))); \
Andrew.
More information about the Gcc
mailing list