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.

imax.S 7.5 kB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351
  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. clr $0
  54. mov X, XX
  55. .align 4
  56. cmplt $31, N, $2
  57. cmplt $31, INCX, $3
  58. SXADDQ INCX, $31, INCX
  59. and $2, $3, $2
  60. sra N, 3, $1
  61. fclr $f0
  62. unop
  63. beq $2, $End # if (n <= 0) or (incx <= 0) return
  64. .align 4
  65. LD $f0, 0 * SIZE(X)
  66. unop
  67. unop
  68. ble $1, $L15
  69. .align 4
  70. fmov $f0, $f1
  71. addq X, INCX, X
  72. fmov $f0, $f10
  73. lda $1, -1($1)
  74. LD $f21, 0 * SIZE(X)
  75. fmov $f0, $f11
  76. addq X, INCX, X
  77. fmov $f0, $f12
  78. LD $f22, 0 * SIZE(X)
  79. fmov $f0, $f13
  80. addq X, INCX, X
  81. fmov $f0, $f14
  82. LD $f23, 0 * SIZE(X)
  83. fmov $f0, $f15
  84. addq X, INCX, X
  85. fmov $f0, $f20
  86. LD $f24, 0 * SIZE(X)
  87. addq X, INCX, X
  88. LD $f25, 0 * SIZE(X)
  89. addq X, INCX, X
  90. LD $f26, 0 * SIZE(X)
  91. addq X, INCX, X
  92. LD $f27, 0 * SIZE(X)
  93. addq X, INCX, X
  94. CMPLT($f0, $f20), $f16
  95. CMPLT($f1, $f21), $f17
  96. CMPLT($f10, $f22), $f18
  97. CMPLT($f11, $f23), $f19
  98. ble $1, $L13
  99. .align 4
  100. $L12:
  101. fcmovne $f16, $f20, $f0
  102. LD $f20, 0 * SIZE(X)
  103. CMPLT($f12, $f24), $f16
  104. addq X, INCX, X
  105. fcmovne $f17, $f21, $f1
  106. LD $f21, 0 * SIZE(X)
  107. CMPLT($f13, $f25), $f17
  108. addq X, INCX, X
  109. fcmovne $f18, $f22, $f10
  110. LD $f22, 0 * SIZE(X)
  111. CMPLT($f14, $f26), $f18
  112. addq X, INCX, X
  113. fcmovne $f19, $f23, $f11
  114. LD $f23, 0 * SIZE(X)
  115. CMPLT($f15, $f27), $f19
  116. addq X, INCX, X
  117. fcmovne $f16, $f24, $f12
  118. LD $f24, 0 * SIZE(X)
  119. CMPLT($f0, $f20), $f16
  120. addq X, INCX, X
  121. fcmovne $f17, $f25, $f13
  122. LD $f25, 0 * SIZE(X)
  123. CMPLT($f1, $f21), $f17
  124. addq X, INCX, X
  125. fcmovne $f18, $f26, $f14
  126. LD $f26, 0 * SIZE(X)
  127. CMPLT($f10, $f22), $f18
  128. addq X, INCX, X
  129. fcmovne $f19, $f27, $f15
  130. LD $f27, 0 * SIZE(X)
  131. CMPLT($f11, $f23), $f19
  132. lda $1, -1($1) # i --
  133. addq X, INCX, X
  134. unop
  135. unop
  136. bgt $1,$L12
  137. .align 4
  138. $L13:
  139. fcmovne $f16, $f20, $f0
  140. CMPLT($f12, $f24), $f16
  141. fcmovne $f17, $f21, $f1
  142. CMPLT($f13, $f25), $f17
  143. fcmovne $f18, $f22, $f10
  144. CMPLT($f14, $f26), $f18
  145. fcmovne $f19, $f23, $f11
  146. CMPLT($f15, $f27), $f19
  147. fcmovne $f16, $f24, $f12
  148. CMPLT($f0, $f1), $f16
  149. fcmovne $f17, $f25, $f13
  150. CMPLT($f10, $f11), $f17
  151. fcmovne $f18, $f26, $f14
  152. CMPLT($f12, $f13), $f18
  153. fcmovne $f19, $f27, $f15
  154. CMPLT($f14, $f15), $f19
  155. fcmovne $f16, $f1, $f0
  156. fcmovne $f17, $f11, $f10
  157. fcmovne $f18, $f13, $f12
  158. fcmovne $f19, $f15, $f14
  159. CMPLT($f0, $f10), $f16
  160. CMPLT($f12, $f14), $f17
  161. fcmovne $f16, $f10, $f0
  162. fcmovne $f17, $f14, $f12
  163. CMPLT($f0, $f12), $f16
  164. fcmovne $f16, $f12, $f0
  165. .align 4
  166. $L15:
  167. and N, 7, $1
  168. unop
  169. unop
  170. ble $1, $L20
  171. .align 4
  172. $L16:
  173. LD $f20, 0 * SIZE(X)
  174. addq X, INCX, X
  175. CMPLT($f0, $f20), $f16
  176. fcmovne $f16, $f20, $f0
  177. lda $1, -1($1) # i --
  178. bgt $1, $L16
  179. .align 4
  180. $L20:
  181. sra N, 3, $1
  182. ble $1, $L40
  183. .align 4
  184. LD $f10, 0 * SIZE(XX)
  185. addq XX, INCX, XX
  186. LD $f11, 0 * SIZE(XX)
  187. addq XX, INCX, XX
  188. LD $f12, 0 * SIZE(XX)
  189. addq XX, INCX, XX
  190. LD $f13, 0 * SIZE(XX)
  191. addq XX, INCX, XX
  192. LD $f14, 0 * SIZE(XX)
  193. addq XX, INCX, XX
  194. LD $f15, 0 * SIZE(XX)
  195. addq XX, INCX, XX
  196. LD $f16, 0 * SIZE(XX)
  197. addq XX, INCX, XX
  198. LD $f17, 0 * SIZE(XX)
  199. addq XX, INCX, XX
  200. cmpteq $f0, $f10, $f20
  201. cmpteq $f0, $f11, $f21
  202. cmpteq $f0, $f12, $f22
  203. cmpteq $f0, $f13, $f23
  204. lda $1, -1($1)
  205. ble $1, $L23
  206. .align 4
  207. $L22:
  208. LD $f10, 0 * SIZE(XX)
  209. cmpteq $f0, $f14, $f24
  210. lda $0, 1($0)
  211. addq XX, INCX, XX
  212. fbne $f20, $End
  213. LD $f11, 0 * SIZE(XX)
  214. cmpteq $f0, $f15, $f25
  215. lda $0, 1($0)
  216. addq XX, INCX, XX
  217. fbne $f21, $End
  218. LD $f12, 0 * SIZE(XX)
  219. cmpteq $f0, $f16, $f26
  220. lda $0, 1($0)
  221. addq XX, INCX, XX
  222. fbne $f22, $End
  223. LD $f13, 0 * SIZE(XX)
  224. cmpteq $f0, $f17, $f27
  225. lda $0, 1($0)
  226. addq XX, INCX, XX
  227. fbne $f23, $End
  228. LD $f14, 0 * SIZE(XX)
  229. cmpteq $f0, $f10, $f20
  230. lda $0, 1($0)
  231. addq XX, INCX, XX
  232. fbne $f24, $End
  233. LD $f15, 0 * SIZE(XX)
  234. cmpteq $f0, $f11, $f21
  235. lda $0, 1($0)
  236. addq XX, INCX, XX
  237. fbne $f25, $End
  238. LD $f16, 0 * SIZE(XX)
  239. lda $1, -1($1) # i --
  240. cmpteq $f0, $f12, $f22
  241. lda $0, 1($0)
  242. addq XX, INCX, XX
  243. fbne $f26, $End
  244. LD $f17, 0 * SIZE(XX)
  245. cmpteq $f0, $f13, $f23
  246. lda $0, 1($0)
  247. addq XX, INCX, XX
  248. fbne $f27, $End
  249. bgt $1, $L22
  250. .align 4
  251. $L23:
  252. lda $0, 1($0)
  253. cmpteq $f0, $f14, $f24
  254. unop
  255. fbne $f20, $End
  256. lda $0, 1($0)
  257. cmpteq $f0, $f15, $f25
  258. unop
  259. fbne $f21, $End
  260. lda $0, 1($0)
  261. cmpteq $f0, $f16, $f26
  262. unop
  263. fbne $f22, $End
  264. lda $0, 1($0)
  265. cmpteq $f0, $f17, $f27
  266. unop
  267. fbne $f23, $End
  268. lda $0, 1($0)
  269. fbne $f24, $End
  270. lda $0, 1($0)
  271. fbne $f25, $End
  272. lda $0, 1($0)
  273. fbne $f26, $End
  274. lda $0, 1($0)
  275. fbne $f27, $End
  276. .align 4
  277. $L40:
  278. LD $f20, 0 * SIZE(XX)
  279. addq XX, INCX, XX
  280. cmpteq $f0, $f20, $f29
  281. lda $0, 1($0)
  282. fbne $f29, $End
  283. br $31, $L40
  284. .align 4
  285. $End:
  286. ret
  287. EPILOGUE