divsi3.S 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. //===----------------------Hexagon builtin routine ------------------------===//
  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. .macro FUNCTION_BEGIN name
  9. .text
  10. .p2align 5
  11. .globl \name
  12. .type \name, @function
  13. \name:
  14. .endm
  15. .macro FUNCTION_END name
  16. .size \name, . - \name
  17. .endm
  18. FUNCTION_BEGIN __hexagon_divsi3
  19. {
  20. p0 = cmp.ge(r0,#0)
  21. p1 = cmp.ge(r1,#0)
  22. r1 = abs(r0)
  23. r2 = abs(r1)
  24. }
  25. {
  26. r3 = cl0(r1)
  27. r4 = cl0(r2)
  28. r5 = sub(r1,r2)
  29. p2 = cmp.gtu(r2,r1)
  30. }
  31. #if (__HEXAGON_ARCH__ == 60)
  32. {
  33. r0 = #0
  34. p1 = xor(p0,p1)
  35. p0 = cmp.gtu(r2,r5)
  36. }
  37. if (p2) jumpr r31
  38. #else
  39. {
  40. r0 = #0
  41. p1 = xor(p0,p1)
  42. p0 = cmp.gtu(r2,r5)
  43. if (p2) jumpr r31
  44. }
  45. #endif
  46. {
  47. r0 = mux(p1,#-1,#1)
  48. if (p0) jumpr r31
  49. r4 = sub(r4,r3)
  50. r3 = #1
  51. }
  52. {
  53. r0 = #0
  54. r3:2 = vlslw(r3:2,r4)
  55. loop0(1f,r4)
  56. }
  57. .falign
  58. 1:
  59. {
  60. p0 = cmp.gtu(r2,r1)
  61. if (!p0.new) r1 = sub(r1,r2)
  62. if (!p0.new) r0 = add(r0,r3)
  63. r3:2 = vlsrw(r3:2,#1)
  64. }:endloop0
  65. {
  66. p0 = cmp.gtu(r2,r1)
  67. if (!p0.new) r0 = add(r0,r3)
  68. if (!p1) jumpr r31
  69. }
  70. {
  71. r0 = neg(r0)
  72. jumpr r31
  73. }
  74. FUNCTION_END __hexagon_divsi3
  75. .globl __qdsp_divsi3
  76. .set __qdsp_divsi3, __hexagon_divsi3