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.

iamax.S 5.9 kB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233
  1. /***************************************************************************
  2. Copyright (c) 2021, The OpenBLAS Project
  3. All rights reserved.
  4. Redistribution and use in source and binary forms, with or without
  5. modification, are permitted provided that the following conditions are
  6. met:
  7. 1. Redistributions of source code must retain the above copyright
  8. notice, this list of conditions and the following disclaimer.
  9. 2. Redistributions in binary form must reproduce the above copyright
  10. notice, this list of conditions and the following disclaimer in
  11. the documentation and/or other materials provided with the
  12. distribution.
  13. 3. Neither the name of the OpenBLAS project nor the names of
  14. its contributors may be used to endorse or promote products
  15. derived from this software without specific prior written permission.
  16. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
  17. AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  18. IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
  19. ARE DISCLAIMED. IN NO EVENT SHALL THE OPENBLAS PROJECT OR CONTRIBUTORS BE
  20. LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
  21. DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
  22. SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
  23. CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
  24. OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
  25. USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  26. *****************************************************************************/
  27. #define ASSEMBLER
  28. #include "common.h"
  29. #define N $r4
  30. #define X $r5
  31. #define INCX $r6
  32. #define I $r18
  33. #define TEMP $r7
  34. #define a1 $f10
  35. #define a2 $f11
  36. #define a3 $f12
  37. #define a4 $f13
  38. #define a5 $f14
  39. #define a6 $f15
  40. #define a7 $f16
  41. #define a8 $f17
  42. #define t1 $f0
  43. #define t2 $f1
  44. #define t3 $f2
  45. #define t4 $f3
  46. #define s1 $f22
  47. #define s2 $f8
  48. #define s3 $f23
  49. #define s4 $f9
  50. #define x1 $r17
  51. #define x2 $r8
  52. #define x3 $r9
  53. #define x4 $r10
  54. PROLOGUE
  55. #ifdef F_INTERFACE
  56. LDINT N, 0(N)
  57. LDINT INCX, 0(INCX)
  58. #endif
  59. li.d x1, 0
  60. bge $r0, N, .L999
  61. slli.d INCX, INCX, BASE_SHIFT
  62. bge $r0, INCX, .L999
  63. LD a1, X, 0 * SIZE
  64. addi.d N, N, -1
  65. li.d x1, 1
  66. bge $r0, N, .L999
  67. FABS s1, a1
  68. add.d X, X, INCX
  69. FABS s2, a1
  70. li.d x2, 1
  71. FABS s3, a1
  72. srai.d I, N, 3
  73. FABS s4, a1
  74. li.d x3, 1
  75. li.d TEMP, 2
  76. li.d x4, 1
  77. bge $r0, I, .L15
  78. LD a1, X, 0 * SIZE
  79. add.d X, X, INCX
  80. LD a2, X, 0 * SIZE
  81. add.d X, X, INCX
  82. LD a3, X, 0 * SIZE
  83. add.d X, X, INCX
  84. LD a4, X, 0 * SIZE
  85. add.d X, X, INCX
  86. LD a5, X, 0 * SIZE
  87. add.d X, X, INCX
  88. LD a6, X, 0 * SIZE
  89. add.d X, X, INCX
  90. LD a7, X, 0 * SIZE
  91. add.d X, X, INCX
  92. LD a8, X, 0 * SIZE
  93. addi.d I, I, -1
  94. add.d X, X, INCX
  95. bge $r0, I, .L13
  96. .align 3
  97. .L12:
  98. FABS t1, a1
  99. LD a1, X, 0 * SIZE
  100. FABS t2, a2
  101. add.d X, X, INCX
  102. FABS t3, a3
  103. LD a2, X, 0 * SIZE
  104. FABS t4, a4
  105. add.d X, X, INCX
  106. CMPLT $fcc0, s1, t1
  107. LD a3, X, 0 * SIZE
  108. CMPLT $fcc1, s2, t2
  109. add.d X, X, INCX
  110. CMPLT $fcc2, s3, t3
  111. LD a4, X, 0 * SIZE
  112. CMPLT $fcc3, s4, t4
  113. add.d X, X, INCX
  114. CMOVT s1, s1, t1, $fcc0
  115. MOVT(x1, TEMP, $fcc0)
  116. CMOVT s2, s2, t2, $fcc1
  117. MOVT(x2, TEMP, $fcc1)
  118. CMOVT s3, s3, t3, $fcc2
  119. MOVT(x3, TEMP, $fcc2)
  120. CMOVT s4, s4, t4, $fcc3
  121. MOVT(x4, TEMP, $fcc3)
  122. addi.d TEMP, TEMP, 4
  123. addi.d I, I, -1
  124. FABS t1, a5
  125. LD a5, X, 0 * SIZE
  126. FABS t2, a6
  127. add.d X, X, INCX
  128. FABS t3, a7
  129. LD a6, X, 0 * SIZE
  130. FABS t4, a8
  131. add.d X, X, INCX
  132. CMPLT $fcc0, s1, t1
  133. LD a7, X, 0 * SIZE
  134. CMPLT $fcc1, s2, t2
  135. add.d X, X, INCX
  136. CMPLT $fcc2, s3, t3
  137. LD a8, X, 0 * SIZE
  138. CMPLT $fcc3, s4, t4
  139. add.d X, X, INCX
  140. CMOVT s1, s1, t1, $fcc0
  141. MOVT(x1, TEMP, $fcc0)
  142. CMOVT s2, s2, t2, $fcc1
  143. MOVT(x2, TEMP, $fcc1)
  144. CMOVT s3, s3, t3, $fcc2
  145. MOVT(x3, TEMP, $fcc2)
  146. CMOVT s4, s4, t4, $fcc3
  147. MOVT(x4, TEMP, $fcc3)
  148. addi.d TEMP, TEMP, 4
  149. blt $r0, I, .L12
  150. .align 3
  151. .L13:
  152. FABS t1, a1
  153. FABS t2, a2
  154. FABS t3, a3
  155. FABS t4, a4
  156. CMPLT $fcc0, s1, t1
  157. CMPLT $fcc1, s2, t2
  158. CMPLT $fcc2, s3, t3
  159. CMPLT $fcc3, s4, t4
  160. CMOVT s1, s1, t1, $fcc0
  161. MOVT(x1, TEMP, $fcc0)
  162. CMOVT s2, s2, t2, $fcc1
  163. MOVT(x2, TEMP, $fcc1)
  164. CMOVT s3, s3, t3, $fcc2
  165. MOVT(x3, TEMP, $fcc2)
  166. CMOVT s4, s4, t4, $fcc3
  167. MOVT(x4, TEMP, $fcc3)
  168. FABS t1, a5
  169. addi.d TEMP, TEMP, 4
  170. FABS t2, a6
  171. FABS t3, a7
  172. FABS t4, a8
  173. CMPLT $fcc0, s1, t1
  174. CMPLT $fcc1, s2, t2
  175. CMPLT $fcc2, s3, t3
  176. CMPLT $fcc3, s4, t4
  177. CMOVT s1, s1, t1, $fcc0
  178. MOVT(x1, TEMP, $fcc0)
  179. CMOVT s2, s2, t2, $fcc1
  180. MOVT(x2, TEMP, $fcc1)
  181. CMOVT s3, s3, t3, $fcc2
  182. MOVT(x3, TEMP, $fcc2)
  183. CMOVT s4, s4, t4, $fcc3
  184. MOVT(x4, TEMP, $fcc3)
  185. addi.d TEMP, TEMP, 4
  186. addi.d x2, x2, 1
  187. addi.d x3, x3, 2
  188. addi.d x4, x4, 3
  189. .align 3
  190. .L15:
  191. andi I, N, 7
  192. bge $r0, I, .L998
  193. .align 3
  194. .L16:
  195. LD a1, X, 0 * SIZE
  196. add.d X, X, INCX
  197. FABS t1, a1
  198. addi.d I, I, -1
  199. CMPLT $fcc0, s1, t1
  200. CMOVT s1, s1, t1, $fcc0
  201. MOVT(x1, TEMP, $fcc0)
  202. addi.d TEMP, TEMP, 1
  203. blt $r0, I, .L16
  204. .align 3
  205. .L998:
  206. CMPLT $fcc0, s1, s2
  207. CMPLT $fcc1, s3, s4
  208. CMOVT s1, s1, s2, $fcc0
  209. MOVT(x1, x2, $fcc0)
  210. CMOVT s3, s3, s4, $fcc1
  211. MOVT(x3, x4, $fcc1)
  212. CMPLT $fcc0, s1, s3
  213. CMOVT s1, s1, s3, $fcc0
  214. MOVT(x1, x3, $fcc0)
  215. .align 3
  216. .L999:
  217. move $r4, $r17
  218. fmov.d $f0, $f22
  219. jirl $r0, $r1, 0x0
  220. EPILOGUE