llvm/libc/test/src/string/memory_utils/op_tests.cpp

//===-- Unittests for op_ files -------------------------------------------===//
//
// 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
//
//===----------------------------------------------------------------------===//

#include "memory_check_utils.h"
#include "src/__support/macros/config.h"
#include "src/__support/macros/properties/os.h"
#include "src/__support/macros/properties/types.h" // LIBC_TYPES_HAS_INT64
#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_riscv.h"
#include "src/string/memory_utils/op_x86.h"
#include "test/UnitTest/Test.h"

namespace LIBC_NAMESPACE_DECL {

template <typename T> struct has_head_tail {};

template <typename T> struct has_loop_and_tail {};

// Allocates two Buffer and extracts two spans out of them, one
// aligned and one misaligned. Tests are run on both spans.
struct Buffers {};

MemcpyImplementations;

// Convenient helper to turn a span into cpp::byte *.
static inline cpp::byte *as_byte(cpp::span<char> span) {}

// Adapt CheckMemcpy signature to op implementation signatures.
template <auto FnImpl>
void CopyAdaptor(cpp::span<char> dst, cpp::span<char> src, size_t size) {}
template <size_t Size, auto FnImpl>
void CopyBlockAdaptor(cpp::span<char> dst, cpp::span<char> src, size_t size) {}

TYPED_TEST(LlvmLibcOpTest, Memcpy, MemcpyImplementations) {}

MemsetImplementations;

// Adapt CheckMemset signature to op implementation signatures.
template <auto FnImpl>
void SetAdaptor(cpp::span<char> dst, uint8_t value, size_t size) {}
template <size_t Size, auto FnImpl>
void SetBlockAdaptor(cpp::span<char> dst, uint8_t value, size_t size) {}

TYPED_TEST(LlvmLibcOpTest, Memset, MemsetImplementations) {}

#ifdef LIBC_TARGET_ARCH_IS_X86_64
// Prevent GCC warning due to ignored __aligned__ attributes when passing x86
// SIMD types as template arguments.
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wignored-attributes"
#endif // LIBC_TARGET_ARCH_IS_X86_64

BcmpImplementations;

#ifdef LIBC_TARGET_ARCH_IS_X86_64
#pragma GCC diagnostic pop
#endif // LIBC_TARGET_ARCH_IS_X86_64

// Adapt CheckBcmp signature to op implementation signatures.
template <auto FnImpl>
int CmpAdaptor(cpp::span<char> p1, cpp::span<char> p2, size_t size) {}
template <size_t Size, auto FnImpl>
int CmpBlockAdaptor(cpp::span<char> p1, cpp::span<char> p2, size_t size) {}

TYPED_TEST(LlvmLibcOpTest, Bcmp, BcmpImplementations) {}

#ifdef LIBC_TARGET_ARCH_IS_X86_64
// Prevent GCC warning due to ignored __aligned__ attributes when passing x86
// SIMD types as template arguments.
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wignored-attributes"
#endif // LIBC_TARGET_ARCH_IS_X86_64

MemcmpImplementations;

#ifdef LIBC_TARGET_ARCH_IS_X86_64
#pragma GCC diagnostic pop
#endif // LIBC_TARGET_ARCH_IS_X86_64

TYPED_TEST(LlvmLibcOpTest, Memcmp, MemcmpImplementations) {}

} // namespace LIBC_NAMESPACE_DECL