|
36 | 36 | "_R", _schema.COFFRelocation, _schema.ELFRelocation, _schema.MachORelocation |
37 | 37 | ) |
38 | 38 |
|
39 | | -def _extract_jit_cases(generated_cases: str) -> list[tuple[str, str]]: |
40 | | - begin_case = re.compile(r"\s*/\* BEGIN_JIT_CASE (\w+) \*/\n") |
41 | | - cases_and_opnames: list[tuple[str, str]] = [] |
42 | | - current_opname: str | None = None |
43 | | - current_lines: list[str] = [] |
44 | | - for line in generated_cases.splitlines(keepends=True): |
45 | | - if current_opname is None: |
46 | | - match = begin_case.fullmatch(line) |
47 | | - if match is not None: |
48 | | - current_opname = match.group(1) |
49 | | - current_lines = [] |
50 | | - continue |
51 | | - if line.strip() == f"/* END_JIT_CASE {current_opname} */": |
52 | | - cases_and_opnames.append(("".join(current_lines), current_opname)) |
53 | | - current_opname = None |
54 | | - current_lines = [] |
55 | | - continue |
56 | | - current_lines.append(line) |
57 | | - if current_opname is not None: |
58 | | - raise RuntimeError(f"Unterminated JIT case block for {current_opname}") |
59 | | - return cases_and_opnames |
60 | | - |
61 | | - |
62 | 39 | @dataclasses.dataclass |
63 | 40 | class _Target(typing.Generic[_S, _R]): |
64 | 41 | triple: str |
@@ -217,7 +194,11 @@ async def _compile( |
217 | 194 |
|
218 | 195 | async def _build_stencils(self) -> dict[str, _stencils.StencilGroup]: |
219 | 196 | generated_cases = PYTHON_EXECUTOR_CASES_C_H.read_text() |
220 | | - cases_and_opnames = _extract_jit_cases(generated_cases) |
| 197 | + cases_and_opnames = sorted( |
| 198 | + re.findall( |
| 199 | + r"\n {8}(case (\w+): \{\n.*?\n {8}\})", generated_cases, flags=re.DOTALL |
| 200 | + ) |
| 201 | + ) |
221 | 202 | tasks = [] |
222 | 203 | with tempfile.TemporaryDirectory() as tempdir: |
223 | 204 | work = pathlib.Path(tempdir).resolve() |
|
0 commit comments