rust/library/stdarch
Jonathan Brouwer dc103c4cd9
Rollup merge of #146798 - a4lg:riscv-intrinsics-zkne_or_zknd, r=Amanieu
RISC-V: Implement (Zkne or Zknd) intrinsics correctly

On rust-lang/stdarch#1765, it has been pointed out that two RISC-V (64-bit only) intrinsics to perform AES key scheduling have wrong target feature.
`aes64ks1i` and `aes64ks2` instructions require *either* Zkne (scalar cryptography: AES encryption) or Zknd (scalar cryptography: AES decryption) extension (or both) but corresponding Rust intrinsics (in `core::arch::riscv64`) required *both* Zkne and Zknd extensions.

An excerpt from the original intrinsics:

```rust
#[target_feature(enable = "zkne", enable = "zknd")]
```

To fix that, we need to:

1.  Represent a condition where *either* Zkne or Zknd is available and
2.  Workaround an issue: `llvm.riscv.aes64ks1i` / `llvm.riscv.aes64ks2` LLVM intrinsics require either Zkne or Zknd extension.

This PR attempts to resolve them by:

1.  Adding a perma-unstable RISC-V target feature: `zkne_or_zknd` (implied from both `zkne` and `zknd`) and
2.  Using inline assembly to construct machine code directly (because `zkne_or_zknd` alone cannot imply neither Zkne nor Zknd, we cannot use LLVM intrinsics).

The author confirmed that we can construct an AES key scheduling function with decent performance using fixed `aes64ks1i` and `aes64ks2` intrinsics (with optimization enabled).
2025-12-31 17:32:04 +01:00
..
.github/workflows Merge pull request #1976 from Flakebi/amdgpu-intrinsics 2025-12-19 20:02:31 +00:00
ci Merge pull request #1976 from Flakebi/amdgpu-intrinsics 2025-12-19 20:02:31 +00:00
crates Rollup merge of #146798 - a4lg:riscv-intrinsics-zkne_or_zknd, r=Amanieu 2025-12-31 17:32:04 +01:00
examples examples: Make Clippy happy 2025-09-12 11:51:38 +00:00
intrinsics_data feat: Added x86 to CI pipeline 2025-10-26 17:48:18 +05:30
.git-blame-ignore-revs Add .git-blame-ignore-revs 2025-02-09 12:57:14 -08:00
.gitignore Add lockfile 2025-06-12 06:03:37 +00:00
.gitmodules Remove ACLE submodule 2023-05-15 17:34:11 +02:00
Cargo.lock chore: move from random testing to testing only the first N intrinsics 2025-10-26 17:51:35 +05:30
Cargo.toml exclude generated rust programs from the workspace 2025-07-18 13:17:38 +02:00
CONTRIBUTING.md Remove impl_tag from CONTRIBUTING.md file 2025-04-18 06:15:48 +00:00
josh-sync.toml Add config files for rustc-josh-sync 2025-07-07 21:51:29 +00:00
LICENSE-APACHE Add license files 2017-09-25 12:43:06 -07:00
LICENSE-MIT Add license files 2017-09-25 12:43:06 -07:00
README.md Update stdarch README 2025-07-22 20:17:49 +02:00
rust-version Prepare for merging from rust-lang/rust 2025-11-10 04:10:10 +00:00
rustfmt.toml Update the intrinsic checker tool (#1258) 2021-12-04 13:03:30 +00:00
triagebot.toml Remove [no-mentions] handler in our triagebot config 2025-12-08 18:58:56 +01:00
vendor.yml Add SVE support to stdarch-verify 2025-01-16 14:29:19 +00:00

stdarch - Rust's standard library SIMD components

Actions Status

This repository contains the core_arch crate, which implements core::arch - Rust's core library architecture-specific intrinsics.

The std::simd component now lives in the packed_simd_2 crate.

Synchronizing josh subtree with rustc

This repository is linked to rust-lang/rust as a josh subtree. You can use the rustc-josh-sync tool to perform synchronization.

You can find a guide on how to perform the synchronization here.