-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #740 from pq-code-package/simpasm_move
Use 'raw' assembly in main source tree
- Loading branch information
Showing
125 changed files
with
23,036 additions
and
12,561 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
[//]: # (SPDX-License-Identifier: CC-BY-4.0) | ||
|
||
# Development files | ||
|
||
This directory contains intermediate development artifacts that are not part of the final mlkem-native sources. | ||
|
||
It is only relevant to you if you are developing mlkem-native or would like to understand the origin | ||
of the assembly source files. | ||
|
||
## AArch64 arithmetic assembly | ||
|
||
#### Clean | ||
|
||
[`aarch64_clean`](aarch64_clean) contains the 'clean' assembly underlying the AArch64 native backend of mlkem-native. | ||
The files in this directory are handwritten and kept readable through the extensive use of register aliases and macros. | ||
|
||
#### Optimized | ||
|
||
[`aarch64_opt`](aarch64_opt) contains the results of running the [SLOTHY](https://github.com/slothy-optimizer/slothy/) | ||
superoptimizer on the clean assembly files in [`aarch64_clean`](aarch64_clean). The optimized sections are 'raw' | ||
assembly in the sense that they no longer use register macros or aliases, but the surrounding code (such as the | ||
function preamble and postamble) typically still use those register aliases/macros. Also, the macros and alias | ||
definitions themselves are still kept. | ||
|
||
#### Final | ||
|
||
The final AArch64 arithmetic assembly from [mlkem/native/aarch64/src](../mlkem/native/aarch64/src) is auto-generated | ||
from the optimized assembly using the [`simpasm`](../scripts/simpasm) script, which simplifies it through a combination | ||
of assembly+disassembly. This final assembly does not contain any register aliases or macros anymore. | ||
|
||
The final assembly is autogenerated from the optimized assembly through the [`autogen`](../scripts/autogen) script. | ||
Non-assembly files are synchronized by copy between this directory and [`mlkem`](../mlkem). | ||
|
||
#### Testing clean/optimized assembly | ||
|
||
To test the clean assembly, run `autogen --aarch64-clean`. This will import the clean backend into `mlkem/native/aarch64/*`, | ||
replacing the optimized one. With `autogen --aarch64-clean --no-simplify` or `autogen --no-simplify` you can moreover reinstate | ||
the non-simplified assembly in the main source tree. | ||
|
||
Alternatively, you can also just manually copy the entire `aarch64_clean` and `aarch64_opt` trees into `mlkem/native/aarch64/`. | ||
|
||
## AArch64 FIPS-202 assembly | ||
|
||
As for the AArch64 arithmetic assembly, the final FIPS-202 assembly is the result of running [`simpasm`](../scripts/simpasm) | ||
on the assembly in [fips202/aarch64/src](fips202/aarch64/src). Non-assembly files are synchronized by copy. | ||
|
||
## x86_64 arithmetic assembly | ||
|
||
As for the AArch64 arithmetic assembly, the final x86_64 arithmetic assembly is the result of running [`simpasm`](../scripts/simpasm) | ||
on the assembly in [x86_64/src](x86_64/src). Non-assembly files are synchronized by copy. |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
/* | ||
* Copyright (c) 2024-2025 The mlkem-native project authors | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
#ifndef MLKEM_NATIVE_DEV_AARCH64_CLEAN_SRC_CONSTS_H | ||
#define MLKEM_NATIVE_DEV_AARCH64_CLEAN_SRC_CONSTS_H | ||
|
||
#include <stdint.h> | ||
#include "../../../common.h" | ||
|
||
#define zetas_mulcache_native MLKEM_NAMESPACE(zetas_mulcache_native) | ||
extern const int16_t zetas_mulcache_native[256]; | ||
|
||
#define zetas_mulcache_twisted_native \ | ||
MLKEM_NAMESPACE(zetas_mulcache_twisted_native) | ||
extern const int16_t zetas_mulcache_twisted_native[256]; | ||
|
||
#endif /* MLKEM_NATIVE_DEV_AARCH64_CLEAN_SRC_CONSTS_H */ |
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
[//]: # (SPDX-License-Identifier: CC-BY-4.0) | ||
|
||
# AArch64 backend (little endian) | ||
|
||
This directory contains a native backend for little endian AArch64 systems. It is derived from the following research | ||
works: | ||
|
||
- _Neon NTT: Faster Dilithium, Kyber, and Saber on Cortex-A72 and Apple M1_, Hanno Becker, Vincent Hwang, Matthias | ||
J. Kannwischer, Bo-Yin Yang, and Shang-Yi Yang, [https://eprint.iacr.org/2021/986](https://eprint.iacr.org/2021/986) | ||
- _Fast and Clean: Auditable high-performance assembly via constraint solving_, Amin Abdulrahman, Hanno Becker, Matthias | ||
J. Kannwischer, Fabien Klein, [https://eprint.iacr.org/2022/1303](https://eprint.iacr.org/2022/1303) | ||
|
||
|
||
## Variants | ||
|
||
This backend comes in two versions: "clean" and optimized. The "clean" backend is handwritten and meant to be easy to read and modify; for example, is heavily leverages register aliases and assembly macros. This directory contains the optimized version, which is automatically generated from the clean one via [SLOTHY](https://github.com/slothy-optimizer/slothy). Currently, the | ||
target architecture is Cortex-A55, but you can easily re-optimize the code for a different microarchitecture supported | ||
by SLOTHY, by adjusting the parameters in [optimize.sh](../aarch64_clean/src/optimize.sh). |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
/* | ||
* Copyright (c) 2024-2025 The mlkem-native project authors | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
#ifndef MLKEM_NATIVE_DEV_AARCH64_OPT_META_H | ||
#define MLKEM_NATIVE_DEV_AARCH64_OPT_META_H | ||
#ifdef MLKEM_NATIVE_ARITH_PROFILE_H | ||
#error Only one MLKEM_ARITH assembly profile can be defined -- did you include multiple profiles? | ||
#else | ||
#define MLKEM_NATIVE_ARITH_PROFILE_H | ||
|
||
/* Identifier for this backend so that source and assembly files | ||
* in the build can be appropriately guarded. */ | ||
#define MLKEM_NATIVE_ARITH_BACKEND_AARCH64_OPT | ||
|
||
#define MLKEM_NATIVE_ARITH_BACKEND_NAME AARCH64_OPT | ||
|
||
/* Filename of the C backend implementation. | ||
* This is not inlined here because this header is included in assembly | ||
* files as well. */ | ||
#define MLKEM_NATIVE_ARITH_BACKEND_IMPL "native/aarch64/src/opt_impl.h" | ||
|
||
#endif /* MLKEM_NATIVE_ARITH_PROFILE_H */ | ||
|
||
#endif /* MLKEM_NATIVE_DEV_AARCH64_OPT_META_H */ |
Oops, something went wrong.