1 2# qhasm: int64 input_0 3 4# qhasm: int64 input_1 5 6# qhasm: int64 input_2 7 8# qhasm: int64 input_3 9 10# qhasm: int64 input_4 11 12# qhasm: int64 input_5 13 14# qhasm: stack64 input_6 15 16# qhasm: stack64 input_7 17 18# qhasm: int64 caller_r11 19 20# qhasm: int64 caller_r12 21 22# qhasm: int64 caller_r13 23 24# qhasm: int64 caller_r14 25 26# qhasm: int64 caller_r15 27 28# qhasm: int64 caller_rbx 29 30# qhasm: int64 caller_rbp 31 32# qhasm: int64 b64 33 34# qhasm: int64 synd 35 36# qhasm: int64 addr 37 38# qhasm: int64 c 39 40# qhasm: int64 c_all 41 42# qhasm: int64 row 43 44# qhasm: int64 p 45 46# qhasm: int64 e 47 48# qhasm: int64 s 49 50# qhasm: reg256 pp 51 52# qhasm: reg256 ee 53 54# qhasm: reg256 ss 55 56# qhasm: int64 buf_ptr 57 58# qhasm: stack256 buf 59 60# qhasm: enter syndrome_asm 61.p2align 5 62.global _PQCLEAN_MCELIECE348864F_AVX_syndrome_asm 63.global PQCLEAN_MCELIECE348864F_AVX_syndrome_asm 64_PQCLEAN_MCELIECE348864F_AVX_syndrome_asm: 65PQCLEAN_MCELIECE348864F_AVX_syndrome_asm: 66mov %rsp,%r11 67and $31,%r11 68add $32,%r11 69sub %r11,%rsp 70 71# qhasm: input_1 += 260780 72# asm 1: add $260780,<input_1=int64#2 73# asm 2: add $260780,<input_1=%rsi 74add $260780,%rsi 75 76# qhasm: buf_ptr = &buf 77# asm 1: leaq <buf=stack256#1,>buf_ptr=int64#4 78# asm 2: leaq <buf=0(%rsp),>buf_ptr=%rcx 79leaq 0(%rsp),%rcx 80 81# qhasm: row = 768 82# asm 1: mov $768,>row=int64#5 83# asm 2: mov $768,>row=%r8 84mov $768,%r8 85 86# qhasm: loop: 87._loop: 88 89# qhasm: row -= 1 90# asm 1: sub $1,<row=int64#5 91# asm 2: sub $1,<row=%r8 92sub $1,%r8 93 94# qhasm: ss = mem256[ input_1 + 0 ] 95# asm 1: vmovupd 0(<input_1=int64#2),>ss=reg256#1 96# asm 2: vmovupd 0(<input_1=%rsi),>ss=%ymm0 97vmovupd 0(%rsi),%ymm0 98 99# qhasm: ee = mem256[ input_2 + 96 ] 100# asm 1: vmovupd 96(<input_2=int64#3),>ee=reg256#2 101# asm 2: vmovupd 96(<input_2=%rdx),>ee=%ymm1 102vmovupd 96(%rdx),%ymm1 103 104# qhasm: ss &= ee 105# asm 1: vpand <ee=reg256#2,<ss=reg256#1,<ss=reg256#1 106# asm 2: vpand <ee=%ymm1,<ss=%ymm0,<ss=%ymm0 107vpand %ymm1,%ymm0,%ymm0 108 109# qhasm: pp = mem256[ input_1 + 32 ] 110# asm 1: vmovupd 32(<input_1=int64#2),>pp=reg256#2 111# asm 2: vmovupd 32(<input_1=%rsi),>pp=%ymm1 112vmovupd 32(%rsi),%ymm1 113 114# qhasm: ee = mem256[ input_2 + 128 ] 115# asm 1: vmovupd 128(<input_2=int64#3),>ee=reg256#3 116# asm 2: vmovupd 128(<input_2=%rdx),>ee=%ymm2 117vmovupd 128(%rdx),%ymm2 118 119# qhasm: pp &= ee 120# asm 1: vpand <ee=reg256#3,<pp=reg256#2,<pp=reg256#2 121# asm 2: vpand <ee=%ymm2,<pp=%ymm1,<pp=%ymm1 122vpand %ymm2,%ymm1,%ymm1 123 124# qhasm: ss ^= pp 125# asm 1: vpxor <pp=reg256#2,<ss=reg256#1,<ss=reg256#1 126# asm 2: vpxor <pp=%ymm1,<ss=%ymm0,<ss=%ymm0 127vpxor %ymm1,%ymm0,%ymm0 128 129# qhasm: pp = mem256[ input_1 + 64 ] 130# asm 1: vmovupd 64(<input_1=int64#2),>pp=reg256#2 131# asm 2: vmovupd 64(<input_1=%rsi),>pp=%ymm1 132vmovupd 64(%rsi),%ymm1 133 134# qhasm: ee = mem256[ input_2 + 160 ] 135# asm 1: vmovupd 160(<input_2=int64#3),>ee=reg256#3 136# asm 2: vmovupd 160(<input_2=%rdx),>ee=%ymm2 137vmovupd 160(%rdx),%ymm2 138 139# qhasm: pp &= ee 140# asm 1: vpand <ee=reg256#3,<pp=reg256#2,<pp=reg256#2 141# asm 2: vpand <ee=%ymm2,<pp=%ymm1,<pp=%ymm1 142vpand %ymm2,%ymm1,%ymm1 143 144# qhasm: ss ^= pp 145# asm 1: vpxor <pp=reg256#2,<ss=reg256#1,<ss=reg256#1 146# asm 2: vpxor <pp=%ymm1,<ss=%ymm0,<ss=%ymm0 147vpxor %ymm1,%ymm0,%ymm0 148 149# qhasm: pp = mem256[ input_1 + 96 ] 150# asm 1: vmovupd 96(<input_1=int64#2),>pp=reg256#2 151# asm 2: vmovupd 96(<input_1=%rsi),>pp=%ymm1 152vmovupd 96(%rsi),%ymm1 153 154# qhasm: ee = mem256[ input_2 + 192 ] 155# asm 1: vmovupd 192(<input_2=int64#3),>ee=reg256#3 156# asm 2: vmovupd 192(<input_2=%rdx),>ee=%ymm2 157vmovupd 192(%rdx),%ymm2 158 159# qhasm: pp &= ee 160# asm 1: vpand <ee=reg256#3,<pp=reg256#2,<pp=reg256#2 161# asm 2: vpand <ee=%ymm2,<pp=%ymm1,<pp=%ymm1 162vpand %ymm2,%ymm1,%ymm1 163 164# qhasm: ss ^= pp 165# asm 1: vpxor <pp=reg256#2,<ss=reg256#1,<ss=reg256#1 166# asm 2: vpxor <pp=%ymm1,<ss=%ymm0,<ss=%ymm0 167vpxor %ymm1,%ymm0,%ymm0 168 169# qhasm: pp = mem256[ input_1 + 128 ] 170# asm 1: vmovupd 128(<input_1=int64#2),>pp=reg256#2 171# asm 2: vmovupd 128(<input_1=%rsi),>pp=%ymm1 172vmovupd 128(%rsi),%ymm1 173 174# qhasm: ee = mem256[ input_2 + 224 ] 175# asm 1: vmovupd 224(<input_2=int64#3),>ee=reg256#3 176# asm 2: vmovupd 224(<input_2=%rdx),>ee=%ymm2 177vmovupd 224(%rdx),%ymm2 178 179# qhasm: pp &= ee 180# asm 1: vpand <ee=reg256#3,<pp=reg256#2,<pp=reg256#2 181# asm 2: vpand <ee=%ymm2,<pp=%ymm1,<pp=%ymm1 182vpand %ymm2,%ymm1,%ymm1 183 184# qhasm: ss ^= pp 185# asm 1: vpxor <pp=reg256#2,<ss=reg256#1,<ss=reg256#1 186# asm 2: vpxor <pp=%ymm1,<ss=%ymm0,<ss=%ymm0 187vpxor %ymm1,%ymm0,%ymm0 188 189# qhasm: pp = mem256[ input_1 + 160 ] 190# asm 1: vmovupd 160(<input_1=int64#2),>pp=reg256#2 191# asm 2: vmovupd 160(<input_1=%rsi),>pp=%ymm1 192vmovupd 160(%rsi),%ymm1 193 194# qhasm: ee = mem256[ input_2 + 256 ] 195# asm 1: vmovupd 256(<input_2=int64#3),>ee=reg256#3 196# asm 2: vmovupd 256(<input_2=%rdx),>ee=%ymm2 197vmovupd 256(%rdx),%ymm2 198 199# qhasm: pp &= ee 200# asm 1: vpand <ee=reg256#3,<pp=reg256#2,<pp=reg256#2 201# asm 2: vpand <ee=%ymm2,<pp=%ymm1,<pp=%ymm1 202vpand %ymm2,%ymm1,%ymm1 203 204# qhasm: ss ^= pp 205# asm 1: vpxor <pp=reg256#2,<ss=reg256#1,<ss=reg256#1 206# asm 2: vpxor <pp=%ymm1,<ss=%ymm0,<ss=%ymm0 207vpxor %ymm1,%ymm0,%ymm0 208 209# qhasm: pp = mem256[ input_1 + 192 ] 210# asm 1: vmovupd 192(<input_1=int64#2),>pp=reg256#2 211# asm 2: vmovupd 192(<input_1=%rsi),>pp=%ymm1 212vmovupd 192(%rsi),%ymm1 213 214# qhasm: ee = mem256[ input_2 + 288 ] 215# asm 1: vmovupd 288(<input_2=int64#3),>ee=reg256#3 216# asm 2: vmovupd 288(<input_2=%rdx),>ee=%ymm2 217vmovupd 288(%rdx),%ymm2 218 219# qhasm: pp &= ee 220# asm 1: vpand <ee=reg256#3,<pp=reg256#2,<pp=reg256#2 221# asm 2: vpand <ee=%ymm2,<pp=%ymm1,<pp=%ymm1 222vpand %ymm2,%ymm1,%ymm1 223 224# qhasm: ss ^= pp 225# asm 1: vpxor <pp=reg256#2,<ss=reg256#1,<ss=reg256#1 226# asm 2: vpxor <pp=%ymm1,<ss=%ymm0,<ss=%ymm0 227vpxor %ymm1,%ymm0,%ymm0 228 229# qhasm: pp = mem256[ input_1 + 224 ] 230# asm 1: vmovupd 224(<input_1=int64#2),>pp=reg256#2 231# asm 2: vmovupd 224(<input_1=%rsi),>pp=%ymm1 232vmovupd 224(%rsi),%ymm1 233 234# qhasm: ee = mem256[ input_2 + 320 ] 235# asm 1: vmovupd 320(<input_2=int64#3),>ee=reg256#3 236# asm 2: vmovupd 320(<input_2=%rdx),>ee=%ymm2 237vmovupd 320(%rdx),%ymm2 238 239# qhasm: pp &= ee 240# asm 1: vpand <ee=reg256#3,<pp=reg256#2,<pp=reg256#2 241# asm 2: vpand <ee=%ymm2,<pp=%ymm1,<pp=%ymm1 242vpand %ymm2,%ymm1,%ymm1 243 244# qhasm: ss ^= pp 245# asm 1: vpxor <pp=reg256#2,<ss=reg256#1,<ss=reg256#1 246# asm 2: vpxor <pp=%ymm1,<ss=%ymm0,<ss=%ymm0 247vpxor %ymm1,%ymm0,%ymm0 248 249# qhasm: pp = mem256[ input_1 + 256 ] 250# asm 1: vmovupd 256(<input_1=int64#2),>pp=reg256#2 251# asm 2: vmovupd 256(<input_1=%rsi),>pp=%ymm1 252vmovupd 256(%rsi),%ymm1 253 254# qhasm: ee = mem256[ input_2 + 352 ] 255# asm 1: vmovupd 352(<input_2=int64#3),>ee=reg256#3 256# asm 2: vmovupd 352(<input_2=%rdx),>ee=%ymm2 257vmovupd 352(%rdx),%ymm2 258 259# qhasm: pp &= ee 260# asm 1: vpand <ee=reg256#3,<pp=reg256#2,<pp=reg256#2 261# asm 2: vpand <ee=%ymm2,<pp=%ymm1,<pp=%ymm1 262vpand %ymm2,%ymm1,%ymm1 263 264# qhasm: ss ^= pp 265# asm 1: vpxor <pp=reg256#2,<ss=reg256#1,<ss=reg256#1 266# asm 2: vpxor <pp=%ymm1,<ss=%ymm0,<ss=%ymm0 267vpxor %ymm1,%ymm0,%ymm0 268 269# qhasm: pp = mem256[ input_1 + 288 ] 270# asm 1: vmovupd 288(<input_1=int64#2),>pp=reg256#2 271# asm 2: vmovupd 288(<input_1=%rsi),>pp=%ymm1 272vmovupd 288(%rsi),%ymm1 273 274# qhasm: ee = mem256[ input_2 + 384 ] 275# asm 1: vmovupd 384(<input_2=int64#3),>ee=reg256#3 276# asm 2: vmovupd 384(<input_2=%rdx),>ee=%ymm2 277vmovupd 384(%rdx),%ymm2 278 279# qhasm: pp &= ee 280# asm 1: vpand <ee=reg256#3,<pp=reg256#2,<pp=reg256#2 281# asm 2: vpand <ee=%ymm2,<pp=%ymm1,<pp=%ymm1 282vpand %ymm2,%ymm1,%ymm1 283 284# qhasm: ss ^= pp 285# asm 1: vpxor <pp=reg256#2,<ss=reg256#1,<ss=reg256#1 286# asm 2: vpxor <pp=%ymm1,<ss=%ymm0,<ss=%ymm0 287vpxor %ymm1,%ymm0,%ymm0 288 289# qhasm: buf = ss 290# asm 1: vmovapd <ss=reg256#1,>buf=stack256#1 291# asm 2: vmovapd <ss=%ymm0,>buf=0(%rsp) 292vmovapd %ymm0,0(%rsp) 293 294# qhasm: s = *(uint64 *)(input_1 + 320) 295# asm 1: movq 320(<input_1=int64#2),>s=int64#6 296# asm 2: movq 320(<input_1=%rsi),>s=%r9 297movq 320(%rsi),%r9 298 299# qhasm: e = *(uint64 *)(input_2 + 416) 300# asm 1: movq 416(<input_2=int64#3),>e=int64#7 301# asm 2: movq 416(<input_2=%rdx),>e=%rax 302movq 416(%rdx),%rax 303 304# qhasm: s &= e 305# asm 1: and <e=int64#7,<s=int64#6 306# asm 2: and <e=%rax,<s=%r9 307and %rax,%r9 308 309# qhasm: p = *(uint64 *)(input_1 + 328) 310# asm 1: movq 328(<input_1=int64#2),>p=int64#7 311# asm 2: movq 328(<input_1=%rsi),>p=%rax 312movq 328(%rsi),%rax 313 314# qhasm: e = *(uint64 *)(input_2 + 424) 315# asm 1: movq 424(<input_2=int64#3),>e=int64#8 316# asm 2: movq 424(<input_2=%rdx),>e=%r10 317movq 424(%rdx),%r10 318 319# qhasm: p &= e 320# asm 1: and <e=int64#8,<p=int64#7 321# asm 2: and <e=%r10,<p=%rax 322and %r10,%rax 323 324# qhasm: s ^= p 325# asm 1: xor <p=int64#7,<s=int64#6 326# asm 2: xor <p=%rax,<s=%r9 327xor %rax,%r9 328 329# qhasm: p = *(uint32 *)(input_1 + 336) 330# asm 1: movl 336(<input_1=int64#2),>p=int64#7d 331# asm 2: movl 336(<input_1=%rsi),>p=%eax 332movl 336(%rsi),%eax 333 334# qhasm: e = *(uint32 *)(input_2 + 432) 335# asm 1: movl 432(<input_2=int64#3),>e=int64#8d 336# asm 2: movl 432(<input_2=%rdx),>e=%r10d 337movl 432(%rdx),%r10d 338 339# qhasm: p &= e 340# asm 1: and <e=int64#8,<p=int64#7 341# asm 2: and <e=%r10,<p=%rax 342and %r10,%rax 343 344# qhasm: s ^= p 345# asm 1: xor <p=int64#7,<s=int64#6 346# asm 2: xor <p=%rax,<s=%r9 347xor %rax,%r9 348 349# qhasm: c_all = count(s) 350# asm 1: popcnt <s=int64#6, >c_all=int64#6 351# asm 2: popcnt <s=%r9, >c_all=%r9 352popcnt %r9, %r9 353 354# qhasm: b64 = mem64[ buf_ptr + 0 ] 355# asm 1: movq 0(<buf_ptr=int64#4),>b64=int64#7 356# asm 2: movq 0(<buf_ptr=%rcx),>b64=%rax 357movq 0(%rcx),%rax 358 359# qhasm: c = count(b64) 360# asm 1: popcnt <b64=int64#7, >c=int64#7 361# asm 2: popcnt <b64=%rax, >c=%rax 362popcnt %rax, %rax 363 364# qhasm: c_all ^= c 365# asm 1: xor <c=int64#7,<c_all=int64#6 366# asm 2: xor <c=%rax,<c_all=%r9 367xor %rax,%r9 368 369# qhasm: b64 = mem64[ buf_ptr + 8 ] 370# asm 1: movq 8(<buf_ptr=int64#4),>b64=int64#7 371# asm 2: movq 8(<buf_ptr=%rcx),>b64=%rax 372movq 8(%rcx),%rax 373 374# qhasm: c = count(b64) 375# asm 1: popcnt <b64=int64#7, >c=int64#7 376# asm 2: popcnt <b64=%rax, >c=%rax 377popcnt %rax, %rax 378 379# qhasm: c_all ^= c 380# asm 1: xor <c=int64#7,<c_all=int64#6 381# asm 2: xor <c=%rax,<c_all=%r9 382xor %rax,%r9 383 384# qhasm: b64 = mem64[ buf_ptr + 16 ] 385# asm 1: movq 16(<buf_ptr=int64#4),>b64=int64#7 386# asm 2: movq 16(<buf_ptr=%rcx),>b64=%rax 387movq 16(%rcx),%rax 388 389# qhasm: c = count(b64) 390# asm 1: popcnt <b64=int64#7, >c=int64#7 391# asm 2: popcnt <b64=%rax, >c=%rax 392popcnt %rax, %rax 393 394# qhasm: c_all ^= c 395# asm 1: xor <c=int64#7,<c_all=int64#6 396# asm 2: xor <c=%rax,<c_all=%r9 397xor %rax,%r9 398 399# qhasm: b64 = mem64[ buf_ptr + 24 ] 400# asm 1: movq 24(<buf_ptr=int64#4),>b64=int64#7 401# asm 2: movq 24(<buf_ptr=%rcx),>b64=%rax 402movq 24(%rcx),%rax 403 404# qhasm: c = count(b64) 405# asm 1: popcnt <b64=int64#7, >c=int64#7 406# asm 2: popcnt <b64=%rax, >c=%rax 407popcnt %rax, %rax 408 409# qhasm: c_all ^= c 410# asm 1: xor <c=int64#7,<c_all=int64#6 411# asm 2: xor <c=%rax,<c_all=%r9 412xor %rax,%r9 413 414# qhasm: addr = row 415# asm 1: mov <row=int64#5,>addr=int64#7 416# asm 2: mov <row=%r8,>addr=%rax 417mov %r8,%rax 418 419# qhasm: (uint64) addr >>= 3 420# asm 1: shr $3,<addr=int64#7 421# asm 2: shr $3,<addr=%rax 422shr $3,%rax 423 424# qhasm: addr += input_0 425# asm 1: add <input_0=int64#1,<addr=int64#7 426# asm 2: add <input_0=%rdi,<addr=%rax 427add %rdi,%rax 428 429# qhasm: synd = *(uint8 *) (addr + 0) 430# asm 1: movzbq 0(<addr=int64#7),>synd=int64#8 431# asm 2: movzbq 0(<addr=%rax),>synd=%r10 432movzbq 0(%rax),%r10 433 434# qhasm: synd <<= 1 435# asm 1: shl $1,<synd=int64#8 436# asm 2: shl $1,<synd=%r10 437shl $1,%r10 438 439# qhasm: (uint32) c_all &= 1 440# asm 1: and $1,<c_all=int64#6d 441# asm 2: and $1,<c_all=%r9d 442and $1,%r9d 443 444# qhasm: synd |= c_all 445# asm 1: or <c_all=int64#6,<synd=int64#8 446# asm 2: or <c_all=%r9,<synd=%r10 447or %r9,%r10 448 449# qhasm: *(uint8 *) (addr + 0) = synd 450# asm 1: movb <synd=int64#8b,0(<addr=int64#7) 451# asm 2: movb <synd=%r10b,0(<addr=%rax) 452movb %r10b,0(%rax) 453 454# qhasm: input_1 -= 340 455# asm 1: sub $340,<input_1=int64#2 456# asm 2: sub $340,<input_1=%rsi 457sub $340,%rsi 458 459# qhasm: =? row-0 460# asm 1: cmp $0,<row=int64#5 461# asm 2: cmp $0,<row=%r8 462cmp $0,%r8 463# comment:fp stack unchanged by jump 464 465# qhasm: goto loop if != 466jne ._loop 467 468# qhasm: ss = mem256[ input_0 + 0 ] 469# asm 1: vmovupd 0(<input_0=int64#1),>ss=reg256#1 470# asm 2: vmovupd 0(<input_0=%rdi),>ss=%ymm0 471vmovupd 0(%rdi),%ymm0 472 473# qhasm: ee = mem256[ input_2 + 0 ] 474# asm 1: vmovupd 0(<input_2=int64#3),>ee=reg256#2 475# asm 2: vmovupd 0(<input_2=%rdx),>ee=%ymm1 476vmovupd 0(%rdx),%ymm1 477 478# qhasm: ss ^= ee 479# asm 1: vpxor <ee=reg256#2,<ss=reg256#1,<ss=reg256#1 480# asm 2: vpxor <ee=%ymm1,<ss=%ymm0,<ss=%ymm0 481vpxor %ymm1,%ymm0,%ymm0 482 483# qhasm: mem256[ input_0 + 0 ] = ss 484# asm 1: vmovupd <ss=reg256#1,0(<input_0=int64#1) 485# asm 2: vmovupd <ss=%ymm0,0(<input_0=%rdi) 486vmovupd %ymm0,0(%rdi) 487 488# qhasm: ss = mem256[ input_0 + 32 ] 489# asm 1: vmovupd 32(<input_0=int64#1),>ss=reg256#1 490# asm 2: vmovupd 32(<input_0=%rdi),>ss=%ymm0 491vmovupd 32(%rdi),%ymm0 492 493# qhasm: ee = mem256[ input_2 + 32 ] 494# asm 1: vmovupd 32(<input_2=int64#3),>ee=reg256#2 495# asm 2: vmovupd 32(<input_2=%rdx),>ee=%ymm1 496vmovupd 32(%rdx),%ymm1 497 498# qhasm: ss ^= ee 499# asm 1: vpxor <ee=reg256#2,<ss=reg256#1,<ss=reg256#1 500# asm 2: vpxor <ee=%ymm1,<ss=%ymm0,<ss=%ymm0 501vpxor %ymm1,%ymm0,%ymm0 502 503# qhasm: mem256[ input_0 + 32 ] = ss 504# asm 1: vmovupd <ss=reg256#1,32(<input_0=int64#1) 505# asm 2: vmovupd <ss=%ymm0,32(<input_0=%rdi) 506vmovupd %ymm0,32(%rdi) 507 508# qhasm: ss = mem256[ input_0 + 64 ] 509# asm 1: vmovupd 64(<input_0=int64#1),>ss=reg256#1 510# asm 2: vmovupd 64(<input_0=%rdi),>ss=%ymm0 511vmovupd 64(%rdi),%ymm0 512 513# qhasm: ee = mem256[ input_2 + 64 ] 514# asm 1: vmovupd 64(<input_2=int64#3),>ee=reg256#2 515# asm 2: vmovupd 64(<input_2=%rdx),>ee=%ymm1 516vmovupd 64(%rdx),%ymm1 517 518# qhasm: ss ^= ee 519# asm 1: vpxor <ee=reg256#2,<ss=reg256#1,<ss=reg256#1 520# asm 2: vpxor <ee=%ymm1,<ss=%ymm0,<ss=%ymm0 521vpxor %ymm1,%ymm0,%ymm0 522 523# qhasm: mem256[ input_0 + 64 ] = ss 524# asm 1: vmovupd <ss=reg256#1,64(<input_0=int64#1) 525# asm 2: vmovupd <ss=%ymm0,64(<input_0=%rdi) 526vmovupd %ymm0,64(%rdi) 527 528# qhasm: return 529add %r11,%rsp 530ret 531