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 6.9 kB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366
  1. /*********************************************************************/
  2. /* Copyright 2009, 2010 The University of Texas at Austin. */
  3. /* All rights reserved. */
  4. /* */
  5. /* Redistribution and use in source and binary forms, with or */
  6. /* without modification, are permitted provided that the following */
  7. /* conditions are met: */
  8. /* */
  9. /* 1. Redistributions of source code must retain the above */
  10. /* copyright notice, this list of conditions and the following */
  11. /* disclaimer. */
  12. /* */
  13. /* 2. Redistributions in binary form must reproduce the above */
  14. /* copyright notice, this list of conditions and the following */
  15. /* disclaimer in the documentation and/or other materials */
  16. /* provided with the distribution. */
  17. /* */
  18. /* THIS SOFTWARE IS PROVIDED BY THE UNIVERSITY OF TEXAS AT */
  19. /* AUSTIN ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, */
  20. /* INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF */
  21. /* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE */
  22. /* DISCLAIMED. IN NO EVENT SHALL THE UNIVERSITY OF TEXAS AT */
  23. /* AUSTIN OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, */
  24. /* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES */
  25. /* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE */
  26. /* GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR */
  27. /* BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF */
  28. /* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT */
  29. /* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT */
  30. /* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE */
  31. /* POSSIBILITY OF SUCH DAMAGE. */
  32. /* */
  33. /* The views and conclusions contained in the software and */
  34. /* documentation are those of the authors and should not be */
  35. /* interpreted as representing official policies, either expressed */
  36. /* or implied, of The University of Texas at Austin. */
  37. /*********************************************************************/
  38. #define ASSEMBLER
  39. #include "common.h"
  40. #define N ARG1 /* rdi */
  41. #define X ARG2 /* rsi */
  42. #define INCX ARG3 /* rdx */
  43. #define Y ARG4 /* rcx */
  44. #ifndef WINDOWS_ABI
  45. #define INCY ARG5 /* r8 */
  46. #define FLAG ARG6
  47. #else
  48. #define INCY %r10
  49. #define FLAG %r11
  50. #endif
  51. #include "l1param.h"
  52. PROLOGUE
  53. PROFCODE
  54. #ifdef WINDOWS_ABI
  55. movq 40(%rsp), INCY
  56. #endif
  57. EMMS
  58. testq N, N # if m == 0 goto End
  59. jle .L999
  60. salq $BASE_SHIFT, INCX
  61. salq $BASE_SHIFT, INCY
  62. cmpq $SIZE, INCX # if incx != 1
  63. jne .L100
  64. cmpq $SIZE, INCY # if incy != 1
  65. jne .L100
  66. movq N, %rax # i = m
  67. sarq $3, %rax
  68. jle .L20
  69. ALIGN_2
  70. .L11:
  71. #ifdef XDOUBLE
  72. #ifdef PREFETCH
  73. PREFETCH (PREFETCHSIZE + 0) - PREOFFSET(X)
  74. #endif
  75. movq 0(X), %mm0
  76. movq 8(X), %mm1
  77. movq %mm0, 0(Y)
  78. movq %mm1, 8(Y)
  79. movq 16(X), %mm2
  80. movq 24(X), %mm3
  81. movq %mm2, 16(Y)
  82. movq %mm3, 24(Y)
  83. movq 32(X), %mm4
  84. movq 40(X), %mm5
  85. movq %mm4, 32(Y)
  86. movq %mm5, 40(Y)
  87. movq 48(X), %mm6
  88. movq 56(X), %mm7
  89. movq %mm6, 48(Y)
  90. movq %mm7, 56(Y)
  91. #ifdef PREFETCHW
  92. PREFETCHW (PREFETCHSIZE + 0) - PREOFFSET(Y)
  93. #endif
  94. movq 64(X), %mm0
  95. movq 72(X), %mm1
  96. movq %mm0, 64(Y)
  97. movq %mm1, 72(Y)
  98. movq 80(X), %mm2
  99. movq 88(X), %mm3
  100. movq %mm2, 80(Y)
  101. movq %mm3, 88(Y)
  102. movq 96(X), %mm4
  103. movq 104(X), %mm5
  104. movq %mm4, 96(Y)
  105. movq %mm5, 104(Y)
  106. movq 112(X), %mm6
  107. movq 120(X), %mm7
  108. movq %mm6, 112(Y)
  109. movq %mm7, 120(Y)
  110. #elif defined(DOUBLE)
  111. movq 0(X), %mm0
  112. movq 8(X), %mm1
  113. #ifdef PREFETCH
  114. PREFETCH (PREFETCHSIZE + 0) - PREOFFSET(X)
  115. #endif
  116. movq %mm0, 0(Y)
  117. movq %mm1, 8(Y)
  118. movq 16(X), %mm2
  119. movq 24(X), %mm3
  120. movq %mm2, 16(Y)
  121. movq %mm3, 24(Y)
  122. movq 32(X), %mm4
  123. movq 40(X), %mm5
  124. #ifdef PREFETCHW
  125. PREFETCHW (PREFETCHSIZE + 0) - PREOFFSET(Y)
  126. #endif
  127. movq %mm4, 32(Y)
  128. movq %mm5, 40(Y)
  129. movq 48(X), %mm6
  130. movq 56(X), %mm7
  131. movq %mm6, 48(Y)
  132. movq %mm7, 56(Y)
  133. #else
  134. movq 0 * SIZE(X), %mm0
  135. movq 2 * SIZE(X), %mm2
  136. #ifdef PREFETCH
  137. PREFETCH (PREFETCHSIZE + 0) - PREOFFSET(X)
  138. #endif
  139. movq %mm0, 0 * SIZE(Y)
  140. movq %mm2, 2 * SIZE(Y)
  141. movq 4 * SIZE(X), %mm4
  142. movq 6 * SIZE(X), %mm6
  143. #ifdef PREFETCHW
  144. PREFETCHW (PREFETCHSIZE + 0) - PREOFFSET(Y)
  145. #endif
  146. movq %mm4, 4 * SIZE(Y)
  147. movq %mm6, 6 * SIZE(Y)
  148. #endif
  149. addq $8 * SIZE, X
  150. addq $8 * SIZE, Y
  151. decq %rax
  152. jg .L11
  153. ALIGN_2
  154. .L20:
  155. movq N, %rax
  156. andq $7, %rax
  157. jle .L99
  158. ALIGN_2
  159. .L21:
  160. #ifdef XDOUBLE
  161. movq 0(X), %mm0
  162. movq 8(X), %mm1
  163. movq %mm0, 0(Y)
  164. movq %mm1, 8(Y)
  165. #else
  166. MOVQ (X), %mm0
  167. MOVQ %mm0, (Y)
  168. #endif
  169. addq $SIZE, X
  170. addq $SIZE, Y
  171. decq %rax
  172. jg .L21
  173. .L99:
  174. xorq %rax,%rax
  175. EMMS
  176. ret
  177. ALIGN_3
  178. .L100:
  179. movq N, %rax
  180. sarq $3, %rax
  181. jle .L120
  182. ALIGN_2
  183. .L111:
  184. #ifdef XDOUBLE
  185. movq 0(X), %mm0
  186. movq 8(X), %mm1
  187. addq INCX, X
  188. movq 0(X), %mm2
  189. movq 8(X), %mm3
  190. addq INCX, X
  191. movq 0(X), %mm4
  192. movq 8(X), %mm5
  193. addq INCX, X
  194. movq 0(X), %mm6
  195. movq 8(X), %mm7
  196. addq INCX, X
  197. movq %mm0, 0(Y)
  198. movq %mm1, 8(Y)
  199. addq INCY, Y
  200. movq %mm2, 0(Y)
  201. movq %mm3, 8(Y)
  202. addq INCY, Y
  203. movq %mm4, 0(Y)
  204. movq %mm5, 8(Y)
  205. addq INCY, Y
  206. movq %mm6, 0(Y)
  207. movq %mm7, 8(Y)
  208. addq INCY, Y
  209. movq 0(X), %mm0
  210. movq 8(X), %mm1
  211. addq INCX, X
  212. movq 0(X), %mm2
  213. movq 8(X), %mm3
  214. addq INCX, X
  215. movq 0(X), %mm4
  216. movq 8(X), %mm5
  217. addq INCX, X
  218. movq 0(X), %mm6
  219. movq 8(X), %mm7
  220. addq INCX, X
  221. movq %mm0, 0(Y)
  222. movq %mm1, 8(Y)
  223. addq INCY, Y
  224. movq %mm2, 0(Y)
  225. movq %mm3, 8(Y)
  226. addq INCY, Y
  227. movq %mm4, 0(Y)
  228. movq %mm5, 8(Y)
  229. addq INCY, Y
  230. movq %mm6, 0(Y)
  231. movq %mm7, 8(Y)
  232. addq INCY, Y
  233. #else
  234. MOVQ (X), %mm0
  235. addq INCX, X
  236. MOVQ (X), %mm1
  237. addq INCX, X
  238. MOVQ (X), %mm2
  239. addq INCX, X
  240. MOVQ (X), %mm3
  241. addq INCX, X
  242. MOVQ (X), %mm4
  243. addq INCX, X
  244. MOVQ (X), %mm5
  245. addq INCX, X
  246. MOVQ (X), %mm6
  247. addq INCX, X
  248. MOVQ (X), %mm7
  249. addq INCX, X
  250. MOVQ %mm0, (Y)
  251. addq INCY, Y
  252. MOVQ %mm1, (Y)
  253. addq INCY, Y
  254. MOVQ %mm2, (Y)
  255. addq INCY, Y
  256. MOVQ %mm3, (Y)
  257. addq INCY, Y
  258. MOVQ %mm4, (Y)
  259. addq INCY, Y
  260. MOVQ %mm5, (Y)
  261. addq INCY, Y
  262. MOVQ %mm6, (Y)
  263. addq INCY, Y
  264. MOVQ %mm7, (Y)
  265. addq INCY, Y
  266. #endif
  267. decq %rax
  268. jg .L111
  269. .L120:
  270. movq N, %rax
  271. andq $7, %rax
  272. jle .L999
  273. ALIGN_2
  274. .L121:
  275. #ifdef XDOUBLE
  276. movq 0(X), %mm0
  277. movq 8(X), %mm1
  278. movq %mm0, 0(Y)
  279. movq %mm1, 8(Y)
  280. #else
  281. MOVQ (X), %mm0
  282. MOVQ %mm0, (Y)
  283. #endif
  284. addq INCX, X
  285. addq INCY, Y
  286. decq %rax
  287. jg .L121
  288. .L999:
  289. xorq %rax,%rax
  290. EMMS
  291. ret
  292. EPILOGUE