1 //===------- bswapdi2 - Implement bswapdi2 --------------------------------===//
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
7 //===----------------------------------------------------------------------===//
9 #include "../assembly.h"
16 // extern uint64_t __bswapdi2(uint64_t);
18 // Reverse all the bytes in a 64-bit integer.
21 DEFINE_COMPILERRT_FUNCTION(__bswapdi2)
23 // before armv6 does not have "rev" instruction
25 eor r2, r0, r0, ror #16
28 eor r2, r2, r0, ror #8
30 eor r0, r1, r1, ror #16
33 eor r0, r0, r1, ror #8
35 rev r2, r0 // r2 = rev(r0)
36 rev r0, r1 // r0 = rev(r1)
38 mov r1, r2 // r1 = r2 = rev(r0)
40 END_COMPILERRT_FUNCTION(__bswapdi2)
42 NO_EXEC_STACK_DIRECTIVE