about summary refs log tree commit diff
path: root/compiler/rustc_target/src
diff options
context:
space:
mode:
authorTsukasa OI <floss_rust@irq.a4lg.com>2025-04-06 03:36:45 +0000
committerTsukasa OI <floss_rust@irq.a4lg.com>2025-04-16 01:20:54 +0000
commitb084603c631cf4cea540a35aca0ad7b2d8599ef2 (patch)
tree7e930b67d266630cc9f75f00e86656d64e70e936 /compiler/rustc_target/src
parent38c560ae681d5c0d3fd615eaedc537a282fb1086 (diff)
downloadrust-b084603c631cf4cea540a35aca0ad7b2d8599ef2.tar.gz
rust-b084603c631cf4cea540a35aca0ad7b2d8599ef2.zip
rustc_target: RISC-V: feature addition batch 2
This commit adds unprivileged ratified extensions that are either
dicoverable from the `riscv_hwprobe` syscall of the Linux kernel (as of
version 6.14) plus 1 minus 3 extensions.

Plus 1:

*   "B"
    This is a combination of "Zba", "Zbb" and "Zbs".
    Note:
    Although not required by the RISC-V specification, it is convenient to
    imply "B" from its three members (will be implemented in LLVM 21/22) but
    this is not yet implemented in Rust due to current implication handling.
    It still implies three members *from* "B".

Minus 2:

*   "Zcf" (target_arch = "riscv32" only)
    This is the compression instruction subset corresponding "F".
    This is implied from RV32 + "C" + "F" but this complex handling is
    not yet supported by Rust's feature handling.
*   "Zcd"
    This is the compression instruction subset corresponding "D".
    This is implied from "C" + "D" but this complex handling is
    not yet supported by Rust's feature handling.
*   "Supm"
    Unlike regular RISC-V extensions, "Supm" and "Sspm" extensions do not
    provide any specific architectural features / constraints but requires
    *some* mechanisms to control pointer masking for the current mode.
    For instance, reported existence of the "Supm" extension in Linux means
    that `prctl` system call to control pointer masking is available and
    there are alternative ways to detect the existence.

Notes:

*   Because this commit adds the "Zca" extension (an integer subset of the
    "C" extension), the "C" extension is modified to imply "Zca".
Diffstat (limited to 'compiler/rustc_target/src')
-rw-r--r--compiler/rustc_target/src/target_features.rs12
1 files changed, 11 insertions, 1 deletions
diff --git a/compiler/rustc_target/src/target_features.rs b/compiler/rustc_target/src/target_features.rs
index b4ec1879fed..aeace6a40c7 100644
--- a/compiler/rustc_target/src/target_features.rs
+++ b/compiler/rustc_target/src/target_features.rs
@@ -491,7 +491,8 @@ const MIPS_FEATURES: &[(&str, Stability, ImpliedFeatures)] = &[
 static RISCV_FEATURES: &[(&str, Stability, ImpliedFeatures)] = &[
     // tidy-alphabetical-start
     ("a", Stable, &["zaamo", "zalrsc"]),
-    ("c", Stable, &[]),
+    ("b", Unstable(sym::riscv_target_feature), &["zba", "zbb", "zbs"]),
+    ("c", Stable, &["zca"]),
     ("d", Unstable(sym::riscv_target_feature), &["f"]),
     ("e", Unstable(sym::riscv_target_feature), &[]),
     ("f", Unstable(sym::riscv_target_feature), &["zicsr"]),
@@ -520,17 +521,25 @@ static RISCV_FEATURES: &[(&str, Stability, ImpliedFeatures)] = &[
     ("zbkc", Stable, &[]),
     ("zbkx", Stable, &[]),
     ("zbs", Stable, &[]),
+    ("zca", Unstable(sym::riscv_target_feature), &[]),
+    ("zcb", Unstable(sym::riscv_target_feature), &["zca"]),
+    ("zcmop", Unstable(sym::riscv_target_feature), &["zca"]),
     ("zdinx", Unstable(sym::riscv_target_feature), &["zfinx"]),
+    ("zfa", Unstable(sym::riscv_target_feature), &["f"]),
     ("zfh", Unstable(sym::riscv_target_feature), &["zfhmin"]),
     ("zfhmin", Unstable(sym::riscv_target_feature), &["f"]),
     ("zfinx", Unstable(sym::riscv_target_feature), &["zicsr"]),
     ("zhinx", Unstable(sym::riscv_target_feature), &["zhinxmin"]),
     ("zhinxmin", Unstable(sym::riscv_target_feature), &["zfinx"]),
+    ("zicboz", Unstable(sym::riscv_target_feature), &[]),
     ("zicntr", Unstable(sym::riscv_target_feature), &["zicsr"]),
+    ("zicond", Unstable(sym::riscv_target_feature), &[]),
     ("zicsr", Unstable(sym::riscv_target_feature), &[]),
     ("zifencei", Unstable(sym::riscv_target_feature), &[]),
+    ("zihintntl", Unstable(sym::riscv_target_feature), &[]),
     ("zihintpause", Unstable(sym::riscv_target_feature), &[]),
     ("zihpm", Unstable(sym::riscv_target_feature), &["zicsr"]),
+    ("zimop", Unstable(sym::riscv_target_feature), &[]),
     ("zk", Stable, &["zkn", "zkr", "zkt"]),
     ("zkn", Stable, &["zbkb", "zbkc", "zbkx", "zkne", "zknd", "zknh"]),
     ("zknd", Stable, &[]),
@@ -541,6 +550,7 @@ static RISCV_FEATURES: &[(&str, Stability, ImpliedFeatures)] = &[
     ("zksed", Stable, &[]),
     ("zksh", Stable, &[]),
     ("zkt", Stable, &[]),
+    ("ztso", Unstable(sym::riscv_target_feature), &[]),
     ("zvbb", Unstable(sym::riscv_target_feature), &["zvkb"]),
     ("zvbc", Unstable(sym::riscv_target_feature), &["zve64x"]),
     ("zve32f", Unstable(sym::riscv_target_feature), &["zve32x", "f"]),