bswapsi2.S 856 B

1234567891011121314151617181920212223242526272829303132333435
  1. //===------- bswapsi2 - Implement bswapsi2 --------------------------------===//
  2. //
  3. // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
  4. // See https://llvm.org/LICENSE.txt for license information.
  5. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
  6. //
  7. //===----------------------------------------------------------------------===//
  8. #include "../assembly.h"
  9. .syntax unified
  10. .text
  11. DEFINE_CODE_STATE
  12. //
  13. // extern uint32_t __bswapsi2(uint32_t);
  14. //
  15. // Reverse all the bytes in a 32-bit integer.
  16. //
  17. .p2align 2
  18. DEFINE_COMPILERRT_FUNCTION(__bswapsi2)
  19. #if __ARM_ARCH < 6
  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
  25. #else
  26. rev r0, r0
  27. #endif
  28. JMP(lr)
  29. END_COMPILERRT_FUNCTION(__bswapsi2)
  30. NO_EXEC_STACK_DIRECTIVE