[libc] move benchmark function registration to a different file

GitOrigin-RevId: adc18ad6ac67658a237ffb345623f4cf78b9c3c8
diff --git a/benchmarks/CMakeLists.txt b/benchmarks/CMakeLists.txt
index 2f06836..18e5fc0 100644
--- a/benchmarks/CMakeLists.txt
+++ b/benchmarks/CMakeLists.txt
@@ -183,6 +183,7 @@
 add_executable(libc.benchmarks.memory_functions.opt_host
   EXCLUDE_FROM_ALL
   LibcMemoryGoogleBenchmarkMain.cpp
+  LibcDefaultImplementations.cpp
 )
 
 target_link_libraries(libc.benchmarks.memory_functions.opt_host
diff --git a/benchmarks/LibcDefaultImplementations.cpp b/benchmarks/LibcDefaultImplementations.cpp
new file mode 100644
index 0000000..bf362f2
--- /dev/null
+++ b/benchmarks/LibcDefaultImplementations.cpp
@@ -0,0 +1,46 @@
+#include "LibcFunctionPrototypes.h"
+#include "llvm/ADT/ArrayRef.h"
+#include <cstddef>
+
+namespace __llvm_libc {
+
+extern void *memcpy(void *__restrict, const void *__restrict, size_t);
+extern void *memset(void *, int, size_t);
+extern void bzero(void *, size_t);
+extern int memcmp(const void *, const void *, size_t);
+extern int bcmp(const void *, const void *, size_t);
+
+} // namespace __llvm_libc
+
+// List of implementations to test.
+
+using llvm::libc_benchmarks::BzeroConfiguration;
+using llvm::libc_benchmarks::MemcmpConfiguration;
+using llvm::libc_benchmarks::MemcpyConfiguration;
+using llvm::libc_benchmarks::MemsetConfiguration;
+
+llvm::ArrayRef<MemcpyConfiguration> getMemcpyConfigurations() {
+  static constexpr MemcpyConfiguration kMemcpyConfigurations[] = {
+      {__llvm_libc::memcpy, "__llvm_libc::memcpy"}};
+  return llvm::makeArrayRef(kMemcpyConfigurations);
+}
+llvm::ArrayRef<MemcmpConfiguration> getMemcmpConfigurations() {
+  static constexpr MemcmpConfiguration kMemcmpConfigurations[] = {
+      {__llvm_libc::memcmp, "__llvm_libc::memcmp"}};
+  return llvm::makeArrayRef(kMemcmpConfigurations);
+}
+llvm::ArrayRef<MemcmpConfiguration> getBcmpConfigurations() {
+  static constexpr MemcmpConfiguration kBcmpConfigurations[] = {
+      {__llvm_libc::bcmp, "__llvm_libc::bcmp"}};
+  return llvm::makeArrayRef(kBcmpConfigurations);
+}
+llvm::ArrayRef<MemsetConfiguration> getMemsetConfigurations() {
+  static constexpr MemsetConfiguration kMemsetConfigurations[] = {
+      {__llvm_libc::memset, "__llvm_libc::memset"}};
+  return llvm::makeArrayRef(kMemsetConfigurations);
+}
+llvm::ArrayRef<BzeroConfiguration> getBzeroConfigurations() {
+  static constexpr BzeroConfiguration kBzeroConfigurations[] = {
+      {__llvm_libc::bzero, "__llvm_libc::bzero"}};
+  return llvm::makeArrayRef(kBzeroConfigurations);
+}
\ No newline at end of file
diff --git a/benchmarks/LibcFunctionPrototypes.h b/benchmarks/LibcFunctionPrototypes.h
new file mode 100644
index 0000000..e856c91
--- /dev/null
+++ b/benchmarks/LibcFunctionPrototypes.h
@@ -0,0 +1,38 @@
+#ifndef LLVM_LIBC_BENCHMARKS_LIBC_FUNCTION_PROTOTYPES_H
+#define LLVM_LIBC_BENCHMARKS_LIBC_FUNCTION_PROTOTYPES_H
+
+#include "llvm/ADT/StringRef.h"
+
+namespace llvm {
+namespace libc_benchmarks {
+
+/// Memory function prototype and configuration.
+using MemcpyFunction = void *(*)(void *__restrict, const void *__restrict,
+                                 size_t);
+struct MemcpyConfiguration {
+  MemcpyFunction Function;
+  llvm::StringRef Name;
+};
+
+using MemsetFunction = void *(*)(void *, int, size_t);
+struct MemsetConfiguration {
+  MemsetFunction Function;
+  llvm::StringRef Name;
+};
+
+using BzeroFunction = void (*)(void *, size_t);
+struct BzeroConfiguration {
+  BzeroFunction Function;
+  llvm::StringRef Name;
+};
+
+using MemcmpFunction = int (*)(const void *, const void *, size_t);
+struct MemcmpConfiguration {
+  MemcmpFunction Function;
+  llvm::StringRef Name;
+};
+
+} // namespace libc_benchmarks
+} // namespace llvm
+
+#endif /* LLVM_LIBC_BENCHMARKS_LIBC_FUNCTION_PROTOTYPES_H */
diff --git a/benchmarks/LibcMemoryBenchmark.h b/benchmarks/LibcMemoryBenchmark.h
index 7badf04..eaba899 100644
--- a/benchmarks/LibcMemoryBenchmark.h
+++ b/benchmarks/LibcMemoryBenchmark.h
@@ -13,6 +13,7 @@
 #define LLVM_LIBC_UTILS_BENCHMARK_MEMORY_BENCHMARK_H
 
 #include "LibcBenchmark.h"
+#include "LibcFunctionPrototypes.h"
 #include "MemorySizeDistributions.h"
 #include "llvm/ADT/SmallVector.h"
 #include "llvm/Support/Alignment.h"
@@ -186,32 +187,6 @@
   std::vector<ParameterType> Parameters;
 };
 
