Skip to content

Commit

Permalink
[libc][NFC] Sink "PlatformDefs.h" into "FloatProperties.h" (#73226)
Browse files Browse the repository at this point in the history
`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.
  • Loading branch information
gchatelet committed Nov 23, 2023
1 parent dbb8643 commit d924c5d
Show file tree
Hide file tree
Showing 17 changed files with 13 additions and 66 deletions.
11 changes: 0 additions & 11 deletions libc/src/__support/FPUtil/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -23,20 +23,11 @@ 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
FloatProperties.h
DEPENDS
.platform_defs
libc.src.__support.uint128
)

Expand All @@ -46,7 +37,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
Expand Down Expand Up @@ -100,7 +90,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
Expand Down
2 changes: 0 additions & 2 deletions libc/src/__support/FPUtil/FPBits.h
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
15 changes: 13 additions & 2 deletions libc/src/__support/FPUtil/FloatProperties.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 {

Expand Down
1 change: 0 additions & 1 deletion libc/src/__support/FPUtil/ManipulationFunctions.h
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
26 changes: 0 additions & 26 deletions libc/src/__support/FPUtil/PlatformDefs.h

This file was deleted.

1 change: 0 additions & 1 deletion libc/src/__support/FPUtil/generic/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 0 additions & 1 deletion libc/src/__support/FPUtil/generic/sqrt.h
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
1 change: 0 additions & 1 deletion libc/test/src/stdio/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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}
)
Expand Down
1 change: 0 additions & 1 deletion libc/test/src/stdio/sprintf_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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"

Expand Down
1 change: 0 additions & 1 deletion libc/test/src/stdio/sscanf_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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"

Expand Down
1 change: 0 additions & 1 deletion libc/utils/MPFRWrapper/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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})
Expand Down
1 change: 0 additions & 1 deletion libc/utils/MPFRWrapper/MPFRUtils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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"

Expand Down
13 changes: 0 additions & 13 deletions utils/bazel/llvm-project-overlay/libc/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -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",
],
)
Expand All @@ -672,7 +671,6 @@ libc_support_library(
":__support_cpp_bit",
":__support_cpp_type_traits",
":__support_fputil_float_properties",
":__support_fputil_platform_defs",
":__support_uint128",
],
)
Expand All @@ -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",
],
Expand Down Expand Up @@ -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",
],
Expand Down Expand Up @@ -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",
Expand All @@ -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",
],
Expand Down
1 change: 0 additions & 1 deletion utils/bazel/llvm-project-overlay/libc/libc_build_rules.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -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",
]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,6 @@ libc_test(
],
deps = [
"//libc:__support_fputil_fp_bits",
"//libc:__support_fputil_platform_defs",
"//libc/test/UnitTest:fp_test_helpers",
],
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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",
],
Expand Down

0 comments on commit d924c5d

Please sign in to comment.