Skip to content

Commit

Permalink
Make usage of SSE extension optional
Browse files Browse the repository at this point in the history
Signed-off-by: Christian Parpart <[email protected]>
Co-authored-by: Yaraslau Tamashevich <[email protected]>
  • Loading branch information
christianparpart and Yaraslaut committed Dec 26, 2023
1 parent 3f9fc8c commit ad31f78
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 1 deletion.
1 change: 1 addition & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ option(LIBUNICODE_EXAMPLES "libunicode: Enables building of example programs. [d
option(LIBUNICODE_TESTING "libunicode: Enables building of unittests for libunicode [default: ${MASTER_PROJECT}" ${MASTER_PROJECT})
option(LIBUNICODE_TOOLS "libunicode: Builds CLI tools [default: ${MASTER_PROJECT}]" ${MASTER_PROJECT})
option(LIBUNICODE_BUILD_STATIC "libunicode: provide static library instead of dynamic [default: ${LIBUNICODE_BUILD_STATIC_DEFAULT}]" ${LIBUNICODE_BUILD_STATIC_DEFAULT})
option(LIBUNICODE_USE_INTRINSICS "libunicode: Use SIMD extenstion during text read [default: ON]" ON)

include(ThirdParties)

Expand Down
2 changes: 1 addition & 1 deletion scripts/install-deps.sh
Original file line number Diff line number Diff line change
Expand Up @@ -235,7 +235,7 @@ main()
Darwin)
install_deps_darwin
;;
freebsd)
FreeBSD)
install_deps_FreeBSD
;;
*)
Expand Down
4 changes: 4 additions & 0 deletions src/libunicode/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,10 @@ add_library(unicode ${LIBUNICODE_LIB_MODE}
codepoint_properties_names.cpp
)

if(LIBUNICODE_USE_INTRINSICS)
target_compile_definitions(unicode PRIVATE USE_INTRINSICS)
endif()

set(public_headers
capi.h
codepoint_properties.h
Expand Down
2 changes: 2 additions & 0 deletions src/libunicode/scan.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ size_t detail::scan_for_text_ascii(string_view text, size_t maxColumnCount) noex
auto input = text.data();
auto const end = text.data() + min(text.size(), maxColumnCount);

#if defined(USE_INTRINSICS)
intrinsics::m128i const ControlCodeMax = intrinsics::set1_epi8(0x20); // 0..0x1F
intrinsics::m128i const Complex = intrinsics::set1_epi8(-128); // equals to 0x80 (0b1000'0000)

Expand All @@ -99,6 +100,7 @@ size_t detail::scan_for_text_ascii(string_view text, size_t maxColumnCount) noex
}
input += sizeof(intrinsics::m128i);
}
#endif

while (input != end && is_ascii(*input))
++input;
Expand Down

0 comments on commit ad31f78

Please sign in to comment.