1//===------- bswapdi2 - Implement bswapdi2 --------------------------------===// 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 uint64_t __bswapdi2(uint64_t); 20// 21// Reverse all the bytes in a 64-bit integer. 22// 23 .p2align 2 24#if __ARM_ARCH_ISA_THUMB == 2 25DEFINE_COMPILERRT_THUMB_FUNCTION(__bswapdi2) 26#else 27DEFINE_COMPILERRT_FUNCTION(__bswapdi2) 28#endif 29#if __ARM_ARCH < 6 30 // before armv6 does not have "rev" instruction 31 // r2 = rev(r0) 32 eor r2, r0, r0, ror #16 33 bic r2, r2, #0xff0000 34 mov r2, r2, lsr #8 35 eor r2, r2, r0, ror #8 36 // r0 = rev(r1) 37 eor r0, r1, r1, ror #16 38 bic r0, r0, #0xff0000 39 mov r0, r0, lsr #8 40 eor r0, r0, r1, ror #8 41#else 42 rev r2, r0 // r2 = rev(r0) 43 rev r0, r1 // r0 = rev(r1) 44#endif 45 mov r1, r2 // r1 = r2 = rev(r0) 46 JMP(lr) 47END_COMPILERRT_FUNCTION(__bswapdi2) 48