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

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