You can not select more than 25 topics Topics must start with a chinese character,a letter or number, can include dashes ('-') and can be up to 35 characters long.

swap_thunderx2t99.S 4.0 kB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183
  1. /*******************************************************************************
  2. Copyright (c) 2017, The OpenBLAS Project
  3. All rights reserved.
  4. Redistribution and use in source and binary forms, with or without
  5. modification, are permitted provided that the following conditions are
  6. met:
  7. 1. Redistributions of source code must retain the above copyright
  8. notice, this list of conditions and the following disclaimer.
  9. 2. Redistributions in binary form must reproduce the above copyright
  10. notice, this list of conditions and the following disclaimer in
  11. the documentation and/or other materials provided with the
  12. distribution.
  13. 3. Neither the name of the OpenBLAS project nor the names of
  14. its contributors may be used to endorse or promote products
  15. derived from this software without specific prior written permission.
  16. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
  17. AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  18. IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
  19. ARE DISCLAIMED. IN NO EVENT SHALL THE OPENBLAS PROJECT OR CONTRIBUTORS BE
  20. LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
  21. DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
  22. SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
  23. CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
  24. OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
  25. USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  26. *******************************************************************************/
  27. #define ASSEMBLER
  28. #include "common.h"
  29. #define N x0 /* vector length */
  30. #define X x3 /* X vector address */
  31. #define INC_X x4 /* X stride */
  32. #define Y x5 /* Y vector address */
  33. #define INC_Y x6 /* Y stride */
  34. #define I x1 /* loop variable */
  35. /*******************************************************************************
  36. * Macro definitions
  37. *******************************************************************************/
  38. #if !defined(COMPLEX)
  39. #if !defined(DOUBLE)
  40. #define TMPF0 s0
  41. #define TMPF1 s1
  42. #define INC_SHIFT 2
  43. #define N_DIV_SHIFT 2
  44. #define N_REM_MASK 3
  45. #else
  46. #define TMPF0 d0
  47. #define TMPF1 d1
  48. #define INC_SHIFT 3
  49. #define N_DIV_SHIFT 1
  50. #define N_REM_MASK 1
  51. #endif
  52. #else
  53. #if !defined(DOUBLE)
  54. #define TMPF0 d0
  55. #define TMPF1 d1
  56. #define INC_SHIFT 3
  57. #define N_DIV_SHIFT 1
  58. #define N_REM_MASK 1
  59. #else
  60. #define TMPF0 q0
  61. #define TMPF1 q1
  62. #define INC_SHIFT 4
  63. #define N_DIV_SHIFT 0
  64. #define N_REM_MASK 0
  65. #endif
  66. #endif
  67. .macro KERNEL_F1
  68. ldr TMPF0, [X]
  69. ldr TMPF1, [Y]
  70. str TMPF0, [Y]
  71. str TMPF1, [X]
  72. add X, X, INC_X
  73. add Y, Y, INC_Y
  74. .endm
  75. .macro KERNEL_F
  76. ldr q0, [X]
  77. ldr q1, [Y]
  78. add X, X, #16
  79. add Y, Y, #16
  80. prfm PLDL1STRM, [X, #1024]
  81. prfm PLDL1STRM, [Y, #1024]
  82. str q0, [Y, #-16]
  83. str q1, [X, #-16]
  84. .endm
  85. .macro INIT
  86. lsl INC_X, INC_X, #INC_SHIFT
  87. lsl INC_Y, INC_Y, #INC_SHIFT
  88. .endm
  89. /*******************************************************************************
  90. * End of macro definitions
  91. *******************************************************************************/
  92. PROLOGUE
  93. cmp N, xzr
  94. ble .Lswap_kernel_L999
  95. cmp INC_X, #1
  96. bne .Lswap_kernel_S_BEGIN
  97. cmp INC_Y, #1
  98. bne .Lswap_kernel_S_BEGIN
  99. .Lswap_kernel_F_BEGIN:
  100. INIT
  101. asr I, N, #N_DIV_SHIFT
  102. cmp I, xzr
  103. beq .Lswap_kernel_F1
  104. .align 5
  105. .Lswap_kernel_F:
  106. KERNEL_F
  107. subs I, I, #1
  108. bne .Lswap_kernel_F
  109. .Lswap_kernel_F1:
  110. #if defined(DOUBLE) && defined(COMPLEX)
  111. b .Lswap_kernel_L999
  112. #else
  113. ands I, N, #N_REM_MASK
  114. ble .Lswap_kernel_L999
  115. #endif
  116. .Lswap_kernel_F10:
  117. KERNEL_F1
  118. subs I, I, #1
  119. bne .Lswap_kernel_F10
  120. b .Lswap_kernel_L999
  121. .Lswap_kernel_S_BEGIN:
  122. INIT
  123. asr I, N, #2
  124. cmp I, xzr
  125. ble .Lswap_kernel_S1
  126. .Lswap_kernel_S4:
  127. KERNEL_F1
  128. KERNEL_F1
  129. KERNEL_F1
  130. KERNEL_F1
  131. subs I, I, #1
  132. bne .Lswap_kernel_S4
  133. .Lswap_kernel_S1:
  134. ands I, N, #3
  135. ble .Lswap_kernel_L999
  136. .Lswap_kernel_S10:
  137. KERNEL_F1
  138. subs I, I, #1
  139. bne .Lswap_kernel_S10
  140. .Lswap_kernel_L999:
  141. mov w0, wzr
  142. ret
  143. EPILOGUE