This is the mail archive of the mailing list for the GCC 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: Endian swapping with C code on ARM

>>>>> "Falk" == Falk Hueffner <> writes:

 Falk> Richard Earnshaw <> writes:
 >> You also get into issues of word size.  Which builtins do you
 >> provide?  32-bit? 16-bit?  64-bit?

 Falk> In theory, any attempt to describe a 16-bit bswap should be
 Falk> recognized as 16 bit rotation. So my patch provides only 32 and
 Falk> 64.

Several platforms don't have a rotate instruction, so you should also
have a 16 bit swap.

 >> When is it best to stop trying to inline all this and drop into a
 >> library call?

 Falk> This patch never open-codes bswap. I'm not sure if it would be
 Falk> worth doing, since basically every platform has some trick that
 Falk> would save a cycle or two over generic inlined code.

bswap is sufficiently important to high speed networking code that you
would only want the function call if -Os is in effect.  Otherwise it
should be inline.  (Certainly that's true for 16 and 32 bit variants;
the 64 bit one is more debatable.)  But the platform specific handling
can certainly do that, so having the library call as a fallback seems

This is good stuff...


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