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