# Macro is_riscv_feature_detected

Source

    macro_rules! is_riscv_feature_detected {
        ("rv32i") => { ... };
        ("rv32e") => { ... };
        ("rv64i") => { ... };
        ("rv128i") => { ... };
        ("unaligned-scalar-mem") => { ... };
        ("unaligned-vector-mem") => { ... };
        ("zicsr") => { ... };
        ("zicntr") => { ... };
        ("zihpm") => { ... };
        ("zifencei") => { ... };
        ("zihintntl") => { ... };
        ("zihintpause") => { ... };
        ("zimop") => { ... };
        ("zicbom") => { ... };
        ("zicboz") => { ... };
        ("zicond") => { ... };
        ("m") => { ... };
        ("a") => { ... };
        ("zalrsc") => { ... };
        ("zaamo") => { ... };
        ("zawrs") => { ... };
        ("zabha") => { ... };
        ("zacas") => { ... };
        ("zam") => { ... };
        ("ztso") => { ... };
        ("f") => { ... };
        ("d") => { ... };
        ("q") => { ... };
        ("zfh") => { ... };
        ("zfhmin") => { ... };
        ("zfa") => { ... };
        ("zfbfmin") => { ... };
        ("zfinx") => { ... };
        ("zdinx") => { ... };
        ("zhinx") => { ... };
        ("zhinxmin") => { ... };
        ("c") => { ... };
        ("zca") => { ... };
        ("zcf") => { ... };
        ("zcd") => { ... };
        ("zcb") => { ... };
        ("zcmop") => { ... };
        ("b") => { ... };
        ("zba") => { ... };
        ("zbb") => { ... };
        ("zbc") => { ... };
        ("zbs") => { ... };
        ("zbkb") => { ... };
        ("zbkc") => { ... };
        ("zbkx") => { ... };
        ("zknd") => { ... };
        ("zkne") => { ... };
        ("zknh") => { ... };
        ("zksed") => { ... };
        ("zksh") => { ... };
        ("zkr") => { ... };
        ("zkn") => { ... };
        ("zks") => { ... };
        ("zk") => { ... };
        ("zkt") => { ... };
        ("v") => { ... };
        ("zve32x") => { ... };
        ("zve32f") => { ... };
        ("zve64x") => { ... };
        ("zve64f") => { ... };
        ("zve64d") => { ... };
        ("zvfh") => { ... };
        ("zvfhmin") => { ... };
        ("zvfbfmin") => { ... };
        ("zvfbfwma") => { ... };
        ("zvbb") => { ... };
        ("zvbc") => { ... };
        ("zvkb") => { ... };
        ("zvkg") => { ... };
        ("zvkned") => { ... };
        ("zvknha") => { ... };
        ("zvknhb") => { ... };
        ("zvksed") => { ... };
        ("zvksh") => { ... };
        ("zvkn") => { ... };
        ("zvknc") => { ... };
        ("zvkng") => { ... };
        ("zvks") => { ... };
        ("zvksc") => { ... };
        ("zvksg") => { ... };
        ("zvkt") => { ... };
        ("j") => { ... };
        ("p") => { ... };
        ($t:tt,) => { ... };
        ($t:tt) => { ... };
    }

🔬This is a nightly-only experimental API. (`stdarch_internal`)
Available on RISC-V RV32 or RISC-V RV64 only.
Expand description

A macro to test at runtime whether instruction sets are available on RISC-V platforms.

RISC-V standard defined the base sets and the extension sets. The base sets are RV32I, RV64I, RV32E or RV128I. Any RISC-V platform must support one base set and/or multiple extension sets.

Any RISC-V standard instruction sets can be in state of either ratified, frozen or draft. The version and status of current standard instruction sets can be checked out from preface section of the ISA manual.

Platform may define and support their own custom instruction sets with ISA prefix X. These sets are highly platform specific and should be detected with their own platform support crates.

## §Platform-specific/agnostic Behavior and Availability

Runtime detection depends on the platform-specific feature detection facility and its availability per feature is highly platform/version-specific.

