gcc only knows what you tell it in the constraints. You have told gcc
that your assembly has an input, and so it has made %0 something that
is suitable only as a source operand. If you tell it the full story,
that your assembly uses %0 as an input and an output, then it will
know that %0 must be suitable as a source and destination operand. So
changing the constraints to
: "=g"(i) :"0"(i) : "eax"
will fix the problem.
But a better solution would be to use
__asm__ volatile ( "
movl %1, %%eax\n
addl $1, %%eax\n
movl %%eax, %0\n"
: "=g"(i) :"g"(i) : "eax"
) ;
since this gives gcc a bit more freedom to generate better code.
(To followup on Jakub's message, i386.md uses "=g" several times, so I
don't think there is any problem with doing that; gcc understands that
it cannot use an immediate operand in that context.)
David Wragg
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.rutgers.edu
Please read the FAQ at http://www.tux.org/lkml/