[libc-commits] [libc] 7fddb2e - [libc][baremetal] add MVE/MVE_FP feature flags detection (#220345)

via libc-commits libc-commits at lists.llvm.org
Wed Sep 2 08:37:30 PDT 2026


Author: Schrodinger ZHU Yifan
Date: 2026-09-02T11:37:24-04:00
New Revision: 7fddb2e0ec7342195bfed56e9bced187568e6210

URL: https://github.com/llvm/llvm-project/commit/7fddb2e0ec7342195bfed56e9bced187568e6210
DIFF: https://github.com/llvm/llvm-project/commit/7fddb2e0ec7342195bfed56e9bced187568e6210.diff

LOG: [libc][baremetal] add MVE/MVE_FP feature flags detection (#220345)

This patch adds MVE/MVE_FP SIMD feature flags for baremetal targets.
Cortex-M85/Cortex-M55 introduced the M-profile Vector Extension
(Helium). The detection is via the `__ARM_FEATURE_MVE` bitfield as
described in the Arm C Language Extensions (ACLE): bit 0 is set when
the MVE integer instructions are available, bit 1 when the
floating-point instructions are also available.

Co-authored-by: Claude Fable 5 <noreply at anthropic.com>

Added: 
    libc/cmake/modules/cpu_features/check_MVE.cpp
    libc/cmake/modules/cpu_features/check_MVE_FP.cpp

Modified: 
    libc/cmake/modules/LLVMLibCCheckCpuFeatures.cmake
    libc/src/__support/macros/properties/cpu_features.h

Removed: 
    


################################################################################
diff  --git a/libc/cmake/modules/LLVMLibCCheckCpuFeatures.cmake b/libc/cmake/modules/LLVMLibCCheckCpuFeatures.cmake
index 05b56d62e6c17..6b8134427ea12 100644
--- a/libc/cmake/modules/LLVMLibCCheckCpuFeatures.cmake
+++ b/libc/cmake/modules/LLVMLibCCheckCpuFeatures.cmake
@@ -11,6 +11,9 @@ if(LIBC_TARGET_ARCHITECTURE_IS_X86_64)
 elseif(LIBC_TARGET_ARCHITECTURE_IS_AARCH64)
   set(ALL_CPU_FEATURES FullFP16 MOPS SVE SVE2)
   set(_libc_native_default -mcpu=native)
+elseif(LIBC_TARGET_ARCHITECTURE_IS_ARM)
+  set(ALL_CPU_FEATURES MVE MVE_FP)
+  set(_libc_native_default "")
 else()
   set(_libc_native_default "")
 endif()

diff  --git a/libc/cmake/modules/cpu_features/check_MVE.cpp b/libc/cmake/modules/cpu_features/check_MVE.cpp
new file mode 100644
index 0000000000000..a83dfbcdefced
--- /dev/null
+++ b/libc/cmake/modules/cpu_features/check_MVE.cpp
@@ -0,0 +1,5 @@
+#include "src/__support/macros/properties/cpu_features.h"
+
+#ifndef LIBC_TARGET_CPU_HAS_MVE
+#error unsupported
+#endif

diff  --git a/libc/cmake/modules/cpu_features/check_MVE_FP.cpp b/libc/cmake/modules/cpu_features/check_MVE_FP.cpp
new file mode 100644
index 0000000000000..36ff4ab3c3489
--- /dev/null
+++ b/libc/cmake/modules/cpu_features/check_MVE_FP.cpp
@@ -0,0 +1,5 @@
+#include "src/__support/macros/properties/cpu_features.h"
+
+#ifndef LIBC_TARGET_CPU_HAS_MVE_FP
+#error unsupported
+#endif

diff  --git a/libc/src/__support/macros/properties/cpu_features.h b/libc/src/__support/macros/properties/cpu_features.h
index 08b5226feff26..7f11f6409f2ee 100644
--- a/libc/src/__support/macros/properties/cpu_features.h
+++ b/libc/src/__support/macros/properties/cpu_features.h
@@ -26,6 +26,16 @@
 #define LIBC_TARGET_CPU_HAS_SVE2
 #endif
 
+// __ARM_FEATURE_MVE is a bitfield
+#if defined(__ARM_FEATURE_MVE)
+#if (__ARM_FEATURE_MVE & 0x1)
+#define LIBC_TARGET_CPU_HAS_MVE
+#endif // LIBC_TARGET_CPU_HAS_MVE
+#if (__ARM_FEATURE_MVE & 0x2)
+#define LIBC_TARGET_CPU_HAS_MVE_FP
+#endif // LIBC_TARGET_CPU_HAS_MVE_FP
+#endif // __ARM_FEATURE_MVE
+
 #if defined(__ARM_FEATURE_MOPS)
 #define LIBC_TARGET_CPU_HAS_MOPS
 #endif


        


More information about the libc-commits mailing list