[libc] [llvm] [libc] Fix _Float16 detection for x86 (PR #73947)

Guillaume Chatelet via llvm-commits llvm-commits at lists.llvm.org
Thu Nov 30 06:53:12 PST 2023


https://github.com/gchatelet updated https://github.com/llvm/llvm-project/pull/73947

>From 0a1a16342be877bfc663646cbadf2ca82a09a55f Mon Sep 17 00:00:00 2001
From: Guillaume Chatelet <gchatelet at google.com>
Date: Thu, 30 Nov 2023 14:50:55 +0000
Subject: [PATCH 1/2] [libc] Fix _Float16 detection for x86

---
 libc/src/__support/macros/properties/float.h | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/libc/src/__support/macros/properties/float.h b/libc/src/__support/macros/properties/float.h
index 7e00ddc8f0cd327..4bafc3777a47146 100644
--- a/libc/src/__support/macros/properties/float.h
+++ b/libc/src/__support/macros/properties/float.h
@@ -13,6 +13,7 @@
 
 #include "src/__support/macros/properties/architectures.h"
 #include "src/__support/macros/properties/compiler.h"
+#include "src/__support/macros/properties/cpu_features.h"
 #include "src/__support/macros/properties/os.h"
 
 #include <float.h> // LDBL_MANT_DIG
@@ -30,7 +31,7 @@
 #endif
 
 // float16 support.
-#if defined(LIBC_TARGET_ARCH_IS_X86_64)
+#if defined(LIBC_TARGET_ARCH_IS_X86_64) && defined(LIBC_TARGET_CPU_HAS_SSE2)
 #if (defined(LIBC_COMPILER_CLANG_VER) && (LIBC_COMPILER_CLANG_VER >= 1500)) || \
     (defined(LIBC_COMPILER_GCC_VER) && (LIBC_COMPILER_GCC_VER >= 1201))
 #define LIBC_COMPILER_HAS_C23_FLOAT16

>From d8fa2c9aaac56d7c4eac92851ba531afab91d50c Mon Sep 17 00:00:00 2001
From: Guillaume Chatelet <gchatelet at google.com>
Date: Thu, 30 Nov 2023 14:52:55 +0000
Subject: [PATCH 2/2] Also add dependencies in the build system

---
 libc/src/__support/macros/properties/CMakeLists.txt | 1 +
 utils/bazel/llvm-project-overlay/libc/BUILD.bazel   | 1 +
 2 files changed, 2 insertions(+)

diff --git a/libc/src/__support/macros/properties/CMakeLists.txt b/libc/src/__support/macros/properties/CMakeLists.txt
index e37cdb78bfa2c57..ee87ce68c9da37d 100644
--- a/libc/src/__support/macros/properties/CMakeLists.txt
+++ b/libc/src/__support/macros/properties/CMakeLists.txt
@@ -31,5 +31,6 @@ add_header_library(
   DEPENDS
     .architectures
     .compiler
+    .cpu_features
     .os
 )
diff --git a/utils/bazel/llvm-project-overlay/libc/BUILD.bazel b/utils/bazel/llvm-project-overlay/libc/BUILD.bazel
index a0a6a4366ea7537..870dd06d3547969 100644
--- a/utils/bazel/llvm-project-overlay/libc/BUILD.bazel
+++ b/utils/bazel/llvm-project-overlay/libc/BUILD.bazel
@@ -86,6 +86,7 @@ libc_support_library(
     deps = [
         ":__support_macros_properties_architectures",
         ":__support_macros_properties_compiler",
+        ":__support_macros_properties_cpu_features",
         ":__support_macros_properties_os",
     ],
 )



More information about the llvm-commits mailing list