Skip to content

Commit 18ce4f1

Browse files
authored
Unrolled build for rust-lang#138823
Rollup merge of rust-lang#138823 - a4lg:riscv-feature-addition-base-i, r=Amanieu rustc_target: RISC-V: add base `I`-related important extensions Of ratified RISC-V features defined, this commit adds extensions satisfying following criteria: * Formerly a part of the `I` extension and splitted thereafter (now ratified as `I` + `Zifencei` + `Zicsr` + `Zicntr` + `Zihpm`) or * Dicoverable from newer versions of the Linux kernel and implemented as a part of `std_detect`'s feature (`Zihintpause`) and * Available on LLVM 18. This is based on [the latest ratified ISA Manuals (version 20240411)](https://lf-riscv.atlassian.net/wiki/spaces/HOME/pages/16154769/RISC-V+Technical+Specifications). LLVM Definitions: * [`Zifencei`](https://github.com/llvm/llvm-project/blob/llvmorg-20.1.0/llvm/lib/Target/RISCV/RISCVFeatures.td#L133-L137) * [`Zicsr`](https://github.com/llvm/llvm-project/blob/llvmorg-20.1.0/llvm/lib/Target/RISCV/RISCVFeatures.td#L116-L120) * [`Zicntr`](https://github.com/llvm/llvm-project/blob/llvmorg-20.1.0/llvm/lib/Target/RISCV/RISCVFeatures.td#L122-L124) * [`Zihpm`](https://github.com/llvm/llvm-project/blob/llvmorg-20.1.0/llvm/lib/Target/RISCV/RISCVFeatures.td#L153-L155) * [`Zihintpause`](https://github.com/llvm/llvm-project/blob/llvmorg-20.1.0/llvm/lib/Target/RISCV/RISCVFeatures.td#L139-L144) Additional (1): One of those, `Zicsr`, is a dependency of many other ISA extensions and this commit adds correct dependencies to `Zicsr`. Additional (2): In RISC-V, `G` is an abbreviation of following extensions: * `I` * `M` * `A` * `F` * `D` * `Zicsr` (although implied by `F`) * `Zifencei` and all RISC-V targets with the `G` abbreviation and targets for Android / VxWorks are updated accordingly. Note: Android will require RVA22 (likely RVA22U64) and some more extensions, which is a superset of RV64GC. For VxWorks, all BSPs currently distributed by Wind River are for boards with RV64GC (this commit also updates `riscv32-wrs-vxworks` though). -------- This is the version 4. `Ztso` in the original proposal is removed on the PR version 2 due to the minimum LLVM version (non-experimental `Ztso` requires LLVM 19 while minimum LLVM version of Rust is 18). This is not back in PR version 3 and 4 after noticing adding `Ztso` is possible by checking host LLVM version because PR version 3 introduces compiler target changes (and adding more extensions would complicate the problems; sorry `Zihintpause`). Version 4: * Fixed some commit messages, * Added Android / VxWorks targets to imply `G` and * Added an implication from `Zve32x` to `Zicsr` (which makes all vector extension subsets to imply `Zicsr`) since rust-lang#138742 is now merged. Related: * rust-lang#44839 (`riscv_target_feature`) * rust-lang#114544 (This PR can be a prerequisite of resolving a part of that tracking issue) * rust-lang#138742 (Touches the same place and vector extensions depend on `Zicsr`) NOT Related but linked: * rust-lang#132618 (This PR won't be blocked by this issue since none of those extensions do not change the ABI) `@rustbot` r? `@Amanieu` `@rustbot` label +T-compiler +O-riscv +A-target-feature
2 parents 70dab5a + 6f40f0c commit 18ce4f1

16 files changed

