brintos

brintos / llvm-project-archived public Read only

0
0
Text · 2.3 KiB · 13975e6 Raw
53 lines · c
1//===-- Memcpy implementation -----------------------------------*- C++ -*-===//2//3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.4// See https://llvm.org/LICENSE.txt for license information.5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception6//7//===----------------------------------------------------------------------===//8 9#ifndef LLVM_LIBC_SRC_STRING_MEMORY_UTILS_INLINE_MEMCPY_H10#define LLVM_LIBC_SRC_STRING_MEMORY_UTILS_INLINE_MEMCPY_H11 12#include "src/__support/macros/attributes.h"               // LIBC_INLINE13#include "src/__support/macros/properties/architectures.h" // LIBC_TARGET_ARCH_IS_14#include "src/string/memory_utils/utils.h"                 // Ptr, CPtr15 16#include <stddef.h> // size_t17 18#if defined(LIBC_COPT_MEMCPY_USE_EMBEDDED_TINY)19#include "src/string/memory_utils/generic/byte_per_byte.h"20#define LIBC_SRC_STRING_MEMORY_UTILS_MEMCPY inline_memcpy_byte_per_byte21#elif defined(LIBC_TARGET_ARCH_IS_X86)22#include "src/string/memory_utils/x86_64/inline_memcpy.h"23#define LIBC_SRC_STRING_MEMORY_UTILS_MEMCPY                                    \24  inline_memcpy_x86_maybe_interpose_repmovsb25#elif defined(LIBC_TARGET_ARCH_IS_ARM)26#include "src/string/memory_utils/arm/inline_memcpy.h"27#define LIBC_SRC_STRING_MEMORY_UTILS_MEMCPY inline_memcpy_arm28#elif defined(LIBC_TARGET_ARCH_IS_AARCH64)29#include "src/string/memory_utils/aarch64/inline_memcpy.h"30#define LIBC_SRC_STRING_MEMORY_UTILS_MEMCPY inline_memcpy_aarch6431#elif defined(LIBC_TARGET_ARCH_IS_ANY_RISCV)32#include "src/string/memory_utils/riscv/inline_memcpy.h"33#define LIBC_SRC_STRING_MEMORY_UTILS_MEMCPY inline_memcpy_riscv34#elif defined(LIBC_TARGET_ARCH_IS_GPU)35#include "src/string/memory_utils/generic/builtin.h"36#define LIBC_SRC_STRING_MEMORY_UTILS_MEMCPY inline_memcpy_builtin37#else38#include "src/string/memory_utils/generic/byte_per_byte.h"39#define LIBC_SRC_STRING_MEMORY_UTILS_MEMCPY inline_memcpy_byte_per_byte40#endif41 42namespace LIBC_NAMESPACE_DECL {43 44[[gnu::flatten]] LIBC_INLINE void45inline_memcpy(void *__restrict dst, const void *__restrict src, size_t count) {46  LIBC_SRC_STRING_MEMORY_UTILS_MEMCPY(reinterpret_cast<Ptr>(dst),47                                      reinterpret_cast<CPtr>(src), count);48}49 50} // namespace LIBC_NAMESPACE_DECL51 52#endif // LLVM_LIBC_SRC_STRING_MEMORY_UTILS_INLINE_MEMCPY_H53