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.S 5.6 kB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266
  1. /*******************************************************************************
  2. Copyright (c) 2015, 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(DOUBLE)
  39. #define TMP0 s0
  40. #define TMPV0 {v0.s}[0]
  41. #define TMP1 s1
  42. #define TMPV1 {v1.s}[0]
  43. #define SZ 4
  44. #else
  45. #define TMP0 d0
  46. #define TMPV0 {v0.d}[0]
  47. #define TMP1 d1
  48. #define TMPV1 {v1.d}[0]
  49. #define SZ 8
  50. #endif
  51. /******************************************************************************/
  52. .macro KERNEL_F1
  53. #if !defined(COMPLEX)
  54. ldr TMP0, [X]
  55. ldr TMP1, [Y]
  56. str TMP0, [Y], #SZ
  57. str TMP1, [X], #SZ
  58. #else
  59. #if !defined(DOUBLE)
  60. ld1 {v0.2s}, [X]
  61. ld1 {v1.2s}, [Y]
  62. st1 {v0.2s}, [Y], #8
  63. st1 {v1.2s}, [X], #8
  64. #else
  65. ld1 {v0.2d}, [X]
  66. ld1 {v1.2d}, [Y]
  67. st1 {v0.2d}, [Y], #16
  68. st1 {v1.2d}, [X], #16
  69. #endif
  70. #endif
  71. .endm
  72. .macro KERNEL_F8
  73. #if !defined(COMPLEX)
  74. #if !defined(DOUBLE)
  75. ld1 {v0.4s, v1.4s}, [X]
  76. ld1 {v2.4s, v3.4s}, [Y]
  77. st1 {v0.4s, v1.4s}, [Y], #32
  78. st1 {v2.4s, v3.4s}, [X], #32
  79. #else // DOUBLE
  80. ld1 {v0.4s, v1.4s}, [X]
  81. ld1 {v2.4s, v3.4s}, [Y]
  82. st1 {v0.4s, v1.4s}, [Y], #32
  83. st1 {v2.4s, v3.4s}, [X], #32
  84. ld1 {v0.4s, v1.4s}, [X]
  85. ld1 {v2.4s, v3.4s}, [Y]
  86. st1 {v0.4s, v1.4s}, [Y], #32
  87. st1 {v2.4s, v3.4s}, [X], #32
  88. #endif
  89. #else // COMPLEX
  90. #if !defined(DOUBLE)
  91. ld1 {v0.4s, v1.4s}, [X]
  92. ld1 {v2.4s, v3.4s}, [Y]
  93. st1 {v0.4s, v1.4s}, [Y], #32
  94. st1 {v2.4s, v3.4s}, [X], #32
  95. ld1 {v0.4s, v1.4s}, [X]
  96. ld1 {v2.4s, v3.4s}, [Y]
  97. st1 {v0.4s, v1.4s}, [Y], #32
  98. st1 {v2.4s, v3.4s}, [X], #32
  99. #else // DOUBLE
  100. ld1 {v0.4s, v1.4s}, [X]
  101. ld1 {v2.4s, v3.4s}, [Y]
  102. st1 {v0.4s, v1.4s}, [Y], #32
  103. st1 {v2.4s, v3.4s}, [X], #32
  104. ld1 {v0.4s, v1.4s}, [X]
  105. ld1 {v2.4s, v3.4s}, [Y]
  106. st1 {v0.4s, v1.4s}, [Y], #32
  107. st1 {v2.4s, v3.4s}, [X], #32
  108. ld1 {v0.4s, v1.4s}, [X]
  109. ld1 {v2.4s, v3.4s}, [Y]
  110. st1 {v0.4s, v1.4s}, [Y], #32
  111. st1 {v2.4s, v3.4s}, [X], #32
  112. ld1 {v0.4s, v1.4s}, [X]
  113. ld1 {v2.4s, v3.4s}, [Y]
  114. st1 {v0.4s, v1.4s}, [Y], #32
  115. st1 {v2.4s, v3.4s}, [X], #32
  116. #endif
  117. #endif
  118. .endm
  119. .macro INIT_S
  120. #if !defined(COMPLEX)
  121. #if !defined(DOUBLE)
  122. lsl INC_X, INC_X, #2
  123. lsl INC_Y, INC_Y, #2
  124. #else
  125. lsl INC_X, INC_X, #3
  126. lsl INC_Y, INC_Y, #3
  127. #endif
  128. #else
  129. #if !defined(DOUBLE)
  130. lsl INC_X, INC_X, #3
  131. lsl INC_Y, INC_Y, #3
  132. #else
  133. lsl INC_X, INC_X, #4
  134. lsl INC_Y, INC_Y, #4
  135. #endif
  136. #endif
  137. .endm
  138. .macro KERNEL_S1
  139. #if !defined(COMPLEX)
  140. #if !defined(DOUBLE)
  141. ldr w10, [X]
  142. ldr w11, [Y]
  143. str w10, [Y]
  144. str w11, [X]
  145. #else
  146. ldr x10, [X]
  147. ldr x11, [Y]
  148. str x10, [Y]
  149. str x11, [X]
  150. #endif
  151. #else
  152. #if !defined(DOUBLE)
  153. ldr x10, [X]
  154. ldr x11, [Y]
  155. str x10, [Y]
  156. str x11, [X]
  157. #else
  158. ldr x10, [X]
  159. ldr x11, [Y]
  160. str x10, [Y]
  161. str x11, [X]
  162. ldr x12, [X, #8]
  163. ldr x13, [Y, #8]
  164. str x12, [Y, #8]
  165. str x13, [X, #8]
  166. #endif
  167. #endif
  168. add Y, Y, INC_Y
  169. add X, X, INC_X
  170. .endm
  171. /*******************************************************************************
  172. * End of macro definitions
  173. *******************************************************************************/
  174. PROLOGUE
  175. cmp N, xzr
  176. ble .Lswap_kernel_L999
  177. cmp INC_X, #1
  178. bne .Lswap_kernel_S_BEGIN
  179. cmp INC_Y, #1
  180. bne .Lswap_kernel_S_BEGIN
  181. .Lswap_kernel_F_BEGIN:
  182. asr I, N, #3
  183. cmp I, xzr
  184. beq .Lswap_kernel_F1
  185. .Lswap_kernel_F8:
  186. KERNEL_F8
  187. subs I, I, #1
  188. bne .Lswap_kernel_F8
  189. .Lswap_kernel_F1:
  190. ands I, N, #7
  191. ble .Lswap_kernel_L999
  192. .Lswap_kernel_F10:
  193. KERNEL_F1
  194. subs I, I, #1
  195. bne .Lswap_kernel_F10
  196. b .Lswap_kernel_L999
  197. .Lswap_kernel_S_BEGIN:
  198. INIT_S
  199. asr I, N, #2
  200. cmp I, xzr
  201. ble .Lswap_kernel_S1
  202. .Lswap_kernel_S4:
  203. KERNEL_S1
  204. KERNEL_S1
  205. KERNEL_S1
  206. KERNEL_S1
  207. subs I, I, #1
  208. bne .Lswap_kernel_S4
  209. .Lswap_kernel_S1:
  210. ands I, N, #3
  211. ble .Lswap_kernel_L999
  212. .Lswap_kernel_S10:
  213. KERNEL_S1
  214. subs I, I, #1
  215. bne .Lswap_kernel_S10
  216. .Lswap_kernel_L999:
  217. mov w0, wzr
  218. ret
  219. EPILOGUE