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.

znrm2.S 7.1 kB

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