Skip to content

Commit ff55f2a

Browse files
authored
Rollup merge of #139440 - a4lg:riscv-feature-addition-batch-2, r=Amanieu
rustc_target: RISC-V: feature addition batch 2 Of ratified RISC-V extensions, this commit adds ones satisfying following criteria: 1. Either discoverable through a `riscv_hwprobe` system call on Linux 6.14 or should be very helpful even on basic needs (the `B` extension), 2. Does not disrupt current Rust's feature handling mechanism and 3. Not too OS-dependent (the `Supm` extension) Due to 2., the author excluded `Zcf` (RV32 only) and `Zcd` from the list despite that they are discoverable from Linux 6.14. Due to 3., the author excluded the `Supm` extension on the PR version 2. This is based on the specification: * [The latest ratified ISA Manuals (version 20240411)](https://lf-riscv.atlassian.net/wiki/spaces/HOME/pages/16154769/RISC-V+Technical+Specifications) Linux Definition: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/arch/riscv/include/uapi/asm/hwprobe.h LLVM Definitions: * [`B`](https://github.com/llvm/llvm-project/blob/llvmorg-19.1.0/llvm/lib/Target/RISCV/RISCVFeatures.td#L507-L510) * [`Zca`](https://github.com/llvm/llvm-project/blob/llvmorg-19.1.0/llvm/lib/Target/RISCV/RISCVFeatures.td#L395-L398) * [`Zcb`](https://github.com/llvm/llvm-project/blob/llvmorg-19.1.0/llvm/lib/Target/RISCV/RISCVFeatures.td#L407-L410) * [`Zcmop`](https://github.com/llvm/llvm-project/blob/llvmorg-19.1.0/llvm/lib/Target/RISCV/RISCVFeatures.td#L460-L463) * [`Zfa`](https://github.com/llvm/llvm-project/blob/llvmorg-19.1.0/llvm/lib/Target/RISCV/RISCVFeatures.td#L335-L338) * [`Zicboz`](https://github.com/llvm/llvm-project/blob/llvmorg-19.1.0/llvm/lib/Target/RISCV/RISCVFeatures.td#L89-L92) * [`Zicond`](https://github.com/llvm/llvm-project/blob/llvmorg-19.1.0/llvm/lib/Target/RISCV/RISCVFeatures.td#L125-L128) * [`Zihintntl`](https://github.com/llvm/llvm-project/blob/llvmorg-19.1.0/llvm/lib/Target/RISCV/RISCVFeatures.td#L148-L151) * [`Zimop`](https://github.com/llvm/llvm-project/blob/llvmorg-19.1.0/llvm/lib/Target/RISCV/RISCVFeatures.td#L161-L162) * [`Ztso`](https://github.com/llvm/llvm-project/blob/llvmorg-19.1.0/llvm/lib/Target/RISCV/RISCVFeatures.td#L214-L217) The author also adds required implication: `C` implies `Zca`. Android RISC-V target is also updated to include the `B` extension (this is just a shorthand combination of `Zba`, `Zbb` and `Zbs` extensions but possibly simplifies `target_feature` handling). # History ## Version 1 → 2 * Remove the `Supm` extension from the Rust target features (thanks, `@Amanieu).` -------- Related: * #44839 (`riscv_target_feature`) * #138823 (my previous batch) * #132618 (stabilization of the `Zfa` extension is blocked by this) `@rustbot` r? `@Amanieu` `@rustbot` label +T-compiler +O-riscv +A-target-feature
2 parents bb3e156 + 52392ec commit ff55f2a

File tree

3 files changed

+22
-2
lines changed

3 files changed

+22
-2
lines changed

