1*0a6a1f1dSLionel Sambuc//===------- bswapsi2 - Implement bswapsi2 --------------------------------===// 2*0a6a1f1dSLionel Sambuc// 3*0a6a1f1dSLionel Sambuc// The LLVM Compiler Infrastructure 4*0a6a1f1dSLionel Sambuc// 5*0a6a1f1dSLionel Sambuc// This file is dual licensed under the MIT and the University of Illinois Open 6*0a6a1f1dSLionel Sambuc// Source Licenses. See LICENSE.TXT for details. 7*0a6a1f1dSLionel Sambuc// 8*0a6a1f1dSLionel Sambuc//===----------------------------------------------------------------------===// 9*0a6a1f1dSLionel Sambuc 10*0a6a1f1dSLionel Sambuc#include "../assembly.h" 11*0a6a1f1dSLionel Sambuc 12*0a6a1f1dSLionel Sambuc .syntax unified 13*0a6a1f1dSLionel Sambuc .text 14*0a6a1f1dSLionel Sambuc#if __ARM_ARCH_ISA_THUMB == 2 15*0a6a1f1dSLionel Sambuc .thumb 16*0a6a1f1dSLionel Sambuc#endif 17*0a6a1f1dSLionel Sambuc 18*0a6a1f1dSLionel Sambuc// 19*0a6a1f1dSLionel Sambuc// extern uint32_t __bswapsi2(uint32_t); 20*0a6a1f1dSLionel Sambuc// 21*0a6a1f1dSLionel Sambuc// Reverse all the bytes in a 32-bit integer. 22*0a6a1f1dSLionel Sambuc// 23*0a6a1f1dSLionel Sambuc .p2align 2 24*0a6a1f1dSLionel SambucDEFINE_COMPILERRT_FUNCTION(__bswapsi2) 25*0a6a1f1dSLionel Sambuc#if __ARM_ARCH < 6 26*0a6a1f1dSLionel Sambuc // before armv6 does not have "rev" instruction 27*0a6a1f1dSLionel Sambuc eor r1, r0, r0, ror #16 28*0a6a1f1dSLionel Sambuc bic r1, r1, #0xff0000 29*0a6a1f1dSLionel Sambuc mov r1, r1, lsr #8 30*0a6a1f1dSLionel Sambuc eor r0, r1, r0, ror #8 31*0a6a1f1dSLionel Sambuc#else 32*0a6a1f1dSLionel Sambuc rev r0, r0 33*0a6a1f1dSLionel Sambuc#endif 34*0a6a1f1dSLionel Sambuc JMP(lr) 35*0a6a1f1dSLionel SambucEND_COMPILERRT_FUNCTION(__bswapsi2) 36