[LLVMdev] about llvm2.7's inline assembly

Duncan Sands baldrick at free.fr
Mon Jul 12 00:29:05 PDT 2010


Hi Sang Kil Cha,

> Whenever I compile a C program containing "FD_SET" function using llvm-gcc
> 2.7 (with -emit-llvm option), I got the following inline assembly in my
> llvm byte code:

this comes directly from your system headers (/usr/include/bits/select.h)
and as such doesn't really have anything to do with llvm-gcc:

#if defined __GNUC__ && __GNUC__ >= 2

# if __WORDSIZE == 64
#  define __FD_ZERO_STOS "stosq"
# else
#  define __FD_ZERO_STOS "stosl"
# endif

# define __FD_ZERO(fdsp) \
   do {                                                                        \
     int __d0, __d1;                                                           \
     __asm__ __volatile__ ("cld; rep; " __FD_ZERO_STOS                         \
                           : "=c" (__d0), "=D" (__d1)                          \
                           : "a" (0), "0" (sizeof (fd_set)                     \
                                           / sizeof (__fd_mask)),              \
                             "1" (&__FDS_BITS (fdsp)[0])                       \
                           : "memory");                                        \
   } while (0)

#else   /* ! GNU CC */

Maybe there's a good reason not to just use memset, but I don't know what it is.

Ciao,

Duncan.



More information about the llvm-dev mailing list