Revert "[libc][NFC] Move memcmp implementations in subfolders"
authorGuillaume Chatelet <gchatelet@google.com>
Tue, 14 Mar 2023 13:00:07 +0000 (13:00 +0000)
committerGuillaume Chatelet <gchatelet@google.com>
Tue, 14 Mar 2023 13:00:40 +0000 (13:00 +0000)
this broke arm32 build bots
This reverts commit 7f20e2a8d2ba73a8b05742903f4ae42afec82bff.

libc/src/string/memory_utils/CMakeLists.txt
libc/src/string/memory_utils/aarch64/memcmp_implementations.h [deleted file]
libc/src/string/memory_utils/memcmp_implementations.h
libc/src/string/memory_utils/x86_64/memcmp_implementations.h [deleted file]
utils/bazel/llvm-project-overlay/libc/BUILD.bazel

index 30123b09a75be9cd3ddfd42ff26a36c310025e37..5210958fe9baa998a861b5c4da8a024aa7195bff 100644 (file)
@@ -2,12 +2,12 @@
 add_header_library(
   memory_utils
   HDRS
-    aarch64/memcmp_implementations.h
-    aarch64/memcpy_implementations.h
     bcmp_implementations.h
     bzero_implementations.h
     memcmp_implementations.h
     memcpy_implementations.h
+    aarch64/memcpy_implementations.h
+    x86_64/memcpy_implementations.h
     memmove_implementations.h
     memset_implementations.h
     op_aarch64.h
@@ -15,8 +15,6 @@ add_header_library(
     op_generic.h
     op_x86.h
     utils.h
-    x86_64/memcmp_implementations.h
-    x86_64/memcpy_implementations.h
   DEPS
     libc.src.__support.CPP.bit
     libc.src.__support.CPP.cstddef
diff --git a/libc/src/string/memory_utils/aarch64/memcmp_implementations.h b/libc/src/string/memory_utils/aarch64/memcmp_implementations.h
deleted file mode 100644 (file)
index 2c9308d..0000000
+++ /dev/null
@@ -1,70 +0,0 @@
-//===-- Memcmp implementation for aarch64 -----------------------*- 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 LIBC_SRC_STRING_MEMORY_UTILS_X86_64_MEMCMP_IMPLEMENTATIONS_H
-#define LIBC_SRC_STRING_MEMORY_UTILS_X86_64_MEMCMP_IMPLEMENTATIONS_H
-
-#include "src/__support/macros/config.h"       // LIBC_INLINE
-#include "src/__support/macros/optimization.h" // LIBC_UNLIKELY
-#include "src/string/memory_utils/op_aarch64.h"
-#include "src/string/memory_utils/op_generic.h"
-#include "src/string/memory_utils/utils.h" // MemcmpReturnType
-
-namespace __llvm_libc {
-
-[[maybe_unused]] LIBC_INLINE MemcmpReturnType
-inline_memcmp_generic_gt16(CPtr p1, CPtr p2, size_t count) {
-  if (LIBC_UNLIKELY(count >= 384)) {
-    if (auto value = generic::Memcmp<16>::block(p1, p2))
-      return value;
-    align_to_next_boundary<16, Arg::P1>(p1, p2, count);
-  }
-  return generic::Memcmp<16>::loop_and_tail(p1, p2, count);
-}
-
-[[maybe_unused]] LIBC_INLINE MemcmpReturnType
-inline_memcmp_aarch64_neon_gt16(CPtr p1, CPtr p2, size_t count) {
-  if (LIBC_UNLIKELY(count >= 128)) { // [128, ∞]
-    if (auto value = generic::Memcmp<16>::block(p1, p2))
-      return value;
-    align_to_next_boundary<16, Arg::P1>(p1, p2, count);
-    return generic::Memcmp<32>::loop_and_tail(p1, p2, count);
-  }
-  if (generic::Bcmp<16>::block(p1, p2)) // [16, 16]
-    return generic::Memcmp<16>::block(p1, p2);
-  if (count < 32) // [17, 31]
-    return generic::Memcmp<16>::tail(p1, p2, count);
-  if (generic::Bcmp<16>::block(p1 + 16, p2 + 16)) // [32, 32]
-    return generic::Memcmp<16>::block(p1 + 16, p2 + 16);
-  if (count < 64) // [33, 63]
-    return generic::Memcmp<32>::tail(p1, p2, count);
-  // [64, 127]
-  return generic::Memcmp<16>::loop_and_tail(p1 + 32, p2 + 32, count - 32);
-}
-
-LIBC_INLINE MemcmpReturnType inline_memcmp_aarch64(CPtr p1, CPtr p2,
-                                                   size_t count) {
-  if (count == 0)
-    return MemcmpReturnType::ZERO();
-  if (count == 1)
-    return generic::Memcmp<1>::block(p1, p2);
-  if (count == 2)
-    return generic::Memcmp<2>::block(p1, p2);
-  if (count == 3)
-    return generic::Memcmp<3>::block(p1, p2);
-  if (count <= 8)
-    return generic::Memcmp<4>::head_tail(p1, p2, count);
-  if (count <= 16)
-    return generic::Memcmp<8>::head_tail(p1, p2, count);
-  if constexpr (aarch64::kNeon)
-    return inline_memcmp_aarch64_neon_gt16(p1, p2, count);
-  else
-    return inline_memcmp_generic_gt16(p1, p2, count);
-}
-} // namespace __llvm_libc
-
-#endif // LIBC_SRC_STRING_MEMORY_UTILS_X86_64_MEMCMP_IMPLEMENTATIONS_H
index 9ae994f39859b5f460eaf93c89145952aa442bf6..01c524d6aa338b96be698b63cddae1ed41399fb9 100644 (file)
 #include "src/__support/common.h"
 #include "src/__support/macros/optimization.h" // LIBC_UNLIKELY LIBC_LOOP_NOUNROLL
 #include "src/__support/macros/properties/architectures.h"
+#include "src/string/memory_utils/op_aarch64.h"
+#include "src/string/memory_utils/op_builtin.h"
+#include "src/string/memory_utils/op_generic.h"
+#include "src/string/memory_utils/op_x86.h"
+#include "src/string/memory_utils/utils.h"
 
 #include <stddef.h> // size_t
 
-#if defined(LIBC_TARGET_ARCH_IS_X86)
-#include "src/string/memory_utils/x86_64/memcmp_implementations.h"
-#elif defined(LIBC_TARGET_ARCH_IS_AARCH64)
-#include "src/string/memory_utils/aarch64/memcmp_implementations.h"
-#endif
-
 namespace __llvm_libc {
-
 [[maybe_unused]] LIBC_INLINE MemcmpReturnType
 inline_memcmp_embedded_tiny(CPtr p1, CPtr p2, size_t count) {
   LIBC_LOOP_NOUNROLL
@@ -32,11 +30,115 @@ inline_memcmp_embedded_tiny(CPtr p1, CPtr p2, size_t count) {
   return MemcmpReturnType::ZERO();
 }
 
+#if defined(LIBC_TARGET_ARCH_IS_X86) || defined(LIBC_TARGET_ARCH_IS_AARCH64)
+[[maybe_unused]] LIBC_INLINE MemcmpReturnType
+inline_memcmp_generic_gt16(CPtr p1, CPtr p2, size_t count) {
+  if (LIBC_UNLIKELY(count >= 384)) {
+    if (auto value = generic::Memcmp<16>::block(p1, p2))
+      return value;
+    align_to_next_boundary<16, Arg::P1>(p1, p2, count);
+  }
+  return generic::Memcmp<16>::loop_and_tail(p1, p2, count);
+}
+#endif // defined(LIBC_TARGET_ARCH_IS_X86) ||
+       // defined(LIBC_TARGET_ARCH_IS_AARCH64)
+
+#if defined(LIBC_TARGET_ARCH_IS_X86)
+[[maybe_unused]] LIBC_INLINE MemcmpReturnType
+inline_memcmp_x86_sse2_gt16(CPtr p1, CPtr p2, size_t count) {
+  if (LIBC_UNLIKELY(count >= 384)) {
+    if (auto value = x86::sse2::Memcmp<16>::block(p1, p2))
+      return value;
+    align_to_next_boundary<16, Arg::P1>(p1, p2, count);
+  }
+  return x86::sse2::Memcmp<16>::loop_and_tail(p1, p2, count);
+}
+
+[[maybe_unused]] LIBC_INLINE MemcmpReturnType
+inline_memcmp_x86_avx2_gt16(CPtr p1, CPtr p2, size_t count) {
+  if (count <= 32)
+    return x86::sse2::Memcmp<16>::head_tail(p1, p2, count);
+  if (count <= 64)
+    return x86::avx2::Memcmp<32>::head_tail(p1, p2, count);
+  if (count <= 128)
+    return x86::avx2::Memcmp<64>::head_tail(p1, p2, count);
+  if (LIBC_UNLIKELY(count >= 384)) {
+    if (auto value = x86::avx2::Memcmp<32>::block(p1, p2))
+      return value;
+    align_to_next_boundary<32, Arg::P1>(p1, p2, count);
+  }
+  return x86::avx2::Memcmp<32>::loop_and_tail(p1, p2, count);
+}
+
+[[maybe_unused]] LIBC_INLINE MemcmpReturnType
+inline_memcmp_x86_avx512bw_gt16(CPtr p1, CPtr p2, size_t count) {
+  if (count <= 32)
+    return x86::sse2::Memcmp<16>::head_tail(p1, p2, count);
+  if (count <= 64)
+    return x86::avx2::Memcmp<32>::head_tail(p1, p2, count);
+  if (count <= 128)
+    return x86::avx512bw::Memcmp<64>::head_tail(p1, p2, count);
+  if (LIBC_UNLIKELY(count >= 384)) {
+    if (auto value = x86::avx512bw::Memcmp<64>::block(p1, p2))
+      return value;
+    align_to_next_boundary<64, Arg::P1>(p1, p2, count);
+  }
+  return x86::avx512bw::Memcmp<64>::loop_and_tail(p1, p2, count);
+}
+
+#endif // defined(LIBC_TARGET_ARCH_IS_X86)
+
+#if defined(LIBC_TARGET_ARCH_IS_AARCH64)
+[[maybe_unused]] LIBC_INLINE MemcmpReturnType
+inline_memcmp_aarch64_neon_gt16(CPtr p1, CPtr p2, size_t count) {
+  if (LIBC_UNLIKELY(count >= 128)) { // [128, ∞]
+    if (auto value = generic::Memcmp<16>::block(p1, p2))
+      return value;
+    align_to_next_boundary<16, Arg::P1>(p1, p2, count);
+    return generic::Memcmp<32>::loop_and_tail(p1, p2, count);
+  }
+  if (generic::Bcmp<16>::block(p1, p2)) // [16, 16]
+    return generic::Memcmp<16>::block(p1, p2);
+  if (count < 32) // [17, 31]
+    return generic::Memcmp<16>::tail(p1, p2, count);
+  if (generic::Bcmp<16>::block(p1 + 16, p2 + 16)) // [32, 32]
+    return generic::Memcmp<16>::block(p1 + 16, p2 + 16);
+  if (count < 64) // [33, 63]
+    return generic::Memcmp<32>::tail(p1, p2, count);
+  // [64, 127]
+  return generic::Memcmp<16>::loop_and_tail(p1 + 32, p2 + 32, count - 32);
+}
+#endif // defined(LIBC_TARGET_ARCH_IS_AARCH64)
+
 LIBC_INLINE MemcmpReturnType inline_memcmp(CPtr p1, CPtr p2, size_t count) {
+#if defined(LIBC_TARGET_ARCH_IS_X86) || defined(LIBC_TARGET_ARCH_IS_AARCH64)
+  if (count == 0)
+    return MemcmpReturnType::ZERO();
+  if (count == 1)
+    return generic::Memcmp<1>::block(p1, p2);
+  if (count == 2)
+    return generic::Memcmp<2>::block(p1, p2);
+  if (count == 3)
+    return generic::Memcmp<3>::block(p1, p2);
+  if (count <= 8)
+    return generic::Memcmp<4>::head_tail(p1, p2, count);
+  if (count <= 16)
+    return generic::Memcmp<8>::head_tail(p1, p2, count);
 #if defined(LIBC_TARGET_ARCH_IS_X86)
-  return inline_memcmp_x86(p1, p2, count);
+  if constexpr (x86::kAvx512BW)
+    return inline_memcmp_x86_avx512bw_gt16(p1, p2, count);
+  else if constexpr (x86::kAvx2)
+    return inline_memcmp_x86_avx2_gt16(p1, p2, count);
+  else if constexpr (x86::kSse2)
+    return inline_memcmp_x86_sse2_gt16(p1, p2, count);
+  else
+    return inline_memcmp_generic_gt16(p1, p2, count);
 #elif defined(LIBC_TARGET_ARCH_IS_AARCH64)
-  return inline_memcmp_aarch64(p1, p2, count);
+  if constexpr (aarch64::kNeon)
+    return inline_memcmp_aarch64_neon_gt16(p1, p2, count);
+  else
+    return inline_memcmp_generic_gt16(p1, p2, count);
+#endif
 #else
   return inline_memcmp_embedded_tiny(p1, p2, count);
 #endif
diff --git a/libc/src/string/memory_utils/x86_64/memcmp_implementations.h b/libc/src/string/memory_utils/x86_64/memcmp_implementations.h
deleted file mode 100644 (file)
index 26de1d9..0000000
+++ /dev/null
@@ -1,96 +0,0 @@
-//===-- Memcmp implementation for x86_64 ------------------------*- 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 LIBC_SRC_STRING_MEMORY_UTILS_X86_64_MEMCMP_IMPLEMENTATIONS_H
-#define LIBC_SRC_STRING_MEMORY_UTILS_X86_64_MEMCMP_IMPLEMENTATIONS_H
-
-#include "src/__support/macros/config.h"       // LIBC_INLINE
-#include "src/__support/macros/optimization.h" // LIBC_UNLIKELY
-#include "src/string/memory_utils/op_generic.h"
-#include "src/string/memory_utils/op_x86.h"
-#include "src/string/memory_utils/utils.h" // MemcmpReturnType
-
-namespace __llvm_libc {
-
-[[maybe_unused]] LIBC_INLINE MemcmpReturnType
-inline_memcmp_generic_gt16(CPtr p1, CPtr p2, size_t count) {
-  if (LIBC_UNLIKELY(count >= 384)) {
-    if (auto value = generic::Memcmp<16>::block(p1, p2))
-      return value;
-    align_to_next_boundary<16, Arg::P1>(p1, p2, count);
-  }
-  return generic::Memcmp<16>::loop_and_tail(p1, p2, count);
-}
-
-[[maybe_unused]] LIBC_INLINE MemcmpReturnType
-inline_memcmp_x86_sse2_gt16(CPtr p1, CPtr p2, size_t count) {
-  if (LIBC_UNLIKELY(count >= 384)) {
-    if (auto value = x86::sse2::Memcmp<16>::block(p1, p2))
-      return value;
-    align_to_next_boundary<16, Arg::P1>(p1, p2, count);
-  }
-  return x86::sse2::Memcmp<16>::loop_and_tail(p1, p2, count);
-}
-
-[[maybe_unused]] LIBC_INLINE MemcmpReturnType
-inline_memcmp_x86_avx2_gt16(CPtr p1, CPtr p2, size_t count) {
-  if (count <= 32)
-    return x86::sse2::Memcmp<16>::head_tail(p1, p2, count);
-  if (count <= 64)
-    return x86::avx2::Memcmp<32>::head_tail(p1, p2, count);
-  if (count <= 128)
-    return x86::avx2::Memcmp<64>::head_tail(p1, p2, count);
-  if (LIBC_UNLIKELY(count >= 384)) {
-    if (auto value = x86::avx2::Memcmp<32>::block(p1, p2))
-      return value;
-    align_to_next_boundary<32, Arg::P1>(p1, p2, count);
-  }
-  return x86::avx2::Memcmp<32>::loop_and_tail(p1, p2, count);
-}
-
-[[maybe_unused]] LIBC_INLINE MemcmpReturnType
-inline_memcmp_x86_avx512bw_gt16(CPtr p1, CPtr p2, size_t count) {
-  if (count <= 32)
-    return x86::sse2::Memcmp<16>::head_tail(p1, p2, count);
-  if (count <= 64)
-    return x86::avx2::Memcmp<32>::head_tail(p1, p2, count);
-  if (count <= 128)
-    return x86::avx512bw::Memcmp<64>::head_tail(p1, p2, count);
-  if (LIBC_UNLIKELY(count >= 384)) {
-    if (auto value = x86::avx512bw::Memcmp<64>::block(p1, p2))
-      return value;
-    align_to_next_boundary<64, Arg::P1>(p1, p2, count);
-  }
-  return x86::avx512bw::Memcmp<64>::loop_and_tail(p1, p2, count);
-}
-
-LIBC_INLINE MemcmpReturnType inline_memcmp_x86(CPtr p1, CPtr p2, size_t count) {
-
-  if (count == 0)
-    return MemcmpReturnType::ZERO();
-  if (count == 1)
-    return generic::Memcmp<1>::block(p1, p2);
-  if (count == 2)
-    return generic::Memcmp<2>::block(p1, p2);
-  if (count == 3)
-    return generic::Memcmp<3>::block(p1, p2);
-  if (count <= 8)
-    return generic::Memcmp<4>::head_tail(p1, p2, count);
-  if (count <= 16)
-    return generic::Memcmp<8>::head_tail(p1, p2, count);
-  if constexpr (x86::kAvx512BW)
-    return inline_memcmp_x86_avx512bw_gt16(p1, p2, count);
-  else if constexpr (x86::kAvx2)
-    return inline_memcmp_x86_avx2_gt16(p1, p2, count);
-  else if constexpr (x86::kSse2)
-    return inline_memcmp_x86_sse2_gt16(p1, p2, count);
-  else
-    return inline_memcmp_generic_gt16(p1, p2, count);
-}
-} // namespace __llvm_libc
-
-#endif // LIBC_SRC_STRING_MEMORY_UTILS_X86_64_MEMCMP_IMPLEMENTATIONS_H
index 23c288db31ada8e2cf7ce8d64d501400cdb90e39..ab797c3fd89e83919d643a14e34870de431be6b2 100644 (file)
@@ -1487,18 +1487,16 @@ libc_support_library(
         "src/string/memory_utils/utils.h",
     ],
     textual_hdrs = [
-        "src/string/memory_utils/aarch64/memcmp_implementations.h",
-        "src/string/memory_utils/aarch64/memcpy_implementations.h",
         "src/string/memory_utils/bcmp_implementations.h",
         "src/string/memory_utils/bzero_implementations.h",
         "src/string/memory_utils/memcmp_implementations.h",
         "src/string/memory_utils/memcpy_implementations.h",
+        "src/string/memory_utils/aarch64/memcpy_implementations.h",
+        "src/string/memory_utils/x86_64/memcpy_implementations.h",
         "src/string/memory_utils/memmove_implementations.h",
         "src/string/memory_utils/memset_implementations.h",
         "src/string/memory_utils/strcmp_implementations.h",
         "src/string/memory_utils/strstr_implementations.h",
-        "src/string/memory_utils/x86_64/memcmp_implementations.h",
-        "src/string/memory_utils/x86_64/memcpy_implementations.h",
     ],
     deps = [
         ":__support_common",