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.

izamax.S 8.3 kB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427
  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. #include "version.h"
  41. #define N $16
  42. #define X $17
  43. #define INCX $18
  44. #define XX $19
  45. #ifndef USE_MIN
  46. #define CMPLT(a, b) cmptlt a, b
  47. #else
  48. #define CMPLT(a, b) cmptlt b, a
  49. #endif
  50. #define STACKSIZE 8 * 8
  51. PROLOGUE
  52. PROFCODE
  53. lda $sp, -STACKSIZE($sp)
  54. stt $f2, 0($sp)
  55. fclr $f16
  56. cmplt $31, N, $2
  57. unop
  58. stt $f3, 8($sp)
  59. fclr $f17
  60. cmplt $31, INCX, $3
  61. unop
  62. stt $f4, 16($sp)
  63. fclr $f18
  64. SXADDQ INCX, $31, INCX
  65. unop
  66. stt $f5, 24($sp)
  67. fclr $f19
  68. and $2, $3, $2
  69. clr $0
  70. stt $f6, 32($sp)
  71. mov X, XX
  72. stt $f7, 40($sp)
  73. stt $f8, 48($sp)
  74. stt $f9, 56($sp)
  75. fclr $f0
  76. beq $2, $End # if (n <= 0) or (incx <= 0) return
  77. .align 4
  78. LD $f20, 0 * SIZE(X)
  79. LD $f21, 1 * SIZE(X)
  80. sra N, 2, $1
  81. addq INCX, INCX, INCX
  82. fabs $f20, $f20
  83. fabs $f21, $f21
  84. addt $f20, $f21, $f0
  85. ble $1, $L15
  86. .align 4
  87. lda $1, -1($1)
  88. unop
  89. addq X, INCX, X
  90. unop
  91. LD $f22, 0 * SIZE(X)
  92. fmov $f0, $f1
  93. LD $f23, 1 * SIZE(X)
  94. addq X, INCX, X
  95. LD $f24, 0 * SIZE(X)
  96. fmov $f0, $f2
  97. LD $f25, 1 * SIZE(X)
  98. addq X, INCX, X
  99. LD $f26, 0 * SIZE(X)
  100. fmov $f0, $f3
  101. LD $f27, 1 * SIZE(X)
  102. addq X, INCX, X
  103. fabs $f20, $f8
  104. fabs $f21, $f9
  105. fabs $f22, $f10
  106. fabs $f23, $f11
  107. fabs $f24, $f12
  108. fabs $f25, $f13
  109. fabs $f26, $f14
  110. fabs $f27, $f15
  111. ble $1, $L14
  112. .align 4
  113. LD $f20, 0 * SIZE(X)
  114. LD $f21, 1 * SIZE(X)
  115. lda $1, -1($1)
  116. addq X, INCX, X
  117. LD $f22, 0 * SIZE(X)
  118. LD $f23, 1 * SIZE(X)
  119. unop
  120. addq X, INCX, X
  121. LD $f24, 0 * SIZE(X)
  122. LD $f25, 1 * SIZE(X)
  123. unop
  124. addq X, INCX, X
  125. LD $f26, 0 * SIZE(X)
  126. LD $f27, 1 * SIZE(X)
  127. addq X, INCX, X
  128. ble $1, $L13
  129. .align 4
  130. $L12:
  131. addt $f8, $f9, $f16
  132. unop
  133. fabs $f20, $f8
  134. ldl $31, 64 * SIZE(X)
  135. addt $f10, $f11, $f17
  136. unop
  137. fabs $f21, $f9
  138. LD $f20, 0 * SIZE(X)
  139. addt $f12, $f13, $f18
  140. LD $f21, 1 * SIZE(X)
  141. fabs $f22, $f10
  142. addq X, INCX, X
  143. addt $f14, $f15, $f19
  144. LD $f22, 0 * SIZE(X)
  145. fabs $f23, $f11
  146. unop
  147. CMPLT($f0, $f16), $f4
  148. LD $f23, 1 * SIZE(X)
  149. fabs $f24, $f12
  150. addq X, INCX, X
  151. CMPLT($f1, $f17), $f5
  152. LD $f24, 0 * SIZE(X)
  153. fabs $f25, $f13
  154. unop
  155. CMPLT($f2, $f18), $f6
  156. LD $f25, 1 * SIZE(X)
  157. fabs $f26, $f14
  158. addq X, INCX, X
  159. CMPLT($f3, $f19), $f7
  160. LD $f26, 0 * SIZE(X)
  161. fabs $f27, $f15
  162. unop
  163. fcmovne $f4, $f16, $f0
  164. LD $f27, 1 * SIZE(X)
  165. addq X, INCX, X
  166. lda $1, -1($1) # i --
  167. fcmovne $f5, $f17, $f1
  168. fcmovne $f6, $f18, $f2
  169. fcmovne $f7, $f19, $f3
  170. bgt $1,$L12
  171. .align 4
  172. $L13:
  173. addt $f8, $f9, $f16
  174. fabs $f20, $f8
  175. addt $f10, $f11, $f17
  176. fabs $f21, $f9
  177. addt $f12, $f13, $f18
  178. fabs $f22, $f10
  179. addt $f14, $f15, $f19
  180. fabs $f23, $f11
  181. CMPLT($f0, $f16), $f4
  182. fabs $f24, $f12
  183. CMPLT($f1, $f17), $f5
  184. fabs $f25, $f13
  185. CMPLT($f2, $f18), $f6
  186. fabs $f26, $f14
  187. CMPLT($f3, $f19), $f7
  188. fabs $f27, $f15
  189. fcmovne $f4, $f16, $f0
  190. fcmovne $f5, $f17, $f1
  191. fcmovne $f6, $f18, $f2
  192. fcmovne $f7, $f19, $f3
  193. .align 4
  194. $L14:
  195. addt $f8, $f9, $f16
  196. addt $f10, $f11, $f17
  197. addt $f12, $f13, $f18
  198. addt $f14, $f15, $f19
  199. CMPLT($f0, $f16), $f4
  200. CMPLT($f1, $f17), $f5
  201. CMPLT($f2, $f18), $f6
  202. CMPLT($f3, $f19), $f7
  203. fcmovne $f4, $f16, $f0
  204. fcmovne $f5, $f17, $f1
  205. fcmovne $f6, $f18, $f2
  206. fcmovne $f7, $f19, $f3
  207. CMPLT($f0, $f1), $f16
  208. CMPLT($f2, $f3), $f17
  209. fcmovne $f16, $f1, $f0
  210. fcmovne $f17, $f3, $f2
  211. CMPLT($f0, $f2), $f16
  212. fcmovne $f16, $f2, $f0
  213. .align 4
  214. $L15:
  215. and N, 3, $1
  216. unop
  217. unop
  218. ble $1, $L20
  219. .align 4
  220. $L16:
  221. LD $f20, 0 * SIZE(X)
  222. LD $f21, 1 * SIZE(X)
  223. unop
  224. addq X, INCX, X
  225. fabs $f20, $f29
  226. fabs $f21, $f30
  227. addt $f29, $f30, $f29
  228. CMPLT($f0, $f29), $f16
  229. fcmovne $f16, $f29, $f0
  230. lda $1, -1($1) # i --
  231. bgt $1, $L16
  232. .align 4
  233. $L20:
  234. sra N, 2, $1
  235. ble $1, $L40
  236. .align 4
  237. LD $f10, 0 * SIZE(XX)
  238. LD $f11, 1 * SIZE(XX)
  239. addq XX, INCX, XX
  240. LD $f12, 0 * SIZE(XX)
  241. LD $f13, 1 * SIZE(XX)
  242. addq XX, INCX, XX
  243. LD $f14, 0 * SIZE(XX)
  244. LD $f15, 1 * SIZE(XX)
  245. addq XX, INCX, XX
  246. LD $f16, 0 * SIZE(XX)
  247. LD $f17, 1 * SIZE(XX)
  248. addq XX, INCX, XX
  249. fabs $f10, $f18
  250. fabs $f11, $f19
  251. fabs $f12, $f20
  252. fabs $f13, $f21
  253. lda $1, -1($1)
  254. ble $1, $L23
  255. .align 4
  256. $L22:
  257. LD $f10, 0 * SIZE(XX)
  258. fabs $f14, $f22
  259. LD $f11, 1 * SIZE(XX)
  260. addq XX, INCX, XX
  261. LD $f12, 0 * SIZE(XX)
  262. fabs $f15, $f23
  263. LD $f13, 1 * SIZE(XX)
  264. addq XX, INCX, XX
  265. LD $f14, 0 * SIZE(XX)
  266. fabs $f16, $f24
  267. LD $f15, 1 * SIZE(XX)
  268. addq XX, INCX, XX
  269. LD $f16, 0 * SIZE(XX)
  270. fabs $f17, $f25
  271. LD $f17, 1 * SIZE(XX)
  272. addq XX, INCX, XX
  273. addt $f18, $f19, $f4
  274. addt $f20, $f21, $f5
  275. addt $f22, $f23, $f6
  276. addt $f24, $f25, $f7
  277. cmpteq $f0, $f4, $f26
  278. cmpteq $f0, $f5, $f27
  279. cmpteq $f0, $f6, $f28
  280. cmpteq $f0, $f7, $f29
  281. fabs $f10, $f18
  282. lda $0, 1($0)
  283. lda $1, -1($1) # i --
  284. fbne $f26, $End
  285. fabs $f11, $f19
  286. lda $0, 1($0)
  287. unop
  288. fbne $f27, $End
  289. fabs $f12, $f20
  290. lda $0, 1($0)
  291. unop
  292. fbne $f28, $End
  293. fabs $f13, $f21
  294. lda $0, 1($0)
  295. fbne $f29, $End
  296. bgt $1, $L22
  297. .align 4
  298. $L23:
  299. fabs $f14, $f22
  300. fabs $f15, $f23
  301. fabs $f16, $f24
  302. fabs $f17, $f25
  303. addt $f18, $f19, $f4
  304. addt $f20, $f21, $f5
  305. addt $f22, $f23, $f6
  306. addt $f24, $f25, $f7
  307. cmpteq $f0, $f4, $f26
  308. cmpteq $f0, $f5, $f27
  309. cmpteq $f0, $f6, $f28
  310. cmpteq $f0, $f7, $f29
  311. lda $0, 1($0)
  312. fbne $f26, $End
  313. lda $0, 1($0)
  314. fbne $f27, $End
  315. lda $0, 1($0)
  316. fbne $f28, $End
  317. lda $0, 1($0)
  318. fbne $f29, $End
  319. .align 4
  320. $L40:
  321. LD $f10, 0 * SIZE(XX)
  322. LD $f11, 1 * SIZE(XX)
  323. addq XX, INCX, XX
  324. fabs $f10, $f18
  325. fabs $f11, $f19
  326. addt $f18, $f19, $f18
  327. cmpteq $f0, $f18, $f2
  328. lda $0, 1($0)
  329. fbne $f2, $End
  330. br $31, $L40
  331. .align 4
  332. $End:
  333. ldt $f2, 0($sp)
  334. ldt $f3, 8($sp)
  335. ldt $f4, 16($sp)
  336. ldt $f5, 24($sp)
  337. ldt $f6, 32($sp)
  338. ldt $f7, 40($sp)
  339. ldt $f8, 48($sp)
  340. ldt $f9, 56($sp)
  341. lda $sp, STACKSIZE($sp)
  342. ret
  343. EPILOGUE