bswapsi2.S revision 1.1.1.4 1 //===------- bswapsi2 - Implement bswapsi2 --------------------------------===//
2 //
3 // The LLVM Compiler Infrastructure
4 //
5 // This file is dual licensed under the MIT and the University of Illinois Open
6 // Source Licenses. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9
10 #include "../assembly.h"
11
12 .syntax unified
13 .text
14 #if __ARM_ARCH_ISA_THUMB == 2
15 .thumb
16 #endif
17
18 //
19 // extern uint32_t __bswapsi2(uint32_t);
20 //
21 // Reverse all the bytes in a 32-bit integer.
22 //
23 .p2align 2
24 #if __ARM_ARCH_ISA_THUMB == 2
25 DEFINE_COMPILERRT_THUMB_FUNCTION(__bswapsi2)
26 #else
27 DEFINE_COMPILERRT_FUNCTION(__bswapsi2)
28 #endif
29 #if __ARM_ARCH < 6
30 // before armv6 does not have "rev" instruction
31 eor r1, r0, r0, ror #16
32 bic r1, r1, #0xff0000
33 mov r1, r1, lsr #8
34 eor r0, r1, r0, ror #8
35 #else
36 rev r0, r0
37 #endif
38 JMP(lr)
39 END_COMPILERRT_FUNCTION(__bswapsi2)
40