From ad093099bd3ad85a24b85d8e87aa78d64536b440 Mon Sep 17 00:00:00 2001 From: Schrodinger ZHU Yifan Date: Thu, 6 Nov 2025 21:35:59 -0500 Subject: [PATCH 1/2] [libc] add cpu feature flags for SVE/SVE2/MOPS --- libc/cmake/modules/LLVMLibCCheckCpuFeatures.cmake | 2 +- libc/cmake/modules/cpu_features/check_MOPS.cpp | 7 +++++++ libc/cmake/modules/cpu_features/check_SVE.cpp | 7 +++++++ libc/cmake/modules/cpu_features/check_SVE2.cpp | 7 +++++++ libc/src/__support/macros/properties/cpu_features.h | 12 ++++++++++++ 5 files changed, 34 insertions(+), 1 deletion(-) create mode 100644 libc/cmake/modules/cpu_features/check_MOPS.cpp create mode 100644 libc/cmake/modules/cpu_features/check_SVE.cpp create mode 100644 libc/cmake/modules/cpu_features/check_SVE2.cpp diff --git a/libc/cmake/modules/LLVMLibCCheckCpuFeatures.cmake b/libc/cmake/modules/LLVMLibCCheckCpuFeatures.cmake index c09d4751d3907..d76f3b16b30ec 100644 --- a/libc/cmake/modules/LLVMLibCCheckCpuFeatures.cmake +++ b/libc/cmake/modules/LLVMLibCCheckCpuFeatures.cmake @@ -9,7 +9,7 @@ if(LIBC_TARGET_ARCHITECTURE_IS_X86_64) set(ALL_CPU_FEATURES SSE2 SSE4_2 AVX AVX2 AVX512F AVX512BW FMA) set(LIBC_COMPILE_OPTIONS_NATIVE -march=native) elseif(LIBC_TARGET_ARCHITECTURE_IS_AARCH64) - set(ALL_CPU_FEATURES "FullFP16") + set(ALL_CPU_FEATURES FullFP16 MOPS SVE SVE2) set(LIBC_COMPILE_OPTIONS_NATIVE -mcpu=native) endif() diff --git a/libc/cmake/modules/cpu_features/check_MOPS.cpp b/libc/cmake/modules/cpu_features/check_MOPS.cpp new file mode 100644 index 0000000000000..bf5d392242b44 --- /dev/null +++ b/libc/cmake/modules/cpu_features/check_MOPS.cpp @@ -0,0 +1,7 @@ +#include "src/__support/macros/properties/cpu_features.h" + +#ifndef LIBC_TARGET_CPU_HAS_MOPS +#error unsupported +#endif + + diff --git a/libc/cmake/modules/cpu_features/check_SVE.cpp b/libc/cmake/modules/cpu_features/check_SVE.cpp new file mode 100644 index 0000000000000..0ae4b4dcf3558 --- /dev/null +++ b/libc/cmake/modules/cpu_features/check_SVE.cpp @@ -0,0 +1,7 @@ +#include "src/__support/macros/properties/cpu_features.h" + +#ifndef LIBC_TARGET_CPU_HAS_SVE +#error unsupported +#endif + + diff --git a/libc/cmake/modules/cpu_features/check_SVE2.cpp b/libc/cmake/modules/cpu_features/check_SVE2.cpp new file mode 100644 index 0000000000000..b46d1ac421267 --- /dev/null +++ b/libc/cmake/modules/cpu_features/check_SVE2.cpp @@ -0,0 +1,7 @@ +#include "src/__support/macros/properties/cpu_features.h" + +#ifndef LIBC_TARGET_CPU_HAS_SVE2 +#error unsupported +#endif + + diff --git a/libc/src/__support/macros/properties/cpu_features.h b/libc/src/__support/macros/properties/cpu_features.h index fc6099ca6ccc5..1fe20d9b23a34 100644 --- a/libc/src/__support/macros/properties/cpu_features.h +++ b/libc/src/__support/macros/properties/cpu_features.h @@ -18,6 +18,18 @@ #define LIBC_TARGET_CPU_HAS_FULLFP16 #endif +#if defined(__ARM_FEATURE_SVE) +#define LIBC_TARGET_CPU_HAS_SVE +#endif + +#if defined(__ARM_FEATURE_SVE2) +#define LIBC_TARGET_CPU_HAS_SVE2 +#endif + +#if defined(__ARM_FEATURE_MOPS) +#define LIBC_TARGET_CPU_HAS_MOPS +#endif + #if defined(__SSE2__) #define LIBC_TARGET_CPU_HAS_SSE2 #define LIBC_TARGET_CPU_HAS_FPU_FLOAT From d3aa2797b47bb746f8b8f2858234e54b4a9fe87a Mon Sep 17 00:00:00 2001 From: Schrodinger ZHU Yifan Date: Thu, 6 Nov 2025 21:41:39 -0500 Subject: [PATCH 2/2] [libc] remove extra lines --- libc/cmake/modules/cpu_features/check_MOPS.cpp | 2 -- libc/cmake/modules/cpu_features/check_SVE.cpp | 2 -- libc/cmake/modules/cpu_features/check_SVE2.cpp | 2 -- 3 files changed, 6 deletions(-) diff --git a/libc/cmake/modules/cpu_features/check_MOPS.cpp b/libc/cmake/modules/cpu_features/check_MOPS.cpp index bf5d392242b44..314fe9b38bc81 100644 --- a/libc/cmake/modules/cpu_features/check_MOPS.cpp +++ b/libc/cmake/modules/cpu_features/check_MOPS.cpp @@ -3,5 +3,3 @@ #ifndef LIBC_TARGET_CPU_HAS_MOPS #error unsupported #endif - - diff --git a/libc/cmake/modules/cpu_features/check_SVE.cpp b/libc/cmake/modules/cpu_features/check_SVE.cpp index 0ae4b4dcf3558..725f42f6eb883 100644 --- a/libc/cmake/modules/cpu_features/check_SVE.cpp +++ b/libc/cmake/modules/cpu_features/check_SVE.cpp @@ -3,5 +3,3 @@ #ifndef LIBC_TARGET_CPU_HAS_SVE #error unsupported #endif - - diff --git a/libc/cmake/modules/cpu_features/check_SVE2.cpp b/libc/cmake/modules/cpu_features/check_SVE2.cpp index b46d1ac421267..37f4b4fa038bb 100644 --- a/libc/cmake/modules/cpu_features/check_SVE2.cpp +++ b/libc/cmake/modules/cpu_features/check_SVE2.cpp @@ -3,5 +3,3 @@ #ifndef LIBC_TARGET_CPU_HAS_SVE2 #error unsupported #endif - -