ed25519-donna-64bit-sse2.h 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436
  1. #if defined(ED25519_GCC_64BIT_SSE_CHOOSE)
  2. #define HAVE_GE25519_SCALARMULT_BASE_CHOOSE_NIELS
  3. DONNA_NOINLINE static void
  4. ge25519_scalarmult_base_choose_niels(ge25519_niels *t, const uint8_t table[256][96], uint32_t pos, signed char b) {
  5. int64_t breg = (int64_t)b;
  6. uint64_t sign = (uint64_t)breg >> 63;
  7. uint64_t mask = ~(sign - 1);
  8. uint64_t u = (breg + mask) ^ mask;
  9. __asm__ __volatile__ (
  10. /* ysubx+xaddy+t2d */
  11. "movq %0, %%rax ;\n"
  12. "movd %%rax, %%xmm14 ;\n"
  13. "pshufd $0x00, %%xmm14, %%xmm14 ;\n"
  14. "pxor %%xmm0, %%xmm0 ;\n"
  15. "pxor %%xmm1, %%xmm1 ;\n"
  16. "pxor %%xmm2, %%xmm2 ;\n"
  17. "pxor %%xmm3, %%xmm3 ;\n"
  18. "pxor %%xmm4, %%xmm4 ;\n"
  19. "pxor %%xmm5, %%xmm5 ;\n"
  20. /* 0 */
  21. "movq $0, %%rax ;\n"
  22. "movd %%rax, %%xmm15 ;\n"
  23. "pshufd $0x00, %%xmm15, %%xmm15 ;\n"
  24. "pcmpeqd %%xmm14, %%xmm15 ;\n"
  25. "movq $1, %%rax ;\n"
  26. "movd %%rax, %%xmm6 ;\n"
  27. "pxor %%xmm7, %%xmm7 ;\n"
  28. "pand %%xmm15, %%xmm6 ;\n"
  29. "pand %%xmm15, %%xmm7 ;\n"
  30. "por %%xmm6, %%xmm0 ;\n"
  31. "por %%xmm7, %%xmm1 ;\n"
  32. "por %%xmm6, %%xmm2 ;\n"
  33. "por %%xmm7, %%xmm3 ;\n"
  34. /* 1 */
  35. "movq $1, %%rax ;\n"
  36. "movd %%rax, %%xmm15 ;\n"
  37. "pshufd $0x00, %%xmm15, %%xmm15 ;\n"
  38. "pcmpeqd %%xmm14, %%xmm15 ;\n"
  39. "movdqa 0(%1), %%xmm6 ;\n"
  40. "movdqa 16(%1), %%xmm7 ;\n"
  41. "movdqa 32(%1), %%xmm8 ;\n"
  42. "movdqa 48(%1), %%xmm9 ;\n"
  43. "movdqa 64(%1), %%xmm10 ;\n"
  44. "movdqa 80(%1), %%xmm11 ;\n"
  45. "pand %%xmm15, %%xmm6 ;\n"
  46. "pand %%xmm15, %%xmm7 ;\n"
  47. "pand %%xmm15, %%xmm8 ;\n"
  48. "pand %%xmm15, %%xmm9 ;\n"
  49. "pand %%xmm15, %%xmm10 ;\n"
  50. "pand %%xmm15, %%xmm11 ;\n"
  51. "por %%xmm6, %%xmm0 ;\n"
  52. "por %%xmm7, %%xmm1 ;\n"
  53. "por %%xmm8, %%xmm2 ;\n"
  54. "por %%xmm9, %%xmm3 ;\n"
  55. "por %%xmm10, %%xmm4 ;\n"
  56. "por %%xmm11, %%xmm5 ;\n"
  57. /* 2 */
  58. "movq $2, %%rax ;\n"
  59. "movd %%rax, %%xmm15 ;\n"
  60. "pshufd $0x00, %%xmm15, %%xmm15 ;\n"
  61. "pcmpeqd %%xmm14, %%xmm15 ;\n"
  62. "movdqa 96(%1), %%xmm6 ;\n"
  63. "movdqa 112(%1), %%xmm7 ;\n"
  64. "movdqa 128(%1), %%xmm8 ;\n"
  65. "movdqa 144(%1), %%xmm9 ;\n"
  66. "movdqa 160(%1), %%xmm10 ;\n"
  67. "movdqa 176(%1), %%xmm11 ;\n"
  68. "pand %%xmm15, %%xmm6 ;\n"
  69. "pand %%xmm15, %%xmm7 ;\n"
  70. "pand %%xmm15, %%xmm8 ;\n"
  71. "pand %%xmm15, %%xmm9 ;\n"
  72. "pand %%xmm15, %%xmm10 ;\n"
  73. "pand %%xmm15, %%xmm11 ;\n"
  74. "por %%xmm6, %%xmm0 ;\n"
  75. "por %%xmm7, %%xmm1 ;\n"
  76. "por %%xmm8, %%xmm2 ;\n"
  77. "por %%xmm9, %%xmm3 ;\n"
  78. "por %%xmm10, %%xmm4 ;\n"
  79. "por %%xmm11, %%xmm5 ;\n"
  80. /* 3 */
  81. "movq $3, %%rax ;\n"
  82. "movd %%rax, %%xmm15 ;\n"
  83. "pshufd $0x00, %%xmm15, %%xmm15 ;\n"
  84. "pcmpeqd %%xmm14, %%xmm15 ;\n"
  85. "movdqa 192(%1), %%xmm6 ;\n"
  86. "movdqa 208(%1), %%xmm7 ;\n"
  87. "movdqa 224(%1), %%xmm8 ;\n"
  88. "movdqa 240(%1), %%xmm9 ;\n"
  89. "movdqa 256(%1), %%xmm10 ;\n"
  90. "movdqa 272(%1), %%xmm11 ;\n"
  91. "pand %%xmm15, %%xmm6 ;\n"
  92. "pand %%xmm15, %%xmm7 ;\n"
  93. "pand %%xmm15, %%xmm8 ;\n"
  94. "pand %%xmm15, %%xmm9 ;\n"
  95. "pand %%xmm15, %%xmm10 ;\n"
  96. "pand %%xmm15, %%xmm11 ;\n"
  97. "por %%xmm6, %%xmm0 ;\n"
  98. "por %%xmm7, %%xmm1 ;\n"
  99. "por %%xmm8, %%xmm2 ;\n"
  100. "por %%xmm9, %%xmm3 ;\n"
  101. "por %%xmm10, %%xmm4 ;\n"
  102. "por %%xmm11, %%xmm5 ;\n"
  103. /* 4 */
  104. "movq $4, %%rax ;\n"
  105. "movd %%rax, %%xmm15 ;\n"
  106. "pshufd $0x00, %%xmm15, %%xmm15 ;\n"
  107. "pcmpeqd %%xmm14, %%xmm15 ;\n"
  108. "movdqa 288(%1), %%xmm6 ;\n"
  109. "movdqa 304(%1), %%xmm7 ;\n"
  110. "movdqa 320(%1), %%xmm8 ;\n"
  111. "movdqa 336(%1), %%xmm9 ;\n"
  112. "movdqa 352(%1), %%xmm10 ;\n"
  113. "movdqa 368(%1), %%xmm11 ;\n"
  114. "pand %%xmm15, %%xmm6 ;\n"
  115. "pand %%xmm15, %%xmm7 ;\n"
  116. "pand %%xmm15, %%xmm8 ;\n"
  117. "pand %%xmm15, %%xmm9 ;\n"
  118. "pand %%xmm15, %%xmm10 ;\n"
  119. "pand %%xmm15, %%xmm11 ;\n"
  120. "por %%xmm6, %%xmm0 ;\n"
  121. "por %%xmm7, %%xmm1 ;\n"
  122. "por %%xmm8, %%xmm2 ;\n"
  123. "por %%xmm9, %%xmm3 ;\n"
  124. "por %%xmm10, %%xmm4 ;\n"
  125. "por %%xmm11, %%xmm5 ;\n"
  126. /* 5 */
  127. "movq $5, %%rax ;\n"
  128. "movd %%rax, %%xmm15 ;\n"
  129. "pshufd $0x00, %%xmm15, %%xmm15 ;\n"
  130. "pcmpeqd %%xmm14, %%xmm15 ;\n"
  131. "movdqa 384(%1), %%xmm6 ;\n"
  132. "movdqa 400(%1), %%xmm7 ;\n"
  133. "movdqa 416(%1), %%xmm8 ;\n"
  134. "movdqa 432(%1), %%xmm9 ;\n"
  135. "movdqa 448(%1), %%xmm10 ;\n"
  136. "movdqa 464(%1), %%xmm11 ;\n"
  137. "pand %%xmm15, %%xmm6 ;\n"
  138. "pand %%xmm15, %%xmm7 ;\n"
  139. "pand %%xmm15, %%xmm8 ;\n"
  140. "pand %%xmm15, %%xmm9 ;\n"
  141. "pand %%xmm15, %%xmm10 ;\n"
  142. "pand %%xmm15, %%xmm11 ;\n"
  143. "por %%xmm6, %%xmm0 ;\n"
  144. "por %%xmm7, %%xmm1 ;\n"
  145. "por %%xmm8, %%xmm2 ;\n"
  146. "por %%xmm9, %%xmm3 ;\n"
  147. "por %%xmm10, %%xmm4 ;\n"
  148. "por %%xmm11, %%xmm5 ;\n"
  149. /* 6 */
  150. "movq $6, %%rax ;\n"
  151. "movd %%rax, %%xmm15 ;\n"
  152. "pshufd $0x00, %%xmm15, %%xmm15 ;\n"
  153. "pcmpeqd %%xmm14, %%xmm15 ;\n"
  154. "movdqa 480(%1), %%xmm6 ;\n"
  155. "movdqa 496(%1), %%xmm7 ;\n"
  156. "movdqa 512(%1), %%xmm8 ;\n"
  157. "movdqa 528(%1), %%xmm9 ;\n"
  158. "movdqa 544(%1), %%xmm10 ;\n"
  159. "movdqa 560(%1), %%xmm11 ;\n"
  160. "pand %%xmm15, %%xmm6 ;\n"
  161. "pand %%xmm15, %%xmm7 ;\n"
  162. "pand %%xmm15, %%xmm8 ;\n"
  163. "pand %%xmm15, %%xmm9 ;\n"
  164. "pand %%xmm15, %%xmm10 ;\n"
  165. "pand %%xmm15, %%xmm11 ;\n"
  166. "por %%xmm6, %%xmm0 ;\n"
  167. "por %%xmm7, %%xmm1 ;\n"
  168. "por %%xmm8, %%xmm2 ;\n"
  169. "por %%xmm9, %%xmm3 ;\n"
  170. "por %%xmm10, %%xmm4 ;\n"
  171. "por %%xmm11, %%xmm5 ;\n"
  172. /* 7 */
  173. "movq $7, %%rax ;\n"
  174. "movd %%rax, %%xmm15 ;\n"
  175. "pshufd $0x00, %%xmm15, %%xmm15 ;\n"
  176. "pcmpeqd %%xmm14, %%xmm15 ;\n"
  177. "movdqa 576(%1), %%xmm6 ;\n"
  178. "movdqa 592(%1), %%xmm7 ;\n"
  179. "movdqa 608(%1), %%xmm8 ;\n"
  180. "movdqa 624(%1), %%xmm9 ;\n"
  181. "movdqa 640(%1), %%xmm10 ;\n"
  182. "movdqa 656(%1), %%xmm11 ;\n"
  183. "pand %%xmm15, %%xmm6 ;\n"
  184. "pand %%xmm15, %%xmm7 ;\n"
  185. "pand %%xmm15, %%xmm8 ;\n"
  186. "pand %%xmm15, %%xmm9 ;\n"
  187. "pand %%xmm15, %%xmm10 ;\n"
  188. "pand %%xmm15, %%xmm11 ;\n"
  189. "por %%xmm6, %%xmm0 ;\n"
  190. "por %%xmm7, %%xmm1 ;\n"
  191. "por %%xmm8, %%xmm2 ;\n"
  192. "por %%xmm9, %%xmm3 ;\n"
  193. "por %%xmm10, %%xmm4 ;\n"
  194. "por %%xmm11, %%xmm5 ;\n"
  195. /* 8 */
  196. "movq $8, %%rax ;\n"
  197. "movd %%rax, %%xmm15 ;\n"
  198. "pshufd $0x00, %%xmm15, %%xmm15 ;\n"
  199. "pcmpeqd %%xmm14, %%xmm15 ;\n"
  200. "movdqa 672(%1), %%xmm6 ;\n"
  201. "movdqa 688(%1), %%xmm7 ;\n"
  202. "movdqa 704(%1), %%xmm8 ;\n"
  203. "movdqa 720(%1), %%xmm9 ;\n"
  204. "movdqa 736(%1), %%xmm10 ;\n"
  205. "movdqa 752(%1), %%xmm11 ;\n"
  206. "pand %%xmm15, %%xmm6 ;\n"
  207. "pand %%xmm15, %%xmm7 ;\n"
  208. "pand %%xmm15, %%xmm8 ;\n"
  209. "pand %%xmm15, %%xmm9 ;\n"
  210. "pand %%xmm15, %%xmm10 ;\n"
  211. "pand %%xmm15, %%xmm11 ;\n"
  212. "por %%xmm6, %%xmm0 ;\n"
  213. "por %%xmm7, %%xmm1 ;\n"
  214. "por %%xmm8, %%xmm2 ;\n"
  215. "por %%xmm9, %%xmm3 ;\n"
  216. "por %%xmm10, %%xmm4 ;\n"
  217. "por %%xmm11, %%xmm5 ;\n"
  218. /* conditionally swap ysubx and xaddy */
  219. "movq %3, %%rax ;\n"
  220. "xorq $1, %%rax ;\n"
  221. "movd %%rax, %%xmm14 ;\n"
  222. "pxor %%xmm15, %%xmm15 ;\n"
  223. "pshufd $0x00, %%xmm14, %%xmm14 ;\n"
  224. "pxor %%xmm0, %%xmm2 ;\n"
  225. "pxor %%xmm1, %%xmm3 ;\n"
  226. "pcmpeqd %%xmm14, %%xmm15 ;\n"
  227. "movdqa %%xmm2, %%xmm6 ;\n"
  228. "movdqa %%xmm3, %%xmm7 ;\n"
  229. "pand %%xmm15, %%xmm6 ;\n"
  230. "pand %%xmm15, %%xmm7 ;\n"
  231. "pxor %%xmm6, %%xmm0 ;\n"
  232. "pxor %%xmm7, %%xmm1 ;\n"
  233. "pxor %%xmm0, %%xmm2 ;\n"
  234. "pxor %%xmm1, %%xmm3 ;\n"
  235. /* store ysubx */
  236. "xorq %%rax, %%rax ;\n"
  237. "movd %%xmm0, %%rcx ;\n"
  238. "movd %%xmm0, %%r8 ;\n"
  239. "movd %%xmm1, %%rsi ;\n"
  240. "pshufd $0xee, %%xmm0, %%xmm0 ;\n"
  241. "pshufd $0xee, %%xmm1, %%xmm1 ;\n"
  242. "movd %%xmm0, %%rdx ;\n"
  243. "movd %%xmm1, %%rdi ;\n"
  244. "shrdq $51, %%rdx, %%r8 ;\n"
  245. "shrdq $38, %%rsi, %%rdx ;\n"
  246. "shrdq $25, %%rdi, %%rsi ;\n"
  247. "shrq $12, %%rdi ;\n"
  248. "movq %%rcx, %%r9 ;\n"
  249. "movq %%r8, %%r10 ;\n"
  250. "movq %%rdx, %%r11 ;\n"
  251. "movq %%rsi, %%r12 ;\n"
  252. "movq %%rdi, %%r13 ;\n"
  253. "shrq $26, %%r9 ;\n"
  254. "shrq $26, %%r10 ;\n"
  255. "shrq $26, %%r11 ;\n"
  256. "shrq $26, %%r12 ;\n"
  257. "shrq $26, %%r13 ;\n"
  258. "andl $0x3ffffff, %%ecx ;\n"
  259. "andl $0x1ffffff, %%r9d ;\n"
  260. "andl $0x3ffffff, %%r8d ;\n"
  261. "andl $0x1ffffff, %%r10d ;\n"
  262. "andl $0x3ffffff, %%edx ;\n"
  263. "andl $0x1ffffff, %%r11d ;\n"
  264. "andl $0x3ffffff, %%esi ;\n"
  265. "andl $0x1ffffff, %%r12d ;\n"
  266. "andl $0x3ffffff, %%edi ;\n"
  267. "andl $0x1ffffff, %%r13d ;\n"
  268. "movl %%ecx, 0(%2) ;\n"
  269. "movl %%r9d, 4(%2) ;\n"
  270. "movl %%r8d, 8(%2) ;\n"
  271. "movl %%r10d, 12(%2) ;\n"
  272. "movl %%edx, 16(%2) ;\n"
  273. "movl %%r11d, 20(%2) ;\n"
  274. "movl %%esi, 24(%2) ;\n"
  275. "movl %%r12d, 28(%2) ;\n"
  276. "movl %%edi, 32(%2) ;\n"
  277. "movl %%r13d, 36(%2) ;\n"
  278. "movq %%rax, 40(%2) ;\n"
  279. /* store xaddy */
  280. "movd %%xmm2, %%rcx ;\n"
  281. "movd %%xmm2, %%r8 ;\n"
  282. "movd %%xmm3, %%rsi ;\n"
  283. "pshufd $0xee, %%xmm2, %%xmm2 ;\n"
  284. "pshufd $0xee, %%xmm3, %%xmm3 ;\n"
  285. "movd %%xmm2, %%rdx ;\n"
  286. "movd %%xmm3, %%rdi ;\n"
  287. "shrdq $51, %%rdx, %%r8 ;\n"
  288. "shrdq $38, %%rsi, %%rdx ;\n"
  289. "shrdq $25, %%rdi, %%rsi ;\n"
  290. "shrq $12, %%rdi ;\n"
  291. "movq %%rcx, %%r9 ;\n"
  292. "movq %%r8, %%r10 ;\n"
  293. "movq %%rdx, %%r11 ;\n"
  294. "movq %%rsi, %%r12 ;\n"
  295. "movq %%rdi, %%r13 ;\n"
  296. "shrq $26, %%r9 ;\n"
  297. "shrq $26, %%r10 ;\n"
  298. "shrq $26, %%r11 ;\n"
  299. "shrq $26, %%r12 ;\n"
  300. "shrq $26, %%r13 ;\n"
  301. "andl $0x3ffffff, %%ecx ;\n"
  302. "andl $0x1ffffff, %%r9d ;\n"
  303. "andl $0x3ffffff, %%r8d ;\n"
  304. "andl $0x1ffffff, %%r10d ;\n"
  305. "andl $0x3ffffff, %%edx ;\n"
  306. "andl $0x1ffffff, %%r11d ;\n"
  307. "andl $0x3ffffff, %%esi ;\n"
  308. "andl $0x1ffffff, %%r12d ;\n"
  309. "andl $0x3ffffff, %%edi ;\n"
  310. "andl $0x1ffffff, %%r13d ;\n"
  311. "movl %%ecx, 48(%2) ;\n"
  312. "movl %%r9d, 52(%2) ;\n"
  313. "movl %%r8d, 56(%2) ;\n"
  314. "movl %%r10d, 60(%2) ;\n"
  315. "movl %%edx, 64(%2) ;\n"
  316. "movl %%r11d, 68(%2) ;\n"
  317. "movl %%esi, 72(%2) ;\n"
  318. "movl %%r12d, 76(%2) ;\n"
  319. "movl %%edi, 80(%2) ;\n"
  320. "movl %%r13d, 84(%2) ;\n"
  321. "movq %%rax, 88(%2) ;\n"
  322. /* extract t2d */
  323. "xorq %%rax, %%rax ;\n"
  324. "movd %%xmm4, %%rcx ;\n"
  325. "movd %%xmm4, %%r8 ;\n"
  326. "movd %%xmm5, %%rsi ;\n"
  327. "pshufd $0xee, %%xmm4, %%xmm4 ;\n"
  328. "pshufd $0xee, %%xmm5, %%xmm5 ;\n"
  329. "movd %%xmm4, %%rdx ;\n"
  330. "movd %%xmm5, %%rdi ;\n"
  331. "shrdq $51, %%rdx, %%r8 ;\n"
  332. "shrdq $38, %%rsi, %%rdx ;\n"
  333. "shrdq $25, %%rdi, %%rsi ;\n"
  334. "shrq $12, %%rdi ;\n"
  335. "movq %%rcx, %%r9 ;\n"
  336. "movq %%r8, %%r10 ;\n"
  337. "movq %%rdx, %%r11 ;\n"
  338. "movq %%rsi, %%r12 ;\n"
  339. "movq %%rdi, %%r13 ;\n"
  340. "shrq $26, %%r9 ;\n"
  341. "shrq $26, %%r10 ;\n"
  342. "shrq $26, %%r11 ;\n"
  343. "shrq $26, %%r12 ;\n"
  344. "shrq $26, %%r13 ;\n"
  345. "andl $0x3ffffff, %%ecx ;\n"
  346. "andl $0x1ffffff, %%r9d ;\n"
  347. "andl $0x3ffffff, %%r8d ;\n"
  348. "andl $0x1ffffff, %%r10d ;\n"
  349. "andl $0x3ffffff, %%edx ;\n"
  350. "andl $0x1ffffff, %%r11d ;\n"
  351. "andl $0x3ffffff, %%esi ;\n"
  352. "andl $0x1ffffff, %%r12d ;\n"
  353. "andl $0x3ffffff, %%edi ;\n"
  354. "andl $0x1ffffff, %%r13d ;\n"
  355. "movd %%ecx, %%xmm0 ;\n"
  356. "movd %%r9d, %%xmm4 ;\n"
  357. "movd %%r8d, %%xmm8 ;\n"
  358. "movd %%r10d, %%xmm3 ;\n"
  359. "movd %%edx, %%xmm1 ;\n"
  360. "movd %%r11d, %%xmm5 ;\n"
  361. "movd %%esi, %%xmm6 ;\n"
  362. "movd %%r12d, %%xmm7 ;\n"
  363. "movd %%edi, %%xmm2 ;\n"
  364. "movd %%r13d, %%xmm9 ;\n"
  365. "punpckldq %%xmm4, %%xmm0 ;\n"
  366. "punpckldq %%xmm3, %%xmm8 ;\n"
  367. "punpckldq %%xmm5, %%xmm1 ;\n"
  368. "punpckldq %%xmm7, %%xmm6 ;\n"
  369. "punpckldq %%xmm9, %%xmm2 ;\n"
  370. "punpcklqdq %%xmm8, %%xmm0 ;\n"
  371. "punpcklqdq %%xmm6, %%xmm1 ;\n"
  372. /* set up 2p in to 3/4 */
  373. "movl $0x7ffffda, %%ecx ;\n"
  374. "movl $0x3fffffe, %%edx ;\n"
  375. "movl $0x7fffffe, %%eax ;\n"
  376. "movd %%ecx, %%xmm3 ;\n"
  377. "movd %%edx, %%xmm5 ;\n"
  378. "movd %%eax, %%xmm4 ;\n"
  379. "punpckldq %%xmm5, %%xmm3 ;\n"
  380. "punpckldq %%xmm5, %%xmm4 ;\n"
  381. "punpcklqdq %%xmm4, %%xmm3 ;\n"
  382. "movdqa %%xmm4, %%xmm5 ;\n"
  383. "punpcklqdq %%xmm4, %%xmm4 ;\n"
  384. /* subtract and conditionally move */
  385. "movl %3, %%ecx ;\n"
  386. "sub $1, %%ecx ;\n"
  387. "movd %%ecx, %%xmm6 ;\n"
  388. "pshufd $0x00, %%xmm6, %%xmm6 ;\n"
  389. "movdqa %%xmm6, %%xmm7 ;\n"
  390. "psubd %%xmm0, %%xmm3 ;\n"
  391. "psubd %%xmm1, %%xmm4 ;\n"
  392. "psubd %%xmm2, %%xmm5 ;\n"
  393. "pand %%xmm6, %%xmm0 ;\n"
  394. "pand %%xmm6, %%xmm1 ;\n"
  395. "pand %%xmm6, %%xmm2 ;\n"
  396. "pandn %%xmm3, %%xmm6 ;\n"
  397. "movdqa %%xmm7, %%xmm3 ;\n"
  398. "pandn %%xmm4, %%xmm7 ;\n"
  399. "pandn %%xmm5, %%xmm3 ;\n"
  400. "por %%xmm6, %%xmm0 ;\n"
  401. "por %%xmm7, %%xmm1 ;\n"
  402. "por %%xmm3, %%xmm2 ;\n"
  403. /* store t2d */
  404. "movdqa %%xmm0, 96(%2) ;\n"
  405. "movdqa %%xmm1, 112(%2) ;\n"
  406. "movdqa %%xmm2, 128(%2) ;\n"
  407. :
  408. : "m"(u), "r"(&table[pos * 8]), "r"(t), "m"(sign) /* %0 = u, %1 = table, %2 = t, %3 = sign */
  409. :
  410. "%rax", "%rcx", "%rdx", "%rdi", "%rsi", "%r8", "%r9", "%r10", "%r11", "%r12", "%r13",
  411. "%xmm0", "%xmm1", "%xmm2", "%xmm3", "%xmm4", "%xmm5", "%xmm6", "%xmm7", "%xmm8", "%xmm9", "%xmm10", "%xmm11", "%xmm14", "%xmm14",
  412. "cc", "memory"
  413. );
  414. }
  415. #endif /* defined(ED25519_GCC_64BIT_SSE_CHOOSE) */