shader_ir: preserve symbolic branch and call targets #3215

Merged
merzleckeier merged 1 commit from upstream-pr/3215 into main 2026-12-03 16:10:21 +00:00
merzleckeier commented 2026-12-02 19:43:34 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by merzleckeier on 2026-12-02T19:43:34Z.


Claimed as SHADER-IR-BRANCH-LABEL-MODIFIERS, following the parser finding.

What and why

shader_ir.parse_line() scans operand text for modifiers. On scalar branches and calls this can consume symbolic target text such as done, .done, glc, and vm. Keep that text in the operand list by skipping modifier extraction for those instructions. Numeric offsets still parse as immediates, and export instructions still parse done and vm as modifiers.

Tested

  • Four target subcases failed with the main parser (b41763227) and passed with the fix. Both parser test modules passed on Linux and with Windows CPython 3.12.10 under Wine 11.22 (44 tests each).
  • LLVM 23.1.5 llvm-mc -show-encoding accepted all four hand-written target forms and the export modifier control for gfx1030.
  • python -I scripts/run_semantic_tests.py tests/semantic -j 8 --timeout 300: 560 files, 6,791 tests, zero failed files.
  • git diff --check and the changed-file scripts/check_no_game_data.py scan passed.

GPUs tested: n/a (synthetic CPU-only parsing and translator tests).

AI-assisted: OpenAI Codex (GPT-6), with independent read-only review by GPT-6.2 Sol.

Checklist

  • Based on upstream main (b41763227).
  • One topic.
  • Synthetic fixtures only.
