[NFC][Py Reformat] Added more commits to .git-blame-ignore-revs
[llvm-project.git] / libc / src / string / memory_utils / aarch64 / memcpy_implementations.h
blobe34eba27ece5b6c3293e9a282784e37c16a87bfb
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-exception
6 //
7 //===----------------------------------------------------------------------===//
8 #ifndef LIBC_SRC_STRING_MEMORY_UTILS_AARCH64_MEMCPY_IMPLEMENTATIONS_H
9 #define LIBC_SRC_STRING_MEMORY_UTILS_AARCH64_MEMCPY_IMPLEMENTATIONS_H
11 #include "src/__support/macros/config.h" // LIBC_INLINE
12 #include "src/string/memory_utils/op_builtin.h"
13 #include "src/string/memory_utils/utils.h"
15 #include <stddef.h> // size_t
17 namespace __llvm_libc {
19 [[maybe_unused]] LIBC_INLINE void
20 inline_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);
46 } // namespace __llvm_libc
48 #endif // LIBC_SRC_STRING_MEMORY_UTILS_AARCH64_MEMCPY_IMPLEMENTATIONS_H