llvm/llvm-project

[RISC-V] Update Linux Feature Detection

Fermée

#192 317 ouverte le 15 avr. 2026

 (9 commentaires) (1 réaction) (1 personne assignée)C++ (10 782 forks)batch import
backend:RISC-Vgood first issue

Métriques du dépôt

Stars
 (26 378 étoiles)
Métriques de merge PR
 (Merge moyen 1j 2h) (1 000 PRs mergées en 30 j)

Description

There are new architecture hwprobe features exposed by recent linux versions. The docs are here: https://docs.kernel.org/arch/riscv/hwprobe.html

I think we have implemented up to RISCV_HWPROBE_EXT_ZAWRS, but no further. We should add support for the rest of the supported extensions.

This entails:

  • Proposing extension bitmask assignments for (standard) extensions that don't have them already. This is done via the https://github.com/riscv-non-isa/riscv-c-api-doc repo (note that there are some proposed but not yet landed bitmask assignments in the open PRs for that repo, which new proposals should not conflict with).
  • Add the RISCVExtensionBitmask to the relevant extensions.
  • Implement detection in llvm/lib/TargetParser/Host.cpp (used by -march=native) and compiler-rt/lib/builtins/cpu_model/riscv.c (used by ifuncs)

There is no compiler-rt interface for exposing vendor-specific extensions (which have a different hwprobe keys), but we may still be able to detect them in llvm/lib/TargetParser/Host.cpp for -march=native.

This would also be a good opportunity to move away from the deprecated RISCV_HWPROBE_KEY_CPUPERF_0, and to RISCV_HWPROBE_KEY_MISALIGNED_SCALAR_PERF, and also implement the same for RISCV_HWPROBE_KEY_MISALIGNED_VECTOR_PERF potentially (this can be a separate PR).

Guide contributeur