Skip to content

Commit

Permalink
reflex: Update to version 5.1.0
Browse files Browse the repository at this point in the history
  • Loading branch information
dnicolodi authored and neheb committed Dec 7, 2024
1 parent f01d8ba commit c8608c7
Show file tree
Hide file tree
Showing 5 changed files with 153 additions and 44 deletions.
1 change: 1 addition & 0 deletions releases.json
Original file line number Diff line number Diff line change
Expand Up @@ -3133,6 +3133,7 @@
"reflex"
],
"versions": [
"5.1.0-1",
"3.2.11-1",
"3.2.7-1",
"3.2.3-1",
Expand Down
172 changes: 144 additions & 28 deletions subprojects/packagefiles/reflex/meson.build
Original file line number Diff line number Diff line change
@@ -1,17 +1,24 @@
project('reflex', 'cpp',
version: '3.2.11',
license: 'BSD-3-Clause',
meson_version: '>=0.49.0')
project(
'reflex', 'cpp',
version: '5.1.0',
license: 'BSD-3-Clause',
meson_version: '>= 1.5.0',
default_options: {
'cpp_std': 'c++11',
}
)

includes = include_directories('include')

cpp = meson.get_compiler('cpp')
msvc = cpp.get_argument_syntax() == 'msvc'

flags = cpp.get_supported_arguments(['-Wno-non-virtual-dtor'])
add_project_arguments(flags, language : 'cpp')
add_project_arguments(flags, language: 'cpp')

unicode_sources = files(
'unicode/block_scripts.cpp',
'unicode/composer.cpp',
'unicode/language_scripts.cpp',
'unicode/letter_scripts.cpp',
)
Expand All @@ -24,6 +31,7 @@ libreflex_sources = files(
'lib/matcher.cpp',
'lib/pattern.cpp',
'lib/posix.cpp',
'lib/simd.cpp',
'lib/unicode.cpp',
'lib/utf8.cpp',
)
Expand All @@ -34,34 +42,142 @@ libreflexmin_sources = files(
'lib/input.cpp',
'lib/matcher.cpp',
'lib/pattern.cpp',
'lib/simd.cpp',
'lib/utf8.cpp',
)

#no dllexport being used here. Must use static library.
if cpp.get_argument_syntax() != 'msvc'
libreflexmin = library(
'reflexmin',
libreflexmin_sources,
include_directories : includes)

libreflex = library(
'reflex',
libreflex_sources, unicode_sources,
include_directories : includes)
have_simd_sse2 = cpp.compiles(
'''
#include <emmintrin.h>
int main(int argc, char** argv) {
__m128i n = _mm_set1_epi8(42);
}
''',
args: msvc ? '/arch:SSE2' : '-msse2',
name: 'cxx supports SSE2 intrinsics with options [\'-msse2\']',
required: get_option('sse2'),
)

have_simd_avx2 = cpp.compiles(
'''
#include <immintrin.h>
int main(int argc, char** argv) {
__m256i n = _mm256_set1_epi8(42);
(void)_mm256_movemask_epi8(_mm256_and_si256(n, n));
}
''',
args: msvc ? '/arch:AVX2' : '-mavx2',
name: 'cxx supports AVX2 intrinsics with options [\'-mavx2\']',
required: get_option('avx2'),
)

have_simd_avx512bw = cpp.compiles(
'''
#include <immintrin.h>
int main(int argc, char** argv) {
__m512i n = _mm512_set1_epi8(42);
(void)_mm512_cmpeq_epi8_mask(n, n);
}
''',
args: msvc ? '/arch:AVX512' : '-mavx512bw',
name: 'cxx supports AVX512BW intrinsics with options [\'-mavx512bw\']',
required: get_option('avx512bw'),
)

if have_simd_avx512bw
simd_args = [msvc ? '/arch:SSE2' : '-msse2']
simd_avx2_args = [msvc ? '/arch:AVX2' : '-mavx2']
simd_avx512bw_args = [msvc ? '/arch:AVX512' : '-mavx512bw']
add_project_arguments('-DHAVE_AVX512BW', language: 'cpp')
elif have_simd_avx2
simd_args = [msvc ? '/arch:SSE2' : '-msse2']
simd_avx2_args = [msvc ? '/arch:AVX2' : '-mavx2']
simd_avx512bw_args = []
add_project_arguments('-DHAVE_AVX2', language: 'cpp')
elif have_simd_sse2
simd_args = [msvc ? '/arch:SSE2' : '-msse2']
simd_avx2_args = []
simd_avx512bw_args = []
add_project_arguments('-DHAVE_SSE2', language: 'cpp')
else
libreflexmin = static_library(
'reflexmin',
libreflexmin_sources,
include_directories : includes)

libreflex = static_library(
'reflex',
libreflex_sources, unicode_sources,
include_directories : includes)
simd_args = []
simd_avx2_args = []
simd_avx512bw_args = []
endif

subdir('src')
foreach args : [[], ['-mfpu=neon'], ['-march=native', '-mfpu=neon']]
have_neon = cpp.compiles(
'''
#include <arm_neon.h>
int main(int argc, char** argv) {
uint64x2_t n;
uint64_t m = vgetq_lane_u64(n, 0);
}
''',
args: args,
name: 'cxx supports NEON intrinsics with options @0@'.format(args),
required: false,
)
if have_neon
simd_args = args
add_project_arguments('-DHAVE_NEON', language: 'cpp')
break
endif
endforeach

libsimd_avx2 = static_library(
'libsimd_avx2',
'lib/matcher_avx2.cpp',
'lib/simd_avx2.cpp',
cpp_args: simd_avx2_args,
include_directories: includes,
build_by_default: false,
)

libsimd_avx512bw = static_library(
'libsimd_avx512bw',
'lib/matcher_avx512bw.cpp',
'lib/simd_avx512bw.cpp',
cpp_args: simd_avx512bw_args,
include_directories: includes,
build_by_default: false,
)

# No DLLEXPORT declarations, thus only static library supported with MSVC
library = msvc ? 'static_library' : 'library'

libreflexmin = build_target(
'reflexmin',
libreflexmin_sources,
include_directories: includes,
cpp_args: simd_args,
# Selected based on a runtime AVX2 AVX512BW check
link_whole: [libsimd_avx2, libsimd_avx512bw],
target_type: library,
)

libreflex = build_target(
'reflex',
libreflex_sources, unicode_sources,
include_directories: includes,
cpp_args: simd_args,
# Selected based on a runtime AVX2 AVX512BW check
link_whole: [libsimd_avx2, libsimd_avx512bw],
target_type: library,
)

reflex = executable(
'reflex',
'src/reflex.cpp',
link_with: libreflex,
include_directories: includes,
install: true,
cpp_args: ['-DPLATFORM="@0@"'.format(host_machine.system())]
)

reflex_dep = declare_dependency(
link_with : libreflex,
include_directories : includes)
link_with: libreflex,
include_directories: includes
)

