xref: /netbsd-src/sys/external/bsd/compiler_rt/dist/lib/builtins/arm/bswapsi2.S (revision b7b7574d3bf8eeb51a1fa3977b59142ec6434a55)
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//
13// extern uint32_t __bswapsi2(uint32_t);
14//
15// Reverse all the bytes in a 32-bit integer.
16//
17.p2align 2
18DEFINE_COMPILERRT_FUNCTION(__bswapsi2)
19#if __ARM_ARCH < 6
20    // before armv6 does not have "rev" instruction
21 	eor	r1, r0, r0, ror #16
22 	bic	r1, r1, #0xff0000
23 	mov	r1, r1, lsr #8
24 	eor	r0, r1, r0, ror #8
25#else
26    rev r0, r0
27#endif
28    JMP(lr)
29END_COMPILERRT_FUNCTION(__bswapsi2)
30