swap instruction generation

Ian Lance Taylor iant@google.com
Mon Apr 18 18:59:00 GMT 2011


naga raj <gnuuser.raj@gmail.com> writes:

>   I need to emit a swap instruction from a embedded target which is
> using Gcc-4.1.2.
>
>   I am trying to emit a instruction which will perform following operation
>
>   R0=0x12345678;
>
>   swap R1,R0
>
>   Then after this R1 should contain R1= 0x00007856;

Not 0x78563421?

>  As there is no bswap rtl expression in Gcc-4.1.2 I have tried various
> alternatives like:
>
>  1. Used rotate rtl expression
>
>   2. ashift,ashiftrt and or to generate the above instruction
>
>
>  but compiler is not generating(emitting) swap instruction.

Current gcc has a bswap RTL pattern which swaps bytes in a word.  It was
added in gcc 4.3.  That's the thing to use if your instruction actually
swaps bytes in a word.  For versions of gcc before that you will have to
use an intrinsic function.

Ian



More information about the Gcc-help mailing list