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 // 13 // extern uint64_t __bswapdi2(uint64_t); 14 // 15 // Reverse all the bytes in a 64-bit integer. 16 // 17 .align 2 18 DEFINE_COMPILERRT_FUNCTION(__bswapdi2) 19 #if __ARM_ARCH_5TEJ__ || __ARM_ARCH_4T__ 20 // before armv6 does not have "rev" instruction 21 // r2 = rev(r0) 22 eor r2, r0, r0, ror #16 23 bic r2, r2, #0xff0000 24 mov r2, r2, lsr #8 25 eor r2, r2, r0, ror #8 26 // r0 = rev(r1) 27 eor r0, r1, r1, ror #16 28 bic r0, r0, #0xff0000 29 mov r0, r0, lsr #8 30 eor r0, r0, r1, ror #8 31 #else 32 rev r2, r0 // r2 = rev(r0) 33 rev r0, r1 // r0 = rev(r1) 34 #endif 35 mov r1, r2 // r1 = r2 = rev(r0) 36 bx lr 37