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.

dot.S 8.2 kB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459
  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 Y $7
  44. #define INCY $8
  45. #define I $2
  46. #define TEMP $3
  47. #define a1 $f2
  48. #define a2 $f3
  49. #define a3 $f4
  50. #define a4 $f5
  51. #define b1 $f6
  52. #define b2 $f7
  53. #define b3 $f8
  54. #define b4 $f9
  55. #define s1 $f0
  56. #define s2 $f1
  57. PROLOGUE
  58. #ifdef F_INTERFACE
  59. LDINT N, 0(N)
  60. LDINT INCX, 0(INCX)
  61. LDINT INCY, 0(INCY)
  62. #endif
  63. MTC $0, s1
  64. MTC $0, s2
  65. dsll INCX, INCX, BASE_SHIFT
  66. li TEMP, SIZE
  67. blez N, .L999
  68. dsll INCY, INCY, BASE_SHIFT
  69. bne INCX, TEMP, .L20
  70. dsra I, N, 3
  71. bne INCY, TEMP, .L20
  72. NOP
  73. blez I, .L15
  74. NOP
  75. LD a1, 0 * SIZE(X)
  76. LD b1, 0 * SIZE(Y)
  77. LD a2, 1 * SIZE(X)
  78. LD b2, 1 * SIZE(Y)
  79. LD a3, 2 * SIZE(X)
  80. LD b3, 2 * SIZE(Y)
  81. LD a4, 3 * SIZE(X)
  82. daddiu I, I, -1
  83. blez I, .L13
  84. LD b4, 3 * SIZE(Y)
  85. .align 3
  86. .L12:
  87. #ifdef DSDOT
  88. cvt.d.s a1, a1
  89. cvt.d.s b1, b1
  90. madd.d s1, s1, a1, b1
  91. #else
  92. MADD s1, s1, a1, b1
  93. #endif
  94. LD a1, 4 * SIZE(X)
  95. LD b1, 4 * SIZE(Y)
  96. #ifdef DSDOT
  97. cvt.d.s a2, a2
  98. cvt.d.s b2, b2
  99. madd.d s2, s2, a2, b2
  100. #else
  101. MADD s2, s2, a2, b2
  102. #endif
  103. LD a2, 5 * SIZE(X)
  104. LD b2, 5 * SIZE(Y)
  105. #ifdef DSDOT
  106. cvt.d.s a3, a3
  107. cvt.d.s b3, b3
  108. madd.d s1, s1, a3, b3
  109. #else
  110. MADD s1, s1, a3, b3
  111. #endif
  112. LD a3, 6 * SIZE(X)
  113. LD b3, 6 * SIZE(Y)
  114. #ifdef DSDOT
  115. cvt.d.s a4, a4
  116. cvt.d.s b4, b4
  117. madd.d s2, s2, a4, b4
  118. #else
  119. MADD s2, s2, a4, b4
  120. #endif
  121. LD a4, 7 * SIZE(X)
  122. LD b4, 7 * SIZE(Y)
  123. #ifdef DSDOT
  124. cvt.d.s a1, a1
  125. cvt.d.s b1, b1
  126. madd.d s1, s1, a1, b1
  127. #else
  128. MADD s1, s1, a1, b1
  129. #endif
  130. LD a1, 8 * SIZE(X)
  131. LD b1, 8 * SIZE(Y)
  132. #ifdef DSDOT
  133. cvt.d.s a2, a2
  134. cvt.d.s b2, b2
  135. madd.d s2, s2, a2, b2
  136. #else
  137. MADD s2, s2, a2, b2
  138. #endif
  139. LD a2, 9 * SIZE(X)
  140. LD b2, 9 * SIZE(Y)
  141. #ifdef DSDOT
  142. cvt.d.s a3, a3
  143. cvt.d.s b3, b3
  144. madd.d s1, s1, a3, b3
  145. #else
  146. MADD s1, s1, a3, b3
  147. #endif
  148. LD a3, 10 * SIZE(X)
  149. LD b3, 10 * SIZE(Y)
  150. #ifdef DSDOT
  151. cvt.d.s a4, a4
  152. cvt.d.s b4, b4
  153. madd.d s2, s2, a4, b4
  154. #else
  155. MADD s2, s2, a4, b4
  156. #endif
  157. LD a4, 11 * SIZE(X)
  158. LD b4, 11 * SIZE(Y)
  159. daddiu I, I, -1
  160. daddiu X, X, 8 * SIZE
  161. bgtz I, .L12
  162. daddiu Y, Y, 8 * SIZE
  163. .align 3
  164. .L13:
  165. #ifdef DSDOT
  166. cvt.d.s a1, a1
  167. cvt.d.s b1, b1
  168. madd.d s1, s1, a1, b1
  169. #else
  170. MADD s1, s1, a1, b1
  171. #endif
  172. LD a1, 4 * SIZE(X)
  173. LD b1, 4 * SIZE(Y)
  174. #ifdef DSDOT
  175. cvt.d.s a2, a2
  176. cvt.d.s b2, b2
  177. madd.d s2, s2, a2, b2
  178. #else
  179. MADD s2, s2, a2, b2
  180. #endif
  181. LD a2, 5 * SIZE(X)
  182. LD b2, 5 * SIZE(Y)
  183. #ifdef DSDOT
  184. cvt.d.s a3, a3
  185. cvt.d.s b3, b3
  186. madd.d s1, s1, a3, b3
  187. #else
  188. MADD s1, s1, a3, b3
  189. #endif
  190. LD a3, 6 * SIZE(X)
  191. LD b3, 6 * SIZE(Y)
  192. #ifdef DSDOT
  193. cvt.d.s a4, a4
  194. cvt.d.s b4, b4
  195. madd.d s2, s2, a4, b4
  196. #else
  197. MADD s2, s2, a4, b4
  198. #endif
  199. LD a4, 7 * SIZE(X)
  200. LD b4, 7 * SIZE(Y)
  201. #ifdef DSDOT
  202. cvt.d.s a1, a1
  203. cvt.d.s b1, b1
  204. madd.d s1, s1, a1, b1
  205. #else
  206. MADD s1, s1, a1, b1
  207. #endif
  208. daddiu X, X, 8 * SIZE
  209. #ifdef DSDOT
  210. cvt.d.s a2, a2
  211. cvt.d.s b2, b2
  212. madd.d s2, s2, a2, b2
  213. #else
  214. MADD s2, s2, a2, b2
  215. #endif
  216. daddiu Y, Y, 8 * SIZE
  217. #ifdef DSDOT
  218. cvt.d.s a3, a3
  219. cvt.d.s b3, b3
  220. madd.d s1, s1, a3, b3
  221. #else
  222. MADD s1, s1, a3, b3
  223. #endif
  224. #ifdef DSDOT
  225. cvt.d.s a4, a4
  226. cvt.d.s b4, b4
  227. madd.d s2, s2, a4, b4
  228. #else
  229. MADD s2, s2, a4, b4
  230. #endif
  231. .align 3
  232. .L15:
  233. andi I, N, 7
  234. blez I, .L999
  235. NOP
  236. .align 3
  237. .L16:
  238. LD a1, 0 * SIZE(X)
  239. LD b1, 0 * SIZE(Y)
  240. #ifdef DSDOT
  241. cvt.d.s a1, a1
  242. cvt.d.s b1, b1
  243. madd.d s1, s1, a1, b1
  244. #else
  245. MADD s1, s1, a1, b1
  246. #endif
  247. daddiu I, I, -1
  248. daddiu X, X, SIZE
  249. daddiu Y, Y, SIZE
  250. bgtz I, .L16
  251. NOP
  252. j .L999
  253. NOP
  254. .align 3
  255. .L20:
  256. #ifdef F_INTERFACE
  257. bgez INCX, .L21
  258. daddiu TEMP, N, -1
  259. mult TEMP, INCX
  260. mflo TEMP
  261. dsub X, X, TEMP
  262. .align 3
  263. .L21:
  264. bgez INCY, .L22
  265. daddiu TEMP, N, -1
  266. mult TEMP, INCY
  267. mflo TEMP
  268. dsub Y, Y, TEMP
  269. .align 3
  270. .L22:
  271. #endif
  272. blez I, .L25
  273. NOP
  274. .align 3
  275. .L23:
  276. LD a1, 0 * SIZE(X)
  277. dadd X, X, INCX
  278. LD b1, 0 * SIZE(Y)
  279. dadd Y, Y, INCY
  280. #ifdef DSDOT
  281. cvt.d.s a1, a1
  282. cvt.d.s b1, b1
  283. madd.d s1, s1, a1, b1
  284. #else
  285. MADD s1, s1, a1, b1
  286. #endif
  287. LD a1, 0 * SIZE(X)
  288. dadd X, X, INCX
  289. LD b1, 0 * SIZE(Y)
  290. dadd Y, Y, INCY
  291. #ifdef DSDOT
  292. cvt.d.s a1, a1
  293. cvt.d.s b1, b1
  294. madd.d s2, s2, a1, b1
  295. #else
  296. MADD s2, s2, a1, b1
  297. #endif
  298. LD a1, 0 * SIZE(X)
  299. dadd X, X, INCX
  300. LD b1, 0 * SIZE(Y)
  301. dadd Y, Y, INCY
  302. #ifdef DSDOT
  303. cvt.d.s a1, a1
  304. cvt.d.s b1, b1
  305. madd.d s1, s1, a1, b1
  306. #else
  307. MADD s1, s1, a1, b1
  308. #endif
  309. LD a1, 0 * SIZE(X)
  310. dadd X, X, INCX
  311. LD b1, 0 * SIZE(Y)
  312. dadd Y, Y, INCY
  313. #ifdef DSDOT
  314. cvt.d.s a1, a1
  315. cvt.d.s b1, b1
  316. madd.d s2, s2, a1, b1
  317. #else
  318. MADD s2, s2, a1, b1
  319. #endif
  320. LD a1, 0 * SIZE(X)
  321. dadd X, X, INCX
  322. LD b1, 0 * SIZE(Y)
  323. dadd Y, Y, INCY
  324. #ifdef DSDOT
  325. cvt.d.s a1, a1
  326. cvt.d.s b1, b1
  327. madd.d s1, s1, a1, b1
  328. #else
  329. MADD s1, s1, a1, b1
  330. #endif
  331. LD a1, 0 * SIZE(X)
  332. dadd X, X, INCX
  333. LD b1, 0 * SIZE(Y)
  334. dadd Y, Y, INCY
  335. #ifdef DSDOT
  336. cvt.d.s a1, a1
  337. cvt.d.s b1, b1
  338. madd.d s2, s2, a1, b1
  339. #else
  340. MADD s2, s2, a1, b1
  341. #endif
  342. LD a1, 0 * SIZE(X)
  343. dadd X, X, INCX
  344. LD b1, 0 * SIZE(Y)
  345. dadd Y, Y, INCY
  346. #ifdef DSDOT
  347. cvt.d.s a1, a1
  348. cvt.d.s b1, b1
  349. madd.d s1, s1, a1, b1
  350. #else
  351. MADD s1, s1, a1, b1
  352. #endif
  353. LD a1, 0 * SIZE(X)
  354. dadd X, X, INCX
  355. LD b1, 0 * SIZE(Y)
  356. dadd Y, Y, INCY
  357. daddiu I, I, -1
  358. bgtz I, .L23
  359. #ifdef DSDOT
  360. cvt.d.s a1, a1
  361. cvt.d.s b1, b1
  362. madd.d s2, s2, a1, b1
  363. #else
  364. MADD s2, s2, a1, b1
  365. #endif
  366. .align 3
  367. .L25:
  368. andi I, N, 7
  369. blez I, .L999
  370. NOP
  371. .align 3
  372. .L26:
  373. LD a1, 0 * SIZE(X)
  374. dadd X, X, INCX
  375. LD b1, 0 * SIZE(Y)
  376. dadd Y, Y, INCY
  377. daddiu I, I, -1
  378. bgtz I, .L26
  379. #ifdef DSDOT
  380. cvt.d.s a1, a1
  381. cvt.d.s b1, b1
  382. madd.d s1, s1, a1, b1
  383. #else
  384. MADD s1, s1, a1, b1
  385. #endif
  386. .align 3
  387. .L999:
  388. #ifdef DSDOT
  389. add.d s1, s1, s2
  390. #else
  391. ADD s1, s1, s2
  392. #endif
  393. j $31
  394. NOP
  395. EPILOGUE