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