bswapsi2.S revision 5d71de26cedae3dafc17449fe0182045c0bd20e8
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
24DEFINE_COMPILERRT_FUNCTION(__bswapsi2)
25#if __ARM_ARCH < 6
26    // before armv6 does not have "rev" instruction
27 	eor	r1, r0, r0, ror #16
28 	bic	r1, r1, #0xff0000
29 	mov	r1, r1, lsr #8
30 	eor	r0, r1, r0, ror #8
31#else
32    rev r0, r0
33#endif
34    JMP(lr)
35END_COMPILERRT_FUNCTION(__bswapsi2)
36