Stephen Canon | fe22a3f | 2010-07-03 01:00:49 +0000 | [diff] [blame] | 1 | //===------- bswapsi2 - Implement bswapsi2 --------------------------------===// |
Nick Kledzik | e80e978 | 2009-09-12 01:23:48 +0000 | [diff] [blame] | 2 | // |
| 3 | // The LLVM Compiler Infrastructure |
| 4 | // |
Howard Hinnant | 9ad441f | 2010-11-16 22:13:33 +0000 | [diff] [blame] | 5 | // This file is dual licensed under the MIT and the University of Illinois Open |
| 6 | // Source Licenses. See LICENSE.TXT for details. |
Nick Kledzik | e80e978 | 2009-09-12 01:23:48 +0000 | [diff] [blame] | 7 | // |
| 8 | //===----------------------------------------------------------------------===// |
| 9 | |
Daniel Dunbar | 19336a2 | 2009-10-27 17:49:50 +0000 | [diff] [blame] | 10 | #include "../assembly.h" |
Nick Kledzik | e80e978 | 2009-09-12 01:23:48 +0000 | [diff] [blame] | 11 | |
| 12 | // |
| 13 | // extern uint32_t __bswapsi2(uint32_t); |
| 14 | // |
Nick Kledzik | 6e8c3ac | 2009-09-13 18:34:39 +0000 | [diff] [blame] | 15 | // Reverse all the bytes in a 32-bit integer. |
Nick Kledzik | e80e978 | 2009-09-12 01:23:48 +0000 | [diff] [blame] | 16 | // |
Stephen Canon | e735b29 | 2010-07-03 21:47:50 +0000 | [diff] [blame] | 17 | .align 2 |
Daniel Dunbar | b4b1e8c | 2009-10-27 17:50:21 +0000 | [diff] [blame] | 18 | DEFINE_COMPILERRT_FUNCTION(__bswapsi2) |
Nick Kledzik | 455c263 | 2010-07-03 00:12:47 +0000 | [diff] [blame] | 19 | #if __ARM_ARCH_5TEJ__ || __ARM_ARCH_4T__ |
Stephen Canon | e735b29 | 2010-07-03 21:47:50 +0000 | [diff] [blame] | 20 | // before armv6 does not have "rev" instruction |
| 21 | eor r1, r0, r0, ror #16 |
| 22 | bic r1, r1, #0xff0000 |
| 23 | mov r1, r1, lsr #8 |
| 24 | eor r0, r1, r0, ror #8 |
Nick Kledzik | 455c263 | 2010-07-03 00:12:47 +0000 | [diff] [blame] | 25 | #else |
Stephen Canon | e735b29 | 2010-07-03 21:47:50 +0000 | [diff] [blame] | 26 | rev r0, r0 |
Nick Kledzik | 455c263 | 2010-07-03 00:12:47 +0000 | [diff] [blame] | 27 | #endif |
Stephen Canon | e735b29 | 2010-07-03 21:47:50 +0000 | [diff] [blame] | 28 | bx lr |