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.

dnrm2.S 7.5 kB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406
  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 $4
  41. #define X $5
  42. #define INCX $6
  43. #define XX $7
  44. #define I $2
  45. #define TEMP $3
  46. #define a1 $f4
  47. #define a2 $f5
  48. #define a3 $f6
  49. #define a4 $f7
  50. #define a5 $f8
  51. #define a6 $f9
  52. #define a7 $f10
  53. #define a8 $f11
  54. #define t1 $f12
  55. #define t2 $f13
  56. #define t3 $f14
  57. #define t4 $f15
  58. #define s1 $f0
  59. #define s2 $f1
  60. #define s3 $f2
  61. #define s4 $f3
  62. #define ALPHA $f16
  63. #define max $f17
  64. #define INF $f18
  65. PROLOGUE
  66. #ifdef F_INTERFACE
  67. LDINT N, 0(N)
  68. LDINT INCX, 0(INCX)
  69. #endif
  70. blez N, .L999
  71. MTC $0, s1
  72. beqz INCX, .L999
  73. dsll INCX, INCX, BASE_SHIFT
  74. move XX, X
  75. NOP
  76. //Init INF
  77. lui TEMP, 0x7FF0
  78. dsll TEMP, TEMP, 32
  79. MTC TEMP, INF
  80. LD a1, 0 * SIZE(X)
  81. daddiu N, N, -1
  82. daddu X, X, INCX
  83. FABS s1, a1
  84. blez N, .L999
  85. FABS s2, a1
  86. FABS s3, a1
  87. dsra I, N, 3
  88. blez I, .L15
  89. FABS s4, a1
  90. LD a1, 0 * SIZE(X)
  91. daddu X, X, INCX
  92. LD a2, 0 * SIZE(X)
  93. daddu X, X, INCX
  94. LD a3, 0 * SIZE(X)
  95. daddu X, X, INCX
  96. LD a4, 0 * SIZE(X)
  97. daddu X, X, INCX
  98. LD a5, 0 * SIZE(X)
  99. daddu X, X, INCX
  100. LD a6, 0 * SIZE(X)
  101. daddu X, X, INCX
  102. LD a7, 0 * SIZE(X)
  103. daddu X, X, INCX
  104. LD a8, 0 * SIZE(X)
  105. daddiu I, I, -1
  106. blez I, .L13
  107. daddu X, X, INCX
  108. .align 3
  109. .L12:
  110. FABS t1, a1
  111. LD a1, 0 * SIZE(X)
  112. FABS t2, a2
  113. daddu X, X, INCX
  114. FABS t3, a3
  115. LD a2, 0 * SIZE(X)
  116. FABS t4, a4
  117. daddu X, X, INCX
  118. CMPLT $fcc0, s1, t1
  119. LD a3, 0 * SIZE(X)
  120. CMPLT $fcc1, s2, t2
  121. daddu X, X, INCX
  122. CMPLT $fcc2, s3, t3
  123. LD a4, 0 * SIZE(X)
  124. CMPLT $fcc3, s4, t4
  125. daddu X, X, INCX
  126. CMOVT s1, t1, $fcc0
  127. CMOVT s2, t2, $fcc1
  128. CMOVT s3, t3, $fcc2
  129. CMOVT s4, t4, $fcc3
  130. FABS t1, a5
  131. LD a5, 0 * SIZE(X)
  132. FABS t2, a6
  133. daddu X, X, INCX
  134. FABS t3, a7
  135. LD a6, 0 * SIZE(X)
  136. FABS t4, a8
  137. daddu X, X, INCX
  138. CMPLT $fcc0, s1, t1
  139. LD a7, 0 * SIZE(X)
  140. CMPLT $fcc1, s2, t2
  141. daddu X, X, INCX
  142. CMPLT $fcc2, s3, t3
  143. LD a8, 0 * SIZE(X)
  144. CMPLT $fcc3, s4, t4
  145. daddu X, X, INCX
  146. CMOVT s1, t1, $fcc0
  147. daddiu I, I, -1
  148. CMOVT s2, t2, $fcc1
  149. CMOVT s3, t3, $fcc2
  150. bgtz I, .L12
  151. CMOVT s4, t4, $fcc3
  152. .align 3
  153. .L13:
  154. FABS t1, a1
  155. FABS t2, a2
  156. FABS t3, a3
  157. FABS t4, a4
  158. CMPLT $fcc0, s1, t1
  159. CMPLT $fcc1, s2, t2
  160. CMPLT $fcc2, s3, t3
  161. CMPLT $fcc3, s4, t4
  162. CMOVT s1, t1, $fcc0
  163. CMOVT s2, t2, $fcc1
  164. CMOVT s3, t3, $fcc2
  165. CMOVT s4, t4, $fcc3
  166. FABS t1, a5
  167. FABS t2, a6
  168. FABS t3, a7
  169. FABS t4, a8
  170. CMPLT $fcc0, s1, t1
  171. CMPLT $fcc1, s2, t2
  172. CMPLT $fcc2, s3, t3
  173. CMPLT $fcc3, s4, t4
  174. CMOVT s1, t1, $fcc0
  175. CMOVT s2, t2, $fcc1
  176. CMOVT s3, t3, $fcc2
  177. CMOVT s4, t4, $fcc3
  178. .align 3
  179. .L15:
  180. andi I, N, 7
  181. blez I, .L100
  182. NOP
  183. .align 3
  184. .L16:
  185. LD a1, 0 * SIZE(X)
  186. daddiu I, I, -1
  187. FABS t1, a1
  188. CMPLT $fcc0, s1, t1
  189. CMOVT s1, t1, $fcc0
  190. bgtz I, .L16
  191. daddu X, X, INCX
  192. .align 3
  193. .L100:
  194. CMPLT $fcc0, s1, s2
  195. CMPLT $fcc1, s3, s4
  196. CMOVT s1, s2, $fcc0
  197. CMOVT s3, s4, $fcc1
  198. CMPLT $fcc0, s1, s3
  199. CMOVT s1, s3, $fcc0
  200. daddiu N, N, 1
  201. lui TEMP, 0x3f80
  202. dmtc1 $0, a1
  203. mtc1 TEMP, ALPHA
  204. CMPEQ $fcc0, s1, a1
  205. bc1t $fcc0, .L999
  206. cvt.d.s ALPHA, ALPHA
  207. div.d ALPHA, ALPHA, s1
  208. MOV max, s1
  209. CMPEQ $fcc0, ALPHA, INF
  210. bc1t $fcc0, .L999
  211. MOV s1, a1
  212. MOV s2, a1
  213. MOV s3, a1
  214. MOV s4, a1
  215. dsra I, N, 3
  216. blez I, .L105
  217. NOP
  218. LD a1, 0 * SIZE(XX)
  219. daddu XX, XX, INCX
  220. LD a2, 0 * SIZE(XX)
  221. daddu XX, XX, INCX
  222. LD a3, 0 * SIZE(XX)
  223. daddu XX, XX, INCX
  224. LD a4, 0 * SIZE(XX)
  225. daddu XX, XX, INCX
  226. LD a5, 0 * SIZE(XX)
  227. daddu XX, XX, INCX
  228. LD a6, 0 * SIZE(XX)
  229. daddu XX, XX, INCX
  230. LD a7, 0 * SIZE(XX)
  231. daddu XX, XX, INCX
  232. LD a8, 0 * SIZE(XX)
  233. daddiu I, I, -1
  234. blez I, .L104
  235. daddu XX, XX, INCX
  236. .align 3
  237. .L103:
  238. MUL t1, ALPHA, a1
  239. LD a1, 0 * SIZE(XX)
  240. MUL t2, ALPHA, a2
  241. daddu XX, XX, INCX
  242. MUL t3, ALPHA, a3
  243. LD a2, 0 * SIZE(XX)
  244. MUL t4, ALPHA, a4
  245. daddu XX, XX, INCX
  246. MADD s1, s1, t1, t1
  247. LD a3, 0 * SIZE(XX)
  248. MADD s2, s2, t2, t2
  249. daddu XX, XX, INCX
  250. MADD s3, s3, t3, t3
  251. LD a4, 0 * SIZE(XX)
  252. MADD s4, s4, t4, t4
  253. daddu XX, XX, INCX
  254. MUL t1, ALPHA, a5
  255. LD a5, 0 * SIZE(XX)
  256. MUL t2, ALPHA, a6
  257. daddu XX, XX, INCX
  258. MUL t3, ALPHA, a7
  259. LD a6, 0 * SIZE(XX)
  260. MUL t4, ALPHA, a8
  261. daddu XX, XX, INCX
  262. MADD s1, s1, t1, t1
  263. LD a7, 0 * SIZE(XX)
  264. MADD s2, s2, t2, t2
  265. daddu XX, XX, INCX
  266. MADD s3, s3, t3, t3
  267. LD a8, 0 * SIZE(XX)
  268. MADD s4, s4, t4, t4
  269. daddiu I, I, -1
  270. bgtz I, .L103
  271. daddu XX, XX, INCX
  272. .align 3
  273. .L104:
  274. MUL t1, ALPHA, a1
  275. MUL t2, ALPHA, a2
  276. MUL t3, ALPHA, a3
  277. MUL t4, ALPHA, a4
  278. MADD s1, s1, t1, t1
  279. MADD s2, s2, t2, t2
  280. MADD s3, s3, t3, t3
  281. MADD s4, s4, t4, t4
  282. MUL t1, ALPHA, a5
  283. MUL t2, ALPHA, a6
  284. MUL t3, ALPHA, a7
  285. MUL t4, ALPHA, a8
  286. MADD s1, s1, t1, t1
  287. MADD s2, s2, t2, t2
  288. MADD s3, s3, t3, t3
  289. MADD s4, s4, t4, t4
  290. .align 3
  291. .L105:
  292. andi I, N, 7
  293. blez I, .L998
  294. NOP
  295. .align 3
  296. .L106:
  297. LD a1, 0 * SIZE(XX)
  298. daddiu I, I, -1
  299. MUL t1, ALPHA, a1
  300. daddu XX, XX, INCX
  301. bgtz I, .L106
  302. MADD s1, s1, t1, t1
  303. .align 3
  304. .L998:
  305. ADD s1, s1, s2
  306. ADD s3, s3, s4
  307. ADD s1, s1, s3
  308. sqrt.d s1, s1
  309. j $31
  310. MUL s1, max, s1
  311. .align 3
  312. .L999:
  313. j $31
  314. NOP
  315. EPILOGUE