[llvm-commits] [PATCH][GNU Build] Add LLVM_IS_TARGET_BIG_ENDIAN to config.h
Duncan Sands
baldrick at free.fr
Fri Oct 22 07:17:20 PDT 2010
Hi Michael,
>> I still don't get it. If you want the endianness of the host, you can use llvm/System/Host.h.
>
> I want it at compile time.
isLittleEndianHost and isBigEndianHost are designed to be turned into constants
when compiled, so there is no efficiency loss in using them. Do you really
need more than this?
> The point is so that you can memory map a file, and directly say "read
> an unsigned 32 bit integer from this address encoded as littlendian."
> On X86 this would just end up as a movl (%addr), %dest. While on PPC
> this would expand to a read and a byteswap.
Why don't you do:
if (isLittleEndianHost) {
code for little endian host
} else {
code for big endian host
}
?
The optimizers will remove the irrelevant branch.
Ciao,
Duncan.
More information about the llvm-commits
mailing list