brintos

brintos / llvm-project-archived public Read only

0
0
Text · 1.7 KiB · 11cf022 Raw
49 lines · c
1//===-- Memcpy implementation for aarch64 -----------------------*- 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#ifndef LLVM_LIBC_SRC_STRING_MEMORY_UTILS_AARCH64_INLINE_MEMCPY_H9#define LLVM_LIBC_SRC_STRING_MEMORY_UTILS_AARCH64_INLINE_MEMCPY_H10 11#include "src/__support/macros/attributes.h" // LIBC_INLINE12#include "src/string/memory_utils/op_builtin.h"13#include "src/string/memory_utils/utils.h"14 15#include <stddef.h> // size_t16 17namespace LIBC_NAMESPACE_DECL {18 19[[maybe_unused]] LIBC_INLINE void20inline_memcpy_aarch64(Ptr __restrict dst, CPtr __restrict src, size_t count) {21  if (count == 0)22    return;23  if (count == 1)24    return builtin::Memcpy<1>::block(dst, src);25  if (count == 2)26    return builtin::Memcpy<2>::block(dst, src);27  if (count == 3)28    return builtin::Memcpy<3>::block(dst, src);29  if (count == 4)30    return builtin::Memcpy<4>::block(dst, src);31  if (count < 8)32    return builtin::Memcpy<4>::head_tail(dst, src, count);33  if (count < 16)34    return builtin::Memcpy<8>::head_tail(dst, src, count);35  if (count < 32)36    return builtin::Memcpy<16>::head_tail(dst, src, count);37  if (count < 64)38    return builtin::Memcpy<32>::head_tail(dst, src, count);39  if (count < 128)40    return builtin::Memcpy<64>::head_tail(dst, src, count);41  builtin::Memcpy<16>::block(dst, src);42  align_to_next_boundary<16, Arg::Src>(dst, src, count);43  return builtin::Memcpy<64>::loop_and_tail(dst, src, count);44}45 46} // namespace LIBC_NAMESPACE_DECL47 48#endif // LLVM_LIBC_SRC_STRING_MEMORY_UTILS_AARCH64_INLINE_MEMCPY_H49