This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

cvs egcs complains about asm statement on x86


The culprit is FD_ZERO on Linux 2.1.125, found in

  /usr/include/asm/posix_types.h
or
  /usr/src/linux/include/asm-i386/posix_types.h

This code demonstrates the problem:

  #define __NFDBITS       (8 * sizeof(unsigned long))
  #define __FD_SETSIZE    1024
  #define __FDSET_LONGS   (__FD_SETSIZE/__NFDBITS)

  typedef struct {
    unsigned long fds_bits [__FDSET_LONGS];
  } __kernel_fd_set;

  void bla(void *fdsetp) {
  __asm__ __volatile__("cld ; rep ; stosl"
	:"=m" (*(__kernel_fd_set *) (fdsetp))
	:"a" (0), "c" (__FDSET_LONGS),
	"D" ((__kernel_fd_set *) (fdsetp)) :"cx","di");
  }

I saved it as t.c and did this:

$ gcc -v
Reading specs from /usr/lib/gcc-lib/i686-pc-linux-gnulibc1/2.8.1/specs
gcc version 2.8.1
$ gcc -c t.c
$ egcc -v
Reading specs from /usr/lib/gcc-lib/i686-pc-linux-gnulibc1/egcs-2.92.17/specs
gcc version egcs-2.92.17 19981031 (gcc2 ss-980609 experimental)
$ egcc -c t.c
t.c: In function `bla':
t.c:13: Invalid `asm' statement:
t.c:13: fixed or forbidden register 2 (cx) was spilled for class CREG.
$

This is today's egcs version!  The CVS egcs has been doing this for at
least a week, but I am reporting it only now because I thought that
something this obvious (try compiling almost any networking program on
Linux!) would be known and fixed soon.

I thought I could fix it myself, so I tried to look up the asm syntax
for x86 in the gcc info file.  But I could not find it!  Why isn't it
there?  Anyway, I have an older text file about Intel inline assembly
from the linux-kernel mailing list that said the last field, the one
egcs complained about, was the clobber list and simply contained the
registers that are spilled.

So I thought that maybe the name changed from cx to ecx, but that was
not the problem.  Removing the clobber list removes the error but
produces wrong code, obviously.

Does anyone know what the problem is and how to fix it?  This is kind of
urgent for Linux users ;-}

Felix


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]