[clang] [llvm] [RISCV] Implement Clang Builtins for XAndesPerf Extension (PR #147018)

Jim Lin via llvm-commits llvm-commits at lists.llvm.org
Tue Dec 16 21:15:24 PST 2025


================
@@ -10,14 +10,68 @@
 #ifndef __RISCV_NDS_H
 #define __RISCV_NDS_H
 
+#include <stdint.h>
+
 #if defined(__cplusplus)
 extern "C" {
 #endif
 
-#if defined(__riscv_xandesbfhcvt)
-
 #define __DEFAULT_FN_ATTRS __attribute__((__always_inline__, __nodebug__))
 
+#if defined(__riscv_xandesperf)
+
+#if __riscv_xlen == 32
+
+static __inline__ int32_t __DEFAULT_FN_ATTRS __riscv_nds_ffb_32(uint32_t a,
----------------
tclin914 wrote:

> I missed it in earlier patches, but intrinsic argument names need to use `__a` so that they fall into the reserved identifier space. If the user code defines a macro named `a` before including this file, the macro would apply here which we don't want. We can assume a user won't define `__a` since identifiers starting with double underscore a reserved for implementation.

Fixed it. Thanks.

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


More information about the llvm-commits mailing list