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.

scal_atom.S 8.7 kB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446
  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. #else
  45. #define M ARG1
  46. #define X ARG2
  47. #define INCX ARG3
  48. #endif
  49. #define XX %r10
  50. #define I %rax
  51. #include "l1param.h"
  52. PROLOGUE
  53. PROFCODE
  54. #ifdef WINDOWS_ABI
  55. movq 40(%rsp), X
  56. movq 48(%rsp), INCX
  57. movaps %xmm3, %xmm0
  58. #endif
  59. SAVEREGISTERS
  60. testq M, M
  61. jle .L999
  62. pxor %xmm1, %xmm1
  63. lea (, INCX, SIZE), INCX
  64. comisd %xmm0, %xmm1
  65. jne .L100
  66. /* Alpha == ZERO */
  67. cmpq $SIZE, INCX
  68. jne .L50
  69. movq M, I
  70. sarq $3, I
  71. jle .L12
  72. ALIGN_4
  73. .L11:
  74. movsd %xmm1, 0 * SIZE(X)
  75. movsd %xmm1, 1 * SIZE(X)
  76. movsd %xmm1, 2 * SIZE(X)
  77. movsd %xmm1, 3 * SIZE(X)
  78. movsd %xmm1, 4 * SIZE(X)
  79. movsd %xmm1, 5 * SIZE(X)
  80. movsd %xmm1, 6 * SIZE(X)
  81. movsd %xmm1, 7 * SIZE(X)
  82. addq $8 * SIZE, X
  83. decq I
  84. jg .L11
  85. ALIGN_4
  86. .L12:
  87. testq $4, M
  88. je .L14
  89. movsd %xmm1, 0 * SIZE(X)
  90. movsd %xmm1, 1 * SIZE(X)
  91. movsd %xmm1, 2 * SIZE(X)
  92. movsd %xmm1, 3 * SIZE(X)
  93. addq $4 * SIZE, X
  94. ALIGN_3
  95. .L14:
  96. testq $2, M
  97. je .L15
  98. movsd %xmm1, 0 * SIZE(X)
  99. movsd %xmm1, 1 * SIZE(X)
  100. addq $2 * SIZE, X
  101. ALIGN_3
  102. .L15:
  103. testq $1, M
  104. je .L999
  105. movsd %xmm1, 0 * SIZE(X)
  106. jmp .L999
  107. ALIGN_4
  108. .L50:
  109. movq M, I
  110. sarq $3, I
  111. jle .L52
  112. ALIGN_4
  113. .L51:
  114. movsd %xmm1, 0 * SIZE(X)
  115. addq INCX, X
  116. movsd %xmm1, 0 * SIZE(X)
  117. addq INCX, X
  118. movsd %xmm1, 0 * SIZE(X)
  119. addq INCX, X
  120. movsd %xmm1, 0 * SIZE(X)
  121. addq INCX, X
  122. movsd %xmm1, 0 * SIZE(X)
  123. addq INCX, X
  124. movsd %xmm1, 0 * SIZE(X)
  125. addq INCX, X
  126. movsd %xmm1, 0 * SIZE(X)
  127. addq INCX, X
  128. movsd %xmm1, 0 * SIZE(X)
  129. addq INCX, X
  130. decq I
  131. jg .L51
  132. ALIGN_4
  133. .L52:
  134. testq $7, M
  135. je .L999
  136. testq $4, M
  137. je .L53
  138. movsd %xmm1, 0 * SIZE(X)
  139. addq INCX, X
  140. movsd %xmm1, 0 * SIZE(X)
  141. addq INCX, X
  142. movsd %xmm1, 0 * SIZE(X)
  143. addq INCX, X
  144. movsd %xmm1, 0 * SIZE(X)
  145. addq INCX, X
  146. ALIGN_3
  147. .L53:
  148. testq $2, M
  149. je .L54
  150. movsd %xmm1, 0 * SIZE(X)
  151. addq INCX, X
  152. movsd %xmm1, 0 * SIZE(X)
  153. addq INCX, X
  154. ALIGN_3
  155. .L54:
  156. testq $1, M
  157. je .L999
  158. movsd %xmm1, 0 * SIZE(X)
  159. jmp .L999
  160. ALIGN_4
  161. /* Alpha != ZERO */
  162. .L100:
  163. cmpq $SIZE, INCX
  164. jne .L150
  165. unpcklpd %xmm0, %xmm0
  166. movq M, I
  167. sarq $3, I
  168. jle .L113
  169. movsd 0 * SIZE(X), %xmm1
  170. movsd 1 * SIZE(X), %xmm2
  171. movsd 2 * SIZE(X), %xmm3
  172. movsd 3 * SIZE(X), %xmm4
  173. movsd 4 * SIZE(X), %xmm5
  174. movsd 5 * SIZE(X), %xmm6
  175. movsd 6 * SIZE(X), %xmm7
  176. movsd 7 * SIZE(X), %xmm8
  177. mulsd %xmm0, %xmm1
  178. mulsd %xmm0, %xmm2
  179. mulsd %xmm0, %xmm3
  180. mulsd %xmm0, %xmm4
  181. decq I
  182. jle .L112
  183. ALIGN_4
  184. .L111:
  185. #ifdef PREFETCHW
  186. PREFETCHW (PREFETCHSIZE + 0) - PREOFFSET(X)
  187. #endif
  188. movsd %xmm1, 0 * SIZE(X)
  189. movsd %xmm2, 1 * SIZE(X)
  190. movsd %xmm3, 2 * SIZE(X)
  191. movsd %xmm4, 3 * SIZE(X)
  192. movsd 8 * SIZE(X), %xmm1
  193. mulsd %xmm0, %xmm5
  194. movsd 9 * SIZE(X), %xmm2
  195. mulsd %xmm0, %xmm6
  196. movsd 10 * SIZE(X), %xmm3
  197. mulsd %xmm0, %xmm7
  198. movsd 11 * SIZE(X), %xmm4
  199. mulsd %xmm0, %xmm8
  200. movsd %xmm5, 4 * SIZE(X)
  201. movsd %xmm6, 5 * SIZE(X)
  202. movsd %xmm7, 6 * SIZE(X)
  203. movsd %xmm8, 7 * SIZE(X)
  204. movsd 12 * SIZE(X), %xmm5
  205. mulsd %xmm0, %xmm1
  206. movsd 13 * SIZE(X), %xmm6
  207. mulsd %xmm0, %xmm2
  208. movsd 14 * SIZE(X), %xmm7
  209. mulsd %xmm0, %xmm3
  210. movsd 15 * SIZE(X), %xmm8
  211. mulsd %xmm0, %xmm4
  212. addq $8 * SIZE, X
  213. decq I
  214. jg .L111
  215. ALIGN_4
  216. .L112:
  217. movsd %xmm1, 0 * SIZE(X)
  218. mulsd %xmm0, %xmm5
  219. movsd %xmm2, 1 * SIZE(X)
  220. mulsd %xmm0, %xmm6
  221. movsd %xmm3, 2 * SIZE(X)
  222. mulsd %xmm0, %xmm7
  223. movsd %xmm4, 3 * SIZE(X)
  224. mulsd %xmm0, %xmm8
  225. movsd %xmm5, 4 * SIZE(X)
  226. movsd %xmm6, 5 * SIZE(X)
  227. movsd %xmm7, 6 * SIZE(X)
  228. movsd %xmm8, 7 * SIZE(X)
  229. addq $8 * SIZE, X
  230. ALIGN_3
  231. .L113:
  232. testq $4, M
  233. je .L115
  234. movsd 0 * SIZE(X), %xmm1
  235. movsd 1 * SIZE(X), %xmm2
  236. movsd 2 * SIZE(X), %xmm3
  237. movsd 3 * SIZE(X), %xmm4
  238. mulsd %xmm0, %xmm1
  239. mulsd %xmm0, %xmm2
  240. mulsd %xmm0, %xmm3
  241. mulsd %xmm0, %xmm4
  242. movsd %xmm1, 0 * SIZE(X)
  243. movsd %xmm2, 1 * SIZE(X)
  244. movsd %xmm3, 2 * SIZE(X)
  245. movsd %xmm4, 3 * SIZE(X)
  246. addq $4 * SIZE, X
  247. ALIGN_3
  248. .L115:
  249. testq $2, M
  250. je .L116
  251. movsd 0 * SIZE(X), %xmm1
  252. movsd 1 * SIZE(X), %xmm2
  253. mulsd %xmm0, %xmm1
  254. mulsd %xmm0, %xmm2
  255. movsd %xmm1, 0 * SIZE(X)
  256. movsd %xmm2, 1 * SIZE(X)
  257. addq $2 * SIZE, X
  258. ALIGN_3
  259. .L116:
  260. testq $1, M
  261. je .L999
  262. movsd 0 * SIZE(X), %xmm1
  263. mulsd %xmm0, %xmm1
  264. movsd %xmm1, 0 * SIZE(X)
  265. jmp .L999
  266. ALIGN_3
  267. /* incx != 1 */
  268. .L150:
  269. movq X, XX
  270. movq M, I # rcx = n
  271. sarq $3, I # (n >> 3)
  272. jle .L152
  273. ALIGN_4
  274. .L151:
  275. movsd 0 * SIZE(X), %xmm1
  276. addq INCX, X
  277. movsd 0 * SIZE(X), %xmm2
  278. addq INCX, X
  279. mulsd %xmm0, %xmm1
  280. movsd 0 * SIZE(X), %xmm3
  281. addq INCX, X
  282. mulsd %xmm0, %xmm2
  283. movsd 0 * SIZE(X), %xmm4
  284. addq INCX, X
  285. mulsd %xmm0, %xmm3
  286. movsd 0 * SIZE(X), %xmm5
  287. addq INCX, X
  288. mulsd %xmm0, %xmm4
  289. movsd 0 * SIZE(X), %xmm6
  290. addq INCX, X
  291. mulsd %xmm0, %xmm5
  292. movsd 0 * SIZE(X), %xmm7
  293. addq INCX, X
  294. mulsd %xmm0, %xmm6
  295. movsd 0 * SIZE(X), %xmm8
  296. addq INCX, X
  297. mulsd %xmm0, %xmm7
  298. movsd %xmm1, 0 * SIZE(XX)
  299. addq INCX, XX
  300. mulsd %xmm0, %xmm8
  301. movsd %xmm2, 0 * SIZE(XX)
  302. addq INCX, XX
  303. movsd %xmm3, 0 * SIZE(XX)
  304. addq INCX, XX
  305. movsd %xmm4, 0 * SIZE(XX)
  306. addq INCX, XX
  307. movsd %xmm5, 0 * SIZE(XX)
  308. addq INCX, XX
  309. movsd %xmm6, 0 * SIZE(XX)
  310. addq INCX, XX
  311. movsd %xmm7, 0 * SIZE(XX)
  312. addq INCX, XX
  313. movsd %xmm8, 0 * SIZE(XX)
  314. addq INCX, XX
  315. decq I
  316. jg .L151
  317. ALIGN_4
  318. .L152:
  319. testq $7, M
  320. je .L999
  321. testq $4, M
  322. je .L153
  323. movsd 0 * SIZE(X), %xmm1
  324. addq INCX, X
  325. movsd 0 * SIZE(X), %xmm2
  326. addq INCX, X
  327. mulsd %xmm0, %xmm1
  328. movsd 0 * SIZE(X), %xmm3
  329. addq INCX, X
  330. mulsd %xmm0, %xmm2
  331. movsd 0 * SIZE(X), %xmm4
  332. addq INCX, X
  333. mulsd %xmm0, %xmm3
  334. movsd %xmm1, 0 * SIZE(XX)
  335. addq INCX, XX
  336. mulsd %xmm0, %xmm4
  337. movsd %xmm2, 0 * SIZE(XX)
  338. addq INCX, XX
  339. movsd %xmm3, 0 * SIZE(XX)
  340. addq INCX, XX
  341. movsd %xmm4, 0 * SIZE(XX)
  342. addq INCX, XX
  343. ALIGN_3
  344. .L153:
  345. testq $2, M
  346. je .L154
  347. movsd 0 * SIZE(X), %xmm1
  348. addq INCX, X
  349. mulsd %xmm0, %xmm1
  350. movsd 0 * SIZE(X), %xmm2
  351. addq INCX, X
  352. mulsd %xmm0, %xmm2
  353. movsd %xmm1, 0 * SIZE(XX)
  354. addq INCX, XX
  355. movsd %xmm2, 0 * SIZE(XX)
  356. addq INCX, XX
  357. ALIGN_3
  358. .L154:
  359. testq $1, M
  360. je .L999
  361. movsd 0 * SIZE(X), %xmm1
  362. mulsd %xmm0, %xmm1
  363. movsd %xmm1, 0 * SIZE(X)
  364. ALIGN_4
  365. .L999:
  366. xorq %rax, %rax
  367. RESTOREREGISTERS
  368. ret
  369. EPILOGUE