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.

gemm_ncopy_2.S 6.6 kB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274
  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 8
  42. #define J 0 + STACK(%esp)
  43. #define M 4 + STACK + ARGS(%esp)
  44. #define N 8 + STACK + ARGS(%esp)
  45. #define A 12 + STACK + ARGS(%esp)
  46. #define LDA 16 + STACK + ARGS(%esp)
  47. #define B 20 + STACK + ARGS(%esp)
  48. PROLOGUE
  49. subl $ARGS, %esp
  50. pushl %ebp
  51. pushl %edi
  52. pushl %esi
  53. pushl %ebx
  54. PROFCODE
  55. EMMS
  56. movl B, %esi # ESI : offsetB
  57. movl M, %edi
  58. movl A, %ebx # EBX : offsetA
  59. movl LDA, %edx
  60. leal (%ebx, %edx, SIZE), %ebp
  61. addl %edx, %edx
  62. subl %edi, %edx # edx = 2 * lda - m
  63. movl N, %eax
  64. sarl $1, %eax
  65. movl %eax, J
  66. je .L20
  67. ALIGN_3
  68. .L21:
  69. #if 0
  70. movl %edi, %ecx # ECX : I(Counter of M)
  71. andl $-8, %ecx
  72. leal (%ebx, %ecx, SIZE), %ebx
  73. leal (%ebp, %ecx, SIZE), %ebp
  74. negl %ecx
  75. ALIGN_3
  76. .Blocking1:
  77. MMXLOAD (%ebx, %ecx, SIZE), %mm0
  78. MMXLOAD (%ebp, %ecx, SIZE), %mm1
  79. addl $8, %ecx
  80. jl .Blocking1
  81. movl %edi, %ecx # ECX : I(Counter of M)
  82. andl $-8, %ecx
  83. negl %ecx
  84. leal (%ebx, %ecx, SIZE), %ebx
  85. leal (%ebp, %ecx, SIZE), %ebp
  86. #endif
  87. movl %edi, %ecx # ECX : I(Counter of M)
  88. sarl $2, %ecx
  89. je .L24
  90. ALIGN_3
  91. .L25:
  92. #ifdef HAVE_MMX
  93. MMXLOAD 0 * SIZE(%ebx), %mm0
  94. MMXLOAD 0 * SIZE(%ebp), %mm1
  95. MMXLOAD 1 * SIZE(%ebx), %mm2
  96. MMXLOAD 1 * SIZE(%ebp), %mm3
  97. MMXLOAD 2 * SIZE(%ebx), %mm4
  98. MMXLOAD 2 * SIZE(%ebp), %mm5
  99. MMXLOAD 3 * SIZE(%ebx), %mm6
  100. MMXLOAD 3 * SIZE(%ebp), %mm7
  101. MMXSTORE %mm0, 0 * SIZE(%esi)
  102. MMXSTORE %mm1, 1 * SIZE(%esi)
  103. MMXSTORE %mm2, 2 * SIZE(%esi)
  104. MMXSTORE %mm3, 3 * SIZE(%esi)
  105. MMXSTORE %mm4, 4 * SIZE(%esi)
  106. MMXSTORE %mm5, 5 * SIZE(%esi)
  107. MMXSTORE %mm6, 6 * SIZE(%esi)
  108. MMXSTORE %mm7, 7 * SIZE(%esi)
  109. #else
  110. FLD 3 * SIZE(%ebp)
  111. FLD 3 * SIZE(%ebx)
  112. FLD 2 * SIZE(%ebp)
  113. FLD 2 * SIZE(%ebx)
  114. FLD 1 * SIZE(%ebp)
  115. FLD 1 * SIZE(%ebx)
  116. FLD 0 * SIZE(%ebp)
  117. FLD 0 * SIZE(%ebx)
  118. FST 0 * SIZE(%esi)
  119. FST 1 * SIZE(%esi)
  120. FST 2 * SIZE(%esi)
  121. FST 3 * SIZE(%esi)
  122. FST 4 * SIZE(%esi)
  123. FST 5 * SIZE(%esi)
  124. FST 6 * SIZE(%esi)
  125. FST 7 * SIZE(%esi)
  126. #endif
  127. addl $4 * SIZE, %ebx
  128. addl $4 * SIZE, %ebp
  129. addl $8 * SIZE, %esi
  130. decl %ecx
  131. jne .L25
  132. ALIGN_3
  133. .L24:
  134. movl %edi, %ecx
  135. andl $3, %ecx
  136. jle .L30
  137. ALIGN_3
  138. .L31:
  139. #ifdef HAVE_MMX
  140. MMXLOAD 0 * SIZE(%ebx), %mm0
  141. MMXLOAD 0 * SIZE(%ebp), %mm1
  142. MMXSTORE %mm0, 0 * SIZE(%esi)
  143. MMXSTORE %mm1, 1 * SIZE(%esi)
  144. #else
  145. FLD 0 * SIZE(%ebp)
  146. FLD 0 * SIZE(%ebx)
  147. FST 0 * SIZE(%esi)
  148. FST 1 * SIZE(%esi)
  149. #endif
  150. addl $1 * SIZE, %ebx
  151. addl $1 * SIZE, %ebp
  152. addl $2 * SIZE, %esi
  153. decl %ecx
  154. jne .L31
  155. ALIGN_3
  156. .L30:
  157. leal (%ebx, %edx, SIZE), %ebx
  158. leal (%ebp, %edx, SIZE), %ebp
  159. decl J
  160. jne .L21
  161. ALIGN_3
  162. .L20:
  163. movl N, %eax
  164. andl $1,%eax
  165. jle .L38
  166. ALIGN_3
  167. .L39:
  168. movl %edi, %ecx
  169. sarl $3, %ecx
  170. je .L42
  171. ALIGN_3
  172. .L43:
  173. #ifdef HAVE_MMX
  174. MMXLOAD 0 * SIZE(%ebx), %mm0
  175. MMXLOAD 1 * SIZE(%ebx), %mm1
  176. MMXLOAD 2 * SIZE(%ebx), %mm2
  177. MMXLOAD 3 * SIZE(%ebx), %mm3
  178. MMXLOAD 4 * SIZE(%ebx), %mm4
  179. MMXLOAD 5 * SIZE(%ebx), %mm5
  180. MMXLOAD 6 * SIZE(%ebx), %mm6
  181. MMXLOAD 7 * SIZE(%ebx), %mm7
  182. MMXSTORE %mm0, 0 * SIZE(%esi)
  183. MMXSTORE %mm1, 1 * SIZE(%esi)
  184. MMXSTORE %mm2, 2 * SIZE(%esi)
  185. MMXSTORE %mm3, 3 * SIZE(%esi)
  186. MMXSTORE %mm4, 4 * SIZE(%esi)
  187. MMXSTORE %mm5, 5 * SIZE(%esi)
  188. MMXSTORE %mm6, 6 * SIZE(%esi)
  189. MMXSTORE %mm7, 7 * SIZE(%esi)
  190. #else
  191. FLD 7 * SIZE(%ebx)
  192. FLD 6 * SIZE(%ebx)
  193. FLD 5 * SIZE(%ebx)
  194. FLD 4 * SIZE(%ebx)
  195. FLD 3 * SIZE(%ebx)
  196. FLD 2 * SIZE(%ebx)
  197. FLD 1 * SIZE(%ebx)
  198. FLD 0 * SIZE(%ebx)
  199. FST 0 * SIZE(%esi)
  200. FST 1 * SIZE(%esi)
  201. FST 2 * SIZE(%esi)
  202. FST 3 * SIZE(%esi)
  203. FST 4 * SIZE(%esi)
  204. FST 5 * SIZE(%esi)
  205. FST 6 * SIZE(%esi)
  206. FST 7 * SIZE(%esi)
  207. #endif
  208. addl $8 * SIZE, %ebx
  209. addl $8 * SIZE, %esi
  210. decl %ecx
  211. jne .L43
  212. ALIGN_3
  213. .L42:
  214. movl %edi, %ecx
  215. andl $7, %ecx
  216. jle .L38
  217. ALIGN_3
  218. .L49:
  219. #ifdef HAVE_MMX
  220. MMXLOAD 0 * SIZE(%ebx), %mm0
  221. MMXSTORE %mm0, 0 * SIZE(%esi)
  222. #else
  223. FLD 0 * SIZE(%ebx)
  224. FST 0 * SIZE(%esi)
  225. #endif
  226. addl $1 * SIZE, %ebx
  227. addl $1 * SIZE, %esi
  228. decl %ecx
  229. jne .L49
  230. ALIGN_3
  231. .L38:
  232. EMMS
  233. popl %ebx
  234. popl %esi
  235. popl %edi
  236. popl %ebp
  237. addl $ARGS, %esp
  238. ret
  239. EPILOGUE