@@ -34,73 +34,54 @@ inline_memmove_embedded_tiny(Ptr dst, CPtr src, size_t count) {
34
34
}
35
35
}
36
36
37
- template <size_t MaxSize>
38
- [[maybe_unused]] LIBC_INLINE void inline_memmove_generic (Ptr dst, CPtr src,
39
- size_t count) {
40
- if (count == 0 )
41
- return ;
42
- if (count == 1 )
43
- return generic::Memmove<1 , MaxSize>::block (dst, src);
44
- if (count <= 4 )
45
- return generic::Memmove<2 , MaxSize>::head_tail (dst, src, count);
46
- if (count <= 8 )
47
- return generic::Memmove<4 , MaxSize>::head_tail (dst, src, count);
48
- if (count <= 16 )
49
- return generic::Memmove<8 , MaxSize>::head_tail (dst, src, count);
50
- if (count <= 32 )
51
- return generic::Memmove<16 , MaxSize>::head_tail (dst, src, count);
52
- if (count <= 64 )
53
- return generic::Memmove<32 , MaxSize>::head_tail (dst, src, count);
54
- if (count <= 128 )
55
- return generic::Memmove<64 , MaxSize>::head_tail (dst, src, count);
56
- if (dst < src) {
57
- generic::Memmove<32 , MaxSize>::template align_forward<Arg::Src>(dst, src,
58
- count);
59
- return generic::Memmove<64 , MaxSize>::loop_and_tail_forward (dst, src,
60
- count);
61
- } else {
62
- generic::Memmove<32 , MaxSize>::template align_backward<Arg::Src>(dst, src,
63
- count);
64
- return generic::Memmove<64 , MaxSize>::loop_and_tail_backward (dst, src,
65
- count);
66
- }
67
- }
68
-
69
37
LIBC_INLINE void inline_memmove (Ptr dst, CPtr src, size_t count) {
70
38
#if defined(LIBC_TARGET_ARCH_IS_X86) || defined(LIBC_TARGET_ARCH_IS_AARCH64)
71
39
#if defined(LIBC_TARGET_ARCH_IS_X86)
72
- static constexpr size_t kMaxSize = x86::kAvx512F ? 64
73
- : x86::kAvx ? 32
74
- : x86::kSse2 ? 16
75
- : 8 ;
40
+ #if defined(__AVX512F__)
41
+ using uint128_t = uint8x16_t ;
42
+ using uint256_t = uint8x32_t ;
43
+ using uint512_t = uint8x64_t ;
44
+ #elif defined(__AVX__)
45
+ using uint128_t = uint8x16_t ;
46
+ using uint256_t = uint8x32_t ;
47
+ using uint512_t = cpp::array<uint8x32_t , 2 >;
48
+ #elif defined(__SSE2__)
49
+ using uint128_t = uint8x16_t ;
50
+ using uint256_t = cpp::array<uint8x16_t , 2 >;
51
+ using uint512_t = cpp::array<uint8x16_t , 4 >;
52
+ #else
53
+ using uint128_t = cpp::array<uint64_t , 2 >;
54
+ using uint256_t = cpp::array<uint64_t , 4 >;
55
+ using uint512_t = cpp::array<uint64_t , 8 >;
56
+ #endif
76
57
#elif defined(LIBC_TARGET_ARCH_IS_AARCH64)
77
- static constexpr size_t kMaxSize = aarch64::kNeon ? 16 : 8 ;
58
+ static_assert (aarch64::kNeon , " aarch64 supports vector types" );
59
+ using uint128_t = uint8x16_t ;
60
+ using uint256_t = uint8x32_t ;
61
+ using uint512_t = uint8x64_t ;
78
62
#endif
79
- // return inline_memmove_generic<kMaxSize>(dst, src, count);
80
63
if (count == 0 )
81
64
return ;
82
65
if (count == 1 )
83
- return generic::Memmove<1 , kMaxSize >::block (dst, src);
66
+ return generic::Memmove<uint8_t >::block (dst, src);
84
67
if (count <= 4 )
85
- return generic::Memmove<2 , kMaxSize >::head_tail (dst, src, count);
68
+ return generic::Memmove<uint16_t >::head_tail (dst, src, count);
86
69
if (count <= 8 )
87
- return generic::Memmove<4 , kMaxSize >::head_tail (dst, src, count);
70
+ return generic::Memmove<uint32_t >::head_tail (dst, src, count);
88
71
if (count <= 16 )
89
- return generic::Memmove<8 , kMaxSize >::head_tail (dst, src, count);
72
+ return generic::Memmove<uint64_t >::head_tail (dst, src, count);
90
73
if (count <= 32 )
91
- return generic::Memmove<16 , kMaxSize >::head_tail (dst, src, count);
74
+ return generic::Memmove<uint128_t >::head_tail (dst, src, count);
92
75
if (count <= 64 )
93
- return generic::Memmove<32 , kMaxSize >::head_tail (dst, src, count);
76
+ return generic::Memmove<uint256_t >::head_tail (dst, src, count);
94
77
if (count <= 128 )
95
- return generic::Memmove<64 , kMaxSize >::head_tail (dst, src, count);
78
+ return generic::Memmove<uint512_t >::head_tail (dst, src, count);
96
79
if (dst < src) {
97
- generic::Memmove<32 , kMaxSize >::align_forward<Arg::Src>(dst, src, count);
98
- return generic::Memmove<64 , kMaxSize >::loop_and_tail_forward (dst, src,
99
- count);
80
+ generic::Memmove<uint256_t >::align_forward<Arg::Src>(dst, src, count);
81
+ return generic::Memmove<uint512_t >::loop_and_tail_forward (dst, src, count);
100
82
} else {
101
- generic::Memmove<32 , kMaxSize >::align_backward<Arg::Src>(dst, src, count);
102
- return generic::Memmove<64 , kMaxSize >::loop_and_tail_backward (dst, src,
103
- count);
83
+ generic::Memmove<uint256_t >::align_backward<Arg::Src>(dst, src, count);
84
+ return generic::Memmove<uint512_t >::loop_and_tail_backward (dst, src, count);
104
85
}
105
86
#else
106
87
return inline_memmove_embedded_tiny (dst, src, count);
0 commit comments