-/// Memory function prototype and configuration.
-using MemcpyFunction = void *(*)(void *__restrict, const void *__restrict,
-                                 size_t);
-struct MemcpyConfiguration {
-  MemcpyFunction Function;
-  llvm::StringRef Name;
-};
-
-using MemsetFunction = void *(*)(void *, int, size_t);
-struct MemsetConfiguration {
-  MemsetFunction Function;
-  llvm::StringRef Name;
-};
-
-using BzeroFunction = void (*)(void *, size_t);
-struct BzeroConfiguration {
-  BzeroFunction Function;
-  llvm::StringRef Name;
-};
-
-using MemcmpFunction = int (*)(const void *, const void *, size_t);
-struct MemcmpConfiguration {
-  MemcmpFunction Function;
-  llvm::StringRef Name;
-};
-
 /// Provides source and destination buffers for the Copy operation as well as
 /// the associated size distributions.
 struct CopySetup : public ParameterBatch {
diff --git a/benchmarks/LibcMemoryGoogleBenchmarkMain.cpp b/benchmarks/LibcMemoryGoogleBenchmarkMain.cpp
index e48b3a7..0941c73 100644
--- a/benchmarks/LibcMemoryGoogleBenchmarkMain.cpp
+++ b/benchmarks/LibcMemoryGoogleBenchmarkMain.cpp
@@ -22,32 +22,6 @@
 using llvm::libc_benchmarks::OffsetDistribution;
 using llvm::libc_benchmarks::SetSetup;
 
-namespace __llvm_libc {
-
-extern void *memcpy(void *__restrict, const void *__restrict, size_t);
-extern void *memset(void *, int, size_t);
-extern void bzero(void *, size_t);
-extern int memcmp(const void *, const void *, size_t);
-extern int bcmp(const void *, const void *, size_t);
-
-} // namespace __llvm_libc
-
-// List of implementations to test.
-static constexpr MemcpyConfiguration kMemcpyConfigurations[] = {
-    {__llvm_libc::memcpy, "__llvm_libc::memcpy"}};
-
-static constexpr MemcmpConfiguration kMemcmpConfigurations[] = {
-    {__llvm_libc::memcmp, "__llvm_libc::memcmp"}};
-
-static constexpr MemcmpConfiguration kBcmpConfigurations[] = {
-    {__llvm_libc::bcmp, "__llvm_libc::bcmp"}};
-
-static constexpr MemsetConfiguration kMemsetConfigurations[] = {
-    {__llvm_libc::memset, "__llvm_libc::memset"}};
-
-static constexpr BzeroConfiguration kBzeroConfigurations[] = {
-    {__llvm_libc::bzero, "__llvm_libc::bzero"}};
-
 // Alignment to use for when accessing the buffers.
 static constexpr Align kBenchmarkAlignment = Align::Constant<1>();
 
@@ -116,13 +90,22 @@
         benchmark->Args({DistIndex, ConfIndex});                               \
   })
 
+extern llvm::ArrayRef<MemcpyConfiguration> getMemcpyConfigurations();
 BENCHMARK_MEMORY_FUNCTION(BM_Memcpy, CopySetup, MemcpyConfiguration,
-                          llvm::makeArrayRef(kMemcpyConfigurations));
+                          getMemcpyConfigurations());
+
+extern llvm::ArrayRef<MemcmpConfiguration> getMemcmpConfigurations();
 BENCHMARK_MEMORY_FUNCTION(BM_Memcmp, ComparisonSetup, MemcmpConfiguration,
-                          llvm::makeArrayRef(kMemcmpConfigurations));
+                          getMemcmpConfigurations());
+
+extern llvm::ArrayRef<MemcmpConfiguration> getBcmpConfigurations();
 BENCHMARK_MEMORY_FUNCTION(BM_Bcmp, ComparisonSetup, MemcmpConfiguration,
-                          llvm::makeArrayRef(kBcmpConfigurations));
+                          getBcmpConfigurations());
+
+extern llvm::ArrayRef<MemsetConfiguration> getMemsetConfigurations();
 BENCHMARK_MEMORY_FUNCTION(BM_Memset, SetSetup, MemsetConfiguration,
-                          llvm::makeArrayRef(kMemsetConfigurations));
+                          getMemsetConfigurations());
+
+extern llvm::ArrayRef<BzeroConfiguration> getBzeroConfigurations();
 BENCHMARK_MEMORY_FUNCTION(BM_Bzero, SetSetup, BzeroConfiguration,
-                          llvm::makeArrayRef(kBzeroConfigurations));
+                          getBzeroConfigurations());