<!-- greyfinch-sync:ubiquitarianism/leonida:issue:5613476167 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/3215). Originally posted by [merzleckeier](https://github.com/merzleckeier) on 2026-12-02T19:43:34Z. --- Claimed as [SHADER-IR-BRANCH-LABEL-MODIFIERS](https://github.com/ProjectLeonida/mandy/issues/2570#issuecomment-7356505217), following the [parser finding](https://github.com/ProjectLeonida/mandy/issues/2570#issuecomment-7354047139). ### What and why `shader_ir.parse_line()` scans operand text for modifiers. On scalar branches and calls this can consume symbolic target text such as `done`, `.done`, `glc`, and `vm`. Keep that text in the operand list by skipping modifier extraction for those instructions. Numeric offsets still parse as immediates, and export instructions still parse `done` and `vm` as modifiers. ### Tested - Four target subcases failed with the `main` parser (`b41763227`) and passed with the fix. Both parser test modules passed on Linux and with Windows CPython 3.12.10 under Wine 11.22 (44 tests each). - LLVM 23.1.5 `llvm-mc -show-encoding` accepted all four hand-written target forms and the export modifier control for `gfx1030`. - `python -I scripts/run_semantic_tests.py tests/semantic -j 8 --timeout 300`: 560 files, 6,791 tests, zero failed files. - `git diff --check` and the changed-file `scripts/check_no_game_data.py` scan passed. GPUs tested: n/a (synthetic CPU-only parsing and translator tests). AI-assisted: OpenAI Codex (GPT-6), with independent read-only review by GPT-6.2 Sol. ### Checklist - [x] Based on upstream `main` (`b41763227`). - [x] One topic. - [x] Synthetic fixtures only.
fiestorra commented 2026-12-02 20:36:37 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by fiestorra on 2026-12-02T20:36:37Z.


VERIFY-3215 — Windows nativo, red then green (4 subcasos fallan sin el arreglo)

Head (this PR)
Merge base b41763227 = current main

Ran

python -I tests/test_shader_ir_parse.py       Ran 5 tests — OK

Negative control (tools/shader_ir.py reverted to main, the PR's tests kept):

FAIL: test_branch_and_call_targets_can_match_modifier_names    (x4 subtests)
Ran 5 tests — FAILED

The fix reads right and is scoped: if rest and op not in ("s_branch", "s_call_b64") and not op.startswith("s_cbranch_") — scalar branches and calls have no trailing modifiers, so a word such as done, glc or vm in the target position is the target, not a modifier. The second test the PR adds (test_export_still_parses_done_and_vm_modifiers) is the guard for the other side — the export syntax, where those same words are modifiers — and it passes on both main and this head, which is exactly what a guard should do.

What I could not test: a real shader corpus through shader_ir.py; the suite is unit-level (5 tests, no I/O). The four subcases are s_cbranch_scc1 done ; plain comment, s_branch .done, s_cbranch_execz glc and s_call_b64 s[0:1], vm.

Verdict: red then green on native Windows.

Written with an AI assistant.

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7358018761 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/3215#issuecomment-7358018761). Originally posted by [fiestorra](https://github.com/fiestorra) on 2026-12-02T20:36:37Z. --- ## VERIFY-3215 — Windows nativo, `red then green` (4 subcasos fallan sin el arreglo) | | | |---|---| | Head | `(this PR)` | | Merge base | `b41763227` = current `main` | **Ran** ``` python -I tests/test_shader_ir_parse.py Ran 5 tests — OK ``` **Negative control** (`tools/shader_ir.py` reverted to `main`, the PR's tests kept): ``` FAIL: test_branch_and_call_targets_can_match_modifier_names (x4 subtests) Ran 5 tests — FAILED ``` **The fix reads right and is scoped**: `if rest and op not in ("s_branch", "s_call_b64") and not op.startswith("s_cbranch_")` — scalar branches and calls have no trailing modifiers, so a word such as `done`, `glc` or `vm` in the target position is the target, not a modifier. The second test the PR adds (`test_export_still_parses_done_and_vm_modifiers`) is the guard for the other side — the export syntax, where those same words *are* modifiers — and it passes **on both `main` and this head**, which is exactly what a guard should do. **What I could not test**: a real shader corpus through `shader_ir.py`; the suite is unit-level (5 tests, no I/O). The four subcases are `s_cbranch_scc1 done ; plain comment`, `s_branch .done`, `s_cbranch_execz glc` and `s_call_b64 s[0:1], vm`. Verdict: **red then green** on native Windows. Written with an AI assistant.
lixonik commented 2026-12-02 22:47:51 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by lixonik on 2026-12-02T22:47:51Z.


Windows native verification (red -> green) -- PASS on head d0fc19927 (merged cleanly via git merge --no-ff onto main 16243cd6e).

Checks (Windows 10 x64, Python 3.12)

  • python -I scripts/check_no_game_data.py -> PASS
  • Green (python -I tests/test_shader_ir_parse.py -v on merged head d0fc19927): Ran 5 tests in 0.001s / OK
  • Red (reverted tools/shader_ir.py to main 16243cd6e, keeping the PR's tests/test_shader_ir_parse.py): Ran 5 tests in 0.002s / FAILED (failures=4)

AI-assisted: yes (Antigravity -- Gemini 4 Neon).

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7361173064 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/3215#issuecomment-7361173064). Originally posted by [lixonik](https://github.com/lixonik) on 2026-12-02T22:47:51Z. --- **Windows native verification (`red -> green`) -- PASS** on head `d0fc19927` (merged cleanly via `git merge --no-ff` onto `main` `16243cd6e`). ### Checks (Windows 10 x64, Python 3.12) - `python -I scripts/check_no_game_data.py` -> **PASS** - **Green** (`python -I tests/test_shader_ir_parse.py -v` on merged head `d0fc19927`): **Ran 5 tests in 0.001s / OK** - **Red** (reverted `tools/shader_ir.py` to `main` `16243cd6e`, keeping the PR's `tests/test_shader_ir_parse.py`): **Ran 5 tests in 0.002s / FAILED (failures=4)** AI-assisted: yes (Antigravity -- Gemini 4 Neon).
Sign in to join this conversation.
No reviewers
No labels
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Reference
ProjectLeonida/mandy!3215
No description provided.