meson.override_find_program('reflex', reflex)
4 changes: 4 additions & 0 deletions subprojects/packagefiles/reflex/meson.options
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
option('sse2', type: 'feature', value: 'auto')
option('avx2', type: 'feature', value: 'auto')
option('avx512bw', type: 'feature', value: 'auto')
option('neon', type: 'feature', value: 'auto')
12 changes: 0 additions & 12 deletions subprojects/packagefiles/reflex/src/meson.build

This file was deleted.

8 changes: 4 additions & 4 deletions subprojects/reflex.wrap
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
[wrap-file]
directory = RE-flex-3.2.11
source_url = https://github.com/Genivia/RE-flex/archive/v3.2.11.tar.gz
source_filename = v3.2.11.tar.gz
source_hash = 45b1b7e6bc47f567a16ffec710dcbfd4e95f0f7a34c14472809ca2fcda0ce143
directory = RE-flex-5.1.0
source_url = https://github.com/Genivia/RE-flex/archive/refs/tags/v5.1.0.tar.gz
source_filename = v5.1.0.tar.gz
source_hash = 42bb511b6d7e12faf2972c4311534d3cca71cc84d2e9f3dd433e0eefb3b46fd1
patch_directory = reflex

[provide]
Expand Down

0 comments on commit c8608c7

Please sign in to comment.