[libc][NFC] separate macros in several targets
authorGuillaume Chatelet <gchatelet@google.com>
Thu, 9 Feb 2023 10:50:49 +0000 (10:50 +0000)
committerGuillaume Chatelet <gchatelet@google.com>
Thu, 9 Feb 2023 10:51:19 +0000 (10:51 +0000)
18 files changed:
libc/src/__support/CMakeLists.txt
libc/src/__support/CPP/CMakeLists.txt
libc/src/__support/FPUtil/CMakeLists.txt
libc/src/__support/FPUtil/FEnvImpl.h
libc/src/__support/FPUtil/aarch64/FEnvImpl.h
libc/src/__support/FPUtil/aarch64/fenv_darwin_impl.h
libc/src/__support/FPUtil/x86_64/FEnvImpl.h
libc/src/__support/UInt.h
libc/src/__support/builtin_wrappers.h
libc/src/__support/macros/CMakeLists.txt [new file with mode: 0644]
libc/src/__support/macros/properties/CMakeLists.txt [new file with mode: 0644]
libc/src/string/memory_utils/CMakeLists.txt
libc/src/string/memory_utils/utils.h
libc/test/src/string/CMakeLists.txt
libc/test/src/string/memory_utils/CMakeLists.txt
libc/test/src/string/memory_utils/memory_check_utils.h
utils/bazel/llvm-project-overlay/libc/BUILD.bazel
utils/bazel/llvm-project-overlay/libc/test/src/string/BUILD.bazel

index 67663bf..3ff22bb 100644 (file)
@@ -1,4 +1,5 @@
 add_subdirectory(CPP)
