52 lines · c
1//===-- Memmove 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 LIBC_SRC_STRING_MEMORY_UTILS_AARCH64_INLINE_MEMMOVE_H9#define LIBC_SRC_STRING_MEMORY_UTILS_AARCH64_INLINE_MEMMOVE_H10 11#include "src/__support/macros/attributes.h" // LIBC_INLINE12#include "src/string/memory_utils/op_builtin.h"13#include "src/string/memory_utils/op_generic.h"14#include "src/string/memory_utils/utils.h"15 16#include <stddef.h> // size_t17 18namespace LIBC_NAMESPACE_DECL {19 20LIBC_INLINE void inline_memmove_aarch64(Ptr dst, CPtr src, size_t count) {21 using uint128_t = generic_v128;22 using uint256_t = generic_v256;23 using uint512_t = generic_v512;24 if (count == 0)25 return;26 if (count == 1)27 return generic::Memmove<uint8_t>::block(dst, src);28 if (count <= 4)29 return generic::Memmove<uint16_t>::head_tail(dst, src, count);30 if (count <= 8)31 return generic::Memmove<uint32_t>::head_tail(dst, src, count);32 if (count <= 16)33 return generic::Memmove<uint64_t>::head_tail(dst, src, count);34 if (count <= 32)35 return generic::Memmove<uint128_t>::head_tail(dst, src, count);36 if (count <= 64)37 return generic::Memmove<uint256_t>::head_tail(dst, src, count);38 if (count <= 128)39 return generic::Memmove<uint512_t>::head_tail(dst, src, count);40 if (dst < src) {41 generic::Memmove<uint256_t>::align_forward<Arg::Src>(dst, src, count);42 return generic::Memmove<uint512_t>::loop_and_tail_forward(dst, src, count);43 } else {44 generic::Memmove<uint256_t>::align_backward<Arg::Src>(dst, src, count);45 return generic::Memmove<uint512_t>::loop_and_tail_backward(dst, src, count);46 }47}48 49} // namespace LIBC_NAMESPACE_DECL50 51#endif // LIBC_SRC_STRING_MEMORY_UTILS_AARCH64_INLINE_MEMMOVE_H52