compiler/rustc_target/src/spec/targets/riscv64_linux_android.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ pub(crate) fn target() -> Target {
1919
options: TargetOptions {
2020
code_model: Some(CodeModel::Medium),
2121
cpu: "generic-rv64".into(),
22-
features: "+m,+a,+f,+d,+c,+zicsr,+zifencei,+zba,+zbb,+zbs,+v".into(),
22+
features: "+m,+a,+f,+d,+c,+b,+v,+zicsr,+zifencei".into(),
2323
llvm_abiname: "lp64d".into(),
2424
supported_sanitizers: SanitizerSet::ADDRESS,
2525
max_atomic_width: Some(64),

compiler/rustc_target/src/target_features.rs

+11-1
Original file line numberDiff line numberDiff line change
@@ -491,7 +491,8 @@ const MIPS_FEATURES: &[(&str, Stability, ImpliedFeatures)] = &[
491491
static RISCV_FEATURES: &[(&str, Stability, ImpliedFeatures)] = &[
492492
// tidy-alphabetical-start
493493
("a", Stable, &["zaamo", "zalrsc"]),
494-
("c", Stable, &[]),
494+
("b", Unstable(sym::riscv_target_feature), &["zba", "zbb", "zbs"]),
495+
("c", Stable, &["zca"]),
495496
("d", Unstable(sym::riscv_target_feature), &["f"]),
496497
("e", Unstable(sym::riscv_target_feature), &[]),
497498
("f", Unstable(sym::riscv_target_feature), &["zicsr"]),
@@ -520,17 +521,25 @@ static RISCV_FEATURES: &[(&str, Stability, ImpliedFeatures)] = &[
520521
("zbkc", Stable, &[]),
521522
("zbkx", Stable, &[]),
522523
("zbs", Stable, &[]),
524+
("zca", Unstable(sym::riscv_target_feature), &[]),
525+
("zcb", Unstable(sym::riscv_target_feature), &["zca"]),
526+
("zcmop", Unstable(sym::riscv_target_feature), &["zca"]),
523527
("zdinx", Unstable(sym::riscv_target_feature), &["zfinx"]),
528+
("zfa", Unstable(sym::riscv_target_feature), &["f"]),
524529
("zfh", Unstable(sym::riscv_target_feature), &["zfhmin"]),
525530
("zfhmin", Unstable(sym::riscv_target_feature), &["f"]),
526531
("zfinx", Unstable(sym::riscv_target_feature), &["zicsr"]),
527532
("zhinx", Unstable(sym::riscv_target_feature), &["zhinxmin"]),
528533
("zhinxmin", Unstable(sym::riscv_target_feature), &["zfinx"]),
534+
("zicboz", Unstable(sym::riscv_target_feature), &[]),
529535
("zicntr", Unstable(sym::riscv_target_feature), &["zicsr"]),
536+
("zicond", Unstable(sym::riscv_target_feature), &[]),
530537
("zicsr", Unstable(sym::riscv_target_feature), &[]),
531538
("zifencei", Unstable(sym::riscv_target_feature), &[]),
539+
("zihintntl", Unstable(sym::riscv_target_feature), &[]),
532540
("zihintpause", Unstable(sym::riscv_target_feature), &[]),
533541
("zihpm", Unstable(sym::riscv_target_feature), &["zicsr"]),
542+
("zimop", Unstable(sym::riscv_target_feature), &[]),
534543
("zk", Stable, &["zkn", "zkr", "zkt"]),
535544
("zkn", Stable, &["zbkb", "zbkc", "zbkx", "zkne", "zknd", "zknh"]),
536545
("zknd", Stable, &[]),
@@ -541,6 +550,7 @@ static RISCV_FEATURES: &[(&str, Stability, ImpliedFeatures)] = &[
541550
("zksed", Stable, &[]),
542551
("zksh", Stable, &[]),
543552
("zkt", Stable, &[]),
553+
("ztso", Unstable(sym::riscv_target_feature), &[]),
544554
("zvbb", Unstable(sym::riscv_target_feature), &["zvkb"]),
545555
("zvbc", Unstable(sym::riscv_target_feature), &["zve64x"]),
546556
("zve32f", Unstable(sym::riscv_target_feature), &["zve32x", "f"]),

tests/ui/check-cfg/target_feature.stderr

+10
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ LL | cfg!(target_feature = "_UNEXPECTED_VALUE");
4949
`avxvnni`
5050
`avxvnniint16`
5151
`avxvnniint8`
52+
`b`
5253
`backchain`
5354
`bf16`
5455
`bmi1`
@@ -318,17 +319,25 @@ LL | cfg!(target_feature = "_UNEXPECTED_VALUE");
318319
`zbkc`
319320
`zbkx`
320321
`zbs`
322+
`zca`
323+
`zcb`
324+
`zcmop`
321325
`zdinx`
326+
`zfa`
322327
`zfh`
323328
`zfhmin`
324329
`zfinx`
325330
`zhinx`
326331
`zhinxmin`
332+
`zicboz`
327333
`zicntr`
334+
`zicond`
328335
`zicsr`
329336
`zifencei`
337+
`zihintntl`
330338
`zihintpause`
331339
`zihpm`
340+
`zimop`
332341
`zk`
333342
`zkn`
334343
`zknd`
@@ -339,6 +348,7 @@ LL | cfg!(target_feature = "_UNEXPECTED_VALUE");
339348
`zksed`
340349
`zksh`
341350
`zkt`
351+
`ztso`
342352
`zvbb`
343353
`zvbc`
344354
`zve32f`

0 commit comments

Comments
 (0)