cpu_feature_scan: flag AVX-512VL regs, fix int/prefix parsing, and guard CLI --base/read errors (CPU-FEATURE-SCAN-CLASSIFY-AND-CLI) #1560

Merged
IlyassRS3 merged 1 commit from upstream-pr/1560 into main 2026-11-28 10:51:20 +00:00
IlyassRS3 commented 2026-11-25 04:36:43 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by IlyassRS3 on 2026-11-25T04:36:43Z.


Item ID: CPU-FEATURE-SCAN-CLASSIFY-AND-CLI (new item; coordination issue #14 is at GitHub's 2,500-comment cap with no open successor at PR time — confirmed 0 open PRs touch tools/cpu_feature_scan.py)

Summary

  • Flag AVX-512VL high vector registers (xmm16–xmm31, ymm16–ymm31): ZMM previously matched only zmm* and {k*}, misclassifying EVEX instructions using xmm16..31 / ymm16..31 (which #UD on Zen 2) as baseline AVX/AVX2 or VAES.
  • Fix int immediate matching: IMMEDIATE previously accepted only uppercase hex with optional h, causing lowercase (int 2ch, int 2dh) and 0x-prefixed (int 0x29, int 0x2c, int 0x2d, int 0x3) Windows-served interrupt vectors to be falsely flagged as kernel-call INT.
  • Fix prefix splitting and case sensitivity in classify(): splitting prefixes with ops.partition(" ") dropped the following mnemonic when separated by multiple spaces or a tab (e.g. lock + cmpxchg16b, rep + \tinsb), and uppercase mnemonics/registers bypassed classification.
  • Harden CLI --base and source reads in main(): reject negative --base values with a clean parser error (replacing <lambda>), and catch OSError from inline_scan.read_lines(args.source) cleanly with exit code 2 instead of a traceback.

Testing

  • AI-assisted: yes
  • GPUs tested: none (CPU/Python stdlib tool; no GPU, no game files)
  • python3 -W error -I tests/test_cpu_feature_scan.py -v: 26/26 passed
  • python3 -W error -I tests/test_text_write_line_endings.py -v: 3/3 passed
  • python3 -I scripts/check_no_game_data.py tools/cpu_feature_scan.py tests/test_cpu_feature_scan.py: passed
  • python3 -m compileall -q make_game.py tools tests: passed
  • Mutation check against unpatched main:tools/cpu_feature_scan.py: all 5 new/updated tests fail (FAILED (failures=5, errors=1)).
<!-- greyfinch-sync:ubiquitarianism/leonida:issue:5485257013 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/1560). Originally posted by [IlyassRS3](https://github.com/IlyassRS3) on 2026-11-25T04:36:43Z. --- Item ID: `CPU-FEATURE-SCAN-CLASSIFY-AND-CLI` (new item; coordination issue #14 is at GitHub's 2,500-comment cap with no open successor at PR time — confirmed 0 open PRs touch `tools/cpu_feature_scan.py`) ## Summary - **Flag AVX-512VL high vector registers (`xmm16`–`xmm31`, `ymm16`–`ymm31`)**: `ZMM` previously matched only `zmm*` and `{k*}`, misclassifying EVEX instructions using `xmm16..31` / `ymm16..31` (which `#UD` on Zen 2) as baseline `AVX`/`AVX2` or `VAES`. - **Fix `int` immediate matching**: `IMMEDIATE` previously accepted only uppercase hex with optional `h`, causing lowercase (`int 2ch`, `int 2dh`) and `0x`-prefixed (`int 0x29`, `int 0x2c`, `int 0x2d`, `int 0x3`) Windows-served interrupt vectors to be falsely flagged as kernel-call `INT`. - **Fix prefix splitting and case sensitivity in `classify()`**: splitting prefixes with `ops.partition(" ")` dropped the following mnemonic when separated by multiple spaces or a tab (e.g. `lock` + ` cmpxchg16b`, `rep` + `\tinsb`), and uppercase mnemonics/registers bypassed classification. - **Harden CLI `--base` and source reads in `main()`**: reject negative `--base` values with a clean parser error (replacing `<lambda>`), and catch `OSError` from `inline_scan.read_lines(args.source)` cleanly with exit code 2 instead of a traceback. ## Testing - AI-assisted: yes - GPUs tested: none (CPU/Python stdlib tool; no GPU, no game files) - `python3 -W error -I tests/test_cpu_feature_scan.py -v`: **26/26 passed** - `python3 -W error -I tests/test_text_write_line_endings.py -v`: **3/3 passed** - `python3 -I scripts/check_no_game_data.py tools/cpu_feature_scan.py tests/test_cpu_feature_scan.py`: passed - `python3 -m compileall -q make_game.py tools tests`: passed - Mutation check against unpatched `main:tools/cpu_feature_scan.py`: all 5 new/updated tests fail (`FAILED (failures=5, errors=1)`).
copilot-pull-request-reviewer[bot] commented 2026-11-25 04:36:53 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by copilot-pull-request-reviewer[bot] on 2026-11-25T04:36:53Z.

Review: COMMENTED


Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.

<!-- greyfinch-sync:ubiquitarianism/leonida:review:6051922651 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/1560#pullrequestreview-6051922651). Originally posted by [copilot-pull-request-reviewer[bot]](https://github.com/apps/copilot-pull-request-reviewer) on 2026-11-25T04:36:53Z. **Review:** COMMENTED --- Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.
MoonEyes commented 2026-11-28 10:51:12 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by MoonEyes on 2026-11-28T10:51:12Z.


Red/green: the PR's tests fail on main and pass with this PR (Linux, Python 3.13.18).
Targeted batch of 19 PRs (their tests, the tests importing the changed modules, the docs tests) on main 3ca0707: no new failure, Linux / Python 3.13.
AI-assisted (Claude Code, Claude Opus 5.5)

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7238164690 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/1560#issuecomment-7238164690). Originally posted by [MoonEyes](https://github.com/MoonEyes) on 2026-11-28T10:51:12Z. --- Red/green: the PR's tests fail on main and pass with this PR (Linux, Python 3.13.18). Targeted batch of 19 PRs (their tests, the tests importing the changed modules, the docs tests) on main 3ca0707: no new failure, Linux / Python 3.13. AI-assisted (Claude Code, Claude Opus 5.5)
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!1560
No description provided.