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

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. EMMS
  87. pxor %mm0, %mm0
  88. cmpl $2 * SIZE, INCX
  89. jne .L20
  90. movl N, I
  91. sarl $2, I
  92. jle .L15
  93. ALIGN_4
  94. .L12:
  95. #ifdef XDOUBLE
  96. movq %mm0, 0(X)
  97. movq %mm0, 8(X)
  98. movq %mm0, 16(X)
  99. movq %mm0, 24(X)
  100. movq %mm0, 32(X)
  101. movq %mm0, 40(X)
  102. movq %mm0, 48(X)
  103. movq %mm0, 56(X)
  104. movq %mm0, 64(X)
  105. movq %mm0, 72(X)
  106. movq %mm0, 80(X)
  107. movq %mm0, 88(X)
  108. movq %mm0, 96(X)
  109. movq %mm0, 104(X)
  110. movq %mm0, 112(X)
  111. movq %mm0, 120(X)
  112. #elif defined(DOUBLE)
  113. movq %mm0, 0(X)
  114. movq %mm0, 8(X)
  115. movq %mm0, 16(X)
  116. movq %mm0, 24(X)
  117. movq %mm0, 32(X)
  118. movq %mm0, 40(X)
  119. movq %mm0, 48(X)
  120. movq %mm0, 56(X)
  121. #else
  122. movq %mm0, 0(X)
  123. movq %mm0, 8(X)
  124. movq %mm0, 16(X)
  125. movq %mm0, 24(X)
  126. #endif
  127. addl $8 * SIZE, X
  128. decl I
  129. jg .L12
  130. ALIGN_3
  131. .L15:
  132. movl N, I
  133. andl $3, I
  134. jle .L18
  135. ALIGN_2
  136. .L16:
  137. #ifdef XDOUBLE
  138. movq %mm0, 0(X)
  139. movq %mm0, 8(X)
  140. movq %mm0, 16(X)
  141. movq %mm0, 24(X)
  142. #elif defined(DOUBLE)
  143. movq %mm0, 0(X)
  144. movq %mm0, 8(X)
  145. #else
  146. movq %mm0, 0(X)
  147. #endif
  148. addl $2 * SIZE, X
  149. decl I
  150. jg .L16
  151. .L18:
  152. EMMS
  153. xorl %eax, %eax
  154. popl %ebx
  155. popl %esi
  156. ret
  157. ALIGN_2
  158. .L20:
  159. movl N, I
  160. sarl $2, I
  161. jle .L25
  162. ALIGN_3
  163. .L22:
  164. #ifdef XDOUBLE
  165. movq %mm0, 0(X)
  166. movq %mm0, 8(X)
  167. movq %mm0, 16(X)
  168. movq %mm0, 24(X)
  169. addl INCX, X
  170. movq %mm0, 0(X)
  171. movq %mm0, 8(X)
  172. movq %mm0, 16(X)
  173. movq %mm0, 24(X)
  174. addl INCX, X
  175. movq %mm0, 0(X)
  176. movq %mm0, 8(X)
  177. movq %mm0, 16(X)
  178. movq %mm0, 24(X)
  179. addl INCX, X
  180. movq %mm0, 0(X)
  181. movq %mm0, 8(X)
  182. movq %mm0, 16(X)
  183. movq %mm0, 24(X)
  184. addl INCX, X
  185. #elif defined(DOUBLE)
  186. movq %mm0, 0(X)
  187. movq %mm0, 8(X)
  188. addl INCX, X
  189. movq %mm0, 0(X)
  190. movq %mm0, 8(X)
  191. addl INCX, X
  192. movq %mm0, 0(X)
  193. movq %mm0, 8(X)
  194. addl INCX, X
  195. movq %mm0, 0(X)
  196. movq %mm0, 8(X)
  197. addl INCX, X
  198. #else
  199. movq %mm0, 0(X)
  200. addl INCX, X
  201. movq %mm0, 0(X)
  202. addl INCX, X
  203. movq %mm0, 0(X)
  204. addl INCX, X
  205. movq %mm0, 0(X)
  206. addl INCX, X
  207. #endif
  208. decl I
  209. jg .L22
  210. ALIGN_3
  211. .L25:
  212. movl N, I
  213. andl $3, I
  214. jle .L28
  215. ALIGN_3
  216. .L26:
  217. #ifdef XDOUBLE
  218. movq %mm0, 0(X)
  219. movq %mm0, 8(X)
  220. movq %mm0, 16(X)
  221. movq %mm0, 24(X)
  222. addl INCX, X
  223. #elif defined(DOUBLE)
  224. movq %mm0, 0(X)
  225. movq %mm0, 8(X)
  226. addl INCX, X
  227. #else
  228. movq %mm0, 0(X)
  229. addl INCX, X
  230. #endif
  231. decl I
  232. jg .L26
  233. .L28:
  234. EMMS
  235. xorl %eax, %eax
  236. popl %ebx
  237. popl %esi
  238. ret
  239. ALIGN_3
  240. .L30:
  241. movl N, I
  242. ALIGN_2
  243. .L32:
  244. FLD 0 * SIZE(X)
  245. fmul %st(1),%st
  246. FLD 1 * SIZE(X)
  247. fmul %st(3),%st
  248. faddp %st,%st(1)
  249. FLD 0 * SIZE(X)
  250. fmul %st(3),%st
  251. FLD 1 * SIZE(X)
  252. fmul %st(3),%st
  253. fsubrp %st,%st(1)
  254. FST 0 * SIZE(X)
  255. FST 1 * SIZE(X)
  256. addl INCX, X
  257. decl I
  258. jg .L32
  259. ALIGN_2
  260. .L999:
  261. ffreep %st(0)
  262. ffreep %st(0)
  263. xorl %eax,%eax
  264. popl %ebx
  265. popl %esi
  266. ret
  267. EPILOGUE