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

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439
  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. #ifndef WINDOWS_ABI
  41. #define N ARG1
  42. #define X ARG4
  43. #define INCX ARG5
  44. #define Y ARG6
  45. #define INCY ARG2
  46. #else
  47. #define N ARG1
  48. #define X ARG2
  49. #define INCX ARG3
  50. #define Y ARG4
  51. #define INCY %rbx
  52. #endif
  53. #define XX %r10
  54. #define YY %r11
  55. #include "l1param.h"
  56. PROLOGUE
  57. PROFCODE
  58. #ifndef WINDOWS_ABI
  59. #ifndef XDOUBLE
  60. movq 8(%rsp), INCY
  61. #else
  62. movq 24(%rsp), INCY
  63. #endif
  64. #else
  65. pushq %rbx
  66. movq 48(%rsp), X
  67. movq 56(%rsp), INCX
  68. movq 64(%rsp), Y
  69. movq 72(%rsp), INCY
  70. #endif
  71. EMMS
  72. salq $BASE_SHIFT, INCX
  73. salq $BASE_SHIFT, INCY
  74. cmpq $SIZE, INCX
  75. jne .L14
  76. cmpq $SIZE, INCY
  77. jne .L14
  78. movq N, %rax
  79. sarq $3, %rax
  80. jle .L15
  81. ALIGN_3
  82. .L16:
  83. #ifdef XDOUBLE
  84. movq 0(X), %mm0
  85. movq 8(X), %mm1
  86. movq 16(X), %mm2
  87. movq 24(X), %mm3
  88. movq 0(Y), %mm4
  89. movq 8(Y), %mm5
  90. movq 16(Y), %mm6
  91. movq 24(Y), %mm7
  92. movq %mm4, 0(X)
  93. movq %mm5, 8(X)
  94. movq %mm6, 16(X)
  95. movq %mm7, 24(X)
  96. movq %mm0, 0(Y)
  97. movq %mm1, 8(Y)
  98. movq %mm2, 16(Y)
  99. movq %mm3, 24(Y)
  100. movq 32(X), %mm0
  101. movq 40(X), %mm1
  102. movq 48(X), %mm2
  103. movq 56(X), %mm3
  104. movq 32(Y), %mm4
  105. movq 40(Y), %mm5
  106. movq 48(Y), %mm6
  107. movq 56(Y), %mm7
  108. movq %mm4, 32(X)
  109. movq %mm5, 40(X)
  110. movq %mm6, 48(X)
  111. movq %mm7, 56(X)
  112. movq %mm0, 32(Y)
  113. movq %mm1, 40(Y)
  114. movq %mm2, 48(Y)
  115. movq %mm3, 56(Y)
  116. movq 64(X), %mm0
  117. movq 72(X), %mm1
  118. movq 80(X), %mm2
  119. movq 88(X), %mm3
  120. movq 64(Y), %mm4
  121. movq 72(Y), %mm5
  122. movq 80(Y), %mm6
  123. movq 88(Y), %mm7
  124. movq %mm4, 64(X)
  125. movq %mm5, 72(X)
  126. movq %mm6, 80(X)
  127. movq %mm7, 88(X)
  128. movq %mm0, 64(Y)
  129. movq %mm1, 72(Y)
  130. movq %mm2, 80(Y)
  131. movq %mm3, 88(Y)
  132. movq 96(X), %mm0
  133. movq 104(X), %mm1
  134. movq 112(X), %mm2
  135. movq 120(X), %mm3
  136. movq 96(Y), %mm4
  137. movq 104(Y), %mm5
  138. movq 112(Y), %mm6
  139. movq 120(Y), %mm7
  140. movq %mm4, 96(X)
  141. movq %mm5, 104(X)
  142. movq %mm6, 112(X)
  143. movq %mm7, 120(X)
  144. movq %mm0, 96(Y)
  145. movq %mm1, 104(Y)
  146. movq %mm2, 112(Y)
  147. movq %mm3, 120(Y)
  148. #elif defined(DOUBLE)
  149. #ifdef PREFETCHW
  150. PREFETCHW (PREFETCHSIZE + 0) - PREOFFSET(X)
  151. #endif
  152. movq 0 * SIZE(X), %mm0
  153. movq 1 * SIZE(X), %mm1
  154. movq 2 * SIZE(X), %mm2
  155. movq 3 * SIZE(X), %mm3
  156. movq 0 * SIZE(Y), %mm4
  157. movq 1 * SIZE(Y), %mm5
  158. movq 2 * SIZE(Y), %mm6
  159. movq 3 * SIZE(Y), %mm7
  160. #ifdef PREFETCHW
  161. PREFETCHW (PREFETCHSIZE + 0) - PREOFFSET(Y)
  162. #endif
  163. movq %mm4, 0 * SIZE(X)
  164. movq %mm5, 1 * SIZE(X)
  165. movq %mm6, 2 * SIZE(X)
  166. movq %mm7, 3 * SIZE(X)
  167. movq %mm0, 0 * SIZE(Y)
  168. movq %mm1, 1 * SIZE(Y)
  169. movq %mm2, 2 * SIZE(Y)
  170. movq %mm3, 3 * SIZE(Y)
  171. #ifdef PREFETCHW
  172. PREFETCHW (PREFETCHSIZE + 64) - PREOFFSET(X)
  173. #endif
  174. movq 4 * SIZE(X), %mm0
  175. movq 5 * SIZE(X), %mm1
  176. movq 6 * SIZE(X), %mm2
  177. movq 7 * SIZE(X), %mm3
  178. movq 4 * SIZE(Y), %mm4
  179. movq 5 * SIZE(Y), %mm5
  180. movq 6 * SIZE(Y), %mm6
  181. movq 7 * SIZE(Y), %mm7
  182. #ifdef PREFETCHW
  183. PREFETCHW (PREFETCHSIZE + 0) - PREOFFSET(Y)
  184. #endif
  185. movq %mm4, 4 * SIZE(X)
  186. movq %mm5, 5 * SIZE(X)
  187. movq %mm6, 6 * SIZE(X)
  188. movq %mm7, 7 * SIZE(X)
  189. movq %mm0, 4 * SIZE(Y)
  190. movq %mm1, 5 * SIZE(Y)
  191. movq %mm2, 6 * SIZE(Y)
  192. movq %mm3, 7 * SIZE(Y)
  193. #else
  194. #ifdef PREFETCHW
  195. PREFETCHW (PREFETCHSIZE + 0) - PREOFFSET(X)
  196. #endif
  197. movq 0 * SIZE(X), %mm0
  198. movq 2 * SIZE(X), %mm1
  199. movq 4 * SIZE(X), %mm2
  200. movq 6 * SIZE(X), %mm3
  201. movq 0 * SIZE(Y), %mm4
  202. movq 2 * SIZE(Y), %mm5
  203. movq 4 * SIZE(Y), %mm6
  204. movq 6 * SIZE(Y), %mm7
  205. #ifdef PREFETCHW
  206. PREFETCHW (PREFETCHSIZE + 0) - PREOFFSET(Y)
  207. #endif
  208. movq %mm4, 0 * SIZE(X)
  209. movq %mm5, 2 * SIZE(X)
  210. movq %mm6, 4 * SIZE(X)
  211. movq %mm7, 6 * SIZE(X)
  212. movq %mm0, 0 * SIZE(Y)
  213. movq %mm1, 2 * SIZE(Y)
  214. movq %mm2, 4 * SIZE(Y)
  215. movq %mm3, 6 * SIZE(Y)
  216. #endif
  217. addq $8 * SIZE, X
  218. addq $8 * SIZE, Y
  219. decq %rax
  220. jg .L16
  221. ALIGN_3
  222. .L15:
  223. movq N, %rax
  224. andq $7, %rax
  225. jle .L27
  226. ALIGN_3
  227. .L22:
  228. #ifdef XDOUBLE
  229. movq 0(X), %mm0
  230. movq 8(X), %mm1
  231. movq 0(Y), %mm4
  232. movq 8(Y), %mm5
  233. movq %mm4, 0(X)
  234. movq %mm5, 8(X)
  235. movq %mm0, 0(Y)
  236. movq %mm1, 8(Y)
  237. #else
  238. MOVQ 0 * SIZE(X), %mm0
  239. MOVQ 0 * SIZE(Y), %mm4
  240. MOVQ %mm4, 0 * SIZE(X)
  241. MOVQ %mm0, 0 * SIZE(Y)
  242. #endif
  243. addq $SIZE, X
  244. addq $SIZE, Y
  245. decq %rax
  246. jg .L22
  247. jmp .L27
  248. ALIGN_3
  249. /* INCX != 1 or INCY != 1 */
  250. .L14:
  251. movq N, %rax
  252. movq X, XX
  253. movq Y, YY
  254. sarq $2, %rax
  255. jle .L28
  256. ALIGN_2
  257. .L29:
  258. #ifdef XDOUBLE
  259. movq 0(X), %mm0
  260. movq 8(X), %mm1
  261. addq INCX, X
  262. movq 0(Y), %mm4
  263. movq 8(Y), %mm5
  264. addq INCY, Y
  265. movq %mm4, 0(XX)
  266. movq %mm5, 8(XX)
  267. addq INCX, XX
  268. movq %mm0, 0(YY)
  269. movq %mm1, 8(YY)
  270. addq INCY, YY
  271. movq 0(X), %mm0
  272. movq 8(X), %mm1
  273. addq INCX, X
  274. movq 0(Y), %mm4
  275. movq 8(Y), %mm5
  276. addq INCY, Y
  277. movq %mm4, 0(XX)
  278. movq %mm5, 8(XX)
  279. addq INCX, XX
  280. movq %mm0, 0(YY)
  281. movq %mm1, 8(YY)
  282. addq INCY, YY
  283. movq 0(X), %mm0
  284. movq 8(X), %mm1
  285. addq INCX, X
  286. movq 0(Y), %mm4
  287. movq 8(Y), %mm5
  288. addq INCY, Y
  289. movq %mm4, 0(XX)
  290. movq %mm5, 8(XX)
  291. addq INCX, XX
  292. movq %mm0, 0(YY)
  293. movq %mm1, 8(YY)
  294. addq INCY, YY
  295. movq 0(X), %mm0
  296. movq 8(X), %mm1
  297. addq INCX, X
  298. movq 0(Y), %mm4
  299. movq 8(Y), %mm5
  300. addq INCY, Y
  301. movq %mm4, 0(XX)
  302. movq %mm5, 8(XX)
  303. addq INCX, XX
  304. movq %mm0, 0(YY)
  305. movq %mm1, 8(YY)
  306. addq INCY, YY
  307. #else
  308. MOVQ (X), %mm0
  309. addq INCX, X
  310. MOVQ (X), %mm1
  311. addq INCX, X
  312. MOVQ (X), %mm2
  313. addq INCX, X
  314. MOVQ (X), %mm3
  315. addq INCX, X
  316. MOVQ (Y), %mm4
  317. addq INCY, Y
  318. MOVQ (Y), %mm5
  319. addq INCY, Y
  320. MOVQ (Y), %mm6
  321. addq INCY, Y
  322. MOVQ (Y), %mm7
  323. addq INCY, Y
  324. MOVQ %mm4, (XX)
  325. addq INCX, XX
  326. MOVQ %mm5, (XX)
  327. addq INCX, XX
  328. MOVQ %mm6, (XX)
  329. addq INCX, XX
  330. MOVQ %mm7, (XX)
  331. addq INCX, XX
  332. MOVQ %mm0, (YY)
  333. addq INCY, YY
  334. MOVQ %mm1, (YY)
  335. addq INCY, YY
  336. MOVQ %mm2, (YY)
  337. addq INCY, YY
  338. MOVQ %mm3, (YY)
  339. addq INCY, YY
  340. #endif
  341. decq %rax
  342. jg .L29
  343. ALIGN_3
  344. .L28:
  345. movq N, %rax
  346. andq $3, %rax
  347. jle .L27
  348. ALIGN_3
  349. .L35:
  350. #ifdef XDOUBLE
  351. movq 0(X), %mm0
  352. movq 8(X), %mm1
  353. movq 0(Y), %mm4
  354. movq 8(Y), %mm5
  355. movq %mm4, 0(X)
  356. movq %mm5, 8(X)
  357. movq %mm0, 0(Y)
  358. movq %mm1, 8(Y)
  359. #else
  360. MOVQ (X), %mm0
  361. MOVQ (Y), %mm4
  362. MOVQ %mm4, (X)
  363. MOVQ %mm0, (Y)
  364. #endif
  365. addq INCX, X
  366. addq INCY, Y
  367. decq %rax
  368. jg .L35
  369. ALIGN_3
  370. .L27:
  371. EMMS
  372. xorq %rax,%rax
  373. #ifdef WINDOWS_ABI
  374. popq %rbx
  375. #endif
  376. ret
  377. EPILOGUE