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.

max.S 5.6 kB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227
  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. #ifdef F_INTERFACE
  53. ldl N, 0(N) # n
  54. ldl INCX, 0(INCX) # incx
  55. #endif
  56. lda $sp, -STACKSIZE($sp)
  57. nop
  58. .align 4
  59. cmplt $31, N, $2
  60. cmplt $31, INCX, $3
  61. SXADDQ INCX, $31, INCX
  62. and $2, $3, $0
  63. sra N, 3, $1
  64. fclr $f0
  65. unop
  66. beq $0, $End # if (n <= 0) or (incx <= 0) return
  67. .align 4
  68. LD $f0, 0 * SIZE(X)
  69. unop
  70. unop
  71. ble $1, $L15
  72. .align 4
  73. fmov $f0, $f1
  74. addq X, INCX, X
  75. fmov $f0, $f10
  76. lda $1, -1($1)
  77. LD $f21, 0 * SIZE(X)
  78. fmov $f0, $f11
  79. addq X, INCX, X
  80. fmov $f0, $f12
  81. LD $f22, 0 * SIZE(X)
  82. fmov $f0, $f13
  83. addq X, INCX, X
  84. fmov $f0, $f14
  85. LD $f23, 0 * SIZE(X)
  86. fmov $f0, $f15
  87. addq X, INCX, X
  88. fmov $f0, $f20
  89. LD $f24, 0 * SIZE(X)
  90. addq X, INCX, X
  91. LD $f25, 0 * SIZE(X)
  92. addq X, INCX, X
  93. LD $f26, 0 * SIZE(X)
  94. addq X, INCX, X
  95. LD $f27, 0 * SIZE(X)
  96. addq X, INCX, X
  97. CMPLT($f0, $f20), $f16
  98. CMPLT($f1, $f21), $f17
  99. CMPLT($f10, $f22), $f18
  100. CMPLT($f11, $f23), $f19
  101. ble $1, $L13
  102. .align 4
  103. $L12:
  104. fcmovne $f16, $f20, $f0
  105. LD $f20, 0 * SIZE(X)
  106. CMPLT($f12, $f24), $f16
  107. addq X, INCX, X
  108. fcmovne $f17, $f21, $f1
  109. LD $f21, 0 * SIZE(X)
  110. CMPLT($f13, $f25), $f17
  111. addq X, INCX, X
  112. fcmovne $f18, $f22, $f10
  113. LD $f22, 0 * SIZE(X)
  114. CMPLT($f14, $f26), $f18
  115. addq X, INCX, X
  116. fcmovne $f19, $f23, $f11
  117. LD $f23, 0 * SIZE(X)
  118. CMPLT($f15, $f27), $f19
  119. addq X, INCX, X
  120. fcmovne $f16, $f24, $f12
  121. LD $f24, 0 * SIZE(X)
  122. CMPLT($f0, $f20), $f16
  123. addq X, INCX, X
  124. fcmovne $f17, $f25, $f13
  125. LD $f25, 0 * SIZE(X)
  126. CMPLT($f1, $f21), $f17
  127. addq X, INCX, X
  128. fcmovne $f18, $f26, $f14
  129. LD $f26, 0 * SIZE(X)
  130. CMPLT($f10, $f22), $f18
  131. addq X, INCX, X
  132. fcmovne $f19, $f27, $f15
  133. LD $f27, 0 * SIZE(X)
  134. CMPLT($f11, $f23), $f19
  135. lda $1, -1($1) # i --
  136. addq X, INCX, X
  137. unop
  138. unop
  139. bgt $1,$L12
  140. .align 4
  141. $L13:
  142. fcmovne $f16, $f20, $f0
  143. CMPLT($f12, $f24), $f16
  144. fcmovne $f17, $f21, $f1
  145. CMPLT($f13, $f25), $f17
  146. fcmovne $f18, $f22, $f10
  147. CMPLT($f14, $f26), $f18
  148. fcmovne $f19, $f23, $f11
  149. CMPLT($f15, $f27), $f19
  150. fcmovne $f16, $f24, $f12
  151. CMPLT($f0, $f1), $f16
  152. fcmovne $f17, $f25, $f13
  153. CMPLT($f10, $f11), $f17
  154. fcmovne $f18, $f26, $f14
  155. CMPLT($f12, $f13), $f18
  156. fcmovne $f19, $f27, $f15
  157. CMPLT($f14, $f15), $f19
  158. fcmovne $f16, $f1, $f0
  159. fcmovne $f17, $f11, $f10
  160. fcmovne $f18, $f13, $f12
  161. fcmovne $f19, $f15, $f14
  162. CMPLT($f0, $f10), $f16
  163. CMPLT($f12, $f14), $f17
  164. fcmovne $f16, $f10, $f0
  165. fcmovne $f17, $f14, $f12
  166. CMPLT($f0, $f12), $f16
  167. fcmovne $f16, $f12, $f0
  168. .align 4
  169. $L15:
  170. and N, 7, $1
  171. unop
  172. unop
  173. ble $1, $End
  174. .align 4
  175. $L16:
  176. LD $f20, 0 * SIZE(X)
  177. addq X, INCX, X
  178. CMPLT($f0, $f20), $f16
  179. fcmovne $f16, $f20, $f0
  180. lda $1, -1($1) # i --
  181. bgt $1, $L16
  182. .align 4
  183. $End:
  184. lda $sp, STACKSIZE($sp)
  185. ret
  186. EPILOGUE