+28
-18
lines changed

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ pub(crate) fn target() -> Target {
1616
cpu: "generic-rv32".into(),
1717
llvm_abiname: "ilp32d".into(),
1818
max_atomic_width: Some(32),
19-
features: "+m,+a,+f,+d,+c".into(),
19+
features: "+m,+a,+f,+d,+c,+zicsr,+zifencei".into(),
2020
stack_probes: StackProbeType::Inline,
2121
..base::vxworks::opts()
2222
},

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ pub(crate) fn target() -> Target {
1717
options: TargetOptions {
1818
code_model: Some(CodeModel::Medium),
1919
cpu: "generic-rv32".into(),
20-
features: "+m,+a,+f,+d,+c".into(),
20+
features: "+m,+a,+f,+d,+c,+zicsr,+zifencei".into(),
2121
llvm_abiname: "ilp32d".into(),
2222
max_atomic_width: Some(32),
2323
supported_split_debuginfo: Cow::Borrowed(&[SplitDebuginfo::Off]),

compiler/rustc_target/src/spec/targets/riscv32gc_unknown_linux_musl.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-rv32".into(),
22-
features: "+m,+a,+f,+d,+c".into(),
22+
features: "+m,+a,+f,+d,+c,+zicsr,+zifencei".into(),
2323
llvm_abiname: "ilp32d".into(),
2424
max_atomic_width: Some(32),
2525
supported_split_debuginfo: Cow::Borrowed(&[SplitDebuginfo::Off]),

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,+zba,+zbb,+zbs,+v".into(),
22+
features: "+m,+a,+f,+d,+c,+zicsr,+zifencei,+zba,+zbb,+zbs,+v".into(),
2323
llvm_abiname: "lp64d".into(),
2424
supported_sanitizers: SanitizerSet::ADDRESS,
2525
max_atomic_width: Some(64),

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ pub(crate) fn target() -> Target {
1616
cpu: "generic-rv64".into(),
1717
llvm_abiname: "lp64d".into(),
1818
max_atomic_width: Some(64),
19-
features: "+m,+a,+f,+d,+c".into(),
19+
features: "+m,+a,+f,+d,+c,+zicsr,+zifencei".into(),
2020
stack_probes: StackProbeType::Inline,
2121
..base::vxworks::opts()
2222
},

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ pub(crate) fn target() -> Target {
1515
options: TargetOptions {
1616
code_model: Some(CodeModel::Medium),
1717
cpu: "generic-rv64".into(),
18-
features: "+m,+a,+f,+d,+c".into(),
18+
features: "+m,+a,+f,+d,+c,+zicsr,+zifencei".into(),
1919
llvm_abiname: "lp64d".into(),
2020
max_atomic_width: Some(64),
2121
..base::freebsd::opts()

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ pub(crate) fn target() -> Target {
44
let mut base = base::fuchsia::opts();
55
base.code_model = Some(CodeModel::Medium);
66
base.cpu = "generic-rv64".into();
7-
base.features = "+m,+a,+f,+d,+c".into();
7+
base.features = "+m,+a,+f,+d,+c,+zicsr,+zifencei".into();
88
base.llvm_abiname = "lp64d".into();
99
base.max_atomic_width = Some(64);
1010
base.stack_probes = StackProbeType::Inline;

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ pub(crate) fn target() -> Target {
1414
data_layout: "e-m:e-p:64:64-i64:64-i128:128-n32:64-S128".into(),
1515
options: TargetOptions {
1616
cpu: "generic-rv64".into(),
17-
features: "+m,+a,+f,+d,+c".into(),
17+
features: "+m,+a,+f,+d,+c,+zicsr,+zifencei".into(),
1818
relocation_model: RelocModel::Pic,
1919
code_model: Some(CodeModel::Medium),
2020
tls_model: TlsModel::LocalExec,

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ pub(crate) fn target() -> Target {
1717
options: TargetOptions {
1818
code_model: Some(CodeModel::Medium),
1919
cpu: "generic-rv64".into(),
20-
features: "+m,+a,+f,+d,+c".into(),
20+
features: "+m,+a,+f,+d,+c,+zicsr,+zifencei".into(),
2121
llvm_abiname: "lp64d".into(),
2222
max_atomic_width: Some(64),
2323
supported_split_debuginfo: Cow::Borrowed(&[SplitDebuginfo::Off]),

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ pub(crate) fn target() -> Target {
1717
options: TargetOptions {
1818
code_model: Some(CodeModel::Medium),
1919
cpu: "generic-rv64".into(),
20-
features: "+m,+a,+f,+d,+c".into(),
20+
features: "+m,+a,+f,+d,+c,+zicsr,+zifencei".into(),
2121
llvm_abiname: "lp64d".into(),
2222
max_atomic_width: Some(64),
2323
supported_split_debuginfo: Cow::Borrowed(&[SplitDebuginfo::Off]),

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ pub(crate) fn target() -> Target {
1515
options: TargetOptions {
1616
code_model: Some(CodeModel::Medium),
1717
cpu: "generic-rv64".into(),
18-
features: "+m,+a,+f,+d,+c".into(),
18+
features: "+m,+a,+f,+d,+c,+zicsr,+zifencei".into(),
1919
llvm_abiname: "lp64d".into(),
2020
max_atomic_width: Some(64),
2121
mcount: "__mcount".into(),

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ pub(crate) fn target() -> Target {
2222
llvm_abiname: "lp64d".into(),
2323
cpu: "generic-rv64".into(),
2424
max_atomic_width: Some(64),
25-
features: "+m,+a,+f,+d,+c".into(),
25+
features: "+m,+a,+f,+d,+c,+zicsr,+zifencei".into(),
2626
panic_strategy: PanicStrategy::Abort,
2727
relocation_model: RelocModel::Static,
2828
code_model: Some(CodeModel::Medium),

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ pub(crate) fn target() -> Target {
2424
llvm_abiname: "lp64d".into(),
2525
cpu: "generic-rv64".into(),
2626
max_atomic_width: Some(64),
27-
features: "+m,+a,+f,+d,+c".into(),
27+
features: "+m,+a,+f,+d,+c,+zicsr,+zifencei".into(),
2828
panic_strategy: PanicStrategy::Abort,
2929
relocation_model: RelocModel::Static,
3030
code_model: Some(CodeModel::Medium),

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ pub(crate) fn target() -> Target {
1515
options: TargetOptions {
1616
code_model: Some(CodeModel::Medium),
1717
cpu: "generic-rv64".into(),
18-
features: "+m,+a,+f,+d,+c".into(),
18+
features: "+m,+a,+f,+d,+c,+zicsr,+zifencei".into(),
1919
llvm_abiname: "lp64d".into(),
2020
max_atomic_width: Some(64),
2121
..base::openbsd::opts()

compiler/rustc_target/src/target_features.rs

+9-4
Original file line numberDiff line numberDiff line change
@@ -488,7 +488,7 @@ static RISCV_FEATURES: &[(&str, Stability, ImpliedFeatures)] = &[
488488
("c", Stable, &[]),
489489
("d", Unstable(sym::riscv_target_feature), &["f"]),
490490
("e", Unstable(sym::riscv_target_feature), &[]),
491-
("f", Unstable(sym::riscv_target_feature), &[]),
491+
("f", Unstable(sym::riscv_target_feature), &["zicsr"]),
492492
(
493493
"forced-atomics",
494494
Stability::Forbidden { reason: "unsound because it changes the ABI of atomic operations" },
@@ -517,23 +517,28 @@ static RISCV_FEATURES: &[(&str, Stability, ImpliedFeatures)] = &[
517517
("zdinx", Unstable(sym::riscv_target_feature), &["zfinx"]),
518518
("zfh", Unstable(sym::riscv_target_feature), &["zfhmin"]),
519519
("zfhmin", Unstable(sym::riscv_target_feature), &["f"]),
520-
("zfinx", Unstable(sym::riscv_target_feature), &[]),
520+
("zfinx", Unstable(sym::riscv_target_feature), &["zicsr"]),
521521
("zhinx", Unstable(sym::riscv_target_feature), &["zhinxmin"]),
522522
("zhinxmin", Unstable(sym::riscv_target_feature), &["zfinx"]),
523+
("zicntr", Unstable(sym::riscv_target_feature), &["zicsr"]),
524+
("zicsr", Unstable(sym::riscv_target_feature), &[]),
525+
("zifencei", Unstable(sym::riscv_target_feature), &[]),
526+
("zihintpause", Unstable(sym::riscv_target_feature), &[]),
527+
("zihpm", Unstable(sym::riscv_target_feature), &["zicsr"]),
523528
("zk", Stable, &["zkn", "zkr", "zkt"]),
524529
("zkn", Stable, &["zbkb", "zbkc", "zbkx", "zkne", "zknd", "zknh"]),
525530
("zknd", Stable, &[]),
526531
("zkne", Stable, &[]),
527532
("zknh", Stable, &[]),
528-
("zkr", Stable, &[]),
533+
("zkr", Stable, &["zicsr"]),
529534
("zks", Stable, &["zbkb", "zbkc", "zbkx", "zksed", "zksh"]),
530535
("zksed", Stable, &[]),
531536
("zksh", Stable, &[]),
532537
("zkt", Stable, &[]),
533538
("zvbb", Unstable(sym::riscv_target_feature), &["zvkb"]),
534539
("zvbc", Unstable(sym::riscv_target_feature), &["zve64x"]),
535540
("zve32f", Unstable(sym::riscv_target_feature), &["zve32x", "f"]),
536-
("zve32x", Unstable(sym::riscv_target_feature), &["zvl32b"]),
541+
("zve32x", Unstable(sym::riscv_target_feature), &["zvl32b", "zicsr"]),
537542
("zve64d", Unstable(sym::riscv_target_feature), &["zve64f", "d"]),
538543
("zve64f", Unstable(sym::riscv_target_feature), &["zve32f", "zve64x"]),
539544
("zve64x", Unstable(sym::riscv_target_feature), &["zve32x", "zvl64b"]),

tests/ui/check-cfg/target_feature.stderr

+5
Original file line numberDiff line numberDiff line change
@@ -318,6 +318,11 @@ LL | cfg!(target_feature = "_UNEXPECTED_VALUE");
318318
`zfinx`
319319
`zhinx`
320320
`zhinxmin`
321+
`zicntr`
322+
`zicsr`
323+
`zifencei`
324+
`zihintpause`
325+
`zihpm`
321326
`zk`
322327
`zkn`
323328
`zknd`

0 commit comments

Comments
 (0)