xref: /llvm-project/libc/benchmarks/LibcDefaultImplementations.cpp (revision 5ff3ff33ff930e4ec49da7910612d8a41eb068cb)
1adc18ad6SGuillaume Chatelet #include "LibcFunctionPrototypes.h"
2*5ff3ff33SPetr Hosek #include "src/__support/macros/config.h"
3adc18ad6SGuillaume Chatelet #include "llvm/ADT/ArrayRef.h"
4adc18ad6SGuillaume Chatelet #include <cstddef>
5adc18ad6SGuillaume Chatelet 
6*5ff3ff33SPetr Hosek namespace LIBC_NAMESPACE_DECL {
7adc18ad6SGuillaume Chatelet 
8adc18ad6SGuillaume Chatelet extern void *memcpy(void *__restrict, const void *__restrict, size_t);
9de21f346SGuillaume Chatelet extern void *memmove(void *, const void *, size_t);
10adc18ad6SGuillaume Chatelet extern void *memset(void *, int, size_t);
11adc18ad6SGuillaume Chatelet extern void bzero(void *, size_t);
12adc18ad6SGuillaume Chatelet extern int memcmp(const void *, const void *, size_t);
13adc18ad6SGuillaume Chatelet extern int bcmp(const void *, const void *, size_t);
14adc18ad6SGuillaume Chatelet 
15*5ff3ff33SPetr Hosek } // namespace LIBC_NAMESPACE_DECL
16adc18ad6SGuillaume Chatelet 
17adc18ad6SGuillaume Chatelet // List of implementations to test.
18adc18ad6SGuillaume Chatelet 
19adc18ad6SGuillaume Chatelet using llvm::libc_benchmarks::BzeroConfiguration;
204a9bcb60SGuillaume Chatelet using llvm::libc_benchmarks::MemcmpOrBcmpConfiguration;
21adc18ad6SGuillaume Chatelet using llvm::libc_benchmarks::MemcpyConfiguration;
22de21f346SGuillaume Chatelet using llvm::libc_benchmarks::MemmoveConfiguration;
23adc18ad6SGuillaume Chatelet using llvm::libc_benchmarks::MemsetConfiguration;
24adc18ad6SGuillaume Chatelet 
25adc18ad6SGuillaume Chatelet llvm::ArrayRef<MemcpyConfiguration> getMemcpyConfigurations() {
26adc18ad6SGuillaume Chatelet   static constexpr MemcpyConfiguration kMemcpyConfigurations[] = {
27b6bc9d72SGuillaume Chatelet       {LIBC_NAMESPACE::memcpy, "LIBC_NAMESPACE::memcpy"}};
28984b800aSserge-sans-paille   return llvm::ArrayRef(kMemcpyConfigurations);
29adc18ad6SGuillaume Chatelet }
30de21f346SGuillaume Chatelet llvm::ArrayRef<MemmoveConfiguration> getMemmoveConfigurations() {
31de21f346SGuillaume Chatelet   static constexpr MemmoveConfiguration kMemmoveConfigurations[] = {
32b6bc9d72SGuillaume Chatelet       {LIBC_NAMESPACE::memmove, "LIBC_NAMESPACE::memmove"}};
33984b800aSserge-sans-paille   return llvm::ArrayRef(kMemmoveConfigurations);
34de21f346SGuillaume Chatelet }
354a9bcb60SGuillaume Chatelet llvm::ArrayRef<MemcmpOrBcmpConfiguration> getMemcmpConfigurations() {
364a9bcb60SGuillaume Chatelet   static constexpr MemcmpOrBcmpConfiguration kMemcmpConfiguration[] = {
37b6bc9d72SGuillaume Chatelet       {LIBC_NAMESPACE::memcmp, "LIBC_NAMESPACE::memcmp"}};
38984b800aSserge-sans-paille   return llvm::ArrayRef(kMemcmpConfiguration);
39adc18ad6SGuillaume Chatelet }
404a9bcb60SGuillaume Chatelet llvm::ArrayRef<MemcmpOrBcmpConfiguration> getBcmpConfigurations() {
414a9bcb60SGuillaume Chatelet   static constexpr MemcmpOrBcmpConfiguration kBcmpConfigurations[] = {
42b6bc9d72SGuillaume Chatelet       {LIBC_NAMESPACE::bcmp, "LIBC_NAMESPACE::bcmp"}};
43984b800aSserge-sans-paille   return llvm::ArrayRef(kBcmpConfigurations);
44adc18ad6SGuillaume Chatelet }
45adc18ad6SGuillaume Chatelet llvm::ArrayRef<MemsetConfiguration> getMemsetConfigurations() {
46adc18ad6SGuillaume Chatelet   static constexpr MemsetConfiguration kMemsetConfigurations[] = {
47b6bc9d72SGuillaume Chatelet       {LIBC_NAMESPACE::memset, "LIBC_NAMESPACE::memset"}};
48984b800aSserge-sans-paille   return llvm::ArrayRef(kMemsetConfigurations);
49adc18ad6SGuillaume Chatelet }
50adc18ad6SGuillaume Chatelet llvm::ArrayRef<BzeroConfiguration> getBzeroConfigurations() {
51adc18ad6SGuillaume Chatelet   static constexpr BzeroConfiguration kBzeroConfigurations[] = {
52b6bc9d72SGuillaume Chatelet       {LIBC_NAMESPACE::bzero, "LIBC_NAMESPACE::bzero"}};
53984b800aSserge-sans-paille   return llvm::ArrayRef(kBzeroConfigurations);
54adc18ad6SGuillaume Chatelet }
55