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.

zamax.S 7.4 kB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374
  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 %i0
  41. #define X %i1
  42. #define INCX %i2
  43. #define I %i3
  44. #ifdef DOUBLE
  45. #define c1 %f0
  46. #define c2 %f2
  47. #define c3 %f4
  48. #define c4 %f6
  49. #define t1 %f8
  50. #define t2 %f10
  51. #define t3 %f12
  52. #define t4 %f14
  53. #define t5 %f16
  54. #define t6 %f18
  55. #define t7 %f20
  56. #define t8 %f22
  57. #define a1 %f24
  58. #define a2 %f26
  59. #define a3 %f28
  60. #define a4 %f30
  61. #define a5 %f32
  62. #define a6 %f34
  63. #define a7 %f36
  64. #define a8 %f38
  65. #else
  66. #define c1 %f0
  67. #define c2 %f1
  68. #define c3 %f2
  69. #define c4 %f3
  70. #define t1 %f4
  71. #define t2 %f5
  72. #define t3 %f6
  73. #define t4 %f7
  74. #define t5 %f8
  75. #define t6 %f9
  76. #define t7 %f10
  77. #define t8 %f11
  78. #define a1 %f12
  79. #define a2 %f13
  80. #define a3 %f14
  81. #define a4 %f15
  82. #define a5 %f16
  83. #define a6 %f17
  84. #define a7 %f18
  85. #define a8 %f19
  86. #endif
  87. #ifndef USE_MIN
  88. #define FCMOV FMOVG
  89. #else
  90. #define FCMOV FMOVL
  91. #endif
  92. PROLOGUE
  93. SAVESP
  94. FCLR(0)
  95. cmp N, 0
  96. ble .LL20
  97. nop
  98. cmp INCX, 0
  99. ble .LL20
  100. sll INCX, ZBASE_SHIFT, INCX
  101. LDF [X + 0 * SIZE], c1
  102. LDF [X + 1 * SIZE], c2
  103. add N, -1, N
  104. FABS c1, c1
  105. add X, INCX, X
  106. FABS c2, c2
  107. cmp N, 0
  108. ble .LL20
  109. FADD c1, c2, c1
  110. FMOV c1, c2
  111. FMOV c1, c3
  112. FMOV c1, c4
  113. cmp INCX, 2 * SIZE
  114. bne .LL50
  115. nop
  116. sra N, 2, I
  117. cmp I, 0
  118. ble,pn %icc, .LL15
  119. nop
  120. LDF [X + 0 * SIZE], a1
  121. LDF [X + 1 * SIZE], a2
  122. LDF [X + 2 * SIZE], a3
  123. LDF [X + 3 * SIZE], a4
  124. LDF [X + 4 * SIZE], a5
  125. add I, -1, I
  126. LDF [X + 5 * SIZE], a6
  127. cmp I, 0
  128. LDF [X + 6 * SIZE], a7
  129. LDF [X + 7 * SIZE], a8
  130. ble,pt %icc, .LL12
  131. add X, 8 * SIZE, X
  132. #define PREFETCHSIZE 40
  133. .LL11:
  134. prefetch [X + PREFETCHSIZE * SIZE], 0
  135. FABS a1, t1
  136. LDF [X + 0 * SIZE], a1
  137. FABS a2, t2
  138. LDF [X + 1 * SIZE], a2
  139. FABS a3, t3
  140. LDF [X + 2 * SIZE], a3
  141. FABS a4, t4
  142. LDF [X + 3 * SIZE], a4
  143. FABS a5, t5
  144. LDF [X + 4 * SIZE], a5
  145. FABS a6, t6
  146. LDF [X + 5 * SIZE], a6
  147. FABS a7, t7
  148. LDF [X + 6 * SIZE], a7
  149. FABS a8, t8
  150. LDF [X + 7 * SIZE], a8
  151. FADD t1, t2, t1
  152. FADD t3, t4, t3
  153. FADD t5, t6, t5
  154. FADD t7, t8, t7
  155. FCMP %fcc0, t1, c1
  156. FCMP %fcc1, t3, c2
  157. FCMP %fcc2, t5, c3
  158. FCMP %fcc3, t7, c4
  159. FCMOV %fcc0, t1, c1
  160. add I, -1, I
  161. FCMOV %fcc1, t3, c2
  162. cmp I, 0
  163. FCMOV %fcc2, t5, c3
  164. FCMOV %fcc3, t7, c4
  165. bg,pt %icc, .LL11
  166. add X, 8 * SIZE, X
  167. .LL12:
  168. FABS a1, t1
  169. FABS a2, t2
  170. FABS a3, t3
  171. FABS a4, t4
  172. FABS a5, t5
  173. FABS a6, t6
  174. FABS a7, t7
  175. FABS a8, t8
  176. FADD t1, t2, t1
  177. FADD t3, t4, t3
  178. FADD t5, t6, t5
  179. FADD t7, t8, t7
  180. FCMP %fcc0, t1, c1
  181. FCMP %fcc1, t3, c2
  182. FCMP %fcc2, t5, c3
  183. FCMP %fcc3, t7, c4
  184. FCMOV %fcc0, t1, c1
  185. FCMOV %fcc1, t3, c2
  186. FCMOV %fcc2, t5, c3
  187. FCMOV %fcc3, t7, c4
  188. .LL15:
  189. and N, 3, I
  190. cmp I, 0
  191. ble,a,pn %icc, .LL19
  192. nop
  193. .LL16:
  194. LDF [X + 0 * SIZE], a1
  195. LDF [X + 1 * SIZE], a2
  196. FABS a1, t1
  197. FABS a2, t2
  198. FADD t1, t2, t1
  199. FCMP %fcc0, t1, c1
  200. FCMOV %fcc0, t1, c1
  201. add I, -1, I
  202. cmp I, 0
  203. bg,pt %icc, .LL16
  204. add X, 2 * SIZE, X
  205. .LL19:
  206. FCMP %fcc0, c2, c1
  207. FCMP %fcc1, c4, c3
  208. FCMOV %fcc0, c2, c1
  209. FCMOV %fcc1, c4, c3
  210. FCMP %fcc0, c3, c1
  211. FCMOV %fcc0, c3, c1
  212. .LL20:
  213. return %i7 + 8
  214. clr %g0
  215. .LL50:
  216. sra N, 2, I
  217. cmp I, 0
  218. ble,pn %icc, .LL55
  219. nop
  220. LDF [X + 0 * SIZE], a1
  221. LDF [X + 1 * SIZE], a2
  222. add X, INCX, X
  223. LDF [X + 0 * SIZE], a3
  224. LDF [X + 1 * SIZE], a4
  225. add X, INCX, X
  226. LDF [X + 0 * SIZE], a5
  227. LDF [X + 1 * SIZE], a6
  228. add X, INCX, X
  229. add I, -1, I
  230. LDF [X + 0 * SIZE], a7
  231. cmp I, 0
  232. LDF [X + 1 * SIZE], a8
  233. ble,pt %icc, .LL52
  234. add X, INCX, X
  235. .LL51:
  236. FABS a1, t1
  237. LDF [X + 0 * SIZE], a1
  238. FABS a2, t2
  239. LDF [X + 1 * SIZE], a2
  240. add X, INCX, X
  241. FABS a3, t3
  242. LDF [X + 0 * SIZE], a3
  243. FABS a4, t4
  244. LDF [X + 1 * SIZE], a4
  245. add X, INCX, X
  246. FABS a5, t5
  247. LDF [X + 0 * SIZE], a5
  248. FABS a6, t6
  249. LDF [X + 1 * SIZE], a6
  250. add X, INCX, X
  251. FABS a7, t7
  252. LDF [X + 0 * SIZE], a7
  253. FABS a8, t8
  254. LDF [X + 1 * SIZE], a8
  255. FADD t1, t2, t1
  256. FADD t3, t4, t3
  257. FADD t5, t6, t5
  258. FADD t7, t8, t7
  259. FCMP %fcc0, t1, c1
  260. FCMP %fcc1, t3, c2
  261. FCMP %fcc2, t5, c3
  262. FCMP %fcc3, t7, c4
  263. FCMOV %fcc0, t1, c1
  264. add I, -1, I
  265. FCMOV %fcc1, t3, c2
  266. cmp I, 0
  267. FCMOV %fcc2, t5, c3
  268. FCMOV %fcc3, t7, c4
  269. bg,pt %icc, .LL51
  270. add X, INCX, X
  271. .LL52:
  272. FABS a1, t1
  273. FABS a2, t2
  274. FABS a3, t3
  275. FABS a4, t4
  276. FABS a5, t5
  277. FABS a6, t6
  278. FABS a7, t7
  279. FABS a8, t8
  280. FADD t1, t2, t1
  281. FADD t3, t4, t3
  282. FADD t5, t6, t5
  283. FADD t7, t8, t7
  284. FCMP %fcc0, t1, c1
  285. FCMP %fcc1, t3, c2
  286. FCMP %fcc2, t5, c3
  287. FCMP %fcc3, t7, c4
  288. FCMOV %fcc0, t1, c1
  289. FCMOV %fcc1, t3, c2
  290. FCMOV %fcc2, t5, c3
  291. FCMOV %fcc3, t7, c4
  292. .LL55:
  293. and N, 3, I
  294. cmp I, 0
  295. ble,a,pn %icc, .LL59
  296. nop
  297. .LL56:
  298. LDF [X + 0 * SIZE], a1
  299. LDF [X + 1 * SIZE], a2
  300. FABS a1, t1
  301. add I, -1, I
  302. FABS a2, t2
  303. cmp I, 0
  304. FADD t1, t2, t1
  305. FCMP %fcc0, t1, c1
  306. FCMOV %fcc0, t1, c1
  307. bg,pt %icc, .LL56
  308. add X, INCX, X
  309. .LL59:
  310. FCMP %fcc0, c2, c1
  311. FCMP %fcc1, c4, c3
  312. FCMOV %fcc0, c2, c1
  313. FCMOV %fcc1, c4, c3
  314. FCMP %fcc0, c3, c1
  315. FCMOV %fcc0, c3, c1
  316. return %i7 + 8
  317. clr %o0
  318. EPILOGUE