|
15 | 15 | #include <arm_neon.h> |
16 | 16 | #include <stddef.h> // size_t |
17 | 17 | namespace LIBC_NAMESPACE_DECL { |
18 | | -namespace neon { |
| 18 | +namespace internal::neon { |
19 | 19 | [[maybe_unused]] LIBC_NO_SANITIZE_OOB_ACCESS LIBC_INLINE static size_t |
20 | 20 | string_length(const char *src) { |
21 | 21 | using Vector __attribute__((may_alias)) = uint8x8_t; |
@@ -43,15 +43,15 @@ string_length(const char *src) { |
43 | 43 | (cpp::countr_zero(cmp) >> 3)); |
44 | 44 | } |
45 | 45 | } |
46 | | -} // namespace neon |
| 46 | +} // namespace internal::neon |
47 | 47 | } // namespace LIBC_NAMESPACE_DECL |
48 | 48 | #endif // __ARM_NEON |
49 | 49 |
|
50 | 50 | #ifdef LIBC_TARGET_CPU_HAS_SVE |
51 | 51 | #include "src/__support/macros/optimization.h" |
52 | 52 | #include <arm_sve.h> |
53 | 53 | namespace LIBC_NAMESPACE_DECL { |
54 | | -namespace sve { |
| 54 | +namespace internal::sve { |
55 | 55 | [[maybe_unused]] LIBC_INLINE static size_t string_length(const char *src) { |
56 | 56 | const uint8_t *ptr = reinterpret_cast<const uint8_t *>(src); |
57 | 57 | // Initialize the first-fault register to all true |
@@ -92,15 +92,19 @@ namespace sve { |
92 | 92 | len += svcntp_b8(all_true, before_zero); |
93 | 93 | return len; |
94 | 94 | } |
95 | | -} // namespace sve |
| 95 | +} // namespace internal::sve |
96 | 96 | } // namespace LIBC_NAMESPACE_DECL |
97 | 97 | #endif // LIBC_TARGET_CPU_HAS_SVE |
98 | 98 |
|
99 | 99 | namespace LIBC_NAMESPACE_DECL { |
| 100 | +namespace internal::arch_vector { |
| 101 | +[[maybe_unused]] LIBC_INLINE size_t string_length(const char *src) { |
100 | 102 | #ifdef LIBC_TARGET_CPU_HAS_SVE |
101 | | -namespace string_length_impl = sve; |
| 103 | + return sve::string_length(src); |
102 | 104 | #elif defined(__ARM_NEON) |
103 | | -namespace string_length_impl = neon; |
| 105 | + return neon::string_length(src); |
104 | 106 | #endif |
| 107 | +} |
| 108 | +} // namespace internal::arch_vector |
105 | 109 | } // namespace LIBC_NAMESPACE_DECL |
106 | 110 | #endif // LLVM_LIBC_SRC_STRING_MEMORY_UTILS_AARCH64_INLINE_STRLEN_H |
0 commit comments