mul_amd64.s 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168
  1. // Copyright 2012 The Go Authors. All rights reserved.
  2. // Use of this source code is governed by a BSD-style
  3. // license that can be found in the LICENSE file.
  4. // This code was translated into a form compatible with 6a from the public
  5. // domain sources in SUPERCOP: http://bench.cr.yp.to/supercop.html
  6. // +build amd64,!gccgo,!appengine
  7. // func mul(dest, a, b *[5]uint64)
  8. TEXT ·mul(SB),0,$16-24
  9. MOVQ dest+0(FP), DI
  10. MOVQ a+8(FP), SI
  11. MOVQ b+16(FP), DX
  12. MOVQ DX,CX
  13. MOVQ 24(SI),DX
  14. IMUL3Q $19,DX,AX
  15. MOVQ AX,0(SP)
  16. MULQ 16(CX)
  17. MOVQ AX,R8
  18. MOVQ DX,R9
  19. MOVQ 32(SI),DX
  20. IMUL3Q $19,DX,AX
  21. MOVQ AX,8(SP)
  22. MULQ 8(CX)
  23. ADDQ AX,R8
  24. ADCQ DX,R9
  25. MOVQ 0(SI),AX
  26. MULQ 0(CX)
  27. ADDQ AX,R8
  28. ADCQ DX,R9
  29. MOVQ 0(SI),AX
  30. MULQ 8(CX)
  31. MOVQ AX,R10
  32. MOVQ DX,R11
  33. MOVQ 0(SI),AX
  34. MULQ 16(CX)
  35. MOVQ AX,R12
  36. MOVQ DX,R13
  37. MOVQ 0(SI),AX
  38. MULQ 24(CX)
  39. MOVQ AX,R14
  40. MOVQ DX,R15
  41. MOVQ 0(SI),AX
  42. MULQ 32(CX)
  43. MOVQ AX,BX
  44. MOVQ DX,BP
  45. MOVQ 8(SI),AX
  46. MULQ 0(CX)
  47. ADDQ AX,R10
  48. ADCQ DX,R11
  49. MOVQ 8(SI),AX
  50. MULQ 8(CX)
  51. ADDQ AX,R12
  52. ADCQ DX,R13
  53. MOVQ 8(SI),AX
  54. MULQ 16(CX)
  55. ADDQ AX,R14
  56. ADCQ DX,R15
  57. MOVQ 8(SI),AX
  58. MULQ 24(CX)
  59. ADDQ AX,BX
  60. ADCQ DX,BP
  61. MOVQ 8(SI),DX
  62. IMUL3Q $19,DX,AX
  63. MULQ 32(CX)
  64. ADDQ AX,R8
  65. ADCQ DX,R9
  66. MOVQ 16(SI),AX
  67. MULQ 0(CX)
  68. ADDQ AX,R12
  69. ADCQ DX,R13
  70. MOVQ 16(SI),AX
  71. MULQ 8(CX)
  72. ADDQ AX,R14
  73. ADCQ DX,R15
  74. MOVQ 16(SI),AX
  75. MULQ 16(CX)
  76. ADDQ AX,BX
  77. ADCQ DX,BP
  78. MOVQ 16(SI),DX
  79. IMUL3Q $19,DX,AX
  80. MULQ 24(CX)
  81. ADDQ AX,R8
  82. ADCQ DX,R9
  83. MOVQ 16(SI),DX
  84. IMUL3Q $19,DX,AX
  85. MULQ 32(CX)
  86. ADDQ AX,R10
  87. ADCQ DX,R11
  88. MOVQ 24(SI),AX
  89. MULQ 0(CX)
  90. ADDQ AX,R14
  91. ADCQ DX,R15
  92. MOVQ 24(SI),AX
  93. MULQ 8(CX)
  94. ADDQ AX,BX
  95. ADCQ DX,BP
  96. MOVQ 0(SP),AX
  97. MULQ 24(CX)
  98. ADDQ AX,R10
  99. ADCQ DX,R11
  100. MOVQ 0(SP),AX
  101. MULQ 32(CX)
  102. ADDQ AX,R12
  103. ADCQ DX,R13
  104. MOVQ 32(SI),AX
  105. MULQ 0(CX)
  106. ADDQ AX,BX
  107. ADCQ DX,BP
  108. MOVQ 8(SP),AX
  109. MULQ 16(CX)
  110. ADDQ AX,R10
  111. ADCQ DX,R11
  112. MOVQ 8(SP),AX
  113. MULQ 24(CX)
  114. ADDQ AX,R12
  115. ADCQ DX,R13
  116. MOVQ 8(SP),AX
  117. MULQ 32(CX)
  118. ADDQ AX,R14
  119. ADCQ DX,R15
  120. MOVQ ·REDMASK51(SB),SI
  121. SHLQ $13,R9:R8
  122. ANDQ SI,R8
  123. SHLQ $13,R11:R10
  124. ANDQ SI,R10
  125. ADDQ R9,R10
  126. SHLQ $13,R13:R12
  127. ANDQ SI,R12
  128. ADDQ R11,R12
  129. SHLQ $13,R15:R14
  130. ANDQ SI,R14
  131. ADDQ R13,R14
  132. SHLQ $13,BP:BX
  133. ANDQ SI,BX
  134. ADDQ R15,BX
  135. IMUL3Q $19,BP,DX
  136. ADDQ DX,R8
  137. MOVQ R8,DX
  138. SHRQ $51,DX
  139. ADDQ R10,DX
  140. MOVQ DX,CX
  141. SHRQ $51,DX
  142. ANDQ SI,R8
  143. ADDQ R12,DX
  144. MOVQ DX,R9
  145. SHRQ $51,DX
  146. ANDQ SI,CX
  147. ADDQ R14,DX
  148. MOVQ DX,AX
  149. SHRQ $51,DX
  150. ANDQ SI,R9
  151. ADDQ BX,DX
  152. MOVQ DX,R10
  153. SHRQ $51,DX
  154. ANDQ SI,AX
  155. IMUL3Q $19,DX,DX
  156. ADDQ DX,R8
  157. ANDQ SI,R10
  158. MOVQ R8,0(DI)
  159. MOVQ CX,8(DI)
  160. MOVQ R9,16(DI)
  161. MOVQ AX,24(DI)
  162. MOVQ R10,32(DI)
  163. RET