You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

169 lines
2.5 KiB

  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: https://bench.cr.yp.to/supercop.html
  6. // +build amd64,!gccgo,!appengine
  7. #include "const_amd64.h"
  8. // func mul(dest, a, b *[5]uint64)
  9. TEXT ·mul(SB),0,$16-24
  10. MOVQ dest+0(FP), DI
  11. MOVQ a+8(FP), SI
  12. MOVQ b+16(FP), DX
  13. MOVQ DX,CX
  14. MOVQ 24(SI),DX
  15. IMUL3Q $19,DX,AX
  16. MOVQ AX,0(SP)
  17. MULQ 16(CX)
  18. MOVQ AX,R8
  19. MOVQ DX,R9
  20. MOVQ 32(SI),DX
  21. IMUL3Q $19,DX,AX
  22. MOVQ AX,8(SP)
  23. MULQ 8(CX)
  24. ADDQ AX,R8
  25. ADCQ DX,R9
  26. MOVQ 0(SI),AX
  27. MULQ 0(CX)
  28. ADDQ AX,R8
  29. ADCQ DX,R9
  30. MOVQ 0(SI),AX
  31. MULQ 8(CX)
  32. MOVQ AX,R10
  33. MOVQ DX,R11
  34. MOVQ 0(SI),AX
  35. MULQ 16(CX)
  36. MOVQ AX,R12
  37. MOVQ DX,R13
  38. MOVQ 0(SI),AX
  39. MULQ 24(CX)
  40. MOVQ AX,R14
  41. MOVQ DX,R15
  42. MOVQ 0(SI),AX
  43. MULQ 32(CX)
  44. MOVQ AX,BX
  45. MOVQ DX,BP
  46. MOVQ 8(SI),AX
  47. MULQ 0(CX)
  48. ADDQ AX,R10
  49. ADCQ DX,R11
  50. MOVQ 8(SI),AX
  51. MULQ 8(CX)
  52. ADDQ AX,R12
  53. ADCQ DX,R13
  54. MOVQ 8(SI),AX
  55. MULQ 16(CX)
  56. ADDQ AX,R14
  57. ADCQ DX,R15
  58. MOVQ 8(SI),AX
  59. MULQ 24(CX)
  60. ADDQ AX,BX
  61. ADCQ DX,BP
  62. MOVQ 8(SI),DX
  63. IMUL3Q $19,DX,AX
  64. MULQ 32(CX)
  65. ADDQ AX,R8
  66. ADCQ DX,R9
  67. MOVQ 16(SI),AX
  68. MULQ 0(CX)
  69. ADDQ AX,R12
  70. ADCQ DX,R13
  71. MOVQ 16(SI),AX
  72. MULQ 8(CX)
  73. ADDQ AX,R14
  74. ADCQ DX,R15
  75. MOVQ 16(SI),AX
  76. MULQ 16(CX)
  77. ADDQ AX,BX
  78. ADCQ DX,BP
  79. MOVQ 16(SI),DX
  80. IMUL3Q $19,DX,AX
  81. MULQ 24(CX)
  82. ADDQ AX,R8
  83. ADCQ DX,R9
  84. MOVQ 16(SI),DX
  85. IMUL3Q $19,DX,AX
  86. MULQ 32(CX)
  87. ADDQ AX,R10
  88. ADCQ DX,R11
  89. MOVQ 24(SI),AX
  90. MULQ 0(CX)
  91. ADDQ AX,R14
  92. ADCQ DX,R15
  93. MOVQ 24(SI),AX
  94. MULQ 8(CX)
  95. ADDQ AX,BX
  96. ADCQ DX,BP
  97. MOVQ 0(SP),AX
  98. MULQ 24(CX)
  99. ADDQ AX,R10
  100. ADCQ DX,R11
  101. MOVQ 0(SP),AX
  102. MULQ 32(CX)
  103. ADDQ AX,R12
  104. ADCQ DX,R13
  105. MOVQ 32(SI),AX
  106. MULQ 0(CX)
  107. ADDQ AX,BX
  108. ADCQ DX,BP
  109. MOVQ 8(SP),AX
  110. MULQ 16(CX)
  111. ADDQ AX,R10
  112. ADCQ DX,R11
  113. MOVQ 8(SP),AX
  114. MULQ 24(CX)
  115. ADDQ AX,R12
  116. ADCQ DX,R13
  117. MOVQ 8(SP),AX
  118. MULQ 32(CX)
  119. ADDQ AX,R14
  120. ADCQ DX,R15
  121. MOVQ $REDMASK51,SI
  122. SHLQ $13,R9:R8
  123. ANDQ SI,R8
  124. SHLQ $13,R11:R10
  125. ANDQ SI,R10
  126. ADDQ R9,R10
  127. SHLQ $13,R13:R12
  128. ANDQ SI,R12
  129. ADDQ R11,R12
  130. SHLQ $13,R15:R14
  131. ANDQ SI,R14
  132. ADDQ R13,R14
  133. SHLQ $13,BP:BX
  134. ANDQ SI,BX
  135. ADDQ R15,BX
  136. IMUL3Q $19,BP,DX
  137. ADDQ DX,R8
  138. MOVQ R8,DX
  139. SHRQ $51,DX
  140. ADDQ R10,DX
  141. MOVQ DX,CX
  142. SHRQ $51,DX
  143. ANDQ SI,R8
  144. ADDQ R12,DX
  145. MOVQ DX,R9
  146. SHRQ $51,DX
  147. ANDQ SI,CX
  148. ADDQ R14,DX
  149. MOVQ DX,AX
  150. SHRQ $51,DX
  151. ANDQ SI,R9
  152. ADDQ BX,DX
  153. MOVQ DX,R10
  154. SHRQ $51,DX
  155. ANDQ SI,AX
  156. IMUL3Q $19,DX,DX
  157. ADDQ DX,R8
  158. ANDQ SI,R10
  159. MOVQ R8,0(DI)
  160. MOVQ CX,8(DI)
  161. MOVQ R9,16(DI)
  162. MOVQ AX,24(DI)
  163. MOVQ R10,32(DI)
  164. RET