GCC Newspaper
JUNE 15, 2026
Date
/
Architectures
Components
Topics
News & Policy
Other
risc-v

RISC-V: Map existing extensions to Linux hwprobe constants.

Adds mappings between existing RISC-V extensions and their corresponding Linux hwprobe bits, enabling runtime feature detection.

This commit adds mappings between existing RISC-V extensions (supm, zicntr, zihpm, zfbfmin, zvfbfmin, zvfbfwma, zicbom, zaamo, zalrsc, zabha, zalasr, zicbop, zilsd, zclsd, and zicfilp) and their corresponding Linux hwprobe bits in RISCV_HWPROBE_KEY_IMA_EXT_0. By copying the upstream Linux bit assignments and mapping them directly to the matching feature bits, GCC can now detect these extensions at runtime, making it easier to utilize these features when available.

In Details

This patch updates feature_bits.c in libgcc to map various RISC-V extensions to their corresponding Linux hwprobe bits within RISCV_HWPROBE_KEY_IMA_EXT_0. This allows GCC to determine the presence of these extensions at runtime by querying the Linux kernel's hardware probing interface. The extensions covered in this patch include supm, zicntr, and others, ensuring GCC can accurately detect and utilize these features when present. No new ISA support is added by this change.

For Context

RISC-V relies on extensions for optional features, and knowing which ones are present at runtime is crucial for optimization. The Linux kernel exposes hardware information through a mechanism called hwprobe. This commit maps several RISC-V extensions to their corresponding hwprobe bits in Linux. This allows GCC to query the kernel and determine which extensions are supported by the underlying hardware, enabling it to generate optimized code that takes advantage of the available features.

Filed Under: risc-vhwprobefeature detection