Hi all, I've just pushed some changes to git repo that changes the way endian swapping is done. In particular it does: a) On Linux, use the bswap_*() intrinsic. b) On Windows _byteswap_*() intrinsic. c) Falls back to a macro for everything else. I've tested this on 64 bit little endian Linux (x86_64) and 32 bit bug endian Linux (powerpc). Needs testing elsewhere. Cheers, Erik -- ---------------------------------------------------------------------- Erik de Castro Lopo http://www.mega-nerd.com/
Mac OS X also provides routines for byteswapping- for this case CFSwapInt32() which calls through to __DARWIN_OSSwapInt32()- but I don't know if they would be any more efficient than the macro version. Stephen On Feb 5, 2012, at 4:41 AM, Erik de Castro Lopo wrote:> _byteswap_-------------- next part -------------- An HTML attachment was scrubbed... URL: http://lists.xiph.org/pipermail/flac-dev/attachments/20120205/b673a3ed/attachment.htm
On 5 February 2012 01:41, Erik de Castro Lopo <mle+la at mega-nerd.com> wrote:> ?a) On Linux, use the bswap_*() intrinsic.FWIW, Both Apple llvm-gcc 4.2.1 and Apple clang 3.0 support __builtin_bswap32() At least on XCode 4.2. It compiles to the bswap instruction. -r
Ralph Giles wrote:> On 5 February 2012 01:41, Erik de Castro Lopo <mle+la at mega-nerd.com> wrote: > > > ?a) On Linux, use the bswap_*() intrinsic. > > FWIW, Both Apple llvm-gcc 4.2.1 and Apple clang 3.0 support > __builtin_bswap32() At least on XCode 4.2. It compiles to the bswap > instruction.Ok, I have an M4 macro to detect the presence of __builtin_bswap32() and I've tested it on BE and LE linux. The scheme now is: a) Use __builtin_bswap32() where present (should be all versions of GCC and Clang). b) Use _byteswap_ulong() under MSVC. c) Use bwap32() if <byteswap.h> is present. d) Fall back to a macro. Erik -- ---------------------------------------------------------------------- Erik de Castro Lopo http://www.mega-nerd.com/
Reasonably Related Threads
- [LLVMdev] [RFC] Proposal to make LLVM-IR endian agnostic
- BUGS n code generated for target i386 compiling __bswapdi3, and for target x86-64 compiling __bswapsi2()
- BUGS n code generated for target i386 compiling __bswapdi3, and for target x86-64 compiling __bswapsi2()
- LLC Version 3.8 : Unsupported library call operation for a mul instruction
- BSWAP matching in codegen