[libc-commits] [llvm] [libc] [libc][NFC] Sink "PlatformDefs.h" into "FloatProperties.h" (PR #73226)
Guillaume Chatelet via libc-commits
libc-commits at lists.llvm.org
Thu Nov 23 02:03:04 PST 2023
https://github.com/gchatelet created https://github.com/llvm/llvm-project/pull/73226
`PlatformDefs.h` does not bring a lot of value as a separate file.
It is transitively included in `FloatProperties.h` and `FPBits.h`. This patch sinks it into `FloatProperties.h` and removes the associated build targets.
>From dabe4c29c6462980fcceac9cfa8f934216a9cadd Mon Sep 17 00:00:00 2001
From: Guillaume Chatelet <gchatelet at google.com>
Date: Thu, 23 Nov 2023 09:37:15 +0000
Subject: [PATCH] [libc][NFC] Sink "PlatformDefs.h" into "FloatProperties.h"
---
libc/src/__support/FPUtil/CMakeLists.txt | 12 +--------
libc/src/__support/FPUtil/FPBits.h | 2 --
libc/src/__support/FPUtil/FloatProperties.h | 15 +++++++++--
.../__support/FPUtil/ManipulationFunctions.h | 1 -
libc/src/__support/FPUtil/PlatformDefs.h | 26 -------------------
.../__support/FPUtil/generic/CMakeLists.txt | 1 -
libc/src/__support/FPUtil/generic/sqrt.h | 1 -
.../FPUtil/generic/sqrt_80_bit_long_double.h | 1 -
libc/test/src/stdio/CMakeLists.txt | 1 -
libc/test/src/stdio/sprintf_test.cpp | 1 -
libc/test/src/stdio/sscanf_test.cpp | 1 -
libc/utils/MPFRWrapper/CMakeLists.txt | 1 -
libc/utils/MPFRWrapper/MPFRUtils.cpp | 1 -
.../llvm-project-overlay/libc/BUILD.bazel | 13 ----------
.../libc/libc_build_rules.bzl | 1 -
.../libc/test/src/stdio/BUILD.bazel | 1 -
.../libc/utils/MPFRWrapper/BUILD.bazel | 1 -
17 files changed, 14 insertions(+), 66 deletions(-)
delete mode 100644 libc/src/__support/FPUtil/PlatformDefs.h
diff --git a/libc/src/__support/FPUtil/CMakeLists.txt b/libc/src/__support/FPUtil/CMakeLists.txt
index bf6e39f436c8c49..848b166e814b2a8 100644
--- a/libc/src/__support/FPUtil/CMakeLists.txt
+++ b/libc/src/__support/FPUtil/CMakeLists.txt
@@ -23,20 +23,12 @@ add_header_library(
libc.src.errno.errno
)
-add_header_library(
- platform_defs
- HDRS
- PlatformDefs.h
- DEPENDS
- libc.src.__support.common
-)
-
add_header_library(
float_properties
HDRS
+ PlatformDefs.h
FloatProperties.h
DEPENDS
- .platform_defs
libc.src.__support.uint128
)
@@ -46,7 +38,6 @@ add_header_library(
FPBits.h
DEPENDS
.float_properties
- .platform_defs
libc.src.__support.common
libc.src.__support.CPP.bit
libc.src.__support.CPP.type_traits
@@ -100,7 +91,6 @@ add_header_library(
.fp_bits
.nearest_integer_operations
.normal_float
- .platform_defs
libc.src.__support.CPP.bit
libc.src.__support.CPP.type_traits
libc.src.__support.common
diff --git a/libc/src/__support/FPUtil/FPBits.h b/libc/src/__support/FPUtil/FPBits.h
index 0db90d1e36df0c2..8bfb5a24161dae1 100644
--- a/libc/src/__support/FPUtil/FPBits.h
+++ b/libc/src/__support/FPUtil/FPBits.h
@@ -9,8 +9,6 @@
#ifndef LLVM_LIBC_SRC___SUPPORT_FPUTIL_FPBITS_H
#define LLVM_LIBC_SRC___SUPPORT_FPUTIL_FPBITS_H
-#include "PlatformDefs.h"
-
#include "src/__support/CPP/bit.h"
#include "src/__support/CPP/type_traits.h"
#include "src/__support/bit.h"
diff --git a/libc/src/__support/FPUtil/FloatProperties.h b/libc/src/__support/FPUtil/FloatProperties.h
index 9a5f1cced9de970..3be4b518be33843 100644
--- a/libc/src/__support/FPUtil/FloatProperties.h
+++ b/libc/src/__support/FPUtil/FloatProperties.h
@@ -9,12 +9,23 @@
#ifndef LLVM_LIBC_SRC___SUPPORT_FPUTIL_FLOATPROPERTIES_H
#define LLVM_LIBC_SRC___SUPPORT_FPUTIL_FLOATPROPERTIES_H
-#include "PlatformDefs.h"
-
#include "src/__support/UInt128.h"
+#include "src/__support/macros/properties/architectures.h" // LIBC_TARGET_ARCH_XXX
#include <stdint.h>
+// https://developer.arm.com/documentation/dui0491/i/C-and-C---Implementation-Details/Basic-data-types
+// https://developer.apple.com/documentation/xcode/writing-arm64-code-for-apple-platforms
+// https://docs.amd.com/bundle/HIP-Programming-Guide-v5.1/page/Programming_with_HIP.html
+#if defined(_WIN32) || defined(__arm__) || defined(__NVPTX__) || \
+ defined(__AMDGPU__) || (defined(__APPLE__) && defined(__aarch64__))
+#define LONG_DOUBLE_IS_DOUBLE
+#endif
+
+#if !defined(LONG_DOUBLE_IS_DOUBLE) && defined(LIBC_TARGET_ARCH_IS_X86)
+#define SPECIAL_X86_LONG_DOUBLE
+#endif
+
namespace LIBC_NAMESPACE {
namespace fputil {
diff --git a/libc/src/__support/FPUtil/ManipulationFunctions.h b/libc/src/__support/FPUtil/ManipulationFunctions.h
index aa6d3220d6e12a6..f1768885d4ca500 100644
--- a/libc/src/__support/FPUtil/ManipulationFunctions.h
+++ b/libc/src/__support/FPUtil/ManipulationFunctions.h
@@ -13,7 +13,6 @@
#include "FloatProperties.h"
#include "NearestIntegerOperations.h"
#include "NormalFloat.h"
-#include "PlatformDefs.h"
#include "src/__support/CPP/bit.h"
#include "src/__support/CPP/type_traits.h"
diff --git a/libc/src/__support/FPUtil/PlatformDefs.h b/libc/src/__support/FPUtil/PlatformDefs.h
deleted file mode 100644
index 0195b909101db0f..000000000000000
--- a/libc/src/__support/FPUtil/PlatformDefs.h
+++ /dev/null
@@ -1,26 +0,0 @@
-//===-- Platform specific macro definitions ---------------------*- C++ -*-===//
-//
-// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
-// See https://llvm.org/LICENSE.txt for license information.
-// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
-//
-//===----------------------------------------------------------------------===//
-
-#ifndef LLVM_LIBC_SRC___SUPPORT_FPUTIL_PLATFORMDEFS_H
-#define LLVM_LIBC_SRC___SUPPORT_FPUTIL_PLATFORMDEFS_H
-
-#include "src/__support/macros/properties/architectures.h"
-
-// https://developer.arm.com/documentation/dui0491/i/C-and-C---Implementation-Details/Basic-data-types
-// https://developer.apple.com/documentation/xcode/writing-arm64-code-for-apple-platforms
-// https://docs.amd.com/bundle/HIP-Programming-Guide-v5.1/page/Programming_with_HIP.html
-#if defined(_WIN32) || defined(__arm__) || defined(__NVPTX__) || \
- defined(__AMDGPU__) || (defined(__APPLE__) && defined(__aarch64__))
-#define LONG_DOUBLE_IS_DOUBLE
-#endif
-
-#if !defined(LONG_DOUBLE_IS_DOUBLE) && defined(LIBC_TARGET_ARCH_IS_X86)
-#define SPECIAL_X86_LONG_DOUBLE
-#endif
-
-#endif // LLVM_LIBC_SRC___SUPPORT_FPUTIL_PLATFORMDEFS_H
diff --git a/libc/src/__support/FPUtil/generic/CMakeLists.txt b/libc/src/__support/FPUtil/generic/CMakeLists.txt
index cf603e7987e1d68..c799d502b47d61d 100644
--- a/libc/src/__support/FPUtil/generic/CMakeLists.txt
+++ b/libc/src/__support/FPUtil/generic/CMakeLists.txt
@@ -10,7 +10,6 @@ add_header_library(
libc.src.__support.CPP.type_traits
libc.src.__support.FPUtil.fenv_impl
libc.src.__support.FPUtil.fp_bits
- libc.src.__support.FPUtil.platform_defs
libc.src.__support.FPUtil.rounding_mode
libc.src.__support.bit
libc.src.__support.uint128
diff --git a/libc/src/__support/FPUtil/generic/sqrt.h b/libc/src/__support/FPUtil/generic/sqrt.h
index db9f4b11eb17c59..63e8329b066074a 100644
--- a/libc/src/__support/FPUtil/generic/sqrt.h
+++ b/libc/src/__support/FPUtil/generic/sqrt.h
@@ -14,7 +14,6 @@
#include "src/__support/CPP/type_traits.h"
#include "src/__support/FPUtil/FEnvImpl.h"
#include "src/__support/FPUtil/FPBits.h"
-#include "src/__support/FPUtil/PlatformDefs.h"
#include "src/__support/FPUtil/rounding_mode.h"
#include "src/__support/UInt128.h"
#include "src/__support/bit.h"
diff --git a/libc/src/__support/FPUtil/generic/sqrt_80_bit_long_double.h b/libc/src/__support/FPUtil/generic/sqrt_80_bit_long_double.h
index dbbb238ca24d1b8..713c3389051096f 100644
--- a/libc/src/__support/FPUtil/generic/sqrt_80_bit_long_double.h
+++ b/libc/src/__support/FPUtil/generic/sqrt_80_bit_long_double.h
@@ -11,7 +11,6 @@
#include "src/__support/FPUtil/FEnvImpl.h"
#include "src/__support/FPUtil/FPBits.h"
-#include "src/__support/FPUtil/PlatformDefs.h"
#include "src/__support/FPUtil/rounding_mode.h"
#include "src/__support/UInt128.h"
#include "src/__support/bit.h"
diff --git a/libc/test/src/stdio/CMakeLists.txt b/libc/test/src/stdio/CMakeLists.txt
index 9ab2b9f4909bc8f..ffc238443863bff 100644
--- a/libc/test/src/stdio/CMakeLists.txt
+++ b/libc/test/src/stdio/CMakeLists.txt
@@ -132,7 +132,6 @@ add_fp_unittest(
DEPENDS
libc.src.stdio.sprintf
libc.src.__support.FPUtil.fp_bits
- libc.src.__support.FPUtil.platform_defs
COMPILE_OPTIONS
${sprintf_test_copts}
)
diff --git a/libc/test/src/stdio/sprintf_test.cpp b/libc/test/src/stdio/sprintf_test.cpp
index b3497b8a0b29a9e..e41579a20656b72 100644
--- a/libc/test/src/stdio/sprintf_test.cpp
+++ b/libc/test/src/stdio/sprintf_test.cpp
@@ -9,7 +9,6 @@
#include "src/stdio/sprintf.h"
#include "src/__support/FPUtil/FPBits.h"
-#include "src/__support/FPUtil/PlatformDefs.h"
#include "test/UnitTest/RoundingModeUtils.h"
#include "test/UnitTest/Test.h"
diff --git a/libc/test/src/stdio/sscanf_test.cpp b/libc/test/src/stdio/sscanf_test.cpp
index 7efc10dfba69dd3..ec53c08bd9d41bf 100644
--- a/libc/test/src/stdio/sscanf_test.cpp
+++ b/libc/test/src/stdio/sscanf_test.cpp
@@ -8,7 +8,6 @@
#include "src/__support/CPP/limits.h"
#include "src/__support/FPUtil/FPBits.h"
-#include "src/__support/FPUtil/PlatformDefs.h"
#include "src/stdio/sscanf.h"
diff --git a/libc/utils/MPFRWrapper/CMakeLists.txt b/libc/utils/MPFRWrapper/CMakeLists.txt
index 829fd1fb768c227..416307a20d7d181 100644
--- a/libc/utils/MPFRWrapper/CMakeLists.txt
+++ b/libc/utils/MPFRWrapper/CMakeLists.txt
@@ -14,7 +14,6 @@ if(LIBC_TESTS_CAN_USE_MPFR)
libc.src.__support.FPUtil.fp_bits
libc.src.__support.FPUtil.float_properties
libc.src.__support.FPUtil.fpbits_str
- libc.src.__support.FPUtil.platform_defs
LibcTest.unit
)
if(EXISTS ${LLVM_LIBC_MPFR_INSTALL_PATH})
diff --git a/libc/utils/MPFRWrapper/MPFRUtils.cpp b/libc/utils/MPFRWrapper/MPFRUtils.cpp
index cc100f6938f033e..e1213e00ff36140 100644
--- a/libc/utils/MPFRWrapper/MPFRUtils.cpp
+++ b/libc/utils/MPFRWrapper/MPFRUtils.cpp
@@ -12,7 +12,6 @@
#include "src/__support/CPP/string_view.h"
#include "src/__support/FPUtil/FPBits.h"
#include "src/__support/FPUtil/FloatProperties.h"
-#include "src/__support/FPUtil/PlatformDefs.h"
#include "src/__support/FPUtil/fpbits_str.h"
#include "test/UnitTest/FPMatcher.h"
diff --git a/utils/bazel/llvm-project-overlay/libc/BUILD.bazel b/utils/bazel/llvm-project-overlay/libc/BUILD.bazel
index 4e1031fb38f5dce..19573d83b12b3be 100644
--- a/utils/bazel/llvm-project-overlay/libc/BUILD.bazel
+++ b/utils/bazel/llvm-project-overlay/libc/BUILD.bazel
@@ -657,7 +657,6 @@ libc_support_library(
name = "__support_fputil_float_properties",
hdrs = ["src/__support/FPUtil/FloatProperties.h"],
deps = [
- ":__support_fputil_platform_defs",
":__support_uint128",
],
)
@@ -672,7 +671,6 @@ libc_support_library(
":__support_cpp_bit",
":__support_cpp_type_traits",
":__support_fputil_float_properties",
- ":__support_fputil_platform_defs",
":__support_uint128",
],
)
@@ -686,7 +684,6 @@ libc_support_library(
":__support_cpp_type_traits",
":__support_fputil_float_properties",
":__support_fputil_fp_bits",
- ":__support_fputil_platform_defs",
":__support_integer_to_string",
":__support_uint128",
],
@@ -719,7 +716,6 @@ libc_support_library(
":__support_fputil_fp_bits",
":__support_fputil_nearest_integer_operations",
":__support_fputil_normal_float",
- ":__support_fputil_platform_defs",
":__support_macros_optimization",
":__support_uint128",
],
@@ -747,14 +743,6 @@ libc_support_library(
],
)
-libc_support_library(
- name = "__support_fputil_platform_defs",
- hdrs = ["src/__support/FPUtil/PlatformDefs.h"],
- deps = [
- ":__support_common",
- ],
-)
-
sqrt_common_hdrs = [
"src/__support/FPUtil/sqrt.h",
"src/__support/FPUtil/generic/sqrt.h",
@@ -781,7 +769,6 @@ libc_support_library(
":__support_cpp_type_traits",
":__support_fputil_fenv_impl",
":__support_fputil_fp_bits",
- ":__support_fputil_platform_defs",
":__support_fputil_rounding_mode",
":__support_uint128",
],
diff --git a/utils/bazel/llvm-project-overlay/libc/libc_build_rules.bzl b/utils/bazel/llvm-project-overlay/libc/libc_build_rules.bzl
index d93f089ac9ed357..0c63bdb96333726 100644
--- a/utils/bazel/llvm-project-overlay/libc/libc_build_rules.bzl
+++ b/utils/bazel/llvm-project-overlay/libc/libc_build_rules.bzl
@@ -144,7 +144,6 @@ def libc_math_function(
":__support_fputil_manipulation_functions",
":__support_fputil_nearest_integer_operations",
":__support_fputil_normal_float",
- ":__support_fputil_platform_defs",
":__support_math_extras",
":__support_fputil_except_value_utils",
]
diff --git a/utils/bazel/llvm-project-overlay/libc/test/src/stdio/BUILD.bazel b/utils/bazel/llvm-project-overlay/libc/test/src/stdio/BUILD.bazel
index e25ed33b908f8d3..3ec2bdb4dcf458e 100644
--- a/utils/bazel/llvm-project-overlay/libc/test/src/stdio/BUILD.bazel
+++ b/utils/bazel/llvm-project-overlay/libc/test/src/stdio/BUILD.bazel
@@ -61,7 +61,6 @@ libc_test(
],
deps = [
"//libc:__support_fputil_fp_bits",
- "//libc:__support_fputil_platform_defs",
"//libc/test/UnitTest:fp_test_helpers",
],
)
diff --git a/utils/bazel/llvm-project-overlay/libc/utils/MPFRWrapper/BUILD.bazel b/utils/bazel/llvm-project-overlay/libc/utils/MPFRWrapper/BUILD.bazel
index 270fff558bb4e3f..6c8c20e3b9e8776 100644
--- a/utils/bazel/llvm-project-overlay/libc/utils/MPFRWrapper/BUILD.bazel
+++ b/utils/bazel/llvm-project-overlay/libc/utils/MPFRWrapper/BUILD.bazel
@@ -47,7 +47,6 @@ libc_support_library(
"//libc:__support_fputil_float_properties",
"//libc:__support_fputil_fp_bits",
"//libc:__support_fputil_fpbits_str",
- "//libc:__support_fputil_platform_defs",
"//libc/test/UnitTest:fp_test_helpers",
"//libc/utils/MPFRWrapper:mpfr_impl",
],
More information about the libc-commits
mailing list