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.

copy.S 4.7 kB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232
  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 x1 /* X vector address */
  31. #define INC_X x2 /* X stride */
  32. #define Y x3 /* Y vector address */
  33. #define INC_Y x4 /* Y stride */
  34. #define I x5 /* loop variable */
  35. /*******************************************************************************
  36. * Macro definitions
  37. *******************************************************************************/
  38. #if !defined(DOUBLE)
  39. #define TMPF s0
  40. #define TMPVF {v0.s}[0]
  41. #define SZ 4
  42. #else
  43. #define TMPF d0
  44. #define TMPVF {v0.d}[0]
  45. #define SZ 8
  46. #endif
  47. /******************************************************************************/
  48. .macro KERNEL_F1
  49. #if !defined(COMPLEX)
  50. ldr TMPF, [X], #SZ
  51. str TMPF, [Y], #SZ
  52. #else
  53. #if !defined(DOUBLE)
  54. ldr d0, [X], #8
  55. str d0, [Y], #8
  56. #else
  57. ldr q0, [X], #16
  58. str q0, [Y], #16
  59. #endif
  60. #endif
  61. .endm
  62. .macro KERNEL_F4
  63. #if !defined(COMPLEX)
  64. #if !defined(DOUBLE)
  65. ldr q0, [X], #16
  66. str q0, [Y], #16
  67. #else // DOUBLE
  68. ldr q0, [X], #16
  69. str q0, [Y], #16
  70. ldr q1, [X], #16
  71. str q1, [Y], #16
  72. #endif
  73. #else // COMPLEX
  74. #if !defined(DOUBLE)
  75. ldr q0, [X], #16
  76. str q0, [Y], #16
  77. ldr q1, [X], #16
  78. str q1, [Y], #16
  79. #else // DOUBLE
  80. ldr q0, [X], #16
  81. str q0, [Y], #16
  82. ldr q1, [X], #16
  83. str q1, [Y], #16
  84. ldr q2, [X], #16
  85. str q2, [Y], #16
  86. ldr q3, [X], #16
  87. str q3, [Y], #16
  88. #endif
  89. #endif
  90. .endm
  91. .macro INIT_S
  92. #if !defined(COMPLEX)
  93. #if !defined(DOUBLE)
  94. lsl INC_X, INC_X, #2
  95. lsl INC_Y, INC_Y, #2
  96. #else
  97. lsl INC_X, INC_X, #3
  98. lsl INC_Y, INC_Y, #3
  99. #endif
  100. #else
  101. #if !defined(DOUBLE)
  102. lsl INC_X, INC_X, #3
  103. lsl INC_Y, INC_Y, #3
  104. #else
  105. lsl INC_X, INC_X, #4
  106. lsl INC_Y, INC_Y, #4
  107. #endif
  108. #endif
  109. .endm
  110. .macro KERNEL_S1
  111. #if !defined(COMPLEX)
  112. #if !defined(DOUBLE)
  113. ldr w10, [X]
  114. add X, X, INC_X
  115. str w10, [Y]
  116. add Y, Y, INC_Y
  117. #else
  118. ldr x10, [X]
  119. add X, X, INC_X
  120. str x10, [Y]
  121. add Y, Y, INC_Y
  122. #endif
  123. #else
  124. #if !defined(DOUBLE)
  125. ld1 {v0.2s}, [X]
  126. add X, X, INC_X
  127. st1 {v0.2s}, [Y]
  128. add Y, Y, INC_Y
  129. #else
  130. ld1 {v0.2d}, [X]
  131. add X, X, INC_X
  132. st1 {v0.2d}, [Y]
  133. add Y, Y, INC_Y
  134. #endif
  135. #endif
  136. .endm
  137. /*******************************************************************************
  138. * End of macro definitions
  139. *******************************************************************************/
  140. PROLOGUE
  141. cmp N, xzr
  142. ble .Lcopy_kernel_L999
  143. cmp INC_X, #1
  144. bne .Lcopy_kernel_S_BEGIN
  145. cmp INC_Y, #1
  146. bne .Lcopy_kernel_S_BEGIN
  147. .Lcopy_kernel_F_BEGIN:
  148. asr I, N, #2
  149. cmp I, xzr
  150. beq .Lcopy_kernel_F1
  151. .Lcopy_kernel_F4:
  152. KERNEL_F4
  153. subs I, I, #1
  154. bne .Lcopy_kernel_F4
  155. .Lcopy_kernel_F1:
  156. ands I, N, #3
  157. ble .Lcopy_kernel_L999
  158. .Lcopy_kernel_F10:
  159. KERNEL_F1
  160. subs I, I, #1
  161. bne .Lcopy_kernel_F10
  162. mov w0, wzr
  163. ret
  164. .Lcopy_kernel_S_BEGIN:
  165. INIT_S
  166. asr I, N, #2
  167. cmp I, xzr
  168. ble .Lcopy_kernel_S1
  169. .Lcopy_kernel_S4:
  170. KERNEL_S1
  171. KERNEL_S1
  172. KERNEL_S1
  173. KERNEL_S1
  174. subs I, I, #1
  175. bne .Lcopy_kernel_S4
  176. .Lcopy_kernel_S1:
  177. ands I, N, #3
  178. ble .Lcopy_kernel_L999
  179. .Lcopy_kernel_S10:
  180. KERNEL_S1
  181. subs I, I, #1
  182. bne .Lcopy_kernel_S10
  183. .Lcopy_kernel_L999:
  184. mov w0, wzr
  185. ret
  186. EPILOGUE