[libc] [llvm] [libc] add flag for FP_*LOGB0/NAN values (PR #86723)

via llvm-commits llvm-commits at lists.llvm.org
Tue Mar 26 12:55:11 PDT 2024


llvmbot wrote:


<!--LLVM PR SUMMARY COMMENT-->

@llvm/pr-subscribers-libc

Author: Michael Jones (michaelrj-google)

<details>
<summary>Changes</summary>

These values vary by system, this flag allows you to toggle their value.


---
Full diff: https://github.com/llvm/llvm-project/pull/86723.diff


2 Files Affected:

- (modified) libc/include/llvm-libc-macros/math-macros.h (+12-2) 
- (modified) utils/bazel/llvm-project-overlay/libc/BUILD.bazel (+1) 


``````````diff
diff --git a/libc/include/llvm-libc-macros/math-macros.h b/libc/include/llvm-libc-macros/math-macros.h
index 03c7a823e6e96b..0c524eb4918968 100644
--- a/libc/include/llvm-libc-macros/math-macros.h
+++ b/libc/include/llvm-libc-macros/math-macros.h
@@ -30,11 +30,21 @@
 #define INFINITY __builtin_inf()
 #define NAN __builtin_nanf("")
 
+#ifdef __FP_LOGB0_MIN
 #define FP_ILOGB0 (-INT_MAX - 1)
-#define FP_ILOGBNAN INT_MAX
-
 #define FP_LLOGB0 (-LONG_MAX - 1)
+#else
+#define FP_ILOGB0 (-INT_MAX)
+#define FP_LLOGB0 (-LONG_MAX)
+#endif
+
+#ifdef __FP_LOGBNAN_MIN
+#define FP_ILOGBNAN (-INT_MAX - 1)
+#define FP_LLOGBNAN (-LONG_MAX - 1)
+#else
+#define FP_ILOGBNAN INT_MAX
 #define FP_LLOGBNAN LONG_MAX
+#endif
 
 #ifdef __FAST_MATH__
 #define math_errhandling 0
diff --git a/utils/bazel/llvm-project-overlay/libc/BUILD.bazel b/utils/bazel/llvm-project-overlay/libc/BUILD.bazel
index 57dc75a3a48e60..09edc276035260 100644
--- a/utils/bazel/llvm-project-overlay/libc/BUILD.bazel
+++ b/utils/bazel/llvm-project-overlay/libc/BUILD.bazel
@@ -68,6 +68,7 @@ libc_support_library(
     name = "llvm_libc_macros_math_macros",
     hdrs = ["include/llvm-libc-macros/math-macros.h"],
     deps = [":llvm_libc_macros_limits_macros"],
+    defines = ["__FP_LOGBNAN_MIN"],
 )
 
 libc_support_library(

``````````

</details>


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


More information about the llvm-commits mailing list