This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
supression of 'matching constraint does not allow a register' warning
- From: Andrew Haley <aph at redhat dot com>
- To: Peter Barada <peter at the-baradas dot com>
- Cc: gcc at gcc dot gnu dot org
- Date: Fri, 30 Apr 2004 17:23:24 +0100
- Subject: supression of 'matching constraint does not allow a register' warning
- References: <20040430161027.83EF798C8A@baradas.org>
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.