[llvm-commits] [PATCH][System] Add SwapByteOrder and move implementation from Support/MathExtras.h.

Rafael Espindola espindola at google.com
Fri Sep 17 08:40:44 PDT 2010


> The generic code is actually being used for both COFF and ELF with
> signed types, but it hasn't been tested because I've only tried out
> x86{,-64} so far (and thus this function isn't called). If someone
> could send me a small bigendian ELF file I could add a test for it and
> make sure everything works.

Is it common to try to byteswap signed integers? If not, it is
probably a bit safer to just not support it. Things like

int32_t foo;
int64_t bar = SwapByteOrder(foo);

can be a bit surprising. The user might have intended to sign extend
foo first, but that is not what is going to happen.

I compiled gas with at target of ppc64-linux-gnu and passed it an
empty .s. The produced .o is attached.

> Thanks for the review!
>
> - Michael Spencer

Cheers,
-- 
Rafael Ávila de Espíndola




More information about the llvm-commits mailing list