From 6af5e42841f41e812c1eb8cd638b10bd006118f1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tam=C3=A1s=20T=C3=B3th?= Date: Mon, 27 May 2024 09:25:53 +0000 Subject: [PATCH] Add per-backend `md_selector` parameters to `booster_kompile` --- pyk/src/pyk/ktool/kompile.py | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/pyk/src/pyk/ktool/kompile.py b/pyk/src/pyk/ktool/kompile.py index 17c9b6d4bf8..2ad4957b2d5 100644 --- a/pyk/src/pyk/ktool/kompile.py +++ b/pyk/src/pyk/ktool/kompile.py @@ -124,13 +124,17 @@ def _booster_kompile( if llvm_kt and llvm_kt is not LLVMKompileType.C: raise ValueError(f'Unsupported argument value for Booster kompilation: llvm_kompile_type: {llvm_kt.value}') + llvm_md_selector, haskell_md_selector = _group_md_selector(**kwargs) + kwargs.pop('md_selector', None) llvm_args, haskell_args = _group_args(kwargs) llvm_args['backend'] = KompileBackend.LLVM llvm_args['llvm_kompile_type'] = LLVMKompileType.C + llvm_args['md_selector'] = llvm_md_selector llvm_kompile = LLVMKompile.from_dict(llvm_args) haskell_args['backend'] = KompileBackend.HASKELL + haskell_args['md_selector'] = haskell_md_selector haskell_kompile = HaskellKompile.from_dict(haskell_args) main_file = Path(kwargs['main_file']) @@ -176,6 +180,23 @@ def kompile_haskell() -> None: return output_dir +def _group_md_selector( + *, + md_selector: str | None = None, + llvm_md_selector: str | None = None, + haskell_md_selector: str | None = None, + **kwargs: Any, +) -> tuple[str | None, str | None]: + if md_selector: + if llvm_md_selector: + raise ValueError("Parameter llvm_md_selector should not be passed if md_selector is defined") + if haskell_md_selector: + raise ValueError("Parameter haskell_md_selector should not be passed if md_selector is defined") + return md_selector, md_selector + + return llvm_md_selector, haskell_md_selector + + def _group_args(args: Mapping[str, Any]) -> tuple[dict[str, Any], dict[str, Any]]: llvm_args = {} haskell_args = {}