Skip to content

Commit 18da457

Browse files
hanno-beckermkannwischer
authored andcommitted
Remove unused *.inc files in x86_64 backend
The files {fq,poly_basemul,shuffle}.inc are inlined during assembly simplification dev->mlkem and hence not needed in the main source tree mlkem/*. However, they do need to be kept if we want to skip simplification and install dev/* as-is in mlkem/*. This commit adjusts scripts/autogen accordingly. Slightly unsatisfactorily, we have to pass both dev/* and mlkem/* as include paths to simpasm: We need dev/* so that simplification finds the *.inc files that are now no longer in mlkem/*; and we need to keep mlkem/* as otherwise the relative include of "../../../common.h" would need to be patched up during simplification. Signed-off-by: Hanno Becker <[email protected]>
1 parent 0e8f8e2 commit 18da457

File tree

4 files changed

+20
-268
lines changed

4 files changed

+20
-268
lines changed

mlkem/src/native/x86_64/src/fq.inc

Lines changed: 0 additions & 42 deletions
This file was deleted.

mlkem/src/native/x86_64/src/poly_basemul.inc

Lines changed: 0 additions & 168 deletions
This file was deleted.

mlkem/src/native/x86_64/src/shuffle.inc

Lines changed: 0 additions & 42 deletions
This file was deleted.

scripts/autogen

Lines changed: 20 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -2439,84 +2439,84 @@ def gen_hol_light_asm():
24392439
"polyvec_basemul_acc_montgomery_cached_asm_k2.S",
24402440
"mlkem_poly_basemul_acc_montgomery_cached_k2.S",
24412441
"dev/x86_64/src",
2442-
"-Imlkem/src/native/x86_64/src -Imlkem/src/common.h -mavx2 -mbmi2 -msse4 -fcf-protection=full",
2442+
"-Idev/x86_64/src/ -Imlkem/src/native/x86_64/src -mavx2 -mbmi2 -msse4 -fcf-protection=full",
24432443
"x86",
24442444
),
24452445
(
24462446
"polyvec_basemul_acc_montgomery_cached_asm_k3.S",
24472447
"mlkem_poly_basemul_acc_montgomery_cached_k3.S",
24482448
"dev/x86_64/src",
2449-
"-Imlkem/src/native/x86_64/src -Imlkem/src/common.h -mavx2 -mbmi2 -msse4 -fcf-protection=full",
2449+
"-Idev/x86_64/src/ -Imlkem/src/native/x86_64/src -mavx2 -mbmi2 -msse4 -fcf-protection=full",
24502450
"x86",
24512451
),
24522452
(
24532453
"polyvec_basemul_acc_montgomery_cached_asm_k4.S",
24542454
"mlkem_poly_basemul_acc_montgomery_cached_k4.S",
24552455
"dev/x86_64/src",
2456-
"-Imlkem/src/native/x86_64/src -Imlkem/src/common.h -mavx2 -mbmi2 -msse4 -fcf-protection=full",
2456+
"-Idev/x86_64/src/ -Imlkem/src/native/x86_64/src -mavx2 -mbmi2 -msse4 -fcf-protection=full",
24572457
"x86",
24582458
),
24592459
(
24602460
"ntt.S",
24612461
"mlkem_ntt.S",
24622462
"dev/x86_64/src",
2463-
"-Imlkem/src/native/x86_64/src -Imlkem/src/common.h -mavx2 -mbmi2 -msse4 -fcf-protection=full",
2463+
"-Idev/x86_64/src/ -Imlkem/src/native/x86_64/src -mavx2 -mbmi2 -msse4 -fcf-protection=full",
24642464
"x86",
24652465
),
24662466
(
24672467
"intt.S",
24682468
"mlkem_intt.S",
24692469
"dev/x86_64/src",
2470-
"-Imlkem/src/native/x86_64/src -Imlkem/src/common.h -mavx2 -mbmi2 -msse4 -fcf-protection=full",
2470+
"-Idev/x86_64/src/ -Imlkem/src/native/x86_64/src -mavx2 -mbmi2 -msse4 -fcf-protection=full",
24712471
"x86",
24722472
),
24732473
(
24742474
"reduce.S",
24752475
"mlkem_reduce.S",
24762476
"dev/x86_64/src",
2477-
"-Imlkem/src/native/x86_64/src -Imlkem/src/common.h -mavx2 -mbmi2 -msse4 -fcf-protection=full",
2477+
"-Idev/x86_64/src/ -Imlkem/src/native/x86_64/src -mavx2 -mbmi2 -msse4 -fcf-protection=full",
24782478
"x86",
24792479
),
24802480
(
24812481
"ntttobytes.S",
24822482
"mlkem_tobytes.S",
24832483
"dev/x86_64/src",
2484-
"-Imlkem/src/native/x86_64/src -Imlkem/src/common.h -mavx2 -mbmi2 -msse4 -fcf-protection=full",
2484+
"-Idev/x86_64/src/ -Imlkem/src/native/x86_64/src -mavx2 -mbmi2 -msse4 -fcf-protection=full",
24852485
"x86",
24862486
),
24872487
(
24882488
"rej_uniform_asm.S",
24892489
"mlkem_rej_uniform.S",
24902490
"dev/x86_64/src",
2491-
"-Imlkem/src/native/x86_64/src -Imlkem/src/common.h -mavx2 -mbmi2 -msse4 -fcf-protection=full",
2491+
"-Idev/x86_64/src/ -Imlkem/src/native/x86_64/src -mavx2 -mbmi2 -msse4 -fcf-protection=full",
24922492
"x86",
24932493
),
24942494
(
24952495
"nttfrombytes.S",
24962496
"mlkem_frombytes.S",
24972497
"dev/x86_64/src",
2498-
"-Imlkem/src/native/x86_64/src -Imlkem/src/common.h -mavx2 -mbmi2 -msse4 -fcf-protection=full",
2498+
"-Idev/x86_64/src/ -Imlkem/src/native/x86_64/src -mavx2 -mbmi2 -msse4 -fcf-protection=full",
24992499
"x86",
25002500
),
25012501
(
25022502
"tomont.S",
25032503
"mlkem_tomont.S",
25042504
"dev/x86_64/src",
2505-
"-Imlkem/src/native/x86_64/src -Imlkem/src/common.h -mavx2 -mbmi2 -msse4 -fcf-protection=full",
2505+
"-Idev/x86_64/src/ -Imlkem/src/native/x86_64/src -mavx2 -mbmi2 -msse4 -fcf-protection=full",
25062506
"x86",
25072507
),
25082508
(
25092509
"nttunpack.S",
25102510
"mlkem_unpack.S",
25112511
"dev/x86_64/src",
2512-
"-Imlkem/src/native/x86_64/src -Imlkem/src/common.h -mavx2 -mbmi2 -msse4 -fcf-protection=full",
2512+
"-Idev/x86_64/src/ -Imlkem/src/native/x86_64/src -mavx2 -mbmi2 -msse4 -fcf-protection=full",
25132513
"x86",
25142514
),
25152515
(
25162516
"mulcache_compute.S",
25172517
"mlkem_mulcache_compute.S",
25182518
"dev/x86_64/src",
2519-
"-Imlkem/src/native/x86_64/src -Imlkem/src/common.h -mavx2 -mbmi2 -msse4 -fcf-protection=full",
2519+
"-Idev/x86_64/src/ -Imlkem/src/native/x86_64/src -mavx2 -mbmi2 -msse4 -fcf-protection=full",
25202520
"x86",
25212521
),
25222522
]
@@ -2560,6 +2560,10 @@ def synchronize_file(f, in_dir, out_dir, delete=False, no_simplify=False, **kwar
25602560
if delete is True:
25612561
return basename
25622562

2563+
# Skip .inc files when simplification is enabled (they get inlined by simpasm)
2564+
if no_simplify is False and f.endswith(".inc"):
2565+
return None
2566+
25632567
if no_simplify is False and f.endswith(".S"):
25642568
update_via_simpasm(f, out_dir, **kwargs)
25652569
else:
@@ -2646,23 +2650,23 @@ def synchronize_backends(
26462650
delete=delete,
26472651
force_cross=force_cross,
26482652
no_simplify=no_simplify,
2649-
cflags="-Imlkem/src/native/aarch64/src",
2653+
cflags=f"-Idev/aarch64_{ty}/src -Imlkem/src/native/aarch64/src",
26502654
)
26512655
synchronize_backend(
26522656
"dev/fips202/aarch64/src",
26532657
"mlkem/src/fips202/native/aarch64/src",
26542658
delete=delete,
26552659
force_cross=force_cross,
26562660
no_simplify=no_simplify,
2657-
cflags="-Imlkem/src/fips202/native/aarch64/src -march=armv8.4-a+sha3",
2661+
cflags="-Idev/fips202/aarch64/src -Imlkem/src/fips202/native/aarch64/src -march=armv8.4-a+sha3",
26582662
)
26592663
synchronize_backend(
26602664
"dev/fips202/aarch64",
26612665
"mlkem/src/fips202/native/aarch64",
26622666
delete=delete,
26632667
force_cross=force_cross,
26642668
no_simplify=no_simplify,
2665-
cflags="-Imlkem/src/fips202/native/aarch64 -march=armv8.4-a+sha3",
2669+
cflags="-Idev/fips202/aarch64 -Imlkem/src/fips202/native/aarch64 -march=armv8.4-a+sha3",
26662670
)
26672671
synchronize_backend(
26682672
"dev/x86_64/src",
@@ -2678,7 +2682,7 @@ def synchronize_backends(
26782682
# macro.
26792683
# This leads to duplicate endbr64 instructions causing a failure when
26802684
# comparing the object code before and after simplification.
2681-
cflags="-Imlkem/src/native/x86_64/src/ -mavx2 -mbmi2 -msse4 -fcf-protection=none",
2685+
cflags="-Idev/x86_64/src/ -Imlkem/src/native/x86_64/src/ -mavx2 -mbmi2 -msse4 -fcf-protection=none",
26822686
)
26832687

26842688

0 commit comments

Comments
 (0)