[libc-commits] [PATCH] D146730: [libc][RISCV] Let RISCV64 targets test implementations with and without FMA.
Tue Ly via Phabricator via libc-commits
libc-commits at lists.llvm.org
Thu Mar 23 09:08:50 PDT 2023
lntue created this revision.
Herald added subscribers: jobnoorman, VincentWu, vkmr, ecnelises, evandro, luismarques, sameer.abuasal, tschuett, s.egerton, Jim, benna, psnobl, PkmX, rogfer01, shiva0217, kito-cheng, simoncook, asb, arichardson.
Herald added projects: libc-project, All.
lntue requested review of this revision.
Herald added subscribers: pcwang-thead, eopXD.
Let RISCV64 targets math implementations with and without FMA
automatically.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D146730
Files:
libc/cmake/modules/LLVMLibCFlagRules.cmake
libc/cmake/modules/LLVMLibCObjectRules.cmake
libc/src/__support/macros/properties/cpu_features.h
Index: libc/src/__support/macros/properties/cpu_features.h
===================================================================
--- libc/src/__support/macros/properties/cpu_features.h
+++ libc/src/__support/macros/properties/cpu_features.h
@@ -37,7 +37,7 @@
#endif
#if defined(__ARM_FEATURE_FMA) || defined(__AVX2__) || defined(__FMA__) || \
- defined(__riscv)
+ defined(__LIBC_RISCV_USE_FMA)
#define LIBC_TARGET_CPU_HAS_FMA
#endif
Index: libc/cmake/modules/LLVMLibCObjectRules.cmake
===================================================================
--- libc/cmake/modules/LLVMLibCObjectRules.cmake
+++ libc/cmake/modules/LLVMLibCObjectRules.cmake
@@ -5,7 +5,8 @@
if(${fma} LESS 0)
list(FIND flags "${FMA_OPT_FLAG}__ONLY" fma)
endif()
- if((${fma} GREATER -1) AND (LIBC_CPU_FEATURES MATCHES "FMA"))
+ if((${fma} GREATER -1) AND (LIBC_TARGET_ARCHITECTURE_IS_RISCV64 OR
+ (LIBC_CPU_FEATURES MATCHES "FMA")))
set(ADD_FMA_FLAG TRUE)
endif()
@@ -39,8 +40,12 @@
list(APPEND compile_options "-Wthread-safety")
endif()
if(ADD_FMA_FLAG)
- list(APPEND compile_options "-mavx2")
- list(APPEND compile_options "-mfma")
+ if(LIBC_TARGET_ARCHITECTURE_IS_X86)
+ list(APPEND compile_options "-mavx2")
+ list(APPEND compile_options "-mfma")
+ elseif(LIBC_TARGET_ARCHITECTURE_IS_RISCV64)
+ list(APPEND compile_option "-D__LIBC_RISCV_USE_FMA")
+ endif()
endif()
if(ADD_SSE4_2_FLAG)
list(APPEND compile_options "-msse4.2")
Index: libc/cmake/modules/LLVMLibCFlagRules.cmake
===================================================================
--- libc/cmake/modules/LLVMLibCFlagRules.cmake
+++ libc/cmake/modules/LLVMLibCFlagRules.cmake
@@ -134,7 +134,8 @@
set(ROUND_OPT_FLAG "ROUND_OPT")
# Skip FMA_OPT flag for targets that don't support fma.
-if(NOT(LIBC_TARGET_ARCHITECTURE_IS_X86 AND (LIBC_CPU_FEATURES MATCHES "FMA")))
+if(NOT((LIBC_TARGET_ARCHITECTURE_IS_X86 AND (LIBC_CPU_FEATURES MATCHES "FMA")) OR
+ LIBC_TARGET_ARCHITECTURE_IS_RISCV64))
set(SKIP_FLAG_EXPANSION_FMA_OPT TRUE)
endif()
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D146730.507762.patch
Type: text/x-patch
Size: 2139 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/libc-commits/attachments/20230323/2312b6f4/attachment-0001.bin>
More information about the libc-commits
mailing list