Skip to content

rustc_target: Adjust RISC-V feature implication #140139

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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

a4lg
Copy link
Contributor

@a4lg a4lg commented Apr 22, 2025

This commit adjusts feature implication of the RISC-V ISA for better feature detection from the user perspective.

The main rule is:

  • If the feature A is a functional superset of the feature B (A ⊃ B),
    A is to imply B, even if this implication is not on the manual.

Such implications (not directly written in the ISA manual) are commented as A ⊃ B
which means "A is a (functional) superset of B".

  1. ZbcZbkc (add as a superset)
    The Zbkc extension is a subset of the Zbc extension (Zbc minus clmulr instruction).
  2. Zkr → (nothing) (remove dependency to Zicsr)
    Implication to the Zicsr extension is removed because (although nearly harmless), the Zkr extension (or the seed CSR section) defines its own subset of the Zicsr extension (guaranteed to work against the seed CSR which needs read/write access).
  3. ZvbbZvkb (comment as a superset)
    This implication was already there but not denoted as a functional superset. This commit adds the comment.
  4. ZvfhZvfhmin (comment as a superset)
    This is similar to the case above (ZvbbZvkb).
  5. ZvfhZve32f (add implication per the ISA specification)
    This dependency is on the ISA manual but was missing (due to the fact that Zvfh indirectly implies Zve32f on the current implementation through ZvfhZvfhmin which is a functional relation). This commit ensures that this is also ISA-compliant in the source code level (there's no functional changes though).
  6. ZvknhbZvknha (add as a superset)
    The Zvknhb extension (SHA-256 / SHA-512) is a functional superset of the Zvknha extension (SHA-256 only).

Related:

@rustbot r? @Amanieu
@rustbot label +T-compiler +O-riscv +A-target-feature

This commit adjusts feature implication of the RISC-V ISA for better
feature detection from the user perspective.

The main rule is:
If the feature A is a functional superset of the feature B (A ⊃ B),
A is to imply B, even if this implication is not on the manual.

Such implications (not directly referred in the ISA manual) are commented
as "A ⊃ B" which means "A is a (functional) superset of B".

1.  Zbc → Zbkc (add as a superset)
    The Zbkc extension is a subset of the Zbc extension
    (Zbc - "clmulr" instruction == Zbkc)
2.  Zkr → (nothing) (remove dependency to Zicsr)
    Implication to the Zicsr extension is removed because (although nearly
    harmless), the Zkr extension (or the "seed" CSR section) defines its own
    subset of the Zicsr extension.
3.  Zvbb → Zvkb (comment as a superset)
    This implication was already there but not denoted as a functional
    superset.  This commit adds the comment.
4.  Zvfh → Zvfhmin (comment as a superset)
    This is similar to the case above (Zvbb → Zvkb).
5.  Zvfh → Zve32f (add implication per the ISA specification)
    This dependency is on the ISA manual but was missing (due to the fact
    that Zvfh indirectly implies Zve32f on the current implementation
    through Zvfh → Zvfhmin, which is a functional relation).
    This commit ensures that this is *also* ISA-compliant in the
    source code level (there's no functional changes though).
6.  Zvknhb → Zvknha (add as a superset)
    The Zvknhb extension (SHA-256 / SHA-512) is a functional superset of
    the Zvknha extension (SHA-256 only).
@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. A-target-feature Area: Enabling/disabling target features like AVX, Neon, etc. O-riscv Target: RISC-V architecture labels Apr 22, 2025
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-review Status: Awaiting review from the assignee but also interested parties. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants