diff options
author | Jussi Pakkanen <jpakkane@gmail.com> | 2017-02-18 01:40:37 +0200 |
---|---|---|
committer | Jussi Pakkanen <jpakkane@gmail.com> | 2017-07-17 19:06:16 +0300 |
commit | d304aac504af2c627ec2857cc2e86070de089851 (patch) | |
tree | c74f0e835f2eb76bb5ea2ce42014f0f90cfa4fdb /mesonbuild/modules/simd.py | |
parent | 57729e5a782e2bb745179926cfb487b6f417b98f (diff) | |
download | meson-d304aac504af2c627ec2857cc2e86070de089851.zip meson-d304aac504af2c627ec2857cc2e86070de089851.tar.gz meson-d304aac504af2c627ec2857cc2e86070de089851.tar.bz2 |
Created simd module.
Diffstat (limited to 'mesonbuild/modules/simd.py')
-rw-r--r-- | mesonbuild/modules/simd.py | 74 |
1 files changed, 74 insertions, 0 deletions
diff --git a/mesonbuild/modules/simd.py b/mesonbuild/modules/simd.py new file mode 100644 index 0000000..3a9fe59 --- /dev/null +++ b/mesonbuild/modules/simd.py @@ -0,0 +1,74 @@ +# 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, build, 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.Compiler): + raise mesonlib.MesonException('Compiler argument must be a compiler object.') + if 'configuration' not in kwargs: + raise mesonlib.MesonException('Must specify configuration object.') + conf = kwargs['configuration'].held_object + if not isinstance(conf, build.ConfigurationData): + raise mesonlib.MesonException('Configuration must be a configuration 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: + 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 + +def initialize(): + return SimdModule() |