Skip to content

Add SVE Support #432

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions include/ada/common_defs.h
Original file line number Diff line number Diff line change
@@ -292,6 +292,10 @@ namespace ada {
#define ADA_SSE2 1
#endif

#if defined(__ARM_FEATURE_SVE)
#define ADA_SVE 1
#endif

#if defined(__aarch64__) || defined(_M_ARM64)
#define ADA_NEON 1
#endif
25 changes: 23 additions & 2 deletions src/unicode.cpp
Original file line number Diff line number Diff line change
@@ -8,7 +8,9 @@ ADA_PUSH_DISABLE_ALL_WARNINGS
ADA_POP_DISABLE_WARNINGS

#include <algorithm>
#if ADA_NEON
#if ADA_SVE
#include <arm_sve.h>
#elif ADA_NEON
#include <arm_neon.h>
#elif ADA_SSE2
#include <emmintrin.h>
@@ -44,7 +46,26 @@ constexpr bool to_lower_ascii(char* input, size_t length) noexcept {
}
return non_ascii == 0;
}
#if ADA_NEON
#if ADA_SVE
ada_really_inline bool has_tabs_or_newline(
std::string_view user_input) noexcept {
const svuint8_t mask1 = svdup_n_u8('\r');
const svuint8_t mask2 = svdup_n_u8('\n');
const svuint8_t mask3 = svdup_n_u8('\t');
svbool_t running = svdup_n_b8(false);
const size_t lanes = svcntb();
for (size_t i = 0; i < user_input.size(); i += lanes) {
const svbool_t mask = svwhilelt_b8_u64(i, user_input.size());
svuint8_t word = svld1_u8(mask, (const uint8_t*)user_input.data() + i);
running = svorr_b_z(mask,
svorr_b_z(mask, running,
svorr_b_z(mask, svcmpeq_u8(mask, word, mask1),
svcmpeq_u8(mask, word, mask2))),
svcmpeq_u8(mask, word, mask3));
}
return svptest_any(svptrue_b8(), running);
}
#elif ADA_NEON
ada_really_inline bool has_tabs_or_newline(
std::string_view user_input) noexcept {
size_t i = 0;