+add_subdirectory(macros)
 
 add_header_library(
   blockstore
@@ -15,20 +16,6 @@ add_header_library(
 )
 
 add_header_library(
-  compiler_features
-  HDRS
-    macros/properties/compiler.h
-)
-
-add_header_library(
-  sanitizer
-  HDRS
-    macros/sanitizer.h
-  DEPENDS
-    libc.src.__support.compiler_features
-)
-
-add_header_library(
   common
   HDRS
     common.h
@@ -44,9 +31,9 @@ add_header_library(
     builtin_wrappers.h
   DEPENDS
     .named_pair
-    libc.src.__support.common
-    libc.src.__support.compiler_features
     libc.src.__support.CPP.type_traits
+    libc.src.__support.macros.attributes
+    libc.src.__support.macros.properties.compiler
 )
 
 add_header_library(
@@ -192,6 +179,7 @@ add_header_library(
     .integer_utils
     libc.src.__support.CPP.array
     libc.src.__support.CPP.type_traits
+    libc.src.__support.macros.attributes
 )
 
 add_header_library(
index e242d4e..1104114 100644 (file)
@@ -9,7 +9,7 @@ add_header_library(
   HDRS
     bit.h
   DEPENDS
-    libc.src.__support.compiler_features
+    libc.src.__support.macros.properties.compiler
 )
 
 add_header_library(
index 401dcaa..bd9faa7 100644 (file)
@@ -4,8 +4,9 @@ add_header_library(
     FEnvImpl.h
   DEPENDS
     libc.include.fenv
-    libc.src.__support.common
-    libc.src.__support.compiler_features
+    libc.src.__support.macros.attributes
+    libc.src.__support.macros.properties.architectures
+    libc.src.__support.macros.sanitizer
 )
 
 add_header_library(
index 129935e..f24e273 100644 (file)
@@ -9,7 +9,7 @@
 #ifndef LLVM_LIBC_SRC_SUPPORT_FPUTIL_FENVIMPL_H
 #define LLVM_LIBC_SRC_SUPPORT_FPUTIL_FENVIMPL_H
 
-#include "src/__support/common.h"
+#include "src/__support/macros/attributes.h" // LIBC_INLINE
 #include "src/__support/macros/properties/architectures.h"
 
 #if defined(LIBC_TARGET_ARCH_IS_AARCH64)
index 3bf4c7b..e43c718 100644 (file)
@@ -9,7 +9,7 @@
 #ifndef LLVM_LIBC_SRC_SUPPORT_FPUTIL_AARCH64_FENVIMPL_H
 #define LLVM_LIBC_SRC_SUPPORT_FPUTIL_AARCH64_FENVIMPL_H
 
-#include "src/__support/common.h"
+#include "src/__support/macros/attributes.h" // LIBC_INLINE
 #include "src/__support/macros/properties/architectures.h"
 
 #if !defined(LIBC_TARGET_ARCH_IS_AARCH64) || defined(__APPLE__)
index 38ae3f8..ae6ff78 100644 (file)
@@ -9,7 +9,7 @@
 #ifndef LLVM_LIBC_SRC_SUPPORT_FPUTIL_AARCH64_FENV_DARWIN_IMPL_H
 #define LLVM_LIBC_SRC_SUPPORT_FPUTIL_AARCH64_FENV_DARWIN_IMPL_H
 
-#include "src/__support/common.h"
+#include "src/__support/macros/attributes.h" // LIBC_INLINE
 #include "src/__support/macros/properties/architectures.h"
 
 #if !defined(LIBC_TARGET_ARCH_IS_AARCH64) || !defined(__APPLE__)
index 4e9e723..5a496f6 100644 (file)
@@ -9,6 +9,7 @@
 #ifndef LLVM_LIBC_SRC_SUPPORT_FPUTIL_X86_64_FENVIMPL_H
 #define LLVM_LIBC_SRC_SUPPORT_FPUTIL_X86_64_FENVIMPL_H
 
+#include "src/__support/macros/attributes.h" // LIBC_INLINE
 #include "src/__support/macros/properties/architectures.h"
 
 #if !defined(LIBC_TARGET_ARCH_IS_X86)
index d369576..ee1e540 100644 (file)
@@ -14,8 +14,8 @@
 #include "src/__support/CPP/optional.h"
 #include "src/__support/CPP/type_traits.h"
 #include "src/__support/builtin_wrappers.h"
-#include "src/__support/common.h"
 #include "src/__support/integer_utils.h"
+#include "src/__support/macros/attributes.h" // LIBC_UNLIKELY
 #include "src/__support/number_pair.h"
 
 #include <stddef.h> // For size_t
index 81f6622..a46e957 100644 (file)
@@ -12,8 +12,8 @@
 
 #include "named_pair.h"
 #include "src/__support/CPP/type_traits.h"
-#include "src/__support/common.h"
-#include "src/__support/macros/properties/compiler.h"
+#include "src/__support/macros/attributes.h"          // LIBC_INLINE
+#include "src/__support/macros/properties/compiler.h" // LIBC_HAS_BUILTIN
 
 namespace __llvm_libc {
 
diff --git a/libc/src/__support/macros/CMakeLists.txt b/libc/src/__support/macros/CMakeLists.txt
new file mode 100644 (file)
index 0000000..1b37288
--- /dev/null
@@ -0,0 +1,15 @@
+add_subdirectory(properties)
+
+add_header_library(
+  attributes
+  HDRS
+  attributes.h
+)
+
+add_header_library(
+  sanitizer
+  HDRS
+  sanitizer.h
+  DEPENDS
+  libc.src.__support.macros.properties.compiler
+)
diff --git a/libc/src/__support/macros/properties/CMakeLists.txt b/libc/src/__support/macros/properties/CMakeLists.txt
new file mode 100644 (file)
index 0000000..8ddd16a
--- /dev/null
@@ -0,0 +1,17 @@
+add_header_library(
+    architectures
+    HDRS
+    architectures.h
+)
+
+add_header_library(
+    compiler
+    HDRS
+    compiler.h
+)
+
+add_header_library(
+    cpu_features
+    HDRS
+    cpu_features.h
+)
index 9a4df7c..97d314d 100644 (file)
@@ -15,7 +15,7 @@ add_header_library(
     utils.h
   DEPS
     libc.src.__support.common
-    libc.src.__support.compiler_features
+    libc.src.__support.macros.properties.compiler
     libc.src.__support.CPP.bit
     libc.src.__support.CPP.cstddef
     libc.src.__support.CPP.type_traits
index 5d42641..e90016f 100644 (file)
@@ -12,8 +12,8 @@
 #include "src/__support/CPP/bit.h"
 #include "src/__support/CPP/cstddef.h"
 #include "src/__support/CPP/type_traits.h"
-#include "src/__support/common.h"
-#include "src/__support/macros/properties/compiler.h"
+#include "src/__support/macros/attributes.h"          //LIBC_INLINE
+#include "src/__support/macros/properties/compiler.h" // LIBC_HAS_BUILTIN
 
 #include <stddef.h> // size_t
 #include <stdint.h> // intptr_t / uintptr_t
index f7a0e9a..c9623a3 100644 (file)
@@ -367,7 +367,7 @@ function(add_libc_multi_impl_test name)
         ${ARGN}
         DEPENDS
           ${fq_config_name}
-          libc.src.__support.sanitizer
+          libc.src.__support.macros.sanitizer
       )
       get_fq_target_name(${fq_config_name}_test fq_target_name)
     else()
index c06058e..e222a61 100644 (file)
@@ -9,9 +9,9 @@ add_libc_unittest(
     ${LIBC_COMPILE_OPTIONS_NATIVE}
     -ffreestanding
   DEPENDS
-    libc.src.__support.compiler_features
     libc.src.__support.CPP.array
     libc.src.__support.CPP.cstddef
     libc.src.__support.CPP.span
+    libc.src.__support.macros.sanitizer
     libc.src.string.memory_utils.memory_utils
 )
index 19cbe0c..325cba3 100644 (file)
@@ -10,7 +10,6 @@
 #define LIBC_TEST_SRC_STRING_MEMORY_UTILS_MEMORY_CHECK_UTILS_H
 
 #include "src/__support/CPP/span.h"
-#include "src/__support/macros/properties/compiler.h"
 #include "src/__support/macros/sanitizer.h"
 #include "src/string/memory_utils/utils.h"
 #include <assert.h> // assert
index dbed8e4..a63110b 100644 (file)
@@ -61,18 +61,33 @@ cc_library(
 ############################## Support libraries #############################
 
 libc_support_library(
-    name = "__support_compiler_features",
+    name = "__support_macros_properties_architectures",
+    hdrs = ["src/__support/macros/properties/architectures.h"],
+    deps = [":libc_root"],
+)
+
+libc_support_library(
+    name = "__support_macros_properties_compiler",
     hdrs = ["src/__support/macros/properties/compiler.h"],
     deps = [":libc_root"],
 )
 
 libc_support_library(
-    name = "__support_sanitizer",
+    name = "__support_macros_properties_cpu_features",
+    hdrs = ["src/__support/macros/properties/cpu_features.h"],
+    deps = [":libc_root"],
+)
+
+libc_support_library(
+    name = "__support_macros_attributes",
+    hdrs = ["src/__support/macros/attributes.h"],
+    deps = [":libc_root"],
+)
+
+libc_support_library(
+    name = "__support_macros_sanitizer",
     hdrs = ["src/__support/macros/sanitizer.h"],
-    deps = [
-        ":__support_compiler_features",
-        ":libc_root",
-    ],
+    deps = [":libc_root"],
 )
 
 libc_support_library(
@@ -80,11 +95,12 @@ libc_support_library(
     hdrs = [
         "src/__support/common.h",
         "src/__support/endian.h",
-        "src/__support/macros/attributes.h",
-        "src/__support/macros/properties/architectures.h",
-        "src/__support/macros/properties/cpu_features.h",
     ],
-    deps = [":libc_root"],
+    deps = [
+        ":__support_macros_attributes",
+        ":__support_macros_properties_architectures",
+        ":libc_root",
+    ],
 )
 
 libc_support_library(
@@ -97,7 +113,7 @@ libc_support_library(
     name = "__support_cpp_bit",
     hdrs = ["src/__support/CPP/bit.h"],
     deps = [
-        ":__support_compiler_features",
+        ":__support_macros_properties_compiler",
         ":libc_root",
     ],
 )
@@ -205,13 +221,12 @@ libc_support_library(
     hdrs = ["src/__support/UInt.h"],
     deps = [
         "__support_builtin_wrappers",
-        "__support_common",
-        "__support_compiler_features",
         "__support_cpp_array",
         "__support_cpp_limits",
         "__support_cpp_optional",
         "__support_cpp_type_traits",
         "__support_integer_utils",
+        "__support_macros_attributes",
         "__support_number_pair",
         ":libc_root",
     ],
@@ -277,9 +292,9 @@ libc_support_library(
     name = "__support_builtin_wrappers",
     hdrs = ["src/__support/builtin_wrappers.h"],
     deps = [
-        ":__support_common",
-        ":__support_compiler_features",
         ":__support_cpp_type_traits",
+        ":__support_macros_attributes",
+        ":__support_macros_properties_compiler",
         ":__support_named_pair",
         ":libc_root",
     ],
@@ -318,10 +333,10 @@ libc_support_library(
         "src/__support/FPUtil/aarch64/fenv_darwin_impl.h",
     ],
     deps = [
-        ":__support_common",
-        ":__support_compiler_features",
         ":__support_fputil_fp_bits",
-        ":__support_sanitizer",
+        ":__support_macros_attributes",
+        ":__support_macros_properties_architectures",
+        ":__support_macros_sanitizer",
         ":libc_root",
     ],
 )
@@ -473,6 +488,7 @@ libc_support_library(
         ":__support_fputil_fenv_impl",
         ":__support_fputil_float_properties",
         ":__support_fputil_fp_bits",
+        ":__support_macros_properties_cpu_features",
         ":__support_uint128",
         ":libc_root",
     ],
@@ -1345,11 +1361,12 @@ libc_support_library(
     ],
     deps = [
         ":__support_common",
-        ":__support_compiler_features",
         ":__support_cpp_array",
         ":__support_cpp_bit",
         ":__support_cpp_cstddef",
         ":__support_cpp_type_traits",
+        ":__support_macros_attributes",
+        ":__support_macros_properties_compiler",
         ":libc_root",
     ],
 )
index 21a9d61..78e8b3a 100644 (file)
@@ -111,7 +111,7 @@ cc_library(
     hdrs = ["memory_utils/memory_check_utils.h"],
     deps = [
         "//libc:__support_cpp_span",
-        "//libc:__support_sanitizer",
+        "//libc:__support_macros_sanitizer",
         "//libc:string_memory_utils",
     ],
 )