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_sse2.S 11 kB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585
  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 M ARG1
  42. #define X ARG4
  43. #define INCX ARG5
  44. #define Y ARG6
  45. #define INCY ARG2
  46. #else
  47. #define M ARG1
  48. #define X ARG2
  49. #define INCX ARG3
  50. #define Y ARG4
  51. #define INCY %rbx
  52. #endif
  53. #include "l1param.h"
  54. PROLOGUE
  55. PROFCODE
  56. #ifndef WINDOWS_ABI
  57. movq 8(%rsp), INCY
  58. #else
  59. pushq %rbx
  60. movq 48(%rsp), X
  61. movq 56(%rsp), INCX
  62. movq 64(%rsp), Y
  63. movq 72(%rsp), INCY
  64. #endif
  65. SAVEREGISTERS
  66. leaq (, INCX, SIZE), INCX
  67. leaq (, INCY, SIZE), INCY
  68. cmpq $SIZE, INCX
  69. jne .L40
  70. cmpq $SIZE, INCY
  71. jne .L40
  72. testq $SIZE, Y
  73. je .L10
  74. movsd 0 * SIZE(X), %xmm0
  75. movsd 0 * SIZE(Y), %xmm8
  76. movsd %xmm8, 0 * SIZE(X)
  77. movsd %xmm0, 0 * SIZE(Y)
  78. addq $1 * SIZE, X
  79. addq $1 * SIZE, Y
  80. decq M
  81. jle .L19
  82. ALIGN_4
  83. .L10:
  84. subq $-16 * SIZE, X
  85. subq $-16 * SIZE, Y
  86. testq $SIZE, X
  87. jne .L20
  88. movq M, %rax
  89. sarq $4, %rax
  90. jle .L13
  91. ALIGN_3
  92. .L11:
  93. #ifdef PREFETCHW
  94. PREFETCHW (PREFETCHSIZE + 0) - PREOFFSET(X)
  95. #endif
  96. movaps -16 * SIZE(X), %xmm0
  97. movaps -16 * SIZE(Y), %xmm1
  98. movaps %xmm0, -16 * SIZE(Y)
  99. movaps %xmm1, -16 * SIZE(X)
  100. movaps -14 * SIZE(X), %xmm0
  101. movaps -14 * SIZE(Y), %xmm1
  102. movaps %xmm0, -14 * SIZE(Y)
  103. movaps %xmm1, -14 * SIZE(X)
  104. #ifdef PREFETCHW
  105. PREFETCHW (PREFETCHSIZE + 0) - PREOFFSET(Y)
  106. #endif
  107. movaps -12 * SIZE(X), %xmm0
  108. movaps -12 * SIZE(Y), %xmm1
  109. movaps %xmm0, -12 * SIZE(Y)
  110. movaps %xmm1, -12 * SIZE(X)
  111. movaps -10 * SIZE(X), %xmm0
  112. movaps -10 * SIZE(Y), %xmm1
  113. movaps %xmm0, -10 * SIZE(Y)
  114. movaps %xmm1, -10 * SIZE(X)
  115. #ifdef PREFETCHW
  116. PREFETCHW (PREFETCHSIZE + 64) - PREOFFSET(X)
  117. #endif
  118. movaps -8 * SIZE(X), %xmm0
  119. movaps -8 * SIZE(Y), %xmm1
  120. movaps %xmm0, -8 * SIZE(Y)
  121. movaps %xmm1, -8 * SIZE(X)
  122. movaps -6 * SIZE(X), %xmm0
  123. movaps -6 * SIZE(Y), %xmm1
  124. movaps %xmm0, -6 * SIZE(Y)
  125. movaps %xmm1, -6 * SIZE(X)
  126. #ifdef PREFETCHW
  127. PREFETCHW (PREFETCHSIZE + 64) - PREOFFSET(Y)
  128. #endif
  129. movaps -4 * SIZE(X), %xmm0
  130. movaps -4 * SIZE(Y), %xmm1
  131. movaps %xmm0, -4 * SIZE(Y)
  132. movaps %xmm1, -4 * SIZE(X)
  133. movaps -2 * SIZE(X), %xmm0
  134. movaps -2 * SIZE(Y), %xmm1
  135. movaps %xmm0, -2 * SIZE(Y)
  136. movaps %xmm1, -2 * SIZE(X)
  137. subq $-16 * SIZE, Y
  138. subq $-16 * SIZE, X
  139. decq %rax
  140. jg .L11
  141. ALIGN_3
  142. .L13:
  143. testq $8, M
  144. jle .L14
  145. movaps -16 * SIZE(X), %xmm0
  146. movaps -16 * SIZE(Y), %xmm1
  147. movaps %xmm0, -16 * SIZE(Y)
  148. movaps %xmm1, -16 * SIZE(X)
  149. movaps -14 * SIZE(X), %xmm0
  150. movaps -14 * SIZE(Y), %xmm1
  151. movaps %xmm0, -14 * SIZE(Y)
  152. movaps %xmm1, -14 * SIZE(X)
  153. movaps -12 * SIZE(X), %xmm0
  154. movaps -12 * SIZE(Y), %xmm1
  155. movaps %xmm0, -12 * SIZE(Y)
  156. movaps %xmm1, -12 * SIZE(X)
  157. movaps -10 * SIZE(X), %xmm0
  158. movaps -10 * SIZE(Y), %xmm1
  159. movaps %xmm0, -10 * SIZE(Y)
  160. movaps %xmm1, -10 * SIZE(X)
  161. addq $8 * SIZE, X
  162. addq $8 * SIZE, Y
  163. ALIGN_3
  164. .L14:
  165. testq $4, M
  166. jle .L15
  167. movaps -16 * SIZE(X), %xmm0
  168. movaps -16 * SIZE(Y), %xmm1
  169. movaps %xmm0, -16 * SIZE(Y)
  170. movaps %xmm1, -16 * SIZE(X)
  171. movaps -14 * SIZE(X), %xmm0
  172. movaps -14 * SIZE(Y), %xmm1
  173. movaps %xmm0, -14 * SIZE(Y)
  174. movaps %xmm1, -14 * SIZE(X)
  175. addq $4 * SIZE, X
  176. addq $4 * SIZE, Y
  177. ALIGN_3
  178. .L15:
  179. testq $2, M
  180. jle .L16
  181. movaps -16 * SIZE(X), %xmm0
  182. movaps -16 * SIZE(Y), %xmm1
  183. movaps %xmm0, -16 * SIZE(Y)
  184. movaps %xmm1, -16 * SIZE(X)
  185. addq $2 * SIZE, X
  186. addq $2 * SIZE, Y
  187. ALIGN_3
  188. .L16:
  189. testq $1, M
  190. jle .L19
  191. movsd -16 * SIZE(X), %xmm0
  192. movsd -16 * SIZE(Y), %xmm1
  193. movlps %xmm1, -16 * SIZE(X)
  194. movlps %xmm0, -16 * SIZE(Y)
  195. ALIGN_3
  196. .L19:
  197. xorq %rax,%rax
  198. RESTOREREGISTERS
  199. #ifdef WINDOWS_ABI
  200. popq %rbx
  201. #endif
  202. ret
  203. ALIGN_3
  204. .L20:
  205. movhps -16 * SIZE(X), %xmm0
  206. movaps -16 * SIZE(Y), %xmm1
  207. movlps %xmm1, -16 * SIZE(X)
  208. decq M
  209. jle .L29
  210. movq M, %rax
  211. sarq $4, %rax
  212. jle .L23
  213. ALIGN_4
  214. .L21:
  215. #ifdef PREFETCHW
  216. PREFETCHW (PREFETCHSIZE + 0) - PREOFFSET(X)
  217. #endif
  218. movaps -15 * SIZE(X), %xmm2
  219. movaps -14 * SIZE(Y), %xmm3
  220. SHUFPD_1 %xmm2, %xmm0
  221. movaps %xmm0, -16 * SIZE(Y)
  222. SHUFPD_1 %xmm3, %xmm1
  223. movaps %xmm1, -15 * SIZE(X)
  224. movaps -13 * SIZE(X), %xmm0
  225. movaps -12 * SIZE(Y), %xmm1
  226. SHUFPD_1 %xmm0, %xmm2
  227. movaps %xmm2, -14 * SIZE(Y)
  228. SHUFPD_1 %xmm1, %xmm3
  229. movaps %xmm3, -13 * SIZE(X)
  230. #ifdef PREFETCHW
  231. PREFETCHW (PREFETCHSIZE + 0) - PREOFFSET(Y)
  232. #endif
  233. movaps -11 * SIZE(X), %xmm2
  234. movaps -10 * SIZE(Y), %xmm3
  235. SHUFPD_1 %xmm2, %xmm0
  236. movaps %xmm0, -12 * SIZE(Y)
  237. SHUFPD_1 %xmm3, %xmm1
  238. movaps %xmm1, -11 * SIZE(X)
  239. movaps -9 * SIZE(X), %xmm0
  240. movaps -8 * SIZE(Y), %xmm1
  241. SHUFPD_1 %xmm0, %xmm2
  242. movaps %xmm2, -10 * SIZE(Y)
  243. SHUFPD_1 %xmm1, %xmm3
  244. movaps %xmm3, -9 * SIZE(X)
  245. #ifdef PREFETCHW
  246. PREFETCHW (PREFETCHSIZE + 64) - PREOFFSET(X)
  247. #endif
  248. movaps -7 * SIZE(X), %xmm2
  249. movaps -6 * SIZE(Y), %xmm3
  250. SHUFPD_1 %xmm2, %xmm0
  251. movaps %xmm0, -8 * SIZE(Y)
  252. SHUFPD_1 %xmm3, %xmm1
  253. movaps %xmm1, -7 * SIZE(X)
  254. movaps -5 * SIZE(X), %xmm0
  255. movaps -4 * SIZE(Y), %xmm1
  256. SHUFPD_1 %xmm0, %xmm2
  257. movaps %xmm2, -6 * SIZE(Y)
  258. SHUFPD_1 %xmm1, %xmm3
  259. movaps %xmm3, -5 * SIZE(X)
  260. #ifdef PREFETCHW
  261. PREFETCHW (PREFETCHSIZE + 64) - PREOFFSET(Y)
  262. #endif
  263. movaps -3 * SIZE(X), %xmm2
  264. movaps -2 * SIZE(Y), %xmm3
  265. SHUFPD_1 %xmm2, %xmm0
  266. movaps %xmm0, -4 * SIZE(Y)
  267. SHUFPD_1 %xmm3, %xmm1
  268. movaps %xmm1, -3 * SIZE(X)
  269. movaps -1 * SIZE(X), %xmm0
  270. movaps 0 * SIZE(Y), %xmm1
  271. SHUFPD_1 %xmm0, %xmm2
  272. movaps %xmm2, -2 * SIZE(Y)
  273. SHUFPD_1 %xmm1, %xmm3
  274. movaps %xmm3, -1 * SIZE(X)
  275. subq $-16 * SIZE, X
  276. subq $-16 * SIZE, Y
  277. decq %rax
  278. jg .L21
  279. ALIGN_3
  280. .L23:
  281. testq $8, M
  282. jle .L24
  283. movaps -15 * SIZE(X), %xmm2
  284. movaps -14 * SIZE(Y), %xmm3
  285. SHUFPD_1 %xmm2, %xmm0
  286. movaps %xmm0, -16 * SIZE(Y)
  287. SHUFPD_1 %xmm3, %xmm1
  288. movaps %xmm1, -15 * SIZE(X)
  289. movaps -13 * SIZE(X), %xmm0
  290. movaps -12 * SIZE(Y), %xmm1
  291. SHUFPD_1 %xmm0, %xmm2
  292. movaps %xmm2, -14 * SIZE(Y)
  293. SHUFPD_1 %xmm1, %xmm3
  294. movaps %xmm3, -13 * SIZE(X)
  295. movaps -11 * SIZE(X), %xmm2
  296. movaps -10 * SIZE(Y), %xmm3
  297. SHUFPD_1 %xmm2, %xmm0
  298. movaps %xmm0, -12 * SIZE(Y)
  299. SHUFPD_1 %xmm3, %xmm1
  300. movaps %xmm1, -11 * SIZE(X)
  301. movaps -9 * SIZE(X), %xmm0
  302. movaps -8 * SIZE(Y), %xmm1
  303. SHUFPD_1 %xmm0, %xmm2
  304. movaps %xmm2, -10 * SIZE(Y)
  305. SHUFPD_1 %xmm1, %xmm3
  306. movaps %xmm3, -9 * SIZE(X)
  307. addq $8 * SIZE, X
  308. addq $8 * SIZE, Y
  309. ALIGN_3
  310. .L24:
  311. testq $4, M
  312. jle .L25
  313. movaps -15 * SIZE(X), %xmm2
  314. movaps -14 * SIZE(Y), %xmm3
  315. SHUFPD_1 %xmm2, %xmm0
  316. movaps %xmm0, -16 * SIZE(Y)
  317. SHUFPD_1 %xmm3, %xmm1
  318. movaps %xmm1, -15 * SIZE(X)
  319. movaps -13 * SIZE(X), %xmm0
  320. movaps -12 * SIZE(Y), %xmm1
  321. SHUFPD_1 %xmm0, %xmm2
  322. movaps %xmm2, -14 * SIZE(Y)
  323. SHUFPD_1 %xmm1, %xmm3
  324. movaps %xmm3, -13 * SIZE(X)
  325. addq $4 * SIZE, X
  326. addq $4 * SIZE, Y
  327. ALIGN_3
  328. .L25:
  329. testq $2, M
  330. jle .L26
  331. movaps -15 * SIZE(X), %xmm2
  332. movaps -14 * SIZE(Y), %xmm3
  333. SHUFPD_1 %xmm3, %xmm1
  334. movaps %xmm1, -15 * SIZE(X)
  335. SHUFPD_1 %xmm2, %xmm0
  336. movaps %xmm0, -16 * SIZE(Y)
  337. movaps %xmm2, %xmm0
  338. movaps %xmm3, %xmm1
  339. addq $2 * SIZE, X
  340. addq $2 * SIZE, Y
  341. ALIGN_3
  342. .L26:
  343. testq $1, M
  344. jle .L29
  345. movhps %xmm0, -16 * SIZE(Y)
  346. movhps -15 * SIZE(X), %xmm0
  347. movhps %xmm1, -15 * SIZE(X)
  348. addq $SIZE, X
  349. addq $SIZE, Y
  350. ALIGN_3
  351. .L29:
  352. movhps %xmm0, -16 * SIZE(Y)
  353. xorq %rax,%rax
  354. RESTOREREGISTERS
  355. #ifdef WINDOWS_ABI
  356. popq %rbx
  357. #endif
  358. ret
  359. ALIGN_3
  360. .L40:
  361. movq M, %rax
  362. sarq $3, %rax
  363. jle .L45
  364. ALIGN_3
  365. .L41:
  366. movsd (X), %xmm0
  367. movsd (Y), %xmm1
  368. movsd %xmm1, (X)
  369. addq INCX, X
  370. movsd %xmm0, (Y)
  371. addq INCY, Y
  372. movsd (X), %xmm0
  373. movsd (Y), %xmm1
  374. movsd %xmm1, (X)
  375. addq INCX, X
  376. movsd %xmm0, (Y)
  377. addq INCY, Y
  378. movsd (X), %xmm0
  379. movsd (Y), %xmm1
  380. movsd %xmm1, (X)
  381. addq INCX, X
  382. movsd %xmm0, (Y)
  383. addq INCY, Y
  384. movsd (X), %xmm0
  385. movsd (Y), %xmm1
  386. movsd %xmm1, (X)
  387. addq INCX, X
  388. movsd %xmm0, (Y)
  389. addq INCY, Y
  390. movsd (X), %xmm0
  391. movsd (Y), %xmm1
  392. movsd %xmm1, (X)
  393. addq INCX, X
  394. movsd %xmm0, (Y)
  395. addq INCY, Y
  396. movsd (X), %xmm0
  397. movsd (Y), %xmm1
  398. movsd %xmm1, (X)
  399. addq INCX, X
  400. movsd %xmm0, (Y)
  401. addq INCY, Y
  402. movsd (X), %xmm0
  403. movsd (Y), %xmm1
  404. movsd %xmm1, (X)
  405. addq INCX, X
  406. movsd %xmm0, (Y)
  407. addq INCY, Y
  408. movsd (X), %xmm0
  409. movsd (Y), %xmm1
  410. movsd %xmm1, (X)
  411. addq INCX, X
  412. movsd %xmm0, (Y)
  413. addq INCY, Y
  414. decq %rax
  415. jg .L41
  416. ALIGN_3
  417. .L45:
  418. movq M, %rax
  419. andq $7, %rax
  420. jle .L47
  421. ALIGN_3
  422. .L46:
  423. movsd (X), %xmm0
  424. movsd (Y), %xmm1
  425. movsd %xmm1, (X)
  426. movsd %xmm0, (Y)
  427. addq INCX, X
  428. addq INCY, Y
  429. decq %rax
  430. jg .L46
  431. ALIGN_3
  432. .L47:
  433. xorq %rax, %rax
  434. RESTOREREGISTERS
  435. #ifdef WINDOWS_ABI
  436. popq %rbx
  437. #endif
  438. ret
  439. EPILOGUE