This is the mail archive of the libc-alpha@sourceware.org mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH v2 9/10] Tilera (and Linux asm-generic) support for glibc


On 11/11/2011 3:17 PM, Andrew Pinski wrote:
On Fri, Nov 11, 2011 at 12:13 PM, Chris Metcalf<cmetcalf@tilera.com> wrote:
I'm cc'ing the gcc mailing list with this reply, so if someone there
can provide an authoritative statement, that would be great.  It looks
like right now the i386/x86_64, ia64, and s390 architecture don't use
this header anyway, so it's less important for them.  But powerpc and
sparc do use the header (in the core glibc), and most of the
architectures in the "ports" part of glibc do as well.

Roland, Joseph, if we don't hear something definitive from the gcc
folks, I'm inclined to revert this piece back to what I had in the v1
patch, where I provide a tile-specific byteswap.h using
__builtin_bswapNN(), so our gcc 4.4 will generate good code.
Right now it does not emit good code for MIPS 32/64 R2.  Though I have
patches to emit better code for that target.
In retrospect, I guess the right question is not whether it produces
bad code per se, but whether it produces worse code than for the
standard generic byteswap.h:

#define __bswap_16(x) \
     ((((x)>>  8)&  0xff) | (((x)&  0xff)<<  8))

#define __bswap_32(x) \
     ((((x)&  0xff000000)>>  24) | (((x)&  0x00ff0000)>>   8) |               \
      (((x)&  0x0000ff00)<<   8) | (((x)&  0x000000ff)<<  24))

#define __bswap_64(x) \
     ((((x)&  0xff00000000000000ull)>>  56)                                   \
      | (((x)&  0x00ff000000000000ull)>>  40)                                 \
      | (((x)&  0x0000ff0000000000ull)>>  24)                                 \
      | (((x)&  0x000000ff00000000ull)>>  8)                                  \
      | (((x)&  0x00000000ff000000ull)<<  8)                                  \
      | (((x)&  0x0000000000ff0000ull)<<  24)                                 \
      | (((x)&  0x000000000000ff00ull)<<  40)                                 \
      | (((x)&  0x00000000000000ffull)<<  56))

(The 16-bit swap would be done via __builtin_bswap32(x)>>  16.)
If it's no worse for any platform, and better for some, that's
probably sufficient reason to make the change in glibc to use it.

--
Chris Metcalf, Tilera Corp.
http://www.tilera.com


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