1156cd587Sjoerg//===------- bswapsi2 - Implement bswapsi2 --------------------------------===// 2156cd587Sjoerg// 3156cd587Sjoerg// The LLVM Compiler Infrastructure 4156cd587Sjoerg// 5156cd587Sjoerg// This file is dual licensed under the MIT and the University of Illinois Open 6156cd587Sjoerg// Source Licenses. See LICENSE.TXT for details. 7156cd587Sjoerg// 8156cd587Sjoerg//===----------------------------------------------------------------------===// 9156cd587Sjoerg 10156cd587Sjoerg#include "../assembly.h" 11156cd587Sjoerg 12190e92d8Sjoerg .syntax unified 13190e92d8Sjoerg .text 14190e92d8Sjoerg#if __ARM_ARCH_ISA_THUMB == 2 15190e92d8Sjoerg .thumb 16190e92d8Sjoerg#endif 17190e92d8Sjoerg 18156cd587Sjoerg// 19156cd587Sjoerg// extern uint32_t __bswapsi2(uint32_t); 20156cd587Sjoerg// 21156cd587Sjoerg// Reverse all the bytes in a 32-bit integer. 22156cd587Sjoerg// 2361f2f256Sjoerg .p2align 2 24*ef84fd3bSjoerg#if __ARM_ARCH_ISA_THUMB == 2 25*ef84fd3bSjoergDEFINE_COMPILERRT_THUMB_FUNCTION(__bswapsi2) 26*ef84fd3bSjoerg#else 27156cd587SjoergDEFINE_COMPILERRT_FUNCTION(__bswapsi2) 28*ef84fd3bSjoerg#endif 29156cd587Sjoerg#if __ARM_ARCH < 6 30156cd587Sjoerg // before armv6 does not have "rev" instruction 31156cd587Sjoerg eor r1, r0, r0, ror #16 32156cd587Sjoerg bic r1, r1, #0xff0000 33156cd587Sjoerg mov r1, r1, lsr #8 34156cd587Sjoerg eor r0, r1, r0, ror #8 35156cd587Sjoerg#else 36156cd587Sjoerg rev r0, r0 37156cd587Sjoerg#endif 38156cd587Sjoerg JMP(lr) 39156cd587SjoergEND_COMPILERRT_FUNCTION(__bswapsi2) 40