On Sat, 15 Apr 2000, Ryan Cumming wrote:

> gcc -c -I. -I. -I../include -I../include -march=k6 -Wall -fPIC -D__WINE__ 
>-D_REENTRANT -I/usr/X11R6/include -o dpmi.o dpmi.c
> dpmi.c: In function `DPMI_CallRMCBProc':
> dpmi.c:232: Invalid `asm' statement:
> dpmi.c:232: fixed or forbidden register 1 (dx) was spilled for class GENERAL_REGS.

Seen this reported before, but nobody else seems to have the problem. The
real issue is that the asm constraint system provided by gcc is very
flexible, but as far as I know not flexible enough to express the *real*
intention of these constraints (which is that the compiler should feel
free to choose whichever output for "es" it desires, but that all *other*
general registers (the ones it did not select) may end up clobbered). So
just a few general registers are mentioned in the clobber list (ecx, edx,
ebp), but it seems the compiler chose [e]dx somewhere else, so a conflict
occurred.

If some other developer did have this problem, I'm sure it would have been
fixed already. And it's gcc, not binutils, that interprets inline asm
constraints. A gcc -S investigation of dpmi.c shows that for me, the
compiler chose ebp-relative stack variables for all free-select
input/output constraints, and not general registers. Apparently the
compiler did not do so for you (although your compiler may be more correct
anyway; since ebp was in the clobber list, using ebp-relative stack
variables would not be a good idea, and the compiler did not even try
preserving ebp across the asm statement). If I changed the output
constraint for "es" to "r" instead of "g" to force it to choose a
register for "es", it chose "ax", and still compiled fine for me.

Because of the lack of expressive power I described above, I don't know
what the best way to fix the issue is - it seems the only way out is to
limit the compiler's freedom more than necessary (and if we're going to
start doing that anyway, there are plenty of ways of doing that, so which
would be the preferred way?).

Or does someone here know more about constraints than me, that can tell
how to express what we want?

Reply via email to