Skip to content

Commit b084603

Browse files
committed
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".
1 parent 38c560a commit b084603

File tree

2 files changed

+21
-1
lines changed

2 files changed

+21
-1
lines changed

Diff for: 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"]),

Diff for: 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)