llvm/llvm-project

[RISC-V] Update Linux Feature Detection

Geschlossen

#192.317 geöffnet am 15.04.2026

 (9 Kommentare) (1 Reaktion) (1 zugewiesene Person)C++ (10.782 Forks)batch import
backend:RISC-Vgood first issue

Repository-Metriken

Stars
 (26.378 Sterne)
PR-Merge-Metriken
 (Durchschn. Merge 1T 2h) (1.000 gemergte PRs in 30 T)

Beschreibung

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).

Contributor Guide