diff options
author | Nomura <nomura.rh@gmail.com> | 2023-04-26 21:29:59 +0200 |
---|---|---|
committer | Jussi Pakkanen <jpakkane@gmail.com> | 2023-05-06 19:57:06 +0300 |
commit | c1fce8f60f3cbbdf72fb3b987f1d07c86b292c82 (patch) | |
tree | 3914f5a723613bc1e6bf1e2631c1705c1870d586 | |
parent | 1958ded04f2f072571e86bbd5e805c06a4b89704 (diff) | |
download | meson-c1fce8f60f3cbbdf72fb3b987f1d07c86b292c82.tar.gz |
Initial support for Metrowerks Assembler
-rw-r--r-- | docs/markdown/Reference-tables.md | 2 | ||||
-rw-r--r-- | mesonbuild/compilers/asm.py | 46 | ||||
-rw-r--r-- | mesonbuild/compilers/detect.py | 12 | ||||
-rw-r--r-- | mesonbuild/compilers/mixins/metrowerks.py | 68 |
4 files changed, 127 insertions, 1 deletions
diff --git a/docs/markdown/Reference-tables.md b/docs/markdown/Reference-tables.md index fb7deda8a..7354cd4b5 100644 --- a/docs/markdown/Reference-tables.md +++ b/docs/markdown/Reference-tables.md @@ -44,6 +44,8 @@ These are return values of the `get_id` (Compiler family) and | yasm | The YASM compiler (Since 0.64.0) | | | ml | Microsoft Macro Assembler for x86 and x86_64 (Since 0.64.0) | msvc | | armasm | Microsoft Macro Assembler for ARM and AARCH64 (Since 0.64.0) | | +| mwasmarm | Metrowerks Assembler for Embedded ARM | | +| mwasmeppc | Metrowerks Assembler for Embedded PowerPC | | ## Linker ids diff --git a/mesonbuild/compilers/asm.py b/mesonbuild/compilers/asm.py index a156a17ba..17b11ba4c 100644 --- a/mesonbuild/compilers/asm.py +++ b/mesonbuild/compilers/asm.py @@ -3,6 +3,7 @@ import typing as T from ..mesonlib import EnvironmentException, OptionKey, get_meson_command from .compilers import Compiler +from .mixins.metrowerks import MetrowerksCompiler, mwasmarm_instruction_set_args, mwasmeppc_instruction_set_args if T.TYPE_CHECKING: from ..environment import Environment @@ -282,3 +283,48 @@ class MasmARMCompiler(Compiler): def depfile_for_object(self, objfile: str) -> T.Optional[str]: return None + + +class MetrowerksAsmCompiler(MetrowerksCompiler, Compiler): + language = 'nasm' + + def __init__(self, ccache: T.List[str], exelist: T.List[str], version: str, + for_machine: 'MachineChoice', info: 'MachineInfo', + linker: T.Optional['DynamicLinker'] = None, + full_version: T.Optional[str] = None, is_cross: bool = False): + Compiler.__init__(self, ccache, exelist, version, for_machine, info, linker, full_version, is_cross) + MetrowerksCompiler.__init__(self) + + self.warn_args = {'0': [], '1': [], '2': [], '3': [], 'everything': []} # type: T.Dict[str, T.List[str]] + self.can_compile_suffixes.add('s') + + def get_crt_compile_args(self, crt_val: str, buildtype: str) -> T.List[str]: + return [] + + def get_pic_args(self) -> T.List[str]: + return [] + + def needs_static_linker(self) -> bool: + return True + + +class MetrowerksAsmCompilerARM(MetrowerksAsmCompiler): + id = 'mwasmarm' + + def get_instruction_set_args(self, instruction_set: str) -> T.Optional[T.List[str]]: + return mwasmarm_instruction_set_args.get(instruction_set, None) + + def sanity_check(self, work_dir: str, environment: 'Environment') -> None: + if self.info.cpu_family not in {'arm'}: + raise EnvironmentException(f'ASM compiler {self.id!r} does not support {self.info.cpu_family} CPU family') + + +class MetrowerksAsmCompilerEmbeddedPowerPC(MetrowerksAsmCompiler): + id = 'mwasmeppc' + + def get_instruction_set_args(self, instruction_set: str) -> T.Optional[T.List[str]]: + return mwasmeppc_instruction_set_args.get(instruction_set, None) + + def sanity_check(self, work_dir: str, environment: 'Environment') -> None: + if self.info.cpu_family not in {'ppc'}: + raise EnvironmentException(f'ASM compiler {self.id!r} does not support {self.info.cpu_family} CPU family') diff --git a/mesonbuild/compilers/detect.py b/mesonbuild/compilers/detect.py index a700cfd60..1237cacb7 100644 --- a/mesonbuild/compilers/detect.py +++ b/mesonbuild/compilers/detect.py @@ -1216,7 +1216,7 @@ def detect_swift_compiler(env: 'Environment', for_machine: MachineChoice) -> Com raise EnvironmentException('Unknown compiler: ' + join_args(exelist)) def detect_nasm_compiler(env: 'Environment', for_machine: MachineChoice) -> Compiler: - from .asm import NasmCompiler, YasmCompiler + from .asm import NasmCompiler, YasmCompiler, MetrowerksAsmCompilerARM, MetrowerksAsmCompilerEmbeddedPowerPC compilers, _, _ = _get_compilers(env, 'nasm', for_machine) is_cross = env.is_cross_build(for_machine) @@ -1249,6 +1249,16 @@ def detect_nasm_compiler(env: 'Environment', for_machine: MachineChoice) -> Comp comp_class = YasmCompiler env.coredata.add_lang_args(comp_class.language, comp_class, for_machine, env) return comp_class([], comp, version, for_machine, info, cc.linker, is_cross=is_cross) + elif 'Metrowerks' in output or 'Freescale' in output: + if 'ARM' in output: + comp_class_mwasmarm = MetrowerksAsmCompilerARM + env.coredata.add_lang_args(comp_class_mwasmarm.language, comp_class_mwasmarm, for_machine, env) + return comp_class_mwasmarm([], comp, version, for_machine, info, cc.linker, is_cross=is_cross) + else: + comp_class_mwasmeppc = MetrowerksAsmCompilerEmbeddedPowerPC + env.coredata.add_lang_args(comp_class_mwasmeppc.language, comp_class_mwasmeppc, for_machine, env) + return comp_class_mwasmeppc([], comp, version, for_machine, info, cc.linker, is_cross=is_cross) + _handle_exceptions(popen_exceptions, compilers) raise EnvironmentException('Unreachable code (exception to make mypy happy)') diff --git a/mesonbuild/compilers/mixins/metrowerks.py b/mesonbuild/compilers/mixins/metrowerks.py index 89c612835..439014549 100644 --- a/mesonbuild/compilers/mixins/metrowerks.py +++ b/mesonbuild/compilers/mixins/metrowerks.py @@ -99,6 +99,74 @@ mwcceppc_instruction_set_args = { 'gekko': ['-proc', 'gekko'], } # type: T.Dict[str, T.List[str]] +mwasmarm_instruction_set_args = { + 'arm4': ['-proc', 'arm4'], + 'arm4t': ['-proc', 'arm4t'], + 'arm4xm': ['-proc', 'arm4xm'], + 'arm4txm': ['-proc', 'arm4txm'], + 'arm5': ['-proc', 'arm5'], + 'arm5T': ['-proc', 'arm5T'], + 'arm5xM': ['-proc', 'arm5xM'], + 'arm5TxM': ['-proc', 'arm5TxM'], + 'arm5TE': ['-proc', 'arm5TE'], + 'arm5TExP': ['-proc', 'arm5TExP'], + 'arm6': ['-proc', 'arm6'], + 'xscale': ['-proc', 'xscale'] +} # type: T.Dict[str, T.List[str]] + +mwasmeppc_instruction_set_args = { + '401': ['-proc', '401'], + '403': ['-proc', '403'], + '505': ['-proc', '505'], + '509': ['-proc', '509'], + '555': ['-proc', '555'], + '56X': ['-proc', '56X'], + '601': ['-proc', '601'], + '602': ['-proc', '602'], + '603': ['-proc', '603'], + '603e': ['-proc', '603e'], + '604': ['-proc', '604'], + '604e': ['-proc', '604e'], + '740': ['-proc', '740'], + '74X': ['-proc', '74X'], + '750': ['-proc', '750'], + '75X': ['-proc', '75X'], + '801': ['-proc', '801'], + '821': ['-proc', '821'], + '823': ['-proc', '823'], + '850': ['-proc', '850'], + '85X': ['-proc', '85X'], + '860': ['-proc', '860'], + '86X': ['-proc', '86X'], + '87X': ['-proc', '87X'], + '88X': ['-proc', '88X'], + '5100': ['-proc', '5100'], + '5200': ['-proc', '5200'], + '7400': ['-proc', '7400'], + '744X': ['-proc', '744X'], + '7450': ['-proc', '7450'], + '745X': ['-proc', '745X'], + '82XX': ['-proc', '82XX'], + '8240': ['-proc', '8240'], + '824X': ['-proc', '824X'], + '8260': ['-proc', '8260'], + '827X': ['-proc', '827X'], + '8280': ['-proc', '8280'], + 'e300': ['-proc', 'e300'], + 'e300c2': ['-proc', 'e300c2'], + 'e300c3': ['-proc', 'e300c3'], + 'e300c4': ['-proc', 'e300c4'], + 'e600': ['-proc', 'e600'], + '85xx': ['-proc', '85xx'], + 'e500': ['-proc', 'e500'], + 'e500v2': ['-proc', 'e500v2'], + 'Zen': ['-proc', 'Zen'], + '5565': ['-proc', '5565'], + '5674': ['-proc', '5674'], + 'gekko': ['-proc', 'gekko'], + 'generic': ['-proc', 'generic'], +} # type: T.Dict[str, T.List[str]] + mwcc_optimization_args = { 'plain': [], '0': ['-O0'], |