mldsa_gh 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (128) hide show
  1. checksums.yaml +7 -0
  2. data/LICENSE +21 -0
  3. data/README.md +88 -0
  4. data/ext/mldsa_gh_native/extconf.rb +14 -0
  5. data/ext/mldsa_gh_native/mldsa_gh_native.c +222 -0
  6. data/ext/mldsa_gh_native/mldsa_gh_native_all.c +24 -0
  7. data/ext/mldsa_gh_native/mldsa_gh_native_all.h +26 -0
  8. data/ext/mldsa_gh_native/vendor/mldsa-native/BUILDING.md +108 -0
  9. data/ext/mldsa_gh_native/vendor/mldsa-native/LICENSE +305 -0
  10. data/ext/mldsa_gh_native/vendor/mldsa-native/README.md +247 -0
  11. data/ext/mldsa_gh_native/vendor/mldsa-native/mldsa/README.md +23 -0
  12. data/ext/mldsa_gh_native/vendor/mldsa-native/mldsa/mldsa_native.c +803 -0
  13. data/ext/mldsa_gh_native/vendor/mldsa-native/mldsa/mldsa_native.h +956 -0
  14. data/ext/mldsa_gh_native/vendor/mldsa-native/mldsa/mldsa_native_asm.S +830 -0
  15. data/ext/mldsa_gh_native/vendor/mldsa-native/mldsa/mldsa_native_config.h +855 -0
  16. data/ext/mldsa_gh_native/vendor/mldsa-native/mldsa/src/cbmc.h +233 -0
  17. data/ext/mldsa_gh_native/vendor/mldsa-native/mldsa/src/common.h +301 -0
  18. data/ext/mldsa_gh_native/vendor/mldsa-native/mldsa/src/context.h +152 -0
  19. data/ext/mldsa_gh_native/vendor/mldsa-native/mldsa/src/ct.c +21 -0
  20. data/ext/mldsa_gh_native/vendor/mldsa-native/mldsa/src/ct.h +373 -0
  21. data/ext/mldsa_gh_native/vendor/mldsa-native/mldsa/src/debug.c +75 -0
  22. data/ext/mldsa_gh_native/vendor/mldsa-native/mldsa/src/debug.h +125 -0
  23. data/ext/mldsa_gh_native/vendor/mldsa-native/mldsa/src/fips202/fips202.c +270 -0
  24. data/ext/mldsa_gh_native/vendor/mldsa-native/mldsa/src/fips202/fips202.h +224 -0
  25. data/ext/mldsa_gh_native/vendor/mldsa-native/mldsa/src/fips202/fips202x4.c +187 -0
  26. data/ext/mldsa_gh_native/vendor/mldsa-native/mldsa/src/fips202/fips202x4.h +125 -0
  27. data/ext/mldsa_gh_native/vendor/mldsa-native/mldsa/src/fips202/keccakf1600.c +510 -0
  28. data/ext/mldsa_gh_native/vendor/mldsa-native/mldsa/src/fips202/keccakf1600.h +110 -0
  29. data/ext/mldsa_gh_native/vendor/mldsa-native/mldsa/src/fips202/native/aarch64/auto.h +85 -0
  30. data/ext/mldsa_gh_native/vendor/mldsa-native/mldsa/src/fips202/native/aarch64/src/fips202_native_aarch64.h +69 -0
  31. data/ext/mldsa_gh_native/vendor/mldsa-native/mldsa/src/fips202/native/aarch64/src/keccak_f1600_x1_scalar_aarch64_asm.S +378 -0
  32. data/ext/mldsa_gh_native/vendor/mldsa-native/mldsa/src/fips202/native/aarch64/src/keccak_f1600_x1_v84a_aarch64_asm.S +207 -0
  33. data/ext/mldsa_gh_native/vendor/mldsa-native/mldsa/src/fips202/native/aarch64/src/keccak_f1600_x2_v84a_aarch64_asm.S +262 -0
  34. data/ext/mldsa_gh_native/vendor/mldsa-native/mldsa/src/fips202/native/aarch64/src/keccak_f1600_x4_v8a_scalar_hybrid_aarch64_asm.S +1080 -0
  35. data/ext/mldsa_gh_native/vendor/mldsa-native/mldsa/src/fips202/native/aarch64/src/keccak_f1600_x4_v8a_v84a_scalar_hybrid_aarch64_asm.S +990 -0
  36. data/ext/mldsa_gh_native/vendor/mldsa-native/mldsa/src/fips202/native/aarch64/src/keccakf1600_round_constants.c +47 -0
  37. data/ext/mldsa_gh_native/vendor/mldsa-native/mldsa/src/fips202/native/aarch64/x1_scalar.h +27 -0
  38. data/ext/mldsa_gh_native/vendor/mldsa-native/mldsa/src/fips202/native/aarch64/x1_v84a.h +36 -0
  39. data/ext/mldsa_gh_native/vendor/mldsa-native/mldsa/src/fips202/native/aarch64/x2_v84a.h +40 -0
  40. data/ext/mldsa_gh_native/vendor/mldsa-native/mldsa/src/fips202/native/aarch64/x4_v8a_scalar.h +32 -0
  41. data/ext/mldsa_gh_native/vendor/mldsa-native/mldsa/src/fips202/native/aarch64/x4_v8a_v84a_scalar.h +37 -0
  42. data/ext/mldsa_gh_native/vendor/mldsa-native/mldsa/src/fips202/native/api.h +129 -0
  43. data/ext/mldsa_gh_native/vendor/mldsa-native/mldsa/src/fips202/native/armv81m/README.md +10 -0
  44. data/ext/mldsa_gh_native/vendor/mldsa-native/mldsa/src/fips202/native/armv81m/mve.h +67 -0
  45. data/ext/mldsa_gh_native/vendor/mldsa-native/mldsa/src/fips202/native/armv81m/src/fips202_native_armv81m.h +37 -0
  46. data/ext/mldsa_gh_native/vendor/mldsa-native/mldsa/src/fips202/native/armv81m/src/keccak_f1600_x4_mve.S +717 -0
  47. data/ext/mldsa_gh_native/vendor/mldsa-native/mldsa/src/fips202/native/armv81m/src/keccak_f1600_x4_mve.c +42 -0
  48. data/ext/mldsa_gh_native/vendor/mldsa-native/mldsa/src/fips202/native/armv81m/src/keccak_f1600_x4_state_extract_bytes_mve.S +334 -0
  49. data/ext/mldsa_gh_native/vendor/mldsa-native/mldsa/src/fips202/native/armv81m/src/keccak_f1600_x4_state_xor_bytes_mve.S +355 -0
  50. data/ext/mldsa_gh_native/vendor/mldsa-native/mldsa/src/fips202/native/armv81m/src/keccakf1600_round_constants.c +53 -0
  51. data/ext/mldsa_gh_native/vendor/mldsa-native/mldsa/src/fips202/native/auto.h +35 -0
  52. data/ext/mldsa_gh_native/vendor/mldsa-native/mldsa/src/fips202/native/x86_64/keccak_f1600_x4_avx2.h +34 -0
  53. data/ext/mldsa_gh_native/vendor/mldsa-native/mldsa/src/fips202/native/x86_64/src/fips202_native_x86_64.h +45 -0
  54. data/ext/mldsa_gh_native/vendor/mldsa-native/mldsa/src/fips202/native/x86_64/src/keccak_f1600_x4_avx2_asm.S +488 -0
  55. data/ext/mldsa_gh_native/vendor/mldsa-native/mldsa/src/fips202/native/x86_64/src/keccakf1600_constants.c +52 -0
  56. data/ext/mldsa_gh_native/vendor/mldsa-native/mldsa/src/native/aarch64/meta.h +314 -0
  57. data/ext/mldsa_gh_native/vendor/mldsa-native/mldsa/src/native/aarch64/src/aarch64_zetas.c +248 -0
  58. data/ext/mldsa_gh_native/vendor/mldsa-native/mldsa/src/native/aarch64/src/arith_native_aarch64.h +367 -0
  59. data/ext/mldsa_gh_native/vendor/mldsa-native/mldsa/src/native/aarch64/src/mldsa_intt_aarch64_asm.S +786 -0
  60. data/ext/mldsa_gh_native/vendor/mldsa-native/mldsa/src/native/aarch64/src/mldsa_ntt_aarch64_asm.S +686 -0
  61. data/ext/mldsa_gh_native/vendor/mldsa-native/mldsa/src/native/aarch64/src/mldsa_pointwise_montgomery_aarch64_asm.S +106 -0
  62. data/ext/mldsa_gh_native/vendor/mldsa-native/mldsa/src/native/aarch64/src/mldsa_poly_caddq_aarch64_asm.S +69 -0
  63. data/ext/mldsa_gh_native/vendor/mldsa-native/mldsa/src/native/aarch64/src/mldsa_poly_chknorm_aarch64_asm.S +76 -0
  64. data/ext/mldsa_gh_native/vendor/mldsa-native/mldsa/src/native/aarch64/src/mldsa_poly_decompose_32_aarch64_asm.S +108 -0
  65. data/ext/mldsa_gh_native/vendor/mldsa-native/mldsa/src/native/aarch64/src/mldsa_poly_decompose_88_aarch64_asm.S +108 -0
  66. data/ext/mldsa_gh_native/vendor/mldsa-native/mldsa/src/native/aarch64/src/mldsa_poly_use_hint_32_aarch64_asm.S +125 -0
  67. data/ext/mldsa_gh_native/vendor/mldsa-native/mldsa/src/native/aarch64/src/mldsa_poly_use_hint_88_aarch64_asm.S +133 -0
  68. data/ext/mldsa_gh_native/vendor/mldsa-native/mldsa/src/native/aarch64/src/mldsa_polyvecl_pointwise_acc_montgomery_l4_aarch64_asm.S +157 -0
  69. data/ext/mldsa_gh_native/vendor/mldsa-native/mldsa/src/native/aarch64/src/mldsa_polyvecl_pointwise_acc_montgomery_l5_aarch64_asm.S +173 -0
  70. data/ext/mldsa_gh_native/vendor/mldsa-native/mldsa/src/native/aarch64/src/mldsa_polyvecl_pointwise_acc_montgomery_l7_aarch64_asm.S +205 -0
  71. data/ext/mldsa_gh_native/vendor/mldsa-native/mldsa/src/native/aarch64/src/mldsa_polyz_unpack_17_aarch64_asm.S +103 -0
  72. data/ext/mldsa_gh_native/vendor/mldsa-native/mldsa/src/native/aarch64/src/mldsa_polyz_unpack_19_aarch64_asm.S +100 -0
  73. data/ext/mldsa_gh_native/vendor/mldsa-native/mldsa/src/native/aarch64/src/mldsa_rej_uniform_aarch64_asm.S +222 -0
  74. data/ext/mldsa_gh_native/vendor/mldsa-native/mldsa/src/native/aarch64/src/mldsa_rej_uniform_eta2_aarch64_asm.S +170 -0
  75. data/ext/mldsa_gh_native/vendor/mldsa-native/mldsa/src/native/aarch64/src/mldsa_rej_uniform_eta4_aarch64_asm.S +163 -0
  76. data/ext/mldsa_gh_native/vendor/mldsa-native/mldsa/src/native/aarch64/src/polyz_unpack_table.c +52 -0
  77. data/ext/mldsa_gh_native/vendor/mldsa-native/mldsa/src/native/aarch64/src/rej_uniform_eta_table.c +547 -0
  78. data/ext/mldsa_gh_native/vendor/mldsa-native/mldsa/src/native/aarch64/src/rej_uniform_table.c +63 -0
  79. data/ext/mldsa_gh_native/vendor/mldsa-native/mldsa/src/native/api.h +617 -0
  80. data/ext/mldsa_gh_native/vendor/mldsa-native/mldsa/src/native/meta.h +24 -0
  81. data/ext/mldsa_gh_native/vendor/mldsa-native/mldsa/src/native/x86_64/meta.h +323 -0
  82. data/ext/mldsa_gh_native/vendor/mldsa-native/mldsa/src/native/x86_64/src/arith_native_x86_64.h +330 -0
  83. data/ext/mldsa_gh_native/vendor/mldsa-native/mldsa/src/native/x86_64/src/consts.c +157 -0
  84. data/ext/mldsa_gh_native/vendor/mldsa-native/mldsa/src/native/x86_64/src/consts.h +27 -0
  85. data/ext/mldsa_gh_native/vendor/mldsa-native/mldsa/src/native/x86_64/src/mldsa_intt_avx2_asm.S +2333 -0
  86. data/ext/mldsa_gh_native/vendor/mldsa-native/mldsa/src/native/x86_64/src/mldsa_ntt_avx2_asm.S +2405 -0
  87. data/ext/mldsa_gh_native/vendor/mldsa-native/mldsa/src/native/x86_64/src/mldsa_nttunpack_avx2_asm.S +254 -0
  88. data/ext/mldsa_gh_native/vendor/mldsa-native/mldsa/src/native/x86_64/src/mldsa_pointwise_acc_l4_avx2_asm.S +173 -0
  89. data/ext/mldsa_gh_native/vendor/mldsa-native/mldsa/src/native/x86_64/src/mldsa_pointwise_acc_l5_avx2_asm.S +189 -0
  90. data/ext/mldsa_gh_native/vendor/mldsa-native/mldsa/src/native/x86_64/src/mldsa_pointwise_acc_l7_avx2_asm.S +221 -0
  91. data/ext/mldsa_gh_native/vendor/mldsa-native/mldsa/src/native/x86_64/src/mldsa_pointwise_avx2_asm.S +158 -0
  92. data/ext/mldsa_gh_native/vendor/mldsa-native/mldsa/src/native/x86_64/src/mldsa_poly_caddq_avx2_asm.S +199 -0
  93. data/ext/mldsa_gh_native/vendor/mldsa-native/mldsa/src/native/x86_64/src/mldsa_poly_chknorm_avx2_asm.S +176 -0
  94. data/ext/mldsa_gh_native/vendor/mldsa-native/mldsa/src/native/x86_64/src/mldsa_poly_decompose_32_avx2_asm.S +490 -0
  95. data/ext/mldsa_gh_native/vendor/mldsa-native/mldsa/src/native/x86_64/src/mldsa_poly_decompose_88_avx2_asm.S +489 -0
  96. data/ext/mldsa_gh_native/vendor/mldsa-native/mldsa/src/native/x86_64/src/mldsa_poly_use_hint_32_avx2_asm.S +123 -0
  97. data/ext/mldsa_gh_native/vendor/mldsa-native/mldsa/src/native/x86_64/src/mldsa_poly_use_hint_88_avx2_asm.S +125 -0
  98. data/ext/mldsa_gh_native/vendor/mldsa-native/mldsa/src/native/x86_64/src/mldsa_polyz_unpack_17_avx2_asm.S +355 -0
  99. data/ext/mldsa_gh_native/vendor/mldsa-native/mldsa/src/native/x86_64/src/mldsa_polyz_unpack_19_avx2_asm.S +355 -0
  100. data/ext/mldsa_gh_native/vendor/mldsa-native/mldsa/src/native/x86_64/src/mldsa_rej_uniform_avx2_asm.S +132 -0
  101. data/ext/mldsa_gh_native/vendor/mldsa-native/mldsa/src/native/x86_64/src/mldsa_rej_uniform_eta2_avx2_asm.S +205 -0
  102. data/ext/mldsa_gh_native/vendor/mldsa-native/mldsa/src/native/x86_64/src/mldsa_rej_uniform_eta4_avx2_asm.S +176 -0
  103. data/ext/mldsa_gh_native/vendor/mldsa-native/mldsa/src/native/x86_64/src/rej_uniform_table.c +161 -0
  104. data/ext/mldsa_gh_native/vendor/mldsa-native/mldsa/src/packing.c +213 -0
  105. data/ext/mldsa_gh_native/vendor/mldsa-native/mldsa/src/packing.h +277 -0
  106. data/ext/mldsa_gh_native/vendor/mldsa-native/mldsa/src/params.h +153 -0
  107. data/ext/mldsa_gh_native/vendor/mldsa-native/mldsa/src/poly.c +1066 -0
  108. data/ext/mldsa_gh_native/vendor/mldsa-native/mldsa/src/poly.h +464 -0
  109. data/ext/mldsa_gh_native/vendor/mldsa-native/mldsa/src/poly_kl.c +910 -0
  110. data/ext/mldsa_gh_native/vendor/mldsa-native/mldsa/src/poly_kl.h +367 -0
  111. data/ext/mldsa_gh_native/vendor/mldsa-native/mldsa/src/polyvec.c +509 -0
  112. data/ext/mldsa_gh_native/vendor/mldsa-native/mldsa/src/polyvec.h +435 -0
  113. data/ext/mldsa_gh_native/vendor/mldsa-native/mldsa/src/polyvec_lazy.c +311 -0
  114. data/ext/mldsa_gh_native/vendor/mldsa-native/mldsa/src/polyvec_lazy.h +652 -0
  115. data/ext/mldsa_gh_native/vendor/mldsa-native/mldsa/src/randombytes.h +26 -0
  116. data/ext/mldsa_gh_native/vendor/mldsa-native/mldsa/src/reduce.h +144 -0
  117. data/ext/mldsa_gh_native/vendor/mldsa-native/mldsa/src/rounding.h +265 -0
  118. data/ext/mldsa_gh_native/vendor/mldsa-native/mldsa/src/sign.c +1720 -0
  119. data/ext/mldsa_gh_native/vendor/mldsa-native/mldsa/src/sign.h +850 -0
  120. data/ext/mldsa_gh_native/vendor/mldsa-native/mldsa/src/symmetric.h +68 -0
  121. data/ext/mldsa_gh_native/vendor/mldsa-native/mldsa/src/sys.h +327 -0
  122. data/ext/mldsa_gh_native/vendor/mldsa-native/mldsa/src/zetas.inc +55 -0
  123. data/lib/mldsa/parameter_set.rb +82 -0
  124. data/lib/mldsa/signing_key.rb +147 -0
  125. data/lib/mldsa/verify_key.rb +72 -0
  126. data/lib/mldsa/version.rb +7 -0
  127. data/lib/mldsa_gh.rb +93 -0
  128. metadata +225 -0
