aboutsummaryrefslogtreecommitdiff
path: root/meson.build
diff options
context:
space:
mode:
Diffstat (limited to 'meson.build')
-rw-r--r--meson.build54
1 files changed, 33 insertions, 21 deletions
diff --git a/meson.build b/meson.build
index 97e00d6..54e6b09 100644
--- a/meson.build
+++ b/meson.build
@@ -336,15 +336,40 @@ if host_arch == 'i386' and not cc.links('''
qemu_common_flags = ['-march=i486'] + qemu_common_flags
endif
-# Assume x86-64-v2 (minus CMPXCHG16B for 32-bit code)
-if host_arch == 'i386'
- qemu_common_flags = ['-mfpmath=sse'] + qemu_common_flags
-endif
+# Pick x86-64 baseline version
if host_arch in ['i386', 'x86_64']
- qemu_common_flags = ['-mpopcnt', '-msse4.2'] + qemu_common_flags
-endif
-if host_arch == 'x86_64'
- qemu_common_flags = ['-mcx16'] + qemu_common_flags
+ if get_option('x86_version') == '0' and host_arch == 'x86_64'
+ error('x86_64-v1 required for x86-64 hosts')
+ endif
+
+ # add flags for individual instruction set extensions
+ if get_option('x86_version') >= '1'
+ if host_arch == 'i386'
+ qemu_common_flags = ['-mfpmath=sse'] + qemu_common_flags
+ else
+ # present on basically all processors but technically not part of
+ # x86-64-v1, so only include -mneeded for x86-64 version 2 and above
+ qemu_common_flags = ['-mcx16'] + qemu_common_flags
+ endif
+ endif
+ if get_option('x86_version') >= '2'
+ qemu_common_flags = ['-mpopcnt'] + qemu_common_flags
+ qemu_common_flags = cc.get_supported_arguments('-mneeded') + qemu_common_flags
+ endif
+ if get_option('x86_version') >= '3'
+ qemu_common_flags = ['-mmovbe', '-mabm', '-mbmi1', '-mbmi2', '-mfma', '-mf16c'] + qemu_common_flags
+ endif
+
+ # add required vector instruction set (each level implies those below)
+ if get_option('x86_version') == '1'
+ qemu_common_flags = ['-msse2'] + qemu_common_flags
+ elif get_option('x86_version') == '2'
+ qemu_common_flags = ['-msse4.2'] + qemu_common_flags
+ elif get_option('x86_version') == '3'
+ qemu_common_flags = ['-mavx2'] + qemu_common_flags
+ elif get_option('x86_version') == '4'
+ qemu_common_flags = ['-mavx512f', '-mavx512bw', '-mavx512cd', '-mavx512dq', '-mavx512vl'] + qemu_common_flags
+ endif
endif
if get_option('prefer_static')
@@ -2849,18 +2874,6 @@ config_host_data.set('CONFIG_AVX2_OPT', get_option('avx2') \
int main(int argc, char *argv[]) { return bar(argv[argc - 1]); }
'''), error_message: 'AVX2 not available').allowed())
-config_host_data.set('CONFIG_AVX512F_OPT', get_option('avx512f') \
- .require(have_cpuid_h, error_message: 'cpuid.h not available, cannot enable AVX512F') \
- .require(cc.links('''
- #include <cpuid.h>
- #include <immintrin.h>
- static int __attribute__((target("avx512f"))) bar(void *a) {
- __m512i x = *(__m512i *)a;
- return _mm512_test_epi64_mask(x, x);
- }
- int main(int argc, char *argv[]) { return bar(argv[argc - 1]); }
- '''), error_message: 'AVX512F not available').allowed())
-
config_host_data.set('CONFIG_AVX512BW_OPT', get_option('avx512bw') \
.require(have_cpuid_h, error_message: 'cpuid.h not available, cannot enable AVX512BW') \
.require(cc.links('''
@@ -4258,7 +4271,6 @@ summary_info += {'mutex debugging': get_option('debug_mutex')}
summary_info += {'memory allocator': get_option('malloc')}
summary_info += {'avx2 optimization': config_host_data.get('CONFIG_AVX2_OPT')}
summary_info += {'avx512bw optimization': config_host_data.get('CONFIG_AVX512BW_OPT')}
-summary_info += {'avx512f optimization': config_host_data.get('CONFIG_AVX512F_OPT')}
summary_info += {'gcov': get_option('b_coverage')}
summary_info += {'thread sanitizer': get_option('tsan')}
summary_info += {'CFI support': get_option('cfi')}