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.

xtrsm_kernel_LT_1x1.S 9.0 kB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493
  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. #ifdef OPTERON
  41. #define PREFETCH prefetch
  42. #define PREFETCHW prefetchw
  43. #else
  44. #define PREFETCH prefetcht0
  45. #define PREFETCHW prefetcht0
  46. #endif
  47. #define PREFETCHSIZE (5 + 4 * 10)
  48. #define STACK 16
  49. #define ARGS 16
  50. #define J 0 + STACK(%esp)
  51. #define KK 4 + STACK(%esp)
  52. #define KKK 8 + STACK(%esp)
  53. #define AORIG 12 + STACK(%esp)
  54. #define M 4 + STACK + ARGS(%esp)
  55. #define N 8 + STACK + ARGS(%esp)
  56. #define K 12 + STACK + ARGS(%esp)
  57. #define ALPHA_R 16 + STACK + ARGS(%esp)
  58. #define ALPHA_I 32 + STACK + ARGS(%esp)
  59. #define A 48 + STACK + ARGS(%esp)
  60. #define ARG_B 52 + STACK + ARGS(%esp)
  61. #define C 56 + STACK + ARGS(%esp)
  62. #define ARG_LDC 60 + STACK + ARGS(%esp)
  63. #define OFFSET 64 + STACK + ARGS(%esp)
  64. #define I %esi
  65. #define B %ebx
  66. #define CO %edi
  67. #define AO %edx
  68. #define BO %ecx
  69. #define LDC %ebp
  70. #ifndef CONJ
  71. #define ADD1 faddp
  72. #define ADD2 fsubrp
  73. #define ADD3 faddp
  74. #define ADD4 faddp
  75. #elif defined(LN) || defined(LT)
  76. #define ADD1 faddp
  77. #define ADD2 faddp
  78. #define ADD3 fsubrp
  79. #define ADD4 faddp
  80. #else
  81. #define ADD1 faddp
  82. #define ADD2 faddp
  83. #define ADD3 faddp
  84. #define ADD4 fsubrp
  85. #endif
  86. #define PREFETCH_OFFSET 48
  87. PROLOGUE
  88. subl $ARGS, %esp # Generate Stack Frame
  89. pushl %ebp
  90. pushl %edi
  91. pushl %esi
  92. pushl %ebx
  93. PROFCODE
  94. movl ARG_LDC, LDC
  95. movl ARG_B, B
  96. sall $ZBASE_SHIFT, LDC
  97. addl $8 * SIZE, A
  98. addl $8 * SIZE, B
  99. #ifdef LN
  100. movl M, %eax
  101. sall $ZBASE_SHIFT, %eax
  102. addl %eax, C
  103. imull K, %eax
  104. addl %eax, A
  105. #endif
  106. #ifdef RT
  107. movl N, %eax
  108. sall $ZBASE_SHIFT, %eax
  109. imull K, %eax
  110. addl %eax, B
  111. movl N, %eax
  112. imull LDC, %eax
  113. addl %eax, C
  114. #endif
  115. #ifdef RN
  116. movl OFFSET, %eax
  117. negl %eax
  118. movl %eax, KK
  119. #endif
  120. #ifdef RT
  121. movl N, %eax
  122. subl OFFSET, %eax
  123. movl %eax, KK
  124. #endif
  125. cmpl $0, M
  126. jle .L999
  127. movl N, %eax
  128. movl %eax, J
  129. testl %eax, %eax
  130. jle .L999
  131. ALIGN_4
  132. .L01:
  133. #if defined(LT) || defined(RN)
  134. movl A, AO
  135. #else
  136. movl A, %eax
  137. movl %eax, AORIG
  138. #endif
  139. #ifdef RT
  140. movl K, %eax
  141. sall $ZBASE_SHIFT, %eax
  142. subl %eax, B
  143. #endif
  144. #ifdef RT
  145. subl LDC, C
  146. #endif
  147. movl C, CO
  148. #ifndef RT
  149. addl LDC, C
  150. #endif
  151. #ifdef LN
  152. movl OFFSET, %eax
  153. addl M, %eax
  154. movl %eax, KK
  155. #endif
  156. #ifdef LT
  157. movl OFFSET, %eax
  158. movl %eax, KK
  159. #endif
  160. movl M, I
  161. ALIGN_4
  162. .L11:
  163. #ifdef LN
  164. movl K, %eax
  165. sall $ZBASE_SHIFT, %eax
  166. subl %eax, AORIG
  167. #endif
  168. #if defined(LN) || defined(RT)
  169. movl KK, %eax
  170. sall $ZBASE_SHIFT, %eax
  171. movl AORIG, AO
  172. leal (AO, %eax, 1), AO
  173. leal (B, %eax, 1), BO
  174. #else
  175. movl B, BO
  176. #endif
  177. fldz
  178. fldz
  179. fldz
  180. fldz
  181. #if defined(HAVE_3DNOW)
  182. prefetchw 2 * SIZE(CO)
  183. #elif defined(HAVE_SSE)
  184. prefetchnta 2 * SIZE(CO)
  185. #endif
  186. #if defined(LT) || defined(RN)
  187. movl KK, %eax
  188. #else
  189. movl K, %eax
  190. subl KK, %eax
  191. #endif
  192. sarl $2, %eax
  193. je .L15
  194. ALIGN_4
  195. .L12:
  196. PREFETCH (PREFETCHSIZE + 0) * SIZE(AO)
  197. FLD -8 * SIZE(AO)
  198. FLD -8 * SIZE(BO)
  199. fld %st(1)
  200. fmul %st(1), %st
  201. ADD1 %st, %st(3)
  202. FLD -7 * SIZE(BO)
  203. fmul %st, %st(2)
  204. FLD -7 * SIZE(AO)
  205. fmul %st, %st(2)
  206. fmulp %st, %st(1)
  207. ADD2 %st, %st(6)
  208. ADD3 %st, %st(3)
  209. ADD4 %st, %st(3)
  210. FLD -6 * SIZE(AO)
  211. FLD -6 * SIZE(BO)
  212. fld %st(1)
  213. fmul %st(1), %st
  214. ADD1 %st, %st(3)
  215. FLD -5 * SIZE(BO)
  216. fmul %st, %st(2)
  217. FLD -5 * SIZE(AO)
  218. fmul %st, %st(2)
  219. fmulp %st, %st(1)
  220. ADD2 %st, %st(6)
  221. ADD3 %st, %st(3)
  222. ADD4 %st, %st(3)
  223. PREFETCH (PREFETCHSIZE + 4) * SIZE(AO)
  224. FLD -4 * SIZE(AO)
  225. FLD -4 * SIZE(BO)
  226. fld %st(1)
  227. fmul %st(1), %st
  228. ADD1 %st, %st(3)
  229. FLD -3 * SIZE(BO)
  230. fmul %st, %st(2)
  231. FLD -3 * SIZE(AO)
  232. fmul %st, %st(2)
  233. fmulp %st, %st(1)
  234. ADD2 %st, %st(6)
  235. ADD3 %st, %st(3)
  236. ADD4 %st, %st(3)
  237. FLD -2 * SIZE(AO)
  238. FLD -2 * SIZE(BO)
  239. fld %st(1)
  240. fmul %st(1), %st
  241. ADD1 %st, %st(3)
  242. FLD -1 * SIZE(BO)
  243. fmul %st, %st(2)
  244. FLD -1 * SIZE(AO)
  245. fmul %st, %st(2)
  246. fmulp %st, %st(1)
  247. ADD2 %st, %st(6)
  248. ADD3 %st, %st(3)
  249. ADD4 %st, %st(3)
  250. addl $8 * SIZE,AO
  251. addl $8 * SIZE,BO
  252. decl %eax
  253. jne .L12
  254. ALIGN_4
  255. .L15:
  256. #if defined(LT) || defined(RN)
  257. movl KK, %eax
  258. #else
  259. movl K, %eax
  260. subl KK, %eax
  261. #endif
  262. and $3, %eax
  263. je .L18
  264. ALIGN_4
  265. .L16:
  266. FLD -8 * SIZE(AO)
  267. FLD -8 * SIZE(BO)
  268. fld %st(1)
  269. fmul %st(1), %st
  270. ADD1 %st, %st(3)
  271. FLD -7 * SIZE(BO)
  272. fmul %st, %st(2)
  273. FLD -7 * SIZE(AO)
  274. fmul %st, %st(2)
  275. fmulp %st, %st(1)
  276. ADD2 %st, %st(6)
  277. ADD3 %st, %st(3)
  278. ADD4 %st, %st(3)
  279. addl $2 * SIZE,AO
  280. addl $2 * SIZE,BO
  281. decl %eax
  282. jne .L16
  283. ALIGN_4
  284. .L18:
  285. faddp %st, %st(3)
  286. faddp %st, %st(1)
  287. fxch %st(1)
  288. #if defined(LN) || defined(RT)
  289. movl KK, %eax
  290. #ifdef LN
  291. subl $1, %eax
  292. #else
  293. subl $1, %eax
  294. #endif
  295. sall $ZBASE_SHIFT, %eax
  296. movl AORIG, AO
  297. leal (AO, %eax, 1), AO
  298. leal (B, %eax, 1), BO
  299. #endif
  300. #if defined(LN) || defined(LT)
  301. FLD -8 * SIZE(BO)
  302. fsubp %st, %st(1)
  303. FLD -7 * SIZE(BO)
  304. fsubp %st, %st(2)
  305. #else
  306. FLD -8 * SIZE(AO)
  307. fsubp %st, %st(1)
  308. FLD -7 * SIZE(AO)
  309. fsubp %st, %st(2)
  310. #endif
  311. #if defined(LN) || defined(LT)
  312. FLD -8 * SIZE(AO)
  313. fmul %st(1), %st
  314. FLD -8 * SIZE(AO)
  315. fmul %st(3), %st
  316. FLD -7 * SIZE(AO)
  317. fmulp %st, %st(3)
  318. FLD -7 * SIZE(AO)
  319. fmulp %st, %st(4)
  320. #endif
  321. #if defined(RN) || defined(RT)
  322. FLD -8 * SIZE(BO)
  323. fmul %st(1), %st
  324. FLD -8 * SIZE(BO)
  325. fmul %st(3), %st
  326. FLD -7 * SIZE(BO)
  327. fmulp %st, %st(3)
  328. FLD -7 * SIZE(BO)
  329. fmulp %st, %st(4)
  330. #endif
  331. #ifndef CONJ
  332. faddp %st, %st(2)
  333. fsubp %st, %st(2)
  334. #else
  335. fsubp %st, %st(2)
  336. faddp %st, %st(2)
  337. #endif
  338. #if defined(LN) || defined(LT)
  339. fld %st
  340. FST -7 * SIZE(BO)
  341. fxch %st(1)
  342. fld %st
  343. FST -8 * SIZE(BO)
  344. #else
  345. fld %st
  346. FST -7 * SIZE(AO)
  347. fxch %st(1)
  348. fld %st
  349. FST -8 * SIZE(AO)
  350. #endif
  351. #ifdef LN
  352. subl $2 * SIZE, CO
  353. #endif
  354. FST 0 * SIZE(CO)
  355. FST 1 * SIZE(CO)
  356. #ifndef LN
  357. addl $2 * SIZE, CO
  358. #endif
  359. #if defined(LT) || defined(RN)
  360. movl K, %eax
  361. subl KK, %eax
  362. sall $ZBASE_SHIFT, %eax
  363. leal (AO, %eax, 1), AO
  364. leal (BO, %eax, 1), BO
  365. #endif
  366. #ifdef LN
  367. subl $1, KK
  368. #endif
  369. #ifdef LT
  370. addl $1, KK
  371. #endif
  372. #ifdef RT
  373. movl K, %eax
  374. sall $ZBASE_SHIFT, %eax
  375. addl %eax, AORIG
  376. #endif
  377. decl I
  378. jne .L11
  379. #ifdef LN
  380. movl K, %eax
  381. sall $ZBASE_SHIFT, %eax
  382. leal (B, %eax, 1), B
  383. #endif
  384. #if defined(LT) || defined(RN)
  385. movl BO, B
  386. #endif
  387. #ifdef RN
  388. addl $1, KK
  389. #endif
  390. #ifdef RT
  391. subl $1, KK
  392. #endif
  393. decl J
  394. jne .L01
  395. ALIGN_4
  396. .L999:
  397. popl %ebx
  398. popl %esi
  399. popl %edi
  400. popl %ebp
  401. addl $ARGS, %esp
  402. ret
  403. EPILOGUE