diff options
author | Jussi Pakkanen <jpakkane@gmail.com> | 2017-07-19 15:50:04 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-07-19 15:50:04 +0300 |
commit | e89b6cdd1037d4c7cfdcb37555f2cbaf66f6ae05 (patch) | |
tree | e812ee63ecf54b37d17611e8514c5223ff058e47 /mesonbuild/modules | |
parent | acb7e3aaa0a006b36ad8fb86527e46c3b17ff70c (diff) | |
parent | c8981ff111ccb2419c8689dadc567760e0a20750 (diff) | |
download | meson-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/modules')
-rw-r--r-- | mesonbuild/modules/unstable_simd.py | 72 |
1 files changed, 72 insertions, 0 deletions
diff --git a/mesonbuild/modules/unstable_simd.py b/mesonbuild/modules/unstable_simd.py new file mode 100644 index 0000000..4aebc02 --- /dev/null +++ b/mesonbuild/modules/unstable_simd.py @@ -0,0 +1,72 @@ +# Copyright 2017 The Meson development team + +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at + +# http://www.apache.org/licenses/LICENSE-2.0 + +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +from .. import mesonlib, compilers, mlog + +from . import ExtensionModule + +class SimdModule(ExtensionModule): + + def __init__(self): + super().__init__() + self.snippets.add('check') + # FIXME add Altivec and AVX512. + self.isets = ('mmx', + 'sse', + 'sse2', + 'sse3', + 'ssse3', + 'sse41', + 'sse42', + 'avx', + 'avx2', + 'neon', + ) + + def check(self, interpreter, state, args, kwargs): + result = [] + if len(args) != 1: + raise mesonlib.MesonException('Check requires one argument, a name prefix for checks.') + prefix = args[0] + if not isinstance(prefix, str): + raise mesonlib.MesonException('Argument must be a string.') + if 'compiler' not in kwargs: + raise mesonlib.MesonException('Must specify compiler keyword') + compiler = kwargs['compiler'].compiler + if not isinstance(compiler, compilers.compilers.Compiler): + raise mesonlib.MesonException('Compiler argument must be a compiler object.') + cdata = interpreter.func_configuration_data(None, [], {}) + conf = cdata.held_object + for iset in self.isets: + if iset not in kwargs: + continue + iset_fname = kwargs[iset] # Migth also be an array or Files. static_library will validate. + args = compiler.get_instruction_set_args(iset) + if args is None: + mlog.log('Compiler supports %s:' % iset, mlog.red('NO')) + continue + if len(args) > 0: + if not compiler.has_multi_arguments(args, state.environment): + mlog.log('Compiler supports %s:' % iset, mlog.red('NO')) + continue + mlog.log('Compiler supports %s:' % iset, mlog.green('YES')) + conf.values['HAVE_' + iset.upper()] = ('1', 'Compiler supports %s.' % iset) + libname = prefix + '_' + iset + lib_kwargs = {'sources': iset_fname, + compiler.get_language() + '_args': args} + result.append(interpreter.func_static_lib(None, [libname], lib_kwargs)) + return [result, cdata] + +def initialize(): + return SimdModule() |