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 6.5 kB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301
  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. #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. .frame $sp, STACKSIZE, $26, 0
  53. lda $sp, -STACKSIZE($sp)
  54. stt $f2, 0($sp)
  55. fclr $f16
  56. cmplt $31, N, $2
  57. stt $f3, 8($sp)
  58. fclr $f17
  59. cmplt $31, INCX, $3
  60. unop
  61. stt $f4, 16($sp)
  62. fclr $f18
  63. SXADDQ INCX, $31, INCX
  64. unop
  65. stt $f5, 24($sp)
  66. fclr $f19
  67. and $2, $3, $0
  68. unop
  69. stt $f6, 32($sp)
  70. unop
  71. stt $f7, 40($sp)
  72. stt $f8, 48($sp)
  73. stt $f9, 56($sp)
  74. fclr $f0
  75. beq $0, $End # if (n <= 0) or (incx <= 0) return
  76. .align 4
  77. LD $f20, 0 * SIZE(X)
  78. LD $f21, 1 * SIZE(X)
  79. sra N, 2, $1
  80. addq INCX, INCX, INCX
  81. fabs $f20, $f20
  82. fabs $f21, $f21
  83. addt $f20, $f21, $f0
  84. ble $1, $L15
  85. .align 4
  86. lda $1, -1($1)
  87. unop
  88. addq X, INCX, X
  89. unop
  90. LD $f22, 0 * SIZE(X)
  91. fmov $f0, $f1
  92. LD $f23, 1 * SIZE(X)
  93. addq X, INCX, X
  94. LD $f24, 0 * SIZE(X)
  95. fmov $f0, $f2
  96. LD $f25, 1 * SIZE(X)
  97. addq X, INCX, X
  98. LD $f26, 0 * SIZE(X)
  99. fmov $f0, $f3
  100. LD $f27, 1 * SIZE(X)
  101. addq X, INCX, X
  102. fabs $f20, $f8
  103. fabs $f21, $f9
  104. fabs $f22, $f10
  105. fabs $f23, $f11
  106. fabs $f24, $f12
  107. fabs $f25, $f13
  108. fabs $f26, $f14
  109. fabs $f27, $f15
  110. ble $1, $L14
  111. .align 4
  112. LD $f20, 0 * SIZE(X)
  113. LD $f21, 1 * SIZE(X)
  114. lda $1, -1($1)
  115. addq X, INCX, X
  116. LD $f22, 0 * SIZE(X)
  117. LD $f23, 1 * SIZE(X)
  118. unop
  119. addq X, INCX, X
  120. LD $f24, 0 * SIZE(X)
  121. LD $f25, 1 * SIZE(X)
  122. unop
  123. addq X, INCX, X
  124. LD $f26, 0 * SIZE(X)
  125. LD $f27, 1 * SIZE(X)
  126. addq X, INCX, X
  127. ble $1, $L13
  128. .align 4
  129. $L12:
  130. addt $f8, $f9, $f16
  131. unop
  132. fabs $f20, $f8
  133. ldl $31, 64 * SIZE(X)
  134. addt $f10, $f11, $f17
  135. unop
  136. fabs $f21, $f9
  137. LD $f20, 0 * SIZE(X)
  138. addt $f12, $f13, $f18
  139. LD $f21, 1 * SIZE(X)
  140. fabs $f22, $f10
  141. addq X, INCX, X
  142. addt $f14, $f15, $f19
  143. LD $f22, 0 * SIZE(X)
  144. fabs $f23, $f11
  145. unop
  146. CMPLT($f0, $f16), $f4
  147. LD $f23, 1 * SIZE(X)
  148. fabs $f24, $f12
  149. addq X, INCX, X
  150. CMPLT($f1, $f17), $f5
  151. LD $f24, 0 * SIZE(X)
  152. fabs $f25, $f13
  153. unop
  154. CMPLT($f2, $f18), $f6
  155. LD $f25, 1 * SIZE(X)
  156. fabs $f26, $f14
  157. addq X, INCX, X
  158. CMPLT($f3, $f19), $f7
  159. LD $f26, 0 * SIZE(X)
  160. fabs $f27, $f15
  161. unop
  162. fcmovne $f4, $f16, $f0
  163. LD $f27, 1 * SIZE(X)
  164. addq X, INCX, X
  165. lda $1, -1($1) # i --
  166. fcmovne $f5, $f17, $f1
  167. fcmovne $f6, $f18, $f2
  168. fcmovne $f7, $f19, $f3
  169. bgt $1,$L12
  170. .align 4
  171. $L13:
  172. addt $f8, $f9, $f16
  173. fabs $f20, $f8
  174. addt $f10, $f11, $f17
  175. fabs $f21, $f9
  176. addt $f12, $f13, $f18
  177. fabs $f22, $f10
  178. addt $f14, $f15, $f19
  179. fabs $f23, $f11
  180. CMPLT($f0, $f16), $f4
  181. fabs $f24, $f12
  182. CMPLT($f1, $f17), $f5
  183. fabs $f25, $f13
  184. CMPLT($f2, $f18), $f6
  185. fabs $f26, $f14
  186. CMPLT($f3, $f19), $f7
  187. fabs $f27, $f15
  188. fcmovne $f4, $f16, $f0
  189. fcmovne $f5, $f17, $f1
  190. fcmovne $f6, $f18, $f2
  191. fcmovne $f7, $f19, $f3
  192. .align 4
  193. $L14:
  194. addt $f8, $f9, $f16
  195. addt $f10, $f11, $f17
  196. addt $f12, $f13, $f18
  197. addt $f14, $f15, $f19
  198. CMPLT($f0, $f16), $f4
  199. CMPLT($f1, $f17), $f5
  200. CMPLT($f2, $f18), $f6
  201. CMPLT($f3, $f19), $f7
  202. fcmovne $f4, $f16, $f0
  203. fcmovne $f5, $f17, $f1
  204. fcmovne $f6, $f18, $f2
  205. fcmovne $f7, $f19, $f3
  206. CMPLT($f0, $f1), $f16
  207. CMPLT($f2, $f3), $f17
  208. fcmovne $f16, $f1, $f0
  209. fcmovne $f17, $f3, $f2
  210. CMPLT($f0, $f2), $f16
  211. fcmovne $f16, $f2, $f0
  212. .align 4
  213. $L15:
  214. and N, 3, $1
  215. unop
  216. unop
  217. ble $1, $End
  218. .align 4
  219. $L16:
  220. LD $f20, 0 * SIZE(X)
  221. LD $f21, 1 * SIZE(X)
  222. unop
  223. addq X, INCX, X
  224. fabs $f20, $f29
  225. fabs $f21, $f30
  226. addt $f29, $f30, $f29
  227. CMPLT($f0, $f29), $f16
  228. fcmovne $f16, $f29, $f0
  229. lda $1, -1($1) # i --
  230. bgt $1, $L16
  231. .align 4
  232. $End:
  233. ldt $f2, 0($sp)
  234. ldt $f3, 8($sp)
  235. ldt $f4, 16($sp)
  236. ldt $f5, 24($sp)
  237. ldt $f6, 32($sp)
  238. ldt $f7, 40($sp)
  239. ldt $f8, 48($sp)
  240. ldt $f9, 56($sp)
  241. lda $sp, STACKSIZE($sp)
  242. ret
  243. EPILOGUE