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 6.0 kB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352
  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 M ARG1
  41. #define X ARG2
  42. #define INCX ARG3
  43. #define RET %rax
  44. #define I ARG4
  45. #define NUM %r10
  46. #ifndef USE_MIN
  47. #define FMOV fcmovbe
  48. #define IMOV cmovnbe
  49. #else
  50. #define FMOV fcmovnbe
  51. #define IMOV cmovb
  52. #endif
  53. #include "l1param.h"
  54. PROLOGUE
  55. PROFCODE
  56. salq $BASE_SHIFT, INCX
  57. fldz
  58. xorq RET, RET
  59. testq M, M
  60. jle .L999
  61. testq INCX, INCX
  62. jle .L999
  63. ffreep %st
  64. movq $2, NUM
  65. movq $1, RET
  66. FLD (X)
  67. #ifdef USE_ABS
  68. fabs
  69. #endif
  70. addq INCX, X
  71. decq M
  72. jle .L999
  73. cmpq $SIZE, INCX
  74. jne .L40
  75. movq M, I
  76. sarq $3, I
  77. jle .L20
  78. ALIGN_4
  79. .L10:
  80. #ifdef PREFETCH
  81. PREFETCH (PREFETCHSIZE + 0) - PREOFFSET(X)
  82. #endif
  83. FLD 0 * SIZE(X)
  84. #ifdef USE_ABS
  85. fabs
  86. #endif
  87. fcomi
  88. FMOV %st(1), %st(0)
  89. IMOV NUM, RET
  90. fxch %st(1)
  91. ffreep %st
  92. incq NUM
  93. FLD 1 * SIZE(X)
  94. #ifdef USE_ABS
  95. fabs
  96. #endif
  97. fcomi
  98. FMOV %st(1), %st(0)
  99. IMOV NUM, RET
  100. fxch %st(1)
  101. ffreep %st
  102. incq NUM
  103. FLD 2 * SIZE(X)
  104. #ifdef USE_ABS
  105. fabs
  106. #endif
  107. fcomi
  108. FMOV %st(1), %st(0)
  109. IMOV NUM, RET
  110. fxch %st(1)
  111. ffreep %st
  112. incq NUM
  113. FLD 3 * SIZE(X)
  114. #ifdef USE_ABS
  115. fabs
  116. #endif
  117. fcomi
  118. FMOV %st(1), %st(0)
  119. IMOV NUM, RET
  120. fxch %st(1)
  121. ffreep %st
  122. incq NUM
  123. FLD 4 * SIZE(X)
  124. #ifdef USE_ABS
  125. fabs
  126. #endif
  127. fcomi
  128. FMOV %st(1), %st(0)
  129. IMOV NUM, RET
  130. fxch %st(1)
  131. ffreep %st
  132. incq NUM
  133. FLD 5 * SIZE(X)
  134. #ifdef USE_ABS
  135. fabs
  136. #endif
  137. fcomi
  138. FMOV %st(1), %st(0)
  139. IMOV NUM, RET
  140. fxch %st(1)
  141. ffreep %st
  142. incq NUM
  143. FLD 6 * SIZE(X)
  144. #ifdef USE_ABS
  145. fabs
  146. #endif
  147. fcomi
  148. FMOV %st(1), %st(0)
  149. IMOV NUM, RET
  150. fxch %st(1)
  151. ffreep %st
  152. incq NUM
  153. FLD 7 * SIZE(X)
  154. #ifdef USE_ABS
  155. fabs
  156. #endif
  157. fcomi
  158. FMOV %st(1), %st(0)
  159. IMOV NUM, RET
  160. fxch %st(1)
  161. ffreep %st
  162. incq NUM
  163. addq $8 * SIZE, X
  164. decq I
  165. jg .L10
  166. ALIGN_4
  167. .L20:
  168. movq M, I
  169. andq $7, I
  170. jle .L999
  171. ALIGN_4
  172. .L21:
  173. FLD 0 * SIZE(X)
  174. #ifdef USE_ABS
  175. fabs
  176. #endif
  177. fcomi
  178. FMOV %st(1), %st(0)
  179. IMOV NUM, RET
  180. fxch %st(1)
  181. ffreep %st
  182. addq $1 * SIZE, X
  183. incq NUM
  184. decq I
  185. jg .L21
  186. jmp .L999
  187. ALIGN_4
  188. .L40:
  189. movq M, I
  190. sarq $3, I
  191. jle .L60
  192. ALIGN_4
  193. .L50:
  194. FLD 0 * SIZE(X)
  195. addq INCX, X
  196. #ifdef USE_ABS
  197. fabs
  198. #endif
  199. fcomi
  200. FMOV %st(1), %st(0)
  201. IMOV NUM, RET
  202. fxch %st(1)
  203. ffreep %st
  204. incq NUM
  205. FLD 0 * SIZE(X)
  206. addq INCX, X
  207. #ifdef USE_ABS
  208. fabs
  209. #endif
  210. fcomi
  211. FMOV %st(1), %st(0)
  212. IMOV NUM, RET
  213. fxch %st(1)
  214. ffreep %st
  215. incq NUM
  216. FLD 0 * SIZE(X)
  217. addq INCX, X
  218. #ifdef USE_ABS
  219. fabs
  220. #endif
  221. fcomi
  222. FMOV %st(1), %st(0)
  223. IMOV NUM, RET
  224. fxch %st(1)
  225. ffreep %st
  226. incq NUM
  227. FLD 0 * SIZE(X)
  228. addq INCX, X
  229. #ifdef USE_ABS
  230. fabs
  231. #endif
  232. fcomi
  233. FMOV %st(1), %st(0)
  234. IMOV NUM, RET
  235. fxch %st(1)
  236. ffreep %st
  237. incq NUM
  238. FLD 0 * SIZE(X)
  239. addq INCX, X
  240. #ifdef USE_ABS
  241. fabs
  242. #endif
  243. fcomi
  244. FMOV %st(1), %st(0)
  245. IMOV NUM, RET
  246. fxch %st(1)
  247. ffreep %st
  248. incq NUM
  249. FLD 0 * SIZE(X)
  250. addq INCX, X
  251. #ifdef USE_ABS
  252. fabs
  253. #endif
  254. fcomi
  255. FMOV %st(1), %st(0)
  256. IMOV NUM, RET
  257. fxch %st(1)
  258. ffreep %st
  259. incq NUM
  260. FLD 0 * SIZE(X)
  261. addq INCX, X
  262. #ifdef USE_ABS
  263. fabs
  264. #endif
  265. fcomi
  266. FMOV %st(1), %st(0)
  267. IMOV NUM, RET
  268. fxch %st(1)
  269. ffreep %st
  270. incq NUM
  271. FLD 0 * SIZE(X)
  272. addq INCX, X
  273. #ifdef USE_ABS
  274. fabs
  275. #endif
  276. fcomi
  277. FMOV %st(1), %st(0)
  278. IMOV NUM, RET
  279. fxch %st(1)
  280. ffreep %st
  281. incq NUM
  282. decq I
  283. jg .L50
  284. ALIGN_4
  285. .L60:
  286. movq M, I
  287. andq $7, I
  288. jle .L999
  289. ALIGN_4
  290. .L61:
  291. FLD 0 * SIZE(X)
  292. #ifdef USE_ABS
  293. fabs
  294. #endif
  295. fcomi
  296. FMOV %st(1), %st(0)
  297. IMOV NUM, RET
  298. fxch %st(1)
  299. ffreep %st
  300. incq NUM
  301. addq INCX, X
  302. decq I
  303. jg .L61
  304. ALIGN_4
  305. .L999:
  306. ffreep %st
  307. ret
  308. EPILOGUE