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.

amax.S 6.2 kB

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