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.

zscal.S 6.3 kB

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