Still, a best-effort attempt is performed to enable subset/dependent features if a superset feature is enabled regardless of the platform. For instance, if the A extension (`"a"`) is enabled, its subsets (the Zalrsc and Zaamo extensions; `"zalrsc"` and `"zaamo"`) are also enabled. Likewise, if the F extension (`"f"`) is enabled, one of its dependencies (the Zicsr extension `"zicsr"`) is also enabled.

## §Unprivileged Specification

The supported ratified RISC-V instruction sets are as follows:

- RV32E: `"rv32e"`
- RV32I: `"rv32i"`
- RV64I: `"rv64i"`
- A: `"a"`
  - Zaamo: `"zaamo"`
  - Zalrsc: `"zalrsc"`
- B: `"b"`
  - Zba: `"zba"`
  - Zbb: `"zbb"`
  - Zbs: `"zbs"`
- C: `"c"`
  - Zca: `"zca"`
  - Zcd: `"zcd"` (if D is enabled)
  - Zcf: `"zcf"` (if F is enabled on RV32)
- D: `"d"`
- F: `"f"`
- M: `"m"`
- Q: `"q"`
- V: `"v"`
  - Zve32x: `"zve32x"`
  - Zve32f: `"zve32f"`
  - Zve64x: `"zve64x"`
  - Zve64f: `"zve64f"`
  - Zve64d: `"zve64d"`
- Zicbom: `"zicbom"`
- Zicboz: `"zicboz"`
- Zicntr: `"zicntr"`
- Zicond: `"zicond"`
- Zicsr: `"zicsr"`
- Zifencei: `"zifencei"`
- Zihintntl: `"zihintntl"`
- Zihintpause: `"zihintpause"`
- Zihpm: `"zihpm"`
- Zimop: `"zimop"`
- Zabha: `"zabha"`
- Zacas: `"zacas"`
- Zawrs: `"zawrs"`
- Zfa: `"zfa"`
- Zfbfmin: `"zfbfmin"`
- Zfh: `"zfh"`
  - Zfhmin: `"zfhmin"`
- Zfinx: `"zfinx"`
- Zdinx: `"zdinx"`
- Zhinx: `"zhinx"`
  - Zhinxmin: `"zhinxmin"`
- Zcb: `"zcb"`
- Zcmop: `"zcmop"`
- Zbc: `"zbc"`
- Zbkb: `"zbkb"`
- Zbkc: `"zbkc"`
- Zbkx: `"zbkx"`
- Zk: `"zk"`
- Zkn: `"zkn"`
  - Zknd: `"zknd"`
  - Zkne: `"zkne"`
  - Zknh: `"zknh"`
- Zkr: `"zkr"`
- Zks: `"zks"`
  - Zksed: `"zksed"`
  - Zksh: `"zksh"`
- Zkt: `"zkt"`
- Zvbb: `"zvbb"`
- Zvbc: `"zvbc"`
- Zvfbfmin: `"zvfbfmin"`
- Zvfbfwma: `"zvfbfwma"`
- Zvfh: `"zvfh"`
  - Zvfhmin: `"zvfhmin"`
- Zvkb: `"zvkb"`
- Zvkg: `"zvkg"`
- Zvkn: `"zvkn"`
  - Zvkned: `"zvkned"`
  - Zvknha: `"zvknha"`
  - Zvknhb: `"zvknhb"`
- Zvknc: `"zvknc"`
- Zvkng: `"zvkng"`
- Zvks: `"zvks"`
  - Zvksed: `"zvksed"`
  - Zvksh: `"zvksh"`
- Zvksc: `"zvksc"`
- Zvksg: `"zvksg"`
- Zvkt: `"zvkt"`
- Ztso: `"ztso"`

There’s also bases and extensions marked as standard instruction set, but they are in frozen or draft state. These instruction sets are also reserved by this macro and can be detected in the future platforms.

Draft RISC-V instruction sets:

- RV128I: `"rv128i"`
- J: `"j"`
- P: `"p"`
- Zam: `"zam"`

## §Performance Hints

The two features below define performance hints for unaligned scalar/vector memory accesses, respectively. If enabled, it denotes that corresponding unaligned memory access is reasonably fast.

- `"unaligned-scalar-mem"`
  - Runtime detection requires Linux kernel version 6.4 or later.
- `"unaligned-vector-mem"`
  - Runtime detection requires Linux kernel version 6.13 or later.