@@ -0,0 +1,254 @@
1
+ /*
2
+ * Copyright (c) The mlkem-native project authors
3
+ * Copyright (c) The mldsa-native project authors
4
+ * SPDX-License-Identifier: Apache-2.0 OR ISC OR MIT
5
+ */
6
+
7
+ /* References
8
+ * ==========
9
+ *
10
+ * - [REF_AVX2]
11
+ * CRYSTALS-Dilithium optimized AVX2 implementation
12
+ * Bai, Ducas, Kiltz, Lepoint, Lyubashevsky, Schwabe, Seiler, Stehlé
13
+ * https://github.com/pq-crystals/dilithium/tree/master/avx2
14
+ */
15
+
16
+ /*
17
+ * This file is derived from the public domain
18
+ * AVX2 Dilithium implementation @[REF_AVX2].
19
+ */
20
+
21
+ /*yaml
22
+ Name: nttunpack_avx2_asm
23
+ Description: x86_64 AVX2 NTT coefficient unpacking/permutation
24
+ Signature: void mld_nttunpack_avx2_asm(int32_t *r)
25
+ ABI:
26
+ Architecture: x86_64
27
+ CallingConvention: SysV
28
+ Features: [AVX2]
29
+ rdi:
30
+ type: buffer
31
+ size_bytes: 1024
32
+ permissions: read/write
33
+ c_parameter: int32_t *r
34
+ description: Input/output polynomial (256 x int32_t)
35
+ */
36
+
37
+ #include "../../../common.h"
38
+ #if defined(MLD_ARITH_BACKEND_X86_64_DEFAULT) && \
39
+ !defined(MLD_CONFIG_MULTILEVEL_NO_SHARED)
40
+
41
+ /*
42
+ * WARNING: This file is auto-derived from the mldsa-native source file
43
+ * dev/x86_64/src/mldsa_nttunpack_avx2_asm.S using scripts/simpasm. Do not modify it directly.
44
+ */
45
+
46
+ .text
47
+ .balign 4
48
+ .global MLD_ASM_NAMESPACE(nttunpack_avx2_asm)
49
+ MLD_ASM_FN_SYMBOL(nttunpack_avx2_asm)
50
+
51
+ .cfi_startproc
52
+ vmovdqa (%rdi), %ymm4
53
+ vmovdqa 0x20(%rdi), %ymm5
54
+ vmovdqa 0x40(%rdi), %ymm6
55
+ vmovdqa 0x60(%rdi), %ymm7
56
+ vmovdqa 0x80(%rdi), %ymm8
57
+ vmovdqa 0xa0(%rdi), %ymm9
58
+ vmovdqa 0xc0(%rdi), %ymm10
59
+ vmovdqa 0xe0(%rdi), %ymm11
60
+ vperm2i128 $0x20, %ymm8, %ymm4, %ymm3 # ymm3 = ymm4[0,1],ymm8[0,1]
61
+ vperm2i128 $0x31, %ymm8, %ymm4, %ymm8 # ymm8 = ymm4[2,3],ymm8[2,3]
62
+ vperm2i128 $0x20, %ymm9, %ymm5, %ymm4 # ymm4 = ymm5[0,1],ymm9[0,1]
63
+ vperm2i128 $0x31, %ymm9, %ymm5, %ymm9 # ymm9 = ymm5[2,3],ymm9[2,3]
64
+ vperm2i128 $0x20, %ymm10, %ymm6, %ymm5 # ymm5 = ymm6[0,1],ymm10[0,1]
65
+ vperm2i128 $0x31, %ymm10, %ymm6, %ymm10 # ymm10 = ymm6[2,3],ymm10[2,3]
66
+ vperm2i128 $0x20, %ymm11, %ymm7, %ymm6 # ymm6 = ymm7[0,1],ymm11[0,1]
67
+ vperm2i128 $0x31, %ymm11, %ymm7, %ymm11 # ymm11 = ymm7[2,3],ymm11[2,3]
68
+ vpunpcklqdq %ymm5, %ymm3, %ymm7 # ymm7 = ymm3[0],ymm5[0],ymm3[2],ymm5[2]
69
+ vpunpckhqdq %ymm5, %ymm3, %ymm5 # ymm5 = ymm3[1],ymm5[1],ymm3[3],ymm5[3]
70
+ vpunpcklqdq %ymm10, %ymm8, %ymm3 # ymm3 = ymm8[0],ymm10[0],ymm8[2],ymm10[2]
71
+ vpunpckhqdq %ymm10, %ymm8, %ymm10 # ymm10 = ymm8[1],ymm10[1],ymm8[3],ymm10[3]
72
+ vpunpcklqdq %ymm6, %ymm4, %ymm8 # ymm8 = ymm4[0],ymm6[0],ymm4[2],ymm6[2]
73
+ vpunpckhqdq %ymm6, %ymm4, %ymm6 # ymm6 = ymm4[1],ymm6[1],ymm4[3],ymm6[3]
74
+ vpunpcklqdq %ymm11, %ymm9, %ymm4 # ymm4 = ymm9[0],ymm11[0],ymm9[2],ymm11[2]
75
+ vpunpckhqdq %ymm11, %ymm9, %ymm11 # ymm11 = ymm9[1],ymm11[1],ymm9[3],ymm11[3]
76
+ vmovsldup %ymm8, %ymm9 # ymm9 = ymm8[0,0,2,2,4,4,6,6]
77
+ vpblendd $0xaa, %ymm9, %ymm7, %ymm9 # ymm9 = ymm7[0],ymm9[1],ymm7[2],ymm9[3],ymm7[4],ymm9[5],ymm7[6],ymm9[7]
78
+ vpsrlq $0x20, %ymm7, %ymm7
79
+ vpblendd $0xaa, %ymm8, %ymm7, %ymm8 # ymm8 = ymm7[0],ymm8[1],ymm7[2],ymm8[3],ymm7[4],ymm8[5],ymm7[6],ymm8[7]
80
+ vmovsldup %ymm6, %ymm7 # ymm7 = ymm6[0,0,2,2,4,4,6,6]
81
+ vpblendd $0xaa, %ymm7, %ymm5, %ymm7 # ymm7 = ymm5[0],ymm7[1],ymm5[2],ymm7[3],ymm5[4],ymm7[5],ymm5[6],ymm7[7]
82
+ vpsrlq $0x20, %ymm5, %ymm5
83
+ vpblendd $0xaa, %ymm6, %ymm5, %ymm6 # ymm6 = ymm5[0],ymm6[1],ymm5[2],ymm6[3],ymm5[4],ymm6[5],ymm5[6],ymm6[7]
84
+ vmovsldup %ymm4, %ymm5 # ymm5 = ymm4[0,0,2,2,4,4,6,6]
85
+ vpblendd $0xaa, %ymm5, %ymm3, %ymm5 # ymm5 = ymm3[0],ymm5[1],ymm3[2],ymm5[3],ymm3[4],ymm5[5],ymm3[6],ymm5[7]
86
+ vpsrlq $0x20, %ymm3, %ymm3
87
+ vpblendd $0xaa, %ymm4, %ymm3, %ymm4 # ymm4 = ymm3[0],ymm4[1],ymm3[2],ymm4[3],ymm3[4],ymm4[5],ymm3[6],ymm4[7]
88
+ vmovsldup %ymm11, %ymm3 # ymm3 = ymm11[0,0,2,2,4,4,6,6]
89
+ vpblendd $0xaa, %ymm3, %ymm10, %ymm3 # ymm3 = ymm10[0],ymm3[1],ymm10[2],ymm3[3],ymm10[4],ymm3[5],ymm10[6],ymm3[7]
90
+ vpsrlq $0x20, %ymm10, %ymm10
91
+ vpblendd $0xaa, %ymm11, %ymm10, %ymm11 # ymm11 = ymm10[0],ymm11[1],ymm10[2],ymm11[3],ymm10[4],ymm11[5],ymm10[6],ymm11[7]
92
+ vmovdqa %ymm9, (%rdi)
93
+ vmovdqa %ymm8, 0x20(%rdi)
94
+ vmovdqa %ymm7, 0x40(%rdi)
95
+ vmovdqa %ymm6, 0x60(%rdi)
96
+ vmovdqa %ymm5, 0x80(%rdi)
97
+ vmovdqa %ymm4, 0xa0(%rdi)
98
+ vmovdqa %ymm3, 0xc0(%rdi)
99
+ vmovdqa %ymm11, 0xe0(%rdi)
100
+ vmovdqa 0x100(%rdi), %ymm4
101
+ vmovdqa 0x120(%rdi), %ymm5
102
+ vmovdqa 0x140(%rdi), %ymm6
103
+ vmovdqa 0x160(%rdi), %ymm7
104
+ vmovdqa 0x180(%rdi), %ymm8
105
+ vmovdqa 0x1a0(%rdi), %ymm9
106
+ vmovdqa 0x1c0(%rdi), %ymm10
107
+ vmovdqa 0x1e0(%rdi), %ymm11
108
+ vperm2i128 $0x20, %ymm8, %ymm4, %ymm3 # ymm3 = ymm4[0,1],ymm8[0,1]
109
+ vperm2i128 $0x31, %ymm8, %ymm4, %ymm8 # ymm8 = ymm4[2,3],ymm8[2,3]
110
+ vperm2i128 $0x20, %ymm9, %ymm5, %ymm4 # ymm4 = ymm5[0,1],ymm9[0,1]
111
+ vperm2i128 $0x31, %ymm9, %ymm5, %ymm9 # ymm9 = ymm5[2,3],ymm9[2,3]
112
+ vperm2i128 $0x20, %ymm10, %ymm6, %ymm5 # ymm5 = ymm6[0,1],ymm10[0,1]
113
+ vperm2i128 $0x31, %ymm10, %ymm6, %ymm10 # ymm10 = ymm6[2,3],ymm10[2,3]
114
+ vperm2i128 $0x20, %ymm11, %ymm7, %ymm6 # ymm6 = ymm7[0,1],ymm11[0,1]
115
+ vperm2i128 $0x31, %ymm11, %ymm7, %ymm11 # ymm11 = ymm7[2,3],ymm11[2,3]
116
+ vpunpcklqdq %ymm5, %ymm3, %ymm7 # ymm7 = ymm3[0],ymm5[0],ymm3[2],ymm5[2]
117
+ vpunpckhqdq %ymm5, %ymm3, %ymm5 # ymm5 = ymm3[1],ymm5[1],ymm3[3],ymm5[3]
118
+ vpunpcklqdq %ymm10, %ymm8, %ymm3 # ymm3 = ymm8[0],ymm10[0],ymm8[2],ymm10[2]
119
+ vpunpckhqdq %ymm10, %ymm8, %ymm10 # ymm10 = ymm8[1],ymm10[1],ymm8[3],ymm10[3]
120
+ vpunpcklqdq %ymm6, %ymm4, %ymm8 # ymm8 = ymm4[0],ymm6[0],ymm4[2],ymm6[2]
121
+ vpunpckhqdq %ymm6, %ymm4, %ymm6 # ymm6 = ymm4[1],ymm6[1],ymm4[3],ymm6[3]
122
+ vpunpcklqdq %ymm11, %ymm9, %ymm4 # ymm4 = ymm9[0],ymm11[0],ymm9[2],ymm11[2]
123
+ vpunpckhqdq %ymm11, %ymm9, %ymm11 # ymm11 = ymm9[1],ymm11[1],ymm9[3],ymm11[3]
124
+ vmovsldup %ymm8, %ymm9 # ymm9 = ymm8[0,0,2,2,4,4,6,6]
125
+ vpblendd $0xaa, %ymm9, %ymm7, %ymm9 # ymm9 = ymm7[0],ymm9[1],ymm7[2],ymm9[3],ymm7[4],ymm9[5],ymm7[6],ymm9[7]
126
+ vpsrlq $0x20, %ymm7, %ymm7
127
+ vpblendd $0xaa, %ymm8, %ymm7, %ymm8 # ymm8 = ymm7[0],ymm8[1],ymm7[2],ymm8[3],ymm7[4],ymm8[5],ymm7[6],ymm8[7]
128
+ vmovsldup %ymm6, %ymm7 # ymm7 = ymm6[0,0,2,2,4,4,6,6]
129
+ vpblendd $0xaa, %ymm7, %ymm5, %ymm7 # ymm7 = ymm5[0],ymm7[1],ymm5[2],ymm7[3],ymm5[4],ymm7[5],ymm5[6],ymm7[7]
130
+ vpsrlq $0x20, %ymm5, %ymm5
131
+ vpblendd $0xaa, %ymm6, %ymm5, %ymm6 # ymm6 = ymm5[0],ymm6[1],ymm5[2],ymm6[3],ymm5[4],ymm6[5],ymm5[6],ymm6[7]
132
+ vmovsldup %ymm4, %ymm5 # ymm5 = ymm4[0,0,2,2,4,4,6,6]
133
+ vpblendd $0xaa, %ymm5, %ymm3, %ymm5 # ymm5 = ymm3[0],ymm5[1],ymm3[2],ymm5[3],ymm3[4],ymm5[5],ymm3[6],ymm5[7]
134
+ vpsrlq $0x20, %ymm3, %ymm3
135
+ vpblendd $0xaa, %ymm4, %ymm3, %ymm4 # ymm4 = ymm3[0],ymm4[1],ymm3[2],ymm4[3],ymm3[4],ymm4[5],ymm3[6],ymm4[7]
136
+ vmovsldup %ymm11, %ymm3 # ymm3 = ymm11[0,0,2,2,4,4,6,6]
137
+ vpblendd $0xaa, %ymm3, %ymm10, %ymm3 # ymm3 = ymm10[0],ymm3[1],ymm10[2],ymm3[3],ymm10[4],ymm3[5],ymm10[6],ymm3[7]
138
+ vpsrlq $0x20, %ymm10, %ymm10
139
+ vpblendd $0xaa, %ymm11, %ymm10, %ymm11 # ymm11 = ymm10[0],ymm11[1],ymm10[2],ymm11[3],ymm10[4],ymm11[5],ymm10[6],ymm11[7]
140
+ vmovdqa %ymm9, 0x100(%rdi)
141
+ vmovdqa %ymm8, 0x120(%rdi)
142
+ vmovdqa %ymm7, 0x140(%rdi)
143
+ vmovdqa %ymm6, 0x160(%rdi)
144
+ vmovdqa %ymm5, 0x180(%rdi)
145
+ vmovdqa %ymm4, 0x1a0(%rdi)
146
+ vmovdqa %ymm3, 0x1c0(%rdi)
147
+ vmovdqa %ymm11, 0x1e0(%rdi)
148
+ vmovdqa 0x200(%rdi), %ymm4
149
+ vmovdqa 0x220(%rdi), %ymm5
150
+ vmovdqa 0x240(%rdi), %ymm6
151
+ vmovdqa 0x260(%rdi), %ymm7
152
+ vmovdqa 0x280(%rdi), %ymm8
153
+ vmovdqa 0x2a0(%rdi), %ymm9
154
+ vmovdqa 0x2c0(%rdi), %ymm10
155
+ vmovdqa 0x2e0(%rdi), %ymm11
156
+ vperm2i128 $0x20, %ymm8, %ymm4, %ymm3 # ymm3 = ymm4[0,1],ymm8[0,1]
157
+ vperm2i128 $0x31, %ymm8, %ymm4, %ymm8 # ymm8 = ymm4[2,3],ymm8[2,3]
158
+ vperm2i128 $0x20, %ymm9, %ymm5, %ymm4 # ymm4 = ymm5[0,1],ymm9[0,1]
159
+ vperm2i128 $0x31, %ymm9, %ymm5, %ymm9 # ymm9 = ymm5[2,3],ymm9[2,3]
160
+ vperm2i128 $0x20, %ymm10, %ymm6, %ymm5 # ymm5 = ymm6[0,1],ymm10[0,1]
161
+ vperm2i128 $0x31, %ymm10, %ymm6, %ymm10 # ymm10 = ymm6[2,3],ymm10[2,3]
162
+ vperm2i128 $0x20, %ymm11, %ymm7, %ymm6 # ymm6 = ymm7[0,1],ymm11[0,1]
163
+ vperm2i128 $0x31, %ymm11, %ymm7, %ymm11 # ymm11 = ymm7[2,3],ymm11[2,3]
164
+ vpunpcklqdq %ymm5, %ymm3, %ymm7 # ymm7 = ymm3[0],ymm5[0],ymm3[2],ymm5[2]
165
+ vpunpckhqdq %ymm5, %ymm3, %ymm5 # ymm5 = ymm3[1],ymm5[1],ymm3[3],ymm5[3]
166
+ vpunpcklqdq %ymm10, %ymm8, %ymm3 # ymm3 = ymm8[0],ymm10[0],ymm8[2],ymm10[2]
167
+ vpunpckhqdq %ymm10, %ymm8, %ymm10 # ymm10 = ymm8[1],ymm10[1],ymm8[3],ymm10[3]
168
+ vpunpcklqdq %ymm6, %ymm4, %ymm8 # ymm8 = ymm4[0],ymm6[0],ymm4[2],ymm6[2]
169
+ vpunpckhqdq %ymm6, %ymm4, %ymm6 # ymm6 = ymm4[1],ymm6[1],ymm4[3],ymm6[3]
170
+ vpunpcklqdq %ymm11, %ymm9, %ymm4 # ymm4 = ymm9[0],ymm11[0],ymm9[2],ymm11[2]
171
+ vpunpckhqdq %ymm11, %ymm9, %ymm11 # ymm11 = ymm9[1],ymm11[1],ymm9[3],ymm11[3]
172
+ vmovsldup %ymm8, %ymm9 # ymm9 = ymm8[0,0,2,2,4,4,6,6]
173
+ vpblendd $0xaa, %ymm9, %ymm7, %ymm9 # ymm9 = ymm7[0],ymm9[1],ymm7[2],ymm9[3],ymm7[4],ymm9[5],ymm7[6],ymm9[7]
174
+ vpsrlq $0x20, %ymm7, %ymm7
175
+ vpblendd $0xaa, %ymm8, %ymm7, %ymm8 # ymm8 = ymm7[0],ymm8[1],ymm7[2],ymm8[3],ymm7[4],ymm8[5],ymm7[6],ymm8[7]
176
+ vmovsldup %ymm6, %ymm7 # ymm7 = ymm6[0,0,2,2,4,4,6,6]
177
+ vpblendd $0xaa, %ymm7, %ymm5, %ymm7 # ymm7 = ymm5[0],ymm7[1],ymm5[2],ymm7[3],ymm5[4],ymm7[5],ymm5[6],ymm7[7]
178
+ vpsrlq $0x20, %ymm5, %ymm5
179
+ vpblendd $0xaa, %ymm6, %ymm5, %ymm6 # ymm6 = ymm5[0],ymm6[1],ymm5[2],ymm6[3],ymm5[4],ymm6[5],ymm5[6],ymm6[7]
180
+ vmovsldup %ymm4, %ymm5 # ymm5 = ymm4[0,0,2,2,4,4,6,6]
181
+ vpblendd $0xaa, %ymm5, %ymm3, %ymm5 # ymm5 = ymm3[0],ymm5[1],ymm3[2],ymm5[3],ymm3[4],ymm5[5],ymm3[6],ymm5[7]
182
+ vpsrlq $0x20, %ymm3, %ymm3
183
+ vpblendd $0xaa, %ymm4, %ymm3, %ymm4 # ymm4 = ymm3[0],ymm4[1],ymm3[2],ymm4[3],ymm3[4],ymm4[5],ymm3[6],ymm4[7]
184
+ vmovsldup %ymm11, %ymm3 # ymm3 = ymm11[0,0,2,2,4,4,6,6]
185
+ vpblendd $0xaa, %ymm3, %ymm10, %ymm3 # ymm3 = ymm10[0],ymm3[1],ymm10[2],ymm3[3],ymm10[4],ymm3[5],ymm10[6],ymm3[7]
186
+ vpsrlq $0x20, %ymm10, %ymm10
187
+ vpblendd $0xaa, %ymm11, %ymm10, %ymm11 # ymm11 = ymm10[0],ymm11[1],ymm10[2],ymm11[3],ymm10[4],ymm11[5],ymm10[6],ymm11[7]
188
+ vmovdqa %ymm9, 0x200(%rdi)
189
+ vmovdqa %ymm8, 0x220(%rdi)
190
+ vmovdqa %ymm7, 0x240(%rdi)
191
+ vmovdqa %ymm6, 0x260(%rdi)
192
+ vmovdqa %ymm5, 0x280(%rdi)
193
+ vmovdqa %ymm4, 0x2a0(%rdi)
194
+ vmovdqa %ymm3, 0x2c0(%rdi)
195
+ vmovdqa %ymm11, 0x2e0(%rdi)
196
+ vmovdqa 0x300(%rdi), %ymm4
197
+ vmovdqa 0x320(%rdi), %ymm5
198
+ vmovdqa 0x340(%rdi), %ymm6
199
+ vmovdqa 0x360(%rdi), %ymm7
200
+ vmovdqa 0x380(%rdi), %ymm8
201
+ vmovdqa 0x3a0(%rdi), %ymm9
202
+ vmovdqa 0x3c0(%rdi), %ymm10
203
+ vmovdqa 0x3e0(%rdi), %ymm11
204
+ vperm2i128 $0x20, %ymm8, %ymm4, %ymm3 # ymm3 = ymm4[0,1],ymm8[0,1]
205
+ vperm2i128 $0x31, %ymm8, %ymm4, %ymm8 # ymm8 = ymm4[2,3],ymm8[2,3]
206
+ vperm2i128 $0x20, %ymm9, %ymm5, %ymm4 # ymm4 = ymm5[0,1],ymm9[0,1]
207
+ vperm2i128 $0x31, %ymm9, %ymm5, %ymm9 # ymm9 = ymm5[2,3],ymm9[2,3]
208
+ vperm2i128 $0x20, %ymm10, %ymm6, %ymm5 # ymm5 = ymm6[0,1],ymm10[0,1]
209
+ vperm2i128 $0x31, %ymm10, %ymm6, %ymm10 # ymm10 = ymm6[2,3],ymm10[2,3]
210
+ vperm2i128 $0x20, %ymm11, %ymm7, %ymm6 # ymm6 = ymm7[0,1],ymm11[0,1]
211
+ vperm2i128 $0x31, %ymm11, %ymm7, %ymm11 # ymm11 = ymm7[2,3],ymm11[2,3]
212
+ vpunpcklqdq %ymm5, %ymm3, %ymm7 # ymm7 = ymm3[0],ymm5[0],ymm3[2],ymm5[2]
213
+ vpunpckhqdq %ymm5, %ymm3, %ymm5 # ymm5 = ymm3[1],ymm5[1],ymm3[3],ymm5[3]
214
+ vpunpcklqdq %ymm10, %ymm8, %ymm3 # ymm3 = ymm8[0],ymm10[0],ymm8[2],ymm10[2]
215
+ vpunpckhqdq %ymm10, %ymm8, %ymm10 # ymm10 = ymm8[1],ymm10[1],ymm8[3],ymm10[3]
216
+ vpunpcklqdq %ymm6, %ymm4, %ymm8 # ymm8 = ymm4[0],ymm6[0],ymm4[2],ymm6[2]
217
+ vpunpckhqdq %ymm6, %ymm4, %ymm6 # ymm6 = ymm4[1],ymm6[1],ymm4[3],ymm6[3]
218
+ vpunpcklqdq %ymm11, %ymm9, %ymm4 # ymm4 = ymm9[0],ymm11[0],ymm9[2],ymm11[2]
219
+ vpunpckhqdq %ymm11, %ymm9, %ymm11 # ymm11 = ymm9[1],ymm11[1],ymm9[3],ymm11[3]
220
+ vmovsldup %ymm8, %ymm9 # ymm9 = ymm8[0,0,2,2,4,4,6,6]
221
+ vpblendd $0xaa, %ymm9, %ymm7, %ymm9 # ymm9 = ymm7[0],ymm9[1],ymm7[2],ymm9[3],ymm7[4],ymm9[5],ymm7[6],ymm9[7]
222
+ vpsrlq $0x20, %ymm7, %ymm7
223
+ vpblendd $0xaa, %ymm8, %ymm7, %ymm8 # ymm8 = ymm7[0],ymm8[1],ymm7[2],ymm8[3],ymm7[4],ymm8[5],ymm7[6],ymm8[7]
224
+ vmovsldup %ymm6, %ymm7 # ymm7 = ymm6[0,0,2,2,4,4,6,6]
225
+ vpblendd $0xaa, %ymm7, %ymm5, %ymm7 # ymm7 = ymm5[0],ymm7[1],ymm5[2],ymm7[3],ymm5[4],ymm7[5],ymm5[6],ymm7[7]
226
+ vpsrlq $0x20, %ymm5, %ymm5
227
+ vpblendd $0xaa, %ymm6, %ymm5, %ymm6 # ymm6 = ymm5[0],ymm6[1],ymm5[2],ymm6[3],ymm5[4],ymm6[5],ymm5[6],ymm6[7]
228
+ vmovsldup %ymm4, %ymm5 # ymm5 = ymm4[0,0,2,2,4,4,6,6]
229
+ vpblendd $0xaa, %ymm5, %ymm3, %ymm5 # ymm5 = ymm3[0],ymm5[1],ymm3[2],ymm5[3],ymm3[4],ymm5[5],ymm3[6],ymm5[7]
230
+ vpsrlq $0x20, %ymm3, %ymm3
231
+ vpblendd $0xaa, %ymm4, %ymm3, %ymm4 # ymm4 = ymm3[0],ymm4[1],ymm3[2],ymm4[3],ymm3[4],ymm4[5],ymm3[6],ymm4[7]
232
+ vmovsldup %ymm11, %ymm3 # ymm3 = ymm11[0,0,2,2,4,4,6,6]
233
+ vpblendd $0xaa, %ymm3, %ymm10, %ymm3 # ymm3 = ymm10[0],ymm3[1],ymm10[2],ymm3[3],ymm10[4],ymm3[5],ymm10[6],ymm3[7]
234
+ vpsrlq $0x20, %ymm10, %ymm10
235
+ vpblendd $0xaa, %ymm11, %ymm10, %ymm11 # ymm11 = ymm10[0],ymm11[1],ymm10[2],ymm11[3],ymm10[4],ymm11[5],ymm10[6],ymm11[7]
236
+ vmovdqa %ymm9, 0x300(%rdi)
237
+ vmovdqa %ymm8, 0x320(%rdi)
238
+ vmovdqa %ymm7, 0x340(%rdi)
239
+ vmovdqa %ymm6, 0x360(%rdi)
240
+ vmovdqa %ymm5, 0x380(%rdi)
241
+ vmovdqa %ymm4, 0x3a0(%rdi)
242
+ vmovdqa %ymm3, 0x3c0(%rdi)
243
+ vmovdqa %ymm11, 0x3e0(%rdi)
244
+ retq
245
+ .cfi_endproc
246
+
247
+ MLD_ASM_FN_SIZE(nttunpack_avx2_asm)
248
+
249
+ #endif /* MLD_ARITH_BACKEND_X86_64_DEFAULT && !MLD_CONFIG_MULTILEVEL_NO_SHARED \
250
+ */
251
+
252
+ #if defined(__ELF__)
253
+ .section .note.GNU-stack,"",%progbits
254
+ #endif
@@ -0,0 +1,173 @@
1
+ /*
2
+ * Copyright (c) The mldsa-native project authors
3
+ * SPDX-License-Identifier: Apache-2.0 OR ISC OR MIT
4
+ */
5
+
6
+ /* References
7
+ * ==========
8
+ *
9
+ * - [REF_AVX2]
10
+ * CRYSTALS-Dilithium optimized AVX2 implementation
11
+ * Bai, Ducas, Kiltz, Lepoint, Lyubashevsky, Schwabe, Seiler, Stehlé
12
+ * https://github.com/pq-crystals/dilithium/tree/master/avx2
13
+ */
14
+
15
+ /*
16
+ * This file is derived from the public domain
17
+ * AVX2 Dilithium implementation @[REF_AVX2].
18
+ */
19
+
20
+ /*yaml
21
+ Name: pointwise_acc_l4_avx2_asm
22
+ Description: x86_64 AVX2 pointwise multiply-accumulate of length-4 polynomial vectors
23
+ Signature: void mld_pointwise_acc_l4_avx2_asm(int32_t *c, const int32_t a[4][256], const int32_t b[4][256], const int32_t *qdata)
24
+ ABI:
25
+ Architecture: x86_64
26
+ CallingConvention: SysV
27
+ Features: [AVX2]
28
+ rdi:
29
+ type: buffer
30
+ size_bytes: 1024
31
+ permissions: write-only
32
+ c_parameter: int32_t *c
33
+ description: Output polynomial (256 x int32_t)
34
+ rsi:
35
+ type: buffer
36
+ size_bytes: 4096
37
+ permissions: read-only
38
+ c_parameter: const int32_t a[4][256]
39
+ description: Input polynomial vector a (4 x 256 x int32_t)
40
+ rdx:
41
+ type: buffer
42
+ size_bytes: 4096
43
+ permissions: read-only
44
+ c_parameter: const int32_t b[4][256]
45
+ description: Input polynomial vector b (4 x 256 x int32_t)
46
+ rcx:
47
+ type: buffer
48
+ size_bytes: 2496
49
+ permissions: read-only
50
+ c_parameter: const int32_t *qdata
51
+ description: Precomputed constants (624 x int32_t)
52
+ */
53
+
54
+ #include "../../../common.h"
55
+ #if defined(MLD_ARITH_BACKEND_X86_64_DEFAULT) && \
56
+ !defined(MLD_CONFIG_MULTILEVEL_NO_SHARED) && \
57
+ (defined(MLD_CONFIG_MULTILEVEL_WITH_SHARED) || MLDSA_L == 4)
58
+
59
+ /*
60
+ * WARNING: This file is auto-derived from the mldsa-native source file
61
+ * dev/x86_64/src/mldsa_pointwise_acc_l4_avx2_asm.S using scripts/simpasm. Do not modify it directly.
62
+ */
63
+
64
+ .text
65
+ .balign 4
66
+ .global MLD_ASM_NAMESPACE(pointwise_acc_l4_avx2_asm)
67
+ MLD_ASM_FN_SYMBOL(pointwise_acc_l4_avx2_asm)
68
+
69
+ .cfi_startproc
70
+ vmovdqa 0x20(%rcx), %ymm0
71
+ vmovdqa (%rcx), %ymm1
72
+ xorl %eax, %eax
73
+
74
+ Lmld_pointwise_acc_l4_avx2_looptop2:
75
+ vmovdqa (%rsi), %ymm6
76
+ vmovdqa 0x20(%rsi), %ymm8
77
+ vmovdqa (%rdx), %ymm10
78
+ vmovdqa 0x20(%rdx), %ymm12
79
+ vpsrlq $0x20, %ymm6, %ymm7
80
+ vpsrlq $0x20, %ymm8, %ymm9
81
+ vmovshdup %ymm10, %ymm11 # ymm11 = ymm10[1,1,3,3,5,5,7,7]
82
+ vmovshdup %ymm12, %ymm13 # ymm13 = ymm12[1,1,3,3,5,5,7,7]
83
+ vpmuldq %ymm10, %ymm6, %ymm6
84
+ vpmuldq %ymm11, %ymm7, %ymm7
85
+ vpmuldq %ymm12, %ymm8, %ymm8
86
+ vpmuldq %ymm13, %ymm9, %ymm9
87
+ vmovdqa %ymm6, %ymm2
88
+ vmovdqa %ymm7, %ymm3
89
+ vmovdqa %ymm8, %ymm4
90
+ vmovdqa %ymm9, %ymm5
91
+ vmovdqa 0x400(%rsi), %ymm6
92
+ vmovdqa 0x420(%rsi), %ymm8
93
+ vmovdqa 0x400(%rdx), %ymm10
94
+ vmovdqa 0x420(%rdx), %ymm12
95
+ vpsrlq $0x20, %ymm6, %ymm7
96
+ vpsrlq $0x20, %ymm8, %ymm9
97
+ vmovshdup %ymm10, %ymm11 # ymm11 = ymm10[1,1,3,3,5,5,7,7]
98
+ vmovshdup %ymm12, %ymm13 # ymm13 = ymm12[1,1,3,3,5,5,7,7]
99
+ vpmuldq %ymm10, %ymm6, %ymm6
100
+ vpmuldq %ymm11, %ymm7, %ymm7
101
+ vpmuldq %ymm12, %ymm8, %ymm8
102
+ vpmuldq %ymm13, %ymm9, %ymm9
103
+ vpaddq %ymm2, %ymm6, %ymm2
104
+ vpaddq %ymm3, %ymm7, %ymm3
105
+ vpaddq %ymm4, %ymm8, %ymm4
106
+ vpaddq %ymm5, %ymm9, %ymm5
107
+ vmovdqa 0x800(%rsi), %ymm6
108
+ vmovdqa 0x820(%rsi), %ymm8
109
+ vmovdqa 0x800(%rdx), %ymm10
110
+ vmovdqa 0x820(%rdx), %ymm12
111
+ vpsrlq $0x20, %ymm6, %ymm7
112
+ vpsrlq $0x20, %ymm8, %ymm9
113
+ vmovshdup %ymm10, %ymm11 # ymm11 = ymm10[1,1,3,3,5,5,7,7]
114
+ vmovshdup %ymm12, %ymm13 # ymm13 = ymm12[1,1,3,3,5,5,7,7]
115
+ vpmuldq %ymm10, %ymm6, %ymm6
116
+ vpmuldq %ymm11, %ymm7, %ymm7
117
+ vpmuldq %ymm12, %ymm8, %ymm8
118
+ vpmuldq %ymm13, %ymm9, %ymm9
119
+ vpaddq %ymm2, %ymm6, %ymm2
120
+ vpaddq %ymm3, %ymm7, %ymm3
121
+ vpaddq %ymm4, %ymm8, %ymm4
122
+ vpaddq %ymm5, %ymm9, %ymm5
123
+ vmovdqa 0xc00(%rsi), %ymm6
124
+ vmovdqa 0xc20(%rsi), %ymm8
125
+ vmovdqa 0xc00(%rdx), %ymm10
126
+ vmovdqa 0xc20(%rdx), %ymm12
127
+ vpsrlq $0x20, %ymm6, %ymm7
128
+ vpsrlq $0x20, %ymm8, %ymm9
129
+ vmovshdup %ymm10, %ymm11 # ymm11 = ymm10[1,1,3,3,5,5,7,7]
130
+ vmovshdup %ymm12, %ymm13 # ymm13 = ymm12[1,1,3,3,5,5,7,7]
131
+ vpmuldq %ymm10, %ymm6, %ymm6
132
+ vpmuldq %ymm11, %ymm7, %ymm7
133
+ vpmuldq %ymm12, %ymm8, %ymm8
134
+ vpmuldq %ymm13, %ymm9, %ymm9
135
+ vpaddq %ymm2, %ymm6, %ymm2
136
+ vpaddq %ymm3, %ymm7, %ymm3
137
+ vpaddq %ymm4, %ymm8, %ymm4
138
+ vpaddq %ymm5, %ymm9, %ymm5
139
+ vpmuldq %ymm2, %ymm0, %ymm6
140
+ vpmuldq %ymm3, %ymm0, %ymm7
141
+ vpmuldq %ymm4, %ymm0, %ymm8
142
+ vpmuldq %ymm5, %ymm0, %ymm9
143
+ vpmuldq %ymm6, %ymm1, %ymm6
144
+ vpmuldq %ymm7, %ymm1, %ymm7
145
+ vpmuldq %ymm8, %ymm1, %ymm8
146
+ vpmuldq %ymm9, %ymm1, %ymm9
147
+ vpsubq %ymm6, %ymm2, %ymm2
148
+ vpsubq %ymm7, %ymm3, %ymm3
149
+ vpsubq %ymm8, %ymm4, %ymm4
150
+ vpsubq %ymm9, %ymm5, %ymm5
151
+ vpsrlq $0x20, %ymm2, %ymm2
152
+ vmovshdup %ymm4, %ymm4 # ymm4 = ymm4[1,1,3,3,5,5,7,7]
153
+ vpblendd $0xaa, %ymm3, %ymm2, %ymm2 # ymm2 = ymm2[0],ymm3[1],ymm2[2],ymm3[3],ymm2[4],ymm3[5],ymm2[6],ymm3[7]
154
+ vpblendd $0xaa, %ymm5, %ymm4, %ymm4 # ymm4 = ymm4[0],ymm5[1],ymm4[2],ymm5[3],ymm4[4],ymm5[5],ymm4[6],ymm5[7]
155
+ vmovdqa %ymm2, (%rdi)
156
+ vmovdqa %ymm4, 0x20(%rdi)
157
+ addq $0x40, %rsi
158
+ addq $0x40, %rdx
159
+ addq $0x40, %rdi
160
+ addl $0x1, %eax
161
+ cmpl $0x10, %eax
162
+ jb Lmld_pointwise_acc_l4_avx2_looptop2
163
+ retq
164
+ .cfi_endproc
165
+
166
+ MLD_ASM_FN_SIZE(pointwise_acc_l4_avx2_asm)
167
+
168
+ #endif /* MLD_ARITH_BACKEND_X86_64_DEFAULT && !MLD_CONFIG_MULTILEVEL_NO_SHARED \
169
+ && (MLD_CONFIG_MULTILEVEL_WITH_SHARED || MLDSA_L == 4) */
170
+
171
+ #if defined(__ELF__)
172
+ .section .note.GNU-stack,"",%progbits
173
+ #endif
@@ -0,0 +1,189 @@
1
+ /*
2
+ * Copyright (c) The mldsa-native project authors
3
+ * SPDX-License-Identifier: Apache-2.0 OR ISC OR MIT
4
+ */
5
+
6
+ /* References
7
+ * ==========
8
+ *
9
+ * - [REF_AVX2]
10
+ * CRYSTALS-Dilithium optimized AVX2 implementation
11
+ * Bai, Ducas, Kiltz, Lepoint, Lyubashevsky, Schwabe, Seiler, Stehlé
12
+ * https://github.com/pq-crystals/dilithium/tree/master/avx2
13
+ */
14
+
15
+ /*
16
+ * This file is derived from the public domain
17
+ * AVX2 Dilithium implementation @[REF_AVX2].
18
+ */
19
+
20
+ /*yaml
21
+ Name: pointwise_acc_l5_avx2_asm
22
+ Description: x86_64 AVX2 pointwise multiply-accumulate of length-5 polynomial vectors
23
+ Signature: void mld_pointwise_acc_l5_avx2_asm(int32_t *c, const int32_t a[5][256], const int32_t b[5][256], const int32_t *qdata)
24
+ ABI:
25
+ Architecture: x86_64
26
+ CallingConvention: SysV
27
+ Features: [AVX2]
28
+ rdi:
29
+ type: buffer
30
+ size_bytes: 1024
31
+ permissions: write-only
32
+ c_parameter: int32_t *c
33
+ description: Output polynomial (256 x int32_t)
34
+ rsi:
35
+ type: buffer
36
+ size_bytes: 5120
37
+ permissions: read-only
38
+ c_parameter: const int32_t a[5][256]
39
+ description: Input polynomial vector a (5 x 256 x int32_t)
40
+ rdx:
41
+ type: buffer
42
+ size_bytes: 5120
43
+ permissions: read-only
44
+ c_parameter: const int32_t b[5][256]
45
+ description: Input polynomial vector b (5 x 256 x int32_t)
46
+ rcx:
47
+ type: buffer
48
+ size_bytes: 2496
49
+ permissions: read-only
50
+ c_parameter: const int32_t *qdata
51
+ description: Precomputed constants (624 x int32_t)
52
+ */
53
+
54
+ #include "../../../common.h"
55
+ #if defined(MLD_ARITH_BACKEND_X86_64_DEFAULT) && \
56
+ !defined(MLD_CONFIG_MULTILEVEL_NO_SHARED) && \
57
+ (defined(MLD_CONFIG_MULTILEVEL_WITH_SHARED) || MLDSA_L == 5)
58
+
59
+ /*
60
+ * WARNING: This file is auto-derived from the mldsa-native source file
61
+ * dev/x86_64/src/mldsa_pointwise_acc_l5_avx2_asm.S using scripts/simpasm. Do not modify it directly.
62
+ */
63
+
64
+ .text
65
+ .balign 4
66
+ .global MLD_ASM_NAMESPACE(pointwise_acc_l5_avx2_asm)
67
+ MLD_ASM_FN_SYMBOL(pointwise_acc_l5_avx2_asm)
68
+
69
+ .cfi_startproc
70
+ vmovdqa 0x20(%rcx), %ymm0
71
+ vmovdqa (%rcx), %ymm1
72
+ xorl %eax, %eax
73
+
74
+ Lmld_pointwise_acc_l5_avx2_looptop2:
75
+ vmovdqa (%rsi), %ymm6
76
+ vmovdqa 0x20(%rsi), %ymm8
77
+ vmovdqa (%rdx), %ymm10
78
+ vmovdqa 0x20(%rdx), %ymm12
79
+ vpsrlq $0x20, %ymm6, %ymm7
80
+ vpsrlq $0x20, %ymm8, %ymm9
81
+ vmovshdup %ymm10, %ymm11 # ymm11 = ymm10[1,1,3,3,5,5,7,7]
82
+ vmovshdup %ymm12, %ymm13 # ymm13 = ymm12[1,1,3,3,5,5,7,7]
83
+ vpmuldq %ymm10, %ymm6, %ymm6
84
+ vpmuldq %ymm11, %ymm7, %ymm7
85
+ vpmuldq %ymm12, %ymm8, %ymm8
86
+ vpmuldq %ymm13, %ymm9, %ymm9
87
+ vmovdqa %ymm6, %ymm2
88
+ vmovdqa %ymm7, %ymm3
89
+ vmovdqa %ymm8, %ymm4
90
+ vmovdqa %ymm9, %ymm5
91
+ vmovdqa 0x400(%rsi), %ymm6
92
+ vmovdqa 0x420(%rsi), %ymm8
93
+ vmovdqa 0x400(%rdx), %ymm10
94
+ vmovdqa 0x420(%rdx), %ymm12
95
+ vpsrlq $0x20, %ymm6, %ymm7
96
+ vpsrlq $0x20, %ymm8, %ymm9
97
+ vmovshdup %ymm10, %ymm11 # ymm11 = ymm10[1,1,3,3,5,5,7,7]
98
+ vmovshdup %ymm12, %ymm13 # ymm13 = ymm12[1,1,3,3,5,5,7,7]
99
+ vpmuldq %ymm10, %ymm6, %ymm6
100
+ vpmuldq %ymm11, %ymm7, %ymm7
101
+ vpmuldq %ymm12, %ymm8, %ymm8
102
+ vpmuldq %ymm13, %ymm9, %ymm9
103
+ vpaddq %ymm2, %ymm6, %ymm2
104
+ vpaddq %ymm3, %ymm7, %ymm3
105
+ vpaddq %ymm4, %ymm8, %ymm4
106
+ vpaddq %ymm5, %ymm9, %ymm5
107
+ vmovdqa 0x800(%rsi), %ymm6
108
+ vmovdqa 0x820(%rsi), %ymm8
109
+ vmovdqa 0x800(%rdx), %ymm10
110
+ vmovdqa 0x820(%rdx), %ymm12
111
+ vpsrlq $0x20, %ymm6, %ymm7
112
+ vpsrlq $0x20, %ymm8, %ymm9
113
+ vmovshdup %ymm10, %ymm11 # ymm11 = ymm10[1,1,3,3,5,5,7,7]
114
+ vmovshdup %ymm12, %ymm13 # ymm13 = ymm12[1,1,3,3,5,5,7,7]
115
+ vpmuldq %ymm10, %ymm6, %ymm6
116
+ vpmuldq %ymm11, %ymm7, %ymm7
117
+ vpmuldq %ymm12, %ymm8, %ymm8
118
+ vpmuldq %ymm13, %ymm9, %ymm9
119
+ vpaddq %ymm2, %ymm6, %ymm2
120
+ vpaddq %ymm3, %ymm7, %ymm3
121
+ vpaddq %ymm4, %ymm8, %ymm4
122
+ vpaddq %ymm5, %ymm9, %ymm5
123
+ vmovdqa 0xc00(%rsi), %ymm6
124
+ vmovdqa 0xc20(%rsi), %ymm8
125
+ vmovdqa 0xc00(%rdx), %ymm10
126
+ vmovdqa 0xc20(%rdx), %ymm12
127
+ vpsrlq $0x20, %ymm6, %ymm7
128
+ vpsrlq $0x20, %ymm8, %ymm9
129
+ vmovshdup %ymm10, %ymm11 # ymm11 = ymm10[1,1,3,3,5,5,7,7]
130
+ vmovshdup %ymm12, %ymm13 # ymm13 = ymm12[1,1,3,3,5,5,7,7]
131
+ vpmuldq %ymm10, %ymm6, %ymm6
132
+ vpmuldq %ymm11, %ymm7, %ymm7
133
+ vpmuldq %ymm12, %ymm8, %ymm8
134
+ vpmuldq %ymm13, %ymm9, %ymm9
135
+ vpaddq %ymm2, %ymm6, %ymm2
136
+ vpaddq %ymm3, %ymm7, %ymm3
137
+ vpaddq %ymm4, %ymm8, %ymm4
138
+ vpaddq %ymm5, %ymm9, %ymm5
139
+ vmovdqa 0x1000(%rsi), %ymm6
140
+ vmovdqa 0x1020(%rsi), %ymm8
141
+ vmovdqa 0x1000(%rdx), %ymm10
142
+ vmovdqa 0x1020(%rdx), %ymm12
143
+ vpsrlq $0x20, %ymm6, %ymm7
144
+ vpsrlq $0x20, %ymm8, %ymm9
145
+ vmovshdup %ymm10, %ymm11 # ymm11 = ymm10[1,1,3,3,5,5,7,7]
146
+ vmovshdup %ymm12, %ymm13 # ymm13 = ymm12[1,1,3,3,5,5,7,7]
147
+ vpmuldq %ymm10, %ymm6, %ymm6
148
+ vpmuldq %ymm11, %ymm7, %ymm7
149
+ vpmuldq %ymm12, %ymm8, %ymm8
150
+ vpmuldq %ymm13, %ymm9, %ymm9
151
+ vpaddq %ymm2, %ymm6, %ymm2
152
+ vpaddq %ymm3, %ymm7, %ymm3
153
+ vpaddq %ymm4, %ymm8, %ymm4
154
+ vpaddq %ymm5, %ymm9, %ymm5
155
+ vpmuldq %ymm2, %ymm0, %ymm6
156
+ vpmuldq %ymm3, %ymm0, %ymm7
157
+ vpmuldq %ymm4, %ymm0, %ymm8
158
+ vpmuldq %ymm5, %ymm0, %ymm9
159
+ vpmuldq %ymm6, %ymm1, %ymm6
160
+ vpmuldq %ymm7, %ymm1, %ymm7
161
+ vpmuldq %ymm8, %ymm1, %ymm8
162
+ vpmuldq %ymm9, %ymm1, %ymm9
163
+ vpsubq %ymm6, %ymm2, %ymm2
164
+ vpsubq %ymm7, %ymm3, %ymm3
165
+ vpsubq %ymm8, %ymm4, %ymm4
166
+ vpsubq %ymm9, %ymm5, %ymm5
167
+ vpsrlq $0x20, %ymm2, %ymm2
168
+ vmovshdup %ymm4, %ymm4 # ymm4 = ymm4[1,1,3,3,5,5,7,7]
169
+ vpblendd $0xaa, %ymm3, %ymm2, %ymm2 # ymm2 = ymm2[0],ymm3[1],ymm2[2],ymm3[3],ymm2[4],ymm3[5],ymm2[6],ymm3[7]
170
+ vpblendd $0xaa, %ymm5, %ymm4, %ymm4 # ymm4 = ymm4[0],ymm5[1],ymm4[2],ymm5[3],ymm4[4],ymm5[5],ymm4[6],ymm5[7]
171
+ vmovdqa %ymm2, (%rdi)
172
+ vmovdqa %ymm4, 0x20(%rdi)
173
+ addq $0x40, %rsi
174
+ addq $0x40, %rdx
175
+ addq $0x40, %rdi
176
+ addl $0x1, %eax
177
+ cmpl $0x10, %eax
178
+ jb Lmld_pointwise_acc_l5_avx2_looptop2
179
+ retq
180
+ .cfi_endproc
181
+
182
+ MLD_ASM_FN_SIZE(pointwise_acc_l5_avx2_asm)
183
+
184
+ #endif /* MLD_ARITH_BACKEND_X86_64_DEFAULT && !MLD_CONFIG_MULTILEVEL_NO_SHARED \
185
+ && (MLD_CONFIG_MULTILEVEL_WITH_SHARED || MLDSA_L == 5) */
186
+
187
+ #if defined(__ELF__)
188
+ .section .note.GNU-stack,"",%progbits
189
+ #endif