1//===------- bswapsi2 - Implement bswapsi2 --------------------------------===//
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7//===----------------------------------------------------------------------===//
8
9#include "../assembly.h"
10
11	.syntax unified
12	.text
13	DEFINE_CODE_STATE
14
15//
16// extern uint32_t __bswapsi2(uint32_t);
17//
18// Reverse all the bytes in a 32-bit integer.
19//
20	.p2align 2
21DEFINE_COMPILERRT_FUNCTION(__bswapsi2)
22#if __ARM_ARCH < 6
23    // before armv6 does not have "rev" instruction
24 	eor	r1, r0, r0, ror #16
25 	bic	r1, r1, #0xff0000
26 	mov	r1, r1, lsr #8
27 	eor	r0, r1, r0, ror #8
28#else
29    rev r0, r0
30#endif
31    JMP(lr)
32END_COMPILERRT_FUNCTION(__bswapsi2)
33
34NO_EXEC_STACK_DIRECTIVE
35
36