aboutsummaryrefslogtreecommitdiff
path: root/mesonbuild/compilers
diff options
context:
space:
mode:
authorJussi Pakkanen <jpakkane@gmail.com>2017-07-19 15:50:04 +0300
committerGitHub <noreply@github.com>2017-07-19 15:50:04 +0300
commite89b6cdd1037d4c7cfdcb37555f2cbaf66f6ae05 (patch)
treee812ee63ecf54b37d17611e8514c5223ff058e47 /mesonbuild/compilers
parentacb7e3aaa0a006b36ad8fb86527e46c3b17ff70c (diff)
parentc8981ff111ccb2419c8689dadc567760e0a20750 (diff)
downloadmeson-e89b6cdd1037d4c7cfdcb37555f2cbaf66f6ae05.zip
meson-e89b6cdd1037d4c7cfdcb37555f2cbaf66f6ae05.tar.gz
meson-e89b6cdd1037d4c7cfdcb37555f2cbaf66f6ae05.tar.bz2
Merge pull request #1374 from mesonbuild/simd
Add support for SIMD detection
Diffstat (limited to 'mesonbuild/compilers')
-rw-r--r--mesonbuild/compilers/c.py17
-rw-r--r--mesonbuild/compilers/compilers.py52
-rw-r--r--mesonbuild/compilers/cpp.py4
3 files changed, 69 insertions, 4 deletions
diff --git a/mesonbuild/compilers/c.py b/mesonbuild/compilers/c.py
index cf9d1ee..593366a 100644
--- a/mesonbuild/compilers/c.py
+++ b/mesonbuild/compilers/c.py
@@ -25,6 +25,8 @@ from .compilers import (
msvc_buildtype_args,
msvc_buildtype_linker_args,
msvc_winlibs,
+ vs32_instruction_set_args,
+ vs64_instruction_set_args,
ClangCompiler,
Compiler,
CompilerArgs,
@@ -810,7 +812,7 @@ class VisualStudioCCompiler(CCompiler):
std_warn_args = ['/W3']
std_opt_args = ['/O2']
- def __init__(self, exelist, version, is_cross, exe_wrap):
+ def __init__(self, exelist, version, is_cross, exe_wrap, is_64):
CCompiler.__init__(self, exelist, version, is_cross, exe_wrap)
self.id = 'msvc'
# /showIncludes is needed for build dependency tracking in Ninja
@@ -820,6 +822,7 @@ class VisualStudioCCompiler(CCompiler):
'2': ['/W3'],
'3': ['/W4']}
self.base_options = ['b_pch'] # FIXME add lto, pgo and the like
+ self.is_64 = is_64
# Override CCompiler.get_always_args
def get_always_args(self):
@@ -1005,3 +1008,15 @@ class VisualStudioCCompiler(CCompiler):
if not isinstance(args, list):
args = [args]
return ['/WHOLEARCHIVE:' + x for x in args]
+
+ def get_instruction_set_args(self, instruction_set):
+ if self.is_64:
+ return vs64_instruction_set_args.get(instruction_set, None)
+ if self.version.split('.')[0] == '16' and instruction_set == 'avx':
+ # VS documentation says that this exists and should work, but
+ # it does not. The headers do not contain AVX intrinsics
+ # and the can not be called.
+ return None
+ return vs32_instruction_set_args.get(instruction_set, None)
+
+
diff --git a/mesonbuild/compilers/compilers.py b/mesonbuild/compilers/compilers.py
index a8ec5e3..0be3908 100644
--- a/mesonbuild/compilers/compilers.py
+++ b/mesonbuild/compilers/compilers.py
@@ -228,6 +228,43 @@ base_options = {'b_pch': coredata.UserBooleanOption('b_pch', 'Use precompiled he
True),
}
+gnulike_instruction_set_args = {'mmx': ['-mmmx'],
+ 'sse': ['-msse'],
+ 'sse2': ['-msse2'],
+ 'sse3': ['-msse3'],
+ 'ssse3': ['-mssse3'],
+ 'sse41': ['-msse4.1'],
+ 'sse42': ['-msse4.2'],
+ 'avx': ['-mavx'],
+ 'avx2': ['-mavx2'],
+ 'neon': ['-mfpu=neon'],
+ }
+
+vs32_instruction_set_args = {'mmx': ['/arch:SSE'], # There does not seem to be a flag just for MMX
+ 'sse': ['/arch:SSE'],
+ 'sse2': ['/arch:SSE2'],
+ 'sse3': ['/arch:AVX'], # VS leaped from SSE2 directly to AVX.
+ 'sse41': ['/arch:AVX'],
+ 'sse42': ['/arch:AVX'],
+ 'avx': ['/arch:AVX'],
+ 'avx2': ['/arch:AVX2'],
+ 'neon': None,
+}
+
+# The 64 bit compiler defaults to /arch:avx.
+vs64_instruction_set_args = {'mmx': ['/arch:AVX'],
+ 'sse': ['/arch:AVX'],
+ 'sse2': ['/arch:AVX'],
+ 'sse3': ['/arch:AVX'],
+ 'ssse3': ['/arch:AVX'],
+ 'sse41': ['/arch:AVX'],
+ 'sse42': ['/arch:AVX'],
+ 'avx': ['/arch:AVX'],
+ 'avx2': ['/arch:AVX2'],
+ 'neon': None,
+ }
+
+
def sanitizer_compile_args(value):
if value == 'none':
return []
@@ -755,6 +792,12 @@ class Compiler:
return []
raise EnvironmentException('Language %s does not support linking whole archives.' % self.get_display_language())
+ # Compiler arguments needed to enable the given instruction set.
+ # May be [] meaning nothing needed or None meaning the given set
+ # is not supported.
+ def get_instruction_set_args(self, instruction_set):
+ return None
+
def build_unix_rpath_args(self, build_dir, from_dir, rpath_paths, install_rpath):
if not rpath_paths and not install_rpath:
return []
@@ -933,6 +976,10 @@ class GnuCompiler:
return ['-mwindows']
return []
+ def get_instruction_set_args(self, instruction_set):
+ return gnulike_instruction_set_args.get(instruction_set, None)
+
+
class ClangCompiler:
def __init__(self, clang_type):
self.id = 'clang'
@@ -983,7 +1030,7 @@ class ClangCompiler:
def has_multi_arguments(self, args, env):
return super().has_multi_arguments(
- ['-Werror=unknown-warning-option'] + args,
+ ['-Werror=unknown-warning-option', '-Werror=unused-command-line-argument'] + args,
env)
def has_function(self, funcname, prefix, env, extra_args=None, dependencies=None):
@@ -1010,6 +1057,9 @@ class ClangCompiler:
return result
return ['-Wl,--whole-archive'] + args + ['-Wl,--no-whole-archive']
+ def get_instruction_set_args(self, instruction_set):
+ return gnulike_instruction_set_args.get(instruction_set, None)
+
# Tested on linux for ICC 14.0.3, 15.0.6, 16.0.4, 17.0.1
class IntelCompiler:
diff --git a/mesonbuild/compilers/cpp.py b/mesonbuild/compilers/cpp.py
index 01525b0..a8fc8a3 100644
--- a/mesonbuild/compilers/cpp.py
+++ b/mesonbuild/compilers/cpp.py
@@ -173,10 +173,10 @@ class IntelCPPCompiler(IntelCompiler, CPPCompiler):
class VisualStudioCPPCompiler(VisualStudioCCompiler, CPPCompiler):
- def __init__(self, exelist, version, is_cross, exe_wrap):
+ def __init__(self, exelist, version, is_cross, exe_wrap, is_64):
self.language = 'cpp'
CPPCompiler.__init__(self, exelist, version, is_cross, exe_wrap)
- VisualStudioCCompiler.__init__(self, exelist, version, is_cross, exe_wrap)
+ VisualStudioCCompiler.__init__(self, exelist, version, is_cross, exe_wrap, is_64)
self.base_options = ['b_pch'] # FIXME add lto, pgo and the like
def get_options(self):