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

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409
  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. #define N r3
  41. #define XX r4
  42. #define PREA r5
  43. #if defined(linux) || defined(__FreeBSD__)
  44. #ifndef __64BIT__
  45. #define X r6
  46. #define INCX r7
  47. #define FLAG r11
  48. #else
  49. #define X r7
  50. #define INCX r8
  51. #define FLAG r11
  52. #endif
  53. #endif
  54. #if defined(_AIX) || defined(__APPLE__)
  55. #if !defined(__64BIT__) && defined(DOUBLE)
  56. #define X r8
  57. #define INCX r9
  58. #define FLAG r11
  59. #else
  60. #define X r7
  61. #define INCX r8
  62. #define FLAG r11
  63. #endif
  64. #endif
  65. #define FZERO f0
  66. #define ALPHA f1
  67. PROLOGUE
  68. PROFCODE
  69. addi SP, SP, -8
  70. li r0, 0
  71. stw r0, 0(SP)
  72. lfs FZERO, 0(SP)
  73. addi SP, SP, 8
  74. slwi INCX, INCX, BASE_SHIFT
  75. li PREA, L1_PREFETCHSIZE
  76. cmpwi cr0, N, 0
  77. blelr- cr0
  78. fcmpu cr0, FZERO, ALPHA
  79. bne- cr0, LL(A1I1)
  80. LDLONG FLAG, 104(SP)
  81. cmpwi cr0, FLAG, 1
  82. beq- cr0, LL(A1I1)
  83. cmpwi cr0, INCX, SIZE
  84. bne- cr0, LL(A0IN)
  85. srawi. r0, N, 4
  86. mtspr CTR, r0
  87. beq- cr0, LL(A0I1_Remain)
  88. .align 4
  89. LL(A0I1_kernel):
  90. STFD FZERO, 0 * SIZE(X)
  91. STFD FZERO, 1 * SIZE(X)
  92. STFD FZERO, 2 * SIZE(X)
  93. STFD FZERO, 3 * SIZE(X)
  94. STFD FZERO, 4 * SIZE(X)
  95. STFD FZERO, 5 * SIZE(X)
  96. STFD FZERO, 6 * SIZE(X)
  97. STFD FZERO, 7 * SIZE(X)
  98. STFD FZERO, 8 * SIZE(X)
  99. STFD FZERO, 9 * SIZE(X)
  100. STFD FZERO, 10 * SIZE(X)
  101. STFD FZERO, 11 * SIZE(X)
  102. STFD FZERO, 12 * SIZE(X)
  103. STFD FZERO, 13 * SIZE(X)
  104. STFD FZERO, 14 * SIZE(X)
  105. STFD FZERO, 15 * SIZE(X)
  106. addi X, X, 16 * SIZE
  107. bdnz LL(A0I1_kernel)
  108. .align 4
  109. LL(A0I1_Remain):
  110. andi. r0, N, 15
  111. mtspr CTR, r0
  112. beqlr+
  113. .align 4
  114. LL(A0I1_RemainKernel):
  115. STFD FZERO, 0 * SIZE(X)
  116. addi X, X, 1 * SIZE
  117. bdnz LL(A0I1_RemainKernel)
  118. blr
  119. .align 4
  120. LL(A0IN):
  121. srawi. r0, N, 3
  122. mtspr CTR, r0
  123. beq- LL(A0IN_Remain)
  124. .align 4
  125. LL(A0IN_Kernel):
  126. dcbtst X, PREA
  127. STFD FZERO, 0 * SIZE(X)
  128. add X, X, INCX
  129. STFD FZERO, 0 * SIZE(X)
  130. add X, X, INCX
  131. STFD FZERO, 0 * SIZE(X)
  132. add X, X, INCX
  133. STFD FZERO, 0 * SIZE(X)
  134. add X, X, INCX
  135. STFD FZERO, 0 * SIZE(X)
  136. add X, X, INCX
  137. STFD FZERO, 0 * SIZE(X)
  138. add X, X, INCX
  139. STFD FZERO, 0 * SIZE(X)
  140. add X, X, INCX
  141. STFD FZERO, 0 * SIZE(X)
  142. add X, X, INCX
  143. bdnz LL(A0IN_Kernel)
  144. .align 4
  145. LL(A0IN_Remain):
  146. andi. r0, N, 7
  147. mtspr CTR, r0
  148. beqlr+
  149. .align 4
  150. LL(A0IN_RemainKernel):
  151. STFD FZERO, 0 * SIZE(X)
  152. add X, X, INCX
  153. bdnz LL(A0IN_RemainKernel)
  154. blr
  155. .align 4
  156. LL(A1I1):
  157. cmpwi cr0, INCX, SIZE
  158. bne- LL(A1IN)
  159. mr XX, X
  160. srawi. r0, N, 4
  161. mtspr CTR, r0
  162. beq+ LL(A1I1_Remain)
  163. LFD f2, 0 * SIZE(X)
  164. LFD f3, 1 * SIZE(X)
  165. LFD f4, 2 * SIZE(X)
  166. LFD f5, 3 * SIZE(X)
  167. LFD f6, 4 * SIZE(X)
  168. LFD f7, 5 * SIZE(X)
  169. LFD f8, 6 * SIZE(X)
  170. LFD f9, 7 * SIZE(X)
  171. bdz LL(13)
  172. .align 4
  173. LL(A1I1_kernel):
  174. FMUL f10, ALPHA, f2
  175. FMUL f11, ALPHA, f3
  176. FMUL f12, ALPHA, f4
  177. FMUL f13, ALPHA, f5
  178. LFD f2, 8 * SIZE(X)
  179. LFD f3, 9 * SIZE(X)
  180. LFD f4, 10 * SIZE(X)
  181. LFD f5, 11 * SIZE(X)
  182. STFD f10, 0 * SIZE(X)
  183. STFD f11, 1 * SIZE(X)
  184. STFD f12, 2 * SIZE(X)
  185. STFD f13, 3 * SIZE(X)
  186. FMUL f10, ALPHA, f6
  187. FMUL f11, ALPHA, f7
  188. FMUL f12, ALPHA, f8
  189. FMUL f13, ALPHA, f9
  190. LFD f6, 12 * SIZE(X)
  191. LFD f7, 13 * SIZE(X)
  192. LFD f8, 14 * SIZE(X)
  193. LFD f9, 15 * SIZE(X)
  194. STFD f10, 4 * SIZE(X)
  195. STFD f11, 5 * SIZE(X)
  196. STFD f12, 6 * SIZE(X)
  197. STFD f13, 7 * SIZE(X)
  198. FMUL f10, ALPHA, f2
  199. FMUL f11, ALPHA, f3
  200. FMUL f12, ALPHA, f4
  201. FMUL f13, ALPHA, f5
  202. LFD f2, 16 * SIZE(X)
  203. LFD f3, 17 * SIZE(X)
  204. LFD f4, 18 * SIZE(X)
  205. LFD f5, 19 * SIZE(X)
  206. STFD f10, 8 * SIZE(X)
  207. STFD f11, 9 * SIZE(X)
  208. STFD f12, 10 * SIZE(X)
  209. STFD f13, 11 * SIZE(X)
  210. FMUL f10, ALPHA, f6
  211. FMUL f11, ALPHA, f7
  212. FMUL f12, ALPHA, f8
  213. FMUL f13, ALPHA, f9
  214. LFD f6, 20 * SIZE(X)
  215. LFD f7, 21 * SIZE(X)
  216. LFD f8, 22 * SIZE(X)
  217. LFD f9, 23 * SIZE(X)
  218. STFD f10, 12 * SIZE(X)
  219. STFD f11, 13 * SIZE(X)
  220. STFD f12, 14 * SIZE(X)
  221. STFD f13, 15 * SIZE(X)
  222. addi X, X, 16 * SIZE
  223. dcbtst X, PREA
  224. bdnz LL(A1I1_kernel)
  225. .align 4
  226. LL(13):
  227. FMUL f10, ALPHA, f2
  228. FMUL f11, ALPHA, f3
  229. FMUL f12, ALPHA, f4
  230. FMUL f13, ALPHA, f5
  231. LFD f2, 8 * SIZE(X)
  232. LFD f3, 9 * SIZE(X)
  233. LFD f4, 10 * SIZE(X)
  234. LFD f5, 11 * SIZE(X)
  235. STFD f10, 0 * SIZE(X)
  236. STFD f11, 1 * SIZE(X)
  237. STFD f12, 2 * SIZE(X)
  238. STFD f13, 3 * SIZE(X)
  239. FMUL f10, ALPHA, f6
  240. FMUL f11, ALPHA, f7
  241. FMUL f12, ALPHA, f8
  242. FMUL f13, ALPHA, f9
  243. LFD f6, 12 * SIZE(X)
  244. LFD f7, 13 * SIZE(X)
  245. LFD f8, 14 * SIZE(X)
  246. LFD f9, 15 * SIZE(X)
  247. STFD f10, 4 * SIZE(X)
  248. STFD f11, 5 * SIZE(X)
  249. STFD f12, 6 * SIZE(X)
  250. STFD f13, 7 * SIZE(X)
  251. FMUL f10, ALPHA, f2
  252. FMUL f11, ALPHA, f3
  253. FMUL f12, ALPHA, f4
  254. FMUL f13, ALPHA, f5
  255. STFD f10, 8 * SIZE(X)
  256. STFD f11, 9 * SIZE(X)
  257. STFD f12, 10 * SIZE(X)
  258. STFD f13, 11 * SIZE(X)
  259. FMUL f10, ALPHA, f6
  260. FMUL f11, ALPHA, f7
  261. FMUL f12, ALPHA, f8
  262. FMUL f13, ALPHA, f9
  263. STFD f10, 12 * SIZE(X)
  264. STFD f11, 13 * SIZE(X)
  265. STFD f12, 14 * SIZE(X)
  266. STFD f13, 15 * SIZE(X)
  267. addi X, X, 16 * SIZE
  268. .align 4
  269. LL(A1I1_Remain):
  270. andi. r0, N, 15
  271. mtspr CTR, r0
  272. beqlr+
  273. .align 4
  274. LL(A1I1_RemainKernel):
  275. LFD f2, 0 * SIZE(X)
  276. FMUL f2, ALPHA, f2
  277. STFD f2, 0 * SIZE(X)
  278. addi X, X, 1 * SIZE
  279. bdnz LL(A1I1_RemainKernel)
  280. blr
  281. .align 4
  282. LL(A1IN):
  283. mr XX, X
  284. srawi. r0, N, 3
  285. mtspr CTR, r0
  286. beq- LL(A1IN_Remain)
  287. .align 4
  288. LL(A1IN_Kernel):
  289. LFD f2, 0 * SIZE(XX)
  290. add XX, XX, INCX
  291. LFD f3, 0 * SIZE(XX)
  292. add XX, XX, INCX
  293. LFD f4, 0 * SIZE(XX)
  294. add XX, XX, INCX
  295. LFD f5, 0 * SIZE(XX)
  296. add XX, XX, INCX
  297. FMUL f2, ALPHA, f2
  298. FMUL f3, ALPHA, f3
  299. FMUL f4, ALPHA, f4
  300. FMUL f5, ALPHA, f5
  301. LFD f6, 0 * SIZE(XX)
  302. add XX, XX, INCX
  303. LFD f7, 0 * SIZE(XX)
  304. add XX, XX, INCX
  305. LFD f8, 0 * SIZE(XX)
  306. add XX, XX, INCX
  307. LFD f9, 0 * SIZE(XX)
  308. add XX, XX, INCX
  309. FMUL f6, ALPHA, f6
  310. FMUL f7, ALPHA, f7
  311. FMUL f8, ALPHA, f8
  312. FMUL f9, ALPHA, f9
  313. STFD f2, 0 * SIZE(X)
  314. add X, X, INCX
  315. STFD f3, 0 * SIZE(X)
  316. add X, X, INCX
  317. STFD f4, 0 * SIZE(X)
  318. add X, X, INCX
  319. STFD f5, 0 * SIZE(X)
  320. add X, X, INCX
  321. STFD f6, 0 * SIZE(X)
  322. add X, X, INCX
  323. STFD f7, 0 * SIZE(X)
  324. add X, X, INCX
  325. STFD f8, 0 * SIZE(X)
  326. add X, X, INCX
  327. STFD f9, 0 * SIZE(X)
  328. add X, X, INCX
  329. bdnz LL(A1IN_Kernel)
  330. .align 4
  331. LL(A1IN_Remain):
  332. andi. r0, N, 7
  333. mtspr CTR, r0
  334. beqlr+
  335. .align 4
  336. LL(A1IN_RemainKernel):
  337. LFD f2, 0 * SIZE(XX)
  338. add XX, XX, INCX
  339. FMUL f2, ALPHA, f2
  340. STFD f2, 0 * SIZE(X)
  341. add X, X, INCX
  342. bdnz LL(A1IN_RemainKernel)
  343. blr
  344. EPILOGUE