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.

zswap.S 9.4 kB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452
  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 /* rdi */
  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 40(%rsp), INCY
  63. #endif
  64. #else
  65. pushq %rbx
  66. movq 56(%rsp), X
  67. movq 64(%rsp), INCX
  68. movq 72(%rsp), Y
  69. movq 80(%rsp), INCY
  70. #endif
  71. EMMS
  72. salq $ZBASE_SHIFT, INCX
  73. salq $ZBASE_SHIFT, INCY
  74. cmpq $2 * SIZE, INCX
  75. jne .L14
  76. cmpq $2 * SIZE, INCY
  77. jne .L14
  78. movq N, %rax
  79. sarq $2, %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. prefetchw PREFETCHSIZE * SIZE(X)
  150. MOVQ 0 * SIZE(X), %mm0
  151. MOVQ 1 * SIZE(X), %mm1
  152. MOVQ 2 * SIZE(X), %mm2
  153. MOVQ 3 * SIZE(X), %mm3
  154. prefetchw PREFETCHSIZE * SIZE(Y)
  155. MOVQ 0 * SIZE(Y), %mm4
  156. MOVQ 1 * SIZE(Y), %mm5
  157. MOVQ 2 * SIZE(Y), %mm6
  158. MOVQ 3 * SIZE(Y), %mm7
  159. MOVQ %mm4, 0 * SIZE(X)
  160. MOVQ %mm5, 1 * SIZE(X)
  161. MOVQ %mm6, 2 * SIZE(X)
  162. MOVQ %mm7, 3 * SIZE(X)
  163. MOVQ %mm0, 0 * SIZE(Y)
  164. MOVQ %mm1, 1 * SIZE(Y)
  165. MOVQ %mm2, 2 * SIZE(Y)
  166. MOVQ %mm3, 3 * SIZE(Y)
  167. MOVQ 4 * SIZE(X), %mm0
  168. MOVQ 5 * SIZE(X), %mm1
  169. MOVQ 6 * SIZE(X), %mm2
  170. MOVQ 7 * SIZE(X), %mm3
  171. MOVQ 4 * SIZE(Y), %mm4
  172. MOVQ 5 * SIZE(Y), %mm5
  173. MOVQ 6 * SIZE(Y), %mm6
  174. MOVQ 7 * SIZE(Y), %mm7
  175. MOVQ %mm4, 4 * SIZE(X)
  176. MOVQ %mm5, 5 * SIZE(X)
  177. MOVQ %mm6, 6 * SIZE(X)
  178. MOVQ %mm7, 7 * SIZE(X)
  179. MOVQ %mm0, 4 * SIZE(Y)
  180. MOVQ %mm1, 5 * SIZE(Y)
  181. MOVQ %mm2, 6 * SIZE(Y)
  182. MOVQ %mm3, 7 * SIZE(Y)
  183. #else
  184. #ifdef OPTERON
  185. prefetchw PREFETCHSIZE * SIZE(X)
  186. #endif
  187. movq 0 * SIZE(X), %mm0
  188. movq 2 * SIZE(X), %mm1
  189. movq 4 * SIZE(X), %mm2
  190. movq 6 * SIZE(X), %mm3
  191. movq 0 * SIZE(Y), %mm4
  192. movq 2 * SIZE(Y), %mm5
  193. movq 4 * SIZE(Y), %mm6
  194. movq 6 * SIZE(Y), %mm7
  195. #ifdef OPTERON
  196. prefetchw PREFETCHSIZE * SIZE(Y)
  197. #endif
  198. movq %mm4, 0 * SIZE(X)
  199. movq %mm5, 2 * SIZE(X)
  200. movq %mm6, 4 * SIZE(X)
  201. movq %mm7, 6 * SIZE(X)
  202. movq %mm0, 0 * SIZE(Y)
  203. movq %mm1, 2 * SIZE(Y)
  204. movq %mm2, 4 * SIZE(Y)
  205. movq %mm3, 6 * SIZE(Y)
  206. #endif
  207. addq $8 * SIZE, X
  208. addq $8 * SIZE, Y
  209. decq %rax
  210. jg .L16
  211. ALIGN_3
  212. .L15:
  213. movq N, %rax
  214. andq $3, %rax
  215. jle .L27
  216. ALIGN_3
  217. .L22:
  218. #ifdef XDOUBLE
  219. movq 0(X), %mm0
  220. movq 8(X), %mm1
  221. movq 16(X), %mm2
  222. movq 24(X), %mm3
  223. movq 0(Y), %mm4
  224. movq 8(Y), %mm5
  225. movq 16(Y), %mm6
  226. movq 24(Y), %mm7
  227. movq %mm4, 0(X)
  228. movq %mm5, 8(X)
  229. movq %mm6, 16(X)
  230. movq %mm7, 24(X)
  231. movq %mm0, 0(Y)
  232. movq %mm1, 8(Y)
  233. movq %mm2, 16(Y)
  234. movq %mm3, 24(Y)
  235. #elif defined(DOUBLE)
  236. movq 0 * SIZE(X), %mm0
  237. movq 1 * SIZE(X), %mm1
  238. movq 0 * SIZE(Y), %mm4
  239. movq 1 * SIZE(Y), %mm5
  240. movq %mm4, 0 * SIZE(X)
  241. movq %mm5, 1 * SIZE(X)
  242. movq %mm0, 0 * SIZE(Y)
  243. movq %mm1, 1 * SIZE(Y)
  244. #else
  245. movq 0 * SIZE(X), %mm0
  246. movq 0 * SIZE(Y), %mm4
  247. movq %mm4, 0 * SIZE(X)
  248. movq %mm0, 0 * SIZE(Y)
  249. #endif
  250. addq $2 * SIZE, X
  251. addq $2 * SIZE, Y
  252. decq %rax
  253. jg .L22
  254. jmp .L27
  255. ALIGN_3
  256. /* INCX != 1 or INCY != 1 */
  257. .L14:
  258. movq N, %rax
  259. movq X, XX
  260. movq Y, YY
  261. sarq $1, %rax
  262. jle .L28
  263. ALIGN_2
  264. .L29:
  265. #ifdef XDOUBLE
  266. movq 0(X), %mm0
  267. movq 8(X), %mm1
  268. movq 16(X), %mm2
  269. movq 24(X), %mm3
  270. addq INCX, X
  271. movq 0(Y), %mm4
  272. movq 8(Y), %mm5
  273. movq 16(Y), %mm6
  274. movq 24(Y), %mm7
  275. addq INCY, Y
  276. movq %mm4, 0(XX)
  277. movq %mm5, 8(XX)
  278. movq %mm6, 16(XX)
  279. movq %mm7, 24(XX)
  280. addq INCX, XX
  281. movq %mm0, 0(YY)
  282. movq %mm1, 8(YY)
  283. movq %mm2, 16(YY)
  284. movq %mm3, 24(YY)
  285. addq INCY, YY
  286. movq 0(X), %mm0
  287. movq 8(X), %mm1
  288. movq 16(X), %mm2
  289. movq 24(X), %mm3
  290. addq INCX, X
  291. movq 0(Y), %mm4
  292. movq 8(Y), %mm5
  293. movq 16(Y), %mm6
  294. movq 24(Y), %mm7
  295. addq INCY, Y
  296. movq %mm4, 0(XX)
  297. movq %mm5, 8(XX)
  298. movq %mm6, 16(XX)
  299. movq %mm7, 24(XX)
  300. addq INCX, XX
  301. movq %mm0, 0(YY)
  302. movq %mm1, 8(YY)
  303. movq %mm2, 16(YY)
  304. movq %mm3, 24(YY)
  305. addq INCY, YY
  306. #elif defined(DOUBLE)
  307. movq 0 * SIZE(X), %mm0
  308. movq 1 * SIZE(X), %mm1
  309. addq INCX, X
  310. movq 0 * SIZE(X), %mm2
  311. movq 1 * SIZE(X), %mm3
  312. addq INCX, X
  313. movq 0 * SIZE(Y), %mm4
  314. movq 1 * SIZE(Y), %mm5
  315. addq INCY, Y
  316. movq 0 * SIZE(Y), %mm6
  317. movq 1 * SIZE(Y), %mm7
  318. addq INCY, Y
  319. movq %mm4, 0 * SIZE(XX)
  320. movq %mm5, 1 * SIZE(XX)
  321. addq INCX, XX
  322. movq %mm6, 0 * SIZE(XX)
  323. movq %mm7, 1 * SIZE(XX)
  324. addq INCX, XX
  325. movq %mm0, 0 * SIZE(YY)
  326. movq %mm1, 1 * SIZE(YY)
  327. addq INCY, YY
  328. movq %mm2, 0 * SIZE(YY)
  329. movq %mm3, 1 * SIZE(YY)
  330. addq INCY, YY
  331. #else
  332. movq 0 * SIZE(X), %mm0
  333. addq INCX, X
  334. movq 0 * SIZE(X), %mm2
  335. addq INCX, X
  336. movq 0 * SIZE(Y), %mm4
  337. addq INCY, Y
  338. movq 0 * SIZE(Y), %mm6
  339. addq INCY, Y
  340. movq %mm4, 0 * SIZE(XX)
  341. addq INCX, XX
  342. movq %mm6, 0 * SIZE(XX)
  343. addq INCX, XX
  344. movq %mm0, 0 * SIZE(YY)
  345. addq INCY, YY
  346. movq %mm2, 0 * SIZE(YY)
  347. addq INCY, YY
  348. #endif
  349. decq %rax
  350. jg .L29
  351. ALIGN_3
  352. .L28:
  353. movq N, %rax
  354. andq $1, %rax
  355. jle .L27
  356. ALIGN_3
  357. .L35:
  358. #ifdef XDOUBLE
  359. movq 0(X), %mm0
  360. movq 8(X), %mm1
  361. movq 16(X), %mm2
  362. movq 24(X), %mm3
  363. movq 0(Y), %mm4
  364. movq 8(Y), %mm5
  365. movq 16(Y), %mm6
  366. movq 24(Y), %mm7
  367. movq %mm4, 0(X)
  368. movq %mm5, 8(X)
  369. movq %mm6, 16(X)
  370. movq %mm7, 24(X)
  371. movq %mm0, 0(Y)
  372. movq %mm1, 8(Y)
  373. movq %mm2, 16(Y)
  374. movq %mm3, 24(Y)
  375. #elif defined(DOUBLE)
  376. movq 0 * SIZE(X), %mm0
  377. movq 1 * SIZE(X), %mm1
  378. movq 0 * SIZE(Y), %mm4
  379. movq 1 * SIZE(Y), %mm5
  380. movq %mm4, 0 * SIZE(X)
  381. movq %mm5, 1 * SIZE(X)
  382. movq %mm0, 0 * SIZE(Y)
  383. movq %mm1, 1 * SIZE(Y)
  384. #else
  385. movq 0 * SIZE(X), %mm0
  386. movq 0 * SIZE(Y), %mm4
  387. movq %mm4, 0 * SIZE(X)
  388. movq %mm0, 0 * SIZE(Y)
  389. #endif
  390. addq INCX, X
  391. addq INCY, Y
  392. decq %rax
  393. jg .L35
  394. ALIGN_3
  395. .L27:
  396. EMMS
  397. xorq %rax,%rax
  398. #ifdef WINDOWS_ABI
  399. popq %rbx
  400. #endif
  401. ret
  402. EPILOGUE