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.

snrm2.S 6.3 kB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337
  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 I $2
  44. #define TEMP $3
  45. #define a1 $f6
  46. #define a2 $f7
  47. #define a3 $f8
  48. #define a4 $f9
  49. #define a5 $f10
  50. #define a6 $f11
  51. #define a7 $f12
  52. #define a8 $f13
  53. #define s1 $f0
  54. #define s2 $f1
  55. #define t1 $f2
  56. #define t2 $f3
  57. #define t3 $f4
  58. #define t4 $f5
  59. PROLOGUE
  60. #ifdef F_INTERFACE
  61. LDINT N, 0(N)
  62. LDINT INCX, 0(INCX)
  63. #endif
  64. dmtc1 $0, s1
  65. li TEMP, SIZE
  66. blez N, .L999
  67. mov.d s2, s1
  68. beqz INCX, .L999
  69. dsll INCX, INCX, BASE_SHIFT
  70. bne INCX, TEMP, .L20
  71. dsra I, N, 3
  72. blez I, .L15
  73. NOP
  74. LD a1, 0 * SIZE(X)
  75. LD a2, 1 * SIZE(X)
  76. LD a3, 2 * SIZE(X)
  77. LD a4, 3 * SIZE(X)
  78. LD a5, 4 * SIZE(X)
  79. daddiu I, I, -1
  80. cvt.d.s t1, a1
  81. LD a6, 5 * SIZE(X)
  82. cvt.d.s t2, a2
  83. LD a7, 6 * SIZE(X)
  84. cvt.d.s t3, a3
  85. LD a8, 7 * SIZE(X)
  86. blez I, .L13
  87. cvt.d.s t4, a4
  88. .align 3
  89. .L12:
  90. madd.d s1, s1, t1, t1
  91. LD a1, 8 * SIZE(X)
  92. cvt.d.s t1, a5
  93. NOP
  94. madd.d s2, s2, t2, t2
  95. LD a2, 9 * SIZE(X)
  96. cvt.d.s t2, a6
  97. NOP
  98. madd.d s1, s1, t3, t3
  99. LD a3, 10 * SIZE(X)
  100. cvt.d.s t3, a7
  101. NOP
  102. madd.d s2, s2, t4, t4
  103. LD a4, 11 * SIZE(X)
  104. cvt.d.s t4, a8
  105. NOP
  106. madd.d s1, s1, t1, t1
  107. LD a5, 12 * SIZE(X)
  108. cvt.d.s t1, a1
  109. NOP
  110. madd.d s2, s2, t2, t2
  111. LD a6, 13 * SIZE(X)
  112. cvt.d.s t2, a2
  113. daddiu I, I, -1
  114. madd.d s1, s1, t3, t3
  115. LD a7, 14 * SIZE(X)
  116. cvt.d.s t3, a3
  117. daddiu X, X, 8 * SIZE
  118. madd.d s2, s2, t4, t4
  119. LD a8, 7 * SIZE(X)
  120. bgtz I, .L12
  121. cvt.d.s t4, a4
  122. .align 3
  123. .L13:
  124. madd.d s1, s1, t1, t1
  125. cvt.d.s t1, a5
  126. madd.d s2, s2, t2, t2
  127. cvt.d.s t2, a6
  128. madd.d s1, s1, t3, t3
  129. cvt.d.s t3, a7
  130. madd.d s2, s2, t4, t4
  131. cvt.d.s t4, a8
  132. madd.d s1, s1, t1, t1
  133. madd.d s2, s2, t2, t2
  134. madd.d s1, s1, t3, t3
  135. madd.d s2, s2, t4, t4
  136. daddiu X, X, 8 * SIZE
  137. .align 3
  138. .L15:
  139. andi I, N, 7
  140. blez I, .L999
  141. NOP
  142. .align 3
  143. .L16:
  144. LD a1, 0 * SIZE(X)
  145. daddiu I, I, -1
  146. cvt.d.s t1, a1
  147. madd.d s1, s1, t1, t1
  148. bgtz I, .L16
  149. daddiu X, X, SIZE
  150. j .L999
  151. NOP
  152. .align 3
  153. .L20:
  154. blez I, .L25
  155. NOP
  156. LD a1, 0 * SIZE(X)
  157. daddu X, X, INCX
  158. LD a2, 0 * SIZE(X)
  159. daddu X, X, INCX
  160. LD a3, 0 * SIZE(X)
  161. daddu X, X, INCX
  162. LD a4, 0 * SIZE(X)
  163. daddu X, X, INCX
  164. LD a5, 0 * SIZE(X)
  165. daddu X, X, INCX
  166. LD a6, 0 * SIZE(X)
  167. daddu X, X, INCX
  168. LD a7, 0 * SIZE(X)
  169. daddu X, X, INCX
  170. LD a8, 0 * SIZE(X)
  171. daddiu I, I, -1
  172. cvt.d.s t1, a1
  173. cvt.d.s t2, a2
  174. cvt.d.s t3, a3
  175. cvt.d.s t4, a4
  176. blez I, .L24
  177. daddu X, X, INCX
  178. .align 3
  179. .L23:
  180. madd.d s1, s1, t1, t1
  181. LD a1, 0 * SIZE(X)
  182. cvt.d.s t1, a5
  183. daddu X, X, INCX
  184. madd.d s2, s2, t2, t2
  185. LD a2, 0 * SIZE(X)
  186. cvt.d.s t2, a6
  187. daddu X, X, INCX
  188. madd.d s1, s1, t3, t3
  189. LD a3, 0 * SIZE(X)
  190. cvt.d.s t3, a7
  191. daddu X, X, INCX
  192. madd.d s2, s2, t4, t4
  193. LD a4, 0 * SIZE(X)
  194. cvt.d.s t4, a8
  195. daddu X, X, INCX
  196. madd.d s1, s1, t1, t1
  197. LD a5, 0 * SIZE(X)
  198. cvt.d.s t1, a1
  199. daddu X, X, INCX
  200. madd.d s2, s2, t2, t2
  201. LD a6, 0 * SIZE(X)
  202. cvt.d.s t2, a2
  203. daddu X, X, INCX
  204. madd.d s1, s1, t3, t3
  205. LD a7, 0 * SIZE(X)
  206. cvt.d.s t3, a3
  207. daddu X, X, INCX
  208. madd.d s2, s2, t4, t4
  209. LD a8, 0 * SIZE(X)
  210. cvt.d.s t4, a4
  211. daddiu I, I, -1
  212. bgtz I, .L23
  213. daddu X, X, INCX
  214. .align 3
  215. .L24:
  216. madd.d s1, s1, t1, t1
  217. cvt.d.s t1, a5
  218. madd.d s2, s2, t2, t2
  219. cvt.d.s t2, a6
  220. madd.d s1, s1, t3, t3
  221. cvt.d.s t3, a7
  222. madd.d s2, s2, t4, t4
  223. cvt.d.s t4, a8
  224. madd.d s1, s1, t1, t1
  225. madd.d s2, s2, t2, t2
  226. madd.d s1, s1, t3, t3
  227. madd.d s2, s2, t4, t4
  228. .align 3
  229. .L25:
  230. andi I, N, 7
  231. blez I, .L999
  232. NOP
  233. .align 3
  234. .L26:
  235. LD a1, 0 * SIZE(X)
  236. daddiu I, I, -1
  237. cvt.d.s t1, a1
  238. daddu X, X, INCX
  239. bgtz I, .L26
  240. madd.d s1, s1, t1, t1
  241. .align 3
  242. .L999:
  243. add.d s1, s1, s2
  244. sqrt.d s1, s1
  245. j $31
  246. cvt.s.d s1, s1
  247. EPILOGUE