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