-
Notifications
You must be signed in to change notification settings - Fork 13.3k
rustc_target: RISC-V: feature addition batch 2 #139440
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
These commits modify compiler targets. |
Amanieu
reviewed
Apr 11, 2025
6e10c31
to
d2a3049
Compare
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".
The "B" extension is ratified as a combination of three extensions: "Zba", "Zbb" and "Zbs". To maximize discoverability of the RISC-V target features, this commit makes use of the "B" extension instead of its three members. This way, `#[cfg(target_feature = "b")]` can also be used instead of: `#[cfg(all(target_feature = "zba", target_feature = "zbb", target_feature = "zbs"))]`
d2a3049
to
52392ec
Compare
@bors r+ |
bors
added a commit
to rust-lang-ci/rust
that referenced
this pull request
Apr 17, 2025
…iaskrgr Rollup of 9 pull requests Successful merges: - rust-lang#135340 (Add `explicit_extern_abis` Feature and Enforce Explicit ABIs) - rust-lang#139440 (rustc_target: RISC-V: feature addition batch 2) - rust-lang#139667 (cfi: Remove #[no_sanitize(cfi)] for extern weak functions) - rust-lang#139828 (Don't require rigid alias's trait to hold) - rust-lang#139854 (Improve parse errors for stray lifetimes in type position) - rust-lang#139889 (Clean UI tests 3 of n) - rust-lang#139894 (Fix `opt-dist` CLI flag and make it work without LLD) - rust-lang#139900 (stepping into impls for normalization is unproductive) - rust-lang#139915 (replace some #[rustc_intrinsic] usage with use of the libcore declarations) r? `@ghost` `@rustbot` modify labels: rollup
rust-timer
added a commit
to rust-lang-ci/rust
that referenced
this pull request
Apr 17, 2025
Rollup merge of rust-lang#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: * rust-lang#44839 (`riscv_target_feature`) * rust-lang#138823 (my previous batch) * rust-lang#132618 (stabilization of the `Zfa` extension is blocked by this) `@rustbot` r? `@Amanieu` `@rustbot` label +T-compiler +O-riscv +A-target-feature
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
A-target-feature
Area: Enabling/disabling target features like AVX, Neon, etc.
O-riscv
Target: RISC-V architecture
S-waiting-on-bors
Status: Waiting on bors to run and complete tests. Bors will change the label on completion.
T-compiler
Relevant to the compiler team, which will review and decide on the PR/issue.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Of ratified RISC-V extensions, this commit adds ones satisfying following criteria:
riscv_hwprobe
system call on Linux 6.14or should be very helpful even on basic needs (the
B
extension),Supm
extension)Due to 2., the author excluded
Zcf
(RV32 only) andZcd
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:
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
Zca
Zcb
Zcmop
Zfa
Zicboz
Zicond
Zihintntl
Zimop
Ztso
The author also adds required implication:
C
impliesZca
.Android RISC-V target is also updated to include the
B
extension (this is just a shorthand combination ofZba
,Zbb
andZbs
extensions but possibly simplifiestarget_feature
handling).History
Version 1 → 2
Supm
extension from the Rust target features (thanks, @Amanieu).Related:
#[target_feature]
#44839(
riscv_target_feature
)I
-related important extensions #138823(my previous batch)
-Ctarget-feature
s must be restrained on RISCV #132618(stabilization of the
Zfa
extension is blocked by this)@rustbot r? @Amanieu
@rustbot label +T-compiler +O-riscv +A-target-feature