From fc23d9d0f207a5e7d68128db9741db1f7c4ba190 Mon Sep 17 00:00:00 2001 From: Jussi Pakkanen Date: Tue, 18 Jul 2017 21:53:24 +0300 Subject: Turned SIMD into an unstable module. --- mesonbuild/interpreter.py | 4 ++ mesonbuild/modules/simd.py | 72 ---------------------------------- mesonbuild/modules/unstable_simd.py | 72 ++++++++++++++++++++++++++++++++++ test cases/common/155 simd/meson.build | 2 +- 4 files changed, 77 insertions(+), 73 deletions(-) delete mode 100644 mesonbuild/modules/simd.py create mode 100644 mesonbuild/modules/unstable_simd.py diff --git a/mesonbuild/interpreter.py b/mesonbuild/interpreter.py index 43ddd72..359dd17 100644 --- a/mesonbuild/interpreter.py +++ b/mesonbuild/interpreter.py @@ -1490,6 +1490,10 @@ class Interpreter(InterpreterBase): if len(args) != 1: raise InvalidCode('Import takes one argument.') modname = args[0] + if modname.startswith('unstable-'): + plainname = modname.split('-', 1)[1] + mlog.warning('Module %s has no backwards or forwards compatibility and might not exist in future releases.' % modname) + modname = 'unstable_' + plainname if modname not in self.environment.coredata.modules: try: module = importlib.import_module('mesonbuild.modules.' + modname) diff --git a/mesonbuild/modules/simd.py b/mesonbuild/modules/simd.py deleted file mode 100644 index 12d9839..0000000 --- a/mesonbuild/modules/simd.py +++ /dev/null @@ -1,72 +0,0 @@ -# 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.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() diff --git a/mesonbuild/modules/unstable_simd.py b/mesonbuild/modules/unstable_simd.py new file mode 100644 index 0000000..12d9839 --- /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, 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.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() diff --git a/test cases/common/155 simd/meson.build b/test cases/common/155 simd/meson.build index d84b722..9da1651 100644 --- a/test cases/common/155 simd/meson.build +++ b/test cases/common/155 simd/meson.build @@ -1,6 +1,6 @@ project('simd', 'c') -simd = import('simd') +simd = import('unstable-simd') cc = meson.get_compiler('c') -- cgit v1.1