Skip to content

Commit 000763f

Browse files
committed
RISC-V: Add virtual target feature: zkne_or_zknd
Because some AES key scheduling instructions require *either* Zkne or Zknd extension, we must have a target feature to represent `(Zkne || Zknd)`. This commit adds (perma-unstable) target feature to the RISC-V architecture: `zkne_or_zknd` for this purpose. Helped-by: sayantn <sayantn05@gmail.com>
1 parent 5904356 commit 000763f

File tree

3 files changed

+6
-2
lines changed

3 files changed

+6
-2
lines changed

compiler/rustc_codegen_llvm/src/llvm_util.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -251,6 +251,8 @@ pub(crate) fn to_llvm_features<'a>(sess: &Session, s: &'a str) -> Option<LLVMFea
251251
// Filter out features that are not supported by the current LLVM version
252252
("loongarch32" | "loongarch64", "32s") if major < 21 => None,
253253
("powerpc", "power8-crypto") => Some(LLVMFeature::new("crypto")),
254+
// Filter out Rust-specific *virtual* target features
255+
("riscv32" | "riscv64", "zkne_or_zknd") => None,
254256
("sparc", "leoncasa") => Some(LLVMFeature::new("hasleoncasa")),
255257
("x86", "sse4.2") => Some(LLVMFeature::with_dependencies(
256258
"sse4.2",

compiler/rustc_target/src/target_features.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -691,8 +691,9 @@ static RISCV_FEATURES: &[(&str, Stability, ImpliedFeatures)] = &[
691691
("zimop", Unstable(sym::riscv_target_feature), &[]),
692692
("zk", Stable, &["zkn", "zkr", "zkt"]),
693693
("zkn", Stable, &["zbkb", "zbkc", "zbkx", "zkne", "zknd", "zknh"]),
694-
("zknd", Stable, &[]),
695-
("zkne", Stable, &[]),
694+
("zknd", Stable, &["zkne_or_zknd"]),
695+
("zkne", Stable, &["zkne_or_zknd"]),
696+
("zkne_or_zknd", Unstable(sym::riscv_target_feature), &[]), // Not an extension
696697
("zknh", Stable, &[]),
697698
("zkr", Stable, &[]),
698699
("zks", Stable, &["zbkb", "zbkc", "zbkx", "zksed", "zksh"]),

tests/ui/check-cfg/target_feature.stderr

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -424,6 +424,7 @@ LL | cfg!(target_feature = "_UNEXPECTED_VALUE");
424424
`zkn`
425425
`zknd`
426426
`zkne`
427+
`zkne_or_zknd`
427428
`zknh`
428429
`zkr`
429430
`zks`

0 commit comments

Comments
 (0)