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.

xdot.S 6.8 kB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339
  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 12
  41. #define ARGS 0
  42. #if defined(F_INTERFACE) && defined(RETURN_BY_STACK)
  43. #define RESULT 4 + STACK + ARGS(%esp)
  44. #define STACK_N 8 + STACK + ARGS(%esp)
  45. #define STACK_X 12 + STACK + ARGS(%esp)
  46. #define STACK_INCX 16 + STACK + ARGS(%esp)
  47. #define STACK_Y 20 + STACK + ARGS(%esp)
  48. #define STACK_INCY 24 + STACK + ARGS(%esp)
  49. #else
  50. #define STACK_N 4 + STACK + ARGS(%esp)
  51. #define STACK_X 8 + STACK + ARGS(%esp)
  52. #define STACK_INCX 12 + STACK + ARGS(%esp)
  53. #define STACK_Y 16 + STACK + ARGS(%esp)
  54. #define STACK_INCY 20 + STACK + ARGS(%esp)
  55. #endif
  56. PROLOGUE
  57. pushl %edi
  58. pushl %esi
  59. pushl %ebx
  60. PROFCODE
  61. #if defined(F_INTERFACE_GFORT) || defined(F_INTERFACE_G95)
  62. EMMS
  63. #endif
  64. #define N %ebx
  65. #define X %esi
  66. #define INCX %ecx
  67. #define Y %edi
  68. #define INCY %edx
  69. movl STACK_N, N
  70. movl STACK_X, X
  71. movl STACK_INCX, INCX
  72. movl STACK_Y, Y
  73. movl STACK_INCY, INCY
  74. #ifdef F_INTERFACE
  75. movl (N),N
  76. movl (INCX),INCX
  77. movl (INCY),INCY
  78. #endif
  79. testl N, N
  80. jle .L88
  81. sall $ZBASE_SHIFT, INCX
  82. sall $ZBASE_SHIFT, INCY
  83. fldz
  84. fldz
  85. fldz
  86. fldz
  87. cmpl $2 * SIZE, INCX
  88. jne .L14
  89. cmpl $2 * SIZE, INCY
  90. jne .L14
  91. movl N, %eax
  92. sarl $1, %eax
  93. jle .L15
  94. ALIGN_3
  95. .L16:
  96. FLD 0 * SIZE(X)
  97. FLD 0 * SIZE(Y)
  98. fmul %st(1)
  99. faddp %st, %st(2)
  100. FLD 1 * SIZE(Y)
  101. fmulp %st, %st(1)
  102. faddp %st, %st(2)
  103. FLD 1 * SIZE(X)
  104. FLD 0 * SIZE(Y)
  105. fmul %st(1)
  106. faddp %st, %st(4)
  107. FLD 1 * SIZE(Y)
  108. fmulp %st, %st(1)
  109. faddp %st, %st(4)
  110. FLD 2 * SIZE(X)
  111. FLD 2 * SIZE(Y)
  112. fmul %st(1)
  113. faddp %st, %st(2)
  114. FLD 3 * SIZE(Y)
  115. fmulp %st, %st(1)
  116. faddp %st, %st(2)
  117. FLD 3 * SIZE(X)
  118. FLD 2 * SIZE(Y)
  119. fmul %st(1)
  120. faddp %st, %st(4)
  121. FLD 3 * SIZE(Y)
  122. fmulp %st, %st(1)
  123. faddp %st, %st(4)
  124. addl $4 * SIZE, X
  125. addl $4 * SIZE, Y
  126. decl %eax
  127. jg .L16
  128. ALIGN_3
  129. .L15:
  130. movl N, %eax
  131. andl $1, %eax
  132. jle .L27
  133. ALIGN_3
  134. .L22:
  135. FLD 0 * SIZE(X)
  136. FLD 0 * SIZE(Y)
  137. fmul %st(1)
  138. faddp %st, %st(2)
  139. FLD 1 * SIZE(Y)
  140. fmulp %st, %st(1)
  141. faddp %st, %st(2)
  142. FLD 1 * SIZE(X)
  143. FLD 0 * SIZE(Y)
  144. fmul %st(1)
  145. faddp %st, %st(4)
  146. FLD 1 * SIZE(Y)
  147. fmulp %st, %st(1)
  148. faddp %st, %st(4)
  149. jmp .L27
  150. ALIGN_3
  151. .L14:
  152. #ifdef F_INTERFACE
  153. testl INCX, INCX # if (incx < 0)
  154. jge .L28
  155. movl N, %eax
  156. decl %eax
  157. imull INCX, %eax
  158. subl %eax, X
  159. ALIGN_3
  160. .L28:
  161. testl INCY, INCY # if (incy < 0)
  162. jge .L29
  163. movl N, %eax
  164. decl %eax
  165. imull INCY, %eax
  166. subl %eax, Y
  167. ALIGN_3
  168. .L29:
  169. #endif
  170. movl N, %eax
  171. sarl $1, %eax
  172. jle .L30
  173. ALIGN_3
  174. .L31:
  175. FLD 0 * SIZE(X)
  176. FLD 0 * SIZE(Y)
  177. fmul %st(1)
  178. faddp %st, %st(2)
  179. FLD 1 * SIZE(Y)
  180. fmulp %st, %st(1)
  181. faddp %st, %st(2)
  182. FLD 1 * SIZE(X)
  183. FLD 0 * SIZE(Y)
  184. fmul %st(1)
  185. faddp %st, %st(4)
  186. FLD 1 * SIZE(Y)
  187. fmulp %st, %st(1)
  188. faddp %st, %st(4)
  189. addl INCX, X
  190. FLD 0 * SIZE(X)
  191. addl INCY, Y
  192. FLD 0 * SIZE(Y)
  193. fmul %st(1)
  194. faddp %st, %st(2)
  195. FLD 1 * SIZE(Y)
  196. fmulp %st, %st(1)
  197. faddp %st, %st(2)
  198. FLD 1 * SIZE(X)
  199. FLD 0 * SIZE(Y)
  200. fmul %st(1)
  201. faddp %st, %st(4)
  202. FLD 1 * SIZE(Y)
  203. fmulp %st, %st(1)
  204. faddp %st, %st(4)
  205. addl INCX, X
  206. addl INCY, Y
  207. decl %eax
  208. jg .L31
  209. ALIGN_3
  210. .L30:
  211. movl N, %eax
  212. andl $1, %eax
  213. jle .L27
  214. ALIGN_3
  215. .L37:
  216. FLD 0 * SIZE(X)
  217. FLD 0 * SIZE(Y)
  218. fmul %st(1)
  219. faddp %st, %st(2)
  220. FLD 1 * SIZE(Y)
  221. fmulp %st, %st(1)
  222. faddp %st, %st(2)
  223. FLD 1 * SIZE(X)
  224. FLD 0 * SIZE(Y)
  225. fmul %st(1)
  226. faddp %st, %st(4)
  227. FLD 1 * SIZE(Y)
  228. fmulp %st, %st(1)
  229. faddp %st, %st(4)
  230. ALIGN_3
  231. .L27:
  232. #if defined(F_INTERFACE) && defined(RETURN_BY_STACK)
  233. movl RESULT, %eax
  234. #endif
  235. #ifndef CONJ
  236. fsubp %st, %st(3)
  237. faddp %st, %st(1)
  238. #else
  239. faddp %st, %st(3)
  240. fsubp %st, %st(1)
  241. #endif
  242. #if defined(F_INTERFACE) && defined(RETURN_BY_STACK)
  243. FST 1 * SIZE(%eax)
  244. FST 0 * SIZE(%eax)
  245. #else
  246. fxch %st(1)
  247. #endif
  248. popl %ebx
  249. popl %esi
  250. popl %edi
  251. #if defined(F_INTERFACE) && defined(RETURN_BY_STACK)
  252. ret $0x4
  253. #else
  254. ret
  255. #endif
  256. ALIGN_3
  257. .L88:
  258. #if defined(F_INTERFACE) && defined(RETURN_BY_STACK)
  259. movl RESULT, %eax
  260. #endif
  261. fldz
  262. fldz
  263. #if defined(F_INTERFACE) && defined(RETURN_BY_STACK)
  264. FST 1 * SIZE(%eax)
  265. FST 0 * SIZE(%eax)
  266. #endif
  267. popl %ebx
  268. popl %esi
  269. popl %edi
  270. #if defined(F_INTERFACE) && defined(RETURN_BY_STACK)
  271. ret $0x4
  272. #else
  273. ret
  274. #endif
  275. EPILOGUE