[clang] [llvm] [clang][RISCV] Use macro to check if intrinsics are supported (PR #187197)

Brandon Wu via cfe-commits cfe-commits at lists.llvm.org
Sat Apr 25 06:30:38 PDT 2026


================
@@ -0,0 +1,34 @@
+==============
+RISC-V Support
+==============
+
+.. contents::
+   :local:
+
+Intrinsic Detection Macros
+===========================
+
+Clang provides macros to detect which RISC-V intrinsics are supported by the
+toolchain. This is only available if intrinsics are ratified, in other word,
+experimental intrinsics do not have macro defined.
+Note: This is independent from assembler support.
+
+Intrinsic Detection
+---------------------------
+
+Macros of the form ``__riscv_intrinsic_<extension>`` indicate that the toolchain
+supports intrinsics for a given extension:
+
+.. code-block:: c
+
+#if defined(__riscv_intrinsic_zbb)
+  // Toolchain supports Zbb scalar intrinsics like __riscv_orc_b_*
+  // These can be used with target attributes even if -march doesn't include Zbb
+  __attribute__((target("arch=+zbb")))
+  unsigned long process_with_zbb(unsigned long x) {
+    return __riscv_orc_b_64(x);
----------------
4vtomat wrote:

updated and it's passed!

https://github.com/llvm/llvm-project/pull/187197


More information about the cfe-commits mailing list