2010-07-03 09:00:49 +08:00
|
|
|
//===------- bswapdi2 - Implement bswapdi2 --------------------------------===//
|
2009-09-12 09:23:48 +08:00
|
|
|
//
|
|
|
|
// The LLVM Compiler Infrastructure
|
|
|
|
//
|
2010-11-17 06:13:33 +08:00
|
|
|
// This file is dual licensed under the MIT and the University of Illinois Open
|
|
|
|
// Source Licenses. See LICENSE.TXT for details.
|
2009-09-12 09:23:48 +08:00
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
2009-10-28 01:49:50 +08:00
|
|
|
#include "../assembly.h"
|
2009-09-12 09:23:48 +08:00
|
|
|
|
2014-06-01 12:07:03 +08:00
|
|
|
.syntax unified
|
|
|
|
.text
|
2014-06-17 00:05:24 +08:00
|
|
|
#if __ARM_ARCH_ISA_THUMB == 2
|
|
|
|
.thumb
|
|
|
|
#endif
|
2014-06-01 12:07:03 +08:00
|
|
|
|
2009-09-12 09:23:48 +08:00
|
|
|
//
|
|
|
|
// extern uint64_t __bswapdi2(uint64_t);
|
|
|
|
//
|
|
|
|
// Reverse all the bytes in a 64-bit integer.
|
|
|
|
//
|
2014-06-01 12:07:03 +08:00
|
|
|
.p2align 2
|
2014-10-07 10:39:13 +08:00
|
|
|
#if __ARM_ARCH_ISA_THUMB == 2
|
2014-10-04 08:18:59 +08:00
|
|
|
DEFINE_COMPILERRT_THUMB_FUNCTION(__bswapdi2)
|
2014-10-07 10:39:13 +08:00
|
|
|
#else
|
|
|
|
DEFINE_COMPILERRT_FUNCTION(__bswapdi2)
|
|
|
|
#endif
|
2014-01-29 21:54:54 +08:00
|
|
|
#if __ARM_ARCH < 6
|
2010-07-04 05:47:50 +08:00
|
|
|
// before armv6 does not have "rev" instruction
|
|
|
|
// r2 = rev(r0)
|
|
|
|
eor r2, r0, r0, ror #16
|
|
|
|
bic r2, r2, #0xff0000
|
|
|
|
mov r2, r2, lsr #8
|
|
|
|
eor r2, r2, r0, ror #8
|
|
|
|
// r0 = rev(r1)
|
|
|
|
eor r0, r1, r1, ror #16
|
|
|
|
bic r0, r0, #0xff0000
|
|
|
|
mov r0, r0, lsr #8
|
|
|
|
eor r0, r0, r1, ror #8
|
2010-07-03 08:12:47 +08:00
|
|
|
#else
|
2010-07-04 05:47:50 +08:00
|
|
|
rev r2, r0 // r2 = rev(r0)
|
|
|
|
rev r0, r1 // r0 = rev(r1)
|
2010-07-03 08:12:47 +08:00
|
|
|
#endif
|
2010-07-04 05:47:50 +08:00
|
|
|
mov r1, r2 // r1 = r2 = rev(r0)
|
2014-01-29 21:54:54 +08:00
|
|
|
JMP(lr)
|
2014-01-24 22:33:42 +08:00
|
|
|
END_COMPILERRT_FUNCTION(__bswapdi2)
|