2010-07-03 09:00:49 +08:00
|
|
|
//===------- bswapsi2 - Implement bswapsi2 --------------------------------===//
|
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
|
|
|
|
|
|
|
//
|
|
|
|
// extern uint32_t __bswapsi2(uint32_t);
|
|
|
|
//
|
2009-09-14 02:34:39 +08:00
|
|
|
// Reverse all the bytes in a 32-bit integer.
|
2009-09-12 09:23:48 +08:00
|
|
|
//
|
2010-07-04 05:47:50 +08:00
|
|
|
.align 2
|
2009-10-28 01:50:21 +08:00
|
|
|
DEFINE_COMPILERRT_FUNCTION(__bswapsi2)
|
2010-07-03 08:12:47 +08:00
|
|
|
#if __ARM_ARCH_5TEJ__ || __ARM_ARCH_4T__
|
2010-07-04 05:47:50 +08:00
|
|
|
// before armv6 does not have "rev" instruction
|
|
|
|
eor r1, r0, r0, ror #16
|
|
|
|
bic r1, r1, #0xff0000
|
|
|
|
mov r1, r1, lsr #8
|
|
|
|
eor r0, r1, r0, ror #8
|
2010-07-03 08:12:47 +08:00
|
|
|
#else
|
2010-07-04 05:47:50 +08:00
|
|
|
rev r0, r0
|
2010-07-03 08:12:47 +08:00
|
|
|
#endif
|
2010-07-04 05:47:50 +08:00
|
|
|
bx lr
|