summaryrefslogtreecommitdiff
path: root/libc/benchmarks
diff options
context:
space:
mode:
authorGuillaume Chatelet <gchatelet@google.com>2021-08-19 17:55:16 +0000
committerGuillaume Chatelet <gchatelet@google.com>2021-08-19 17:55:16 +0000
commitc8f79892af4c2fd8660180d326e02d95731f8c25 (patch)
tree12c1aaec7da194cbb1470e45ba159356ab7938cd /libc/benchmarks
parent6c75ce1b8b99e70c370ebac897145edd5482699c (diff)
downloadllvm-c8f79892af4c2fd8660180d326e02d95731f8c25.tar.gz
[libc] Add a trivial implementation for bcmp
Differential Revision: https://reviews.llvm.org/D108225
Diffstat (limited to 'libc/benchmarks')
-rw-r--r--libc/benchmarks/CMakeLists.txt2
-rw-r--r--libc/benchmarks/LibcMemoryBenchmarkMain.cpp4
-rw-r--r--libc/benchmarks/LibcMemoryGoogleBenchmarkMain.cpp6
3 files changed, 12 insertions, 0 deletions
diff --git a/libc/benchmarks/CMakeLists.txt b/libc/benchmarks/CMakeLists.txt
index ba46faeaca83..3eece745096f 100644
--- a/libc/benchmarks/CMakeLists.txt
+++ b/libc/benchmarks/CMakeLists.txt
@@ -171,6 +171,7 @@ add_libc_multi_impl_benchmark(memcpy)
add_libc_multi_impl_benchmark(memset)
add_libc_multi_impl_benchmark(bzero)
add_libc_multi_impl_benchmark(memcmp)
+add_libc_multi_impl_benchmark(bcmp)
#==============================================================================
# Google Benchmarking tool
@@ -188,6 +189,7 @@ target_link_libraries(libc.benchmarks.memory_functions.opt_host
PRIVATE
libc-memory-benchmark
libc.src.string.memcmp_opt_host
+ libc.src.string.bcmp_opt_host
libc.src.string.memcpy_opt_host
libc.src.string.memset_opt_host
libc.src.string.bzero_opt_host
diff --git a/libc/benchmarks/LibcMemoryBenchmarkMain.cpp b/libc/benchmarks/LibcMemoryBenchmarkMain.cpp
index 30bbfd44cd9b..8539402a8cda 100644
--- a/libc/benchmarks/LibcMemoryBenchmarkMain.cpp
+++ b/libc/benchmarks/LibcMemoryBenchmarkMain.cpp
@@ -27,6 +27,7 @@ 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
@@ -76,6 +77,9 @@ using BenchmarkSetup = SetSetup;
#elif defined(LIBC_BENCHMARK_FUNCTION_MEMCMP)
#define LIBC_BENCHMARK_FUNCTION LIBC_BENCHMARK_FUNCTION_MEMCMP
using BenchmarkSetup = ComparisonSetup;
+#elif defined(LIBC_BENCHMARK_FUNCTION_BCMP)
+#define LIBC_BENCHMARK_FUNCTION LIBC_BENCHMARK_FUNCTION_BCMP
+using BenchmarkSetup = ComparisonSetup;
#else
#error "Missing LIBC_BENCHMARK_FUNCTION_XXX definition"
#endif
diff --git a/libc/benchmarks/LibcMemoryGoogleBenchmarkMain.cpp b/libc/benchmarks/LibcMemoryGoogleBenchmarkMain.cpp
index 055f9902fcdc..e48b3a79c06c 100644
--- a/libc/benchmarks/LibcMemoryGoogleBenchmarkMain.cpp
+++ b/libc/benchmarks/LibcMemoryGoogleBenchmarkMain.cpp
@@ -28,6 +28,7 @@ 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
@@ -38,6 +39,9 @@ static constexpr MemcpyConfiguration kMemcpyConfigurations[] = {
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"}};
@@ -116,6 +120,8 @@ BENCHMARK_MEMORY_FUNCTION(BM_Memcpy, CopySetup, MemcpyConfiguration,
llvm::makeArrayRef(kMemcpyConfigurations));
BENCHMARK_MEMORY_FUNCTION(BM_Memcmp, ComparisonSetup, MemcmpConfiguration,
llvm::makeArrayRef(kMemcmpConfigurations));
+BENCHMARK_MEMORY_FUNCTION(BM_Bcmp, ComparisonSetup, MemcmpConfiguration,
+ llvm::makeArrayRef(kBcmpConfigurations));
BENCHMARK_MEMORY_FUNCTION(BM_Memset, SetSetup, MemsetConfiguration,
llvm::makeArrayRef(kMemsetConfigurations));
BENCHMARK_MEMORY_FUNCTION(BM_Bzero, SetSetup, BzeroConfiguration,