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.1 kB

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