cpu: lower CBW, CWDE, CDQE, CQO, MOVSX, and ADC instructions #326

Manually merged
github merged 2 commits from gh-pr/326/head into gh-pr/326/base 2026-11-26 21:43:11 +00:00
Owner

@⁠Vonsek on GitHub · 2026-11-21 22:16 UTC · original
Vonsek:ag/cpu-lower-sign-ext-adc → main · +260 −4 · 6 files · 2 commits · merged 2026-11-22 03:52 UTC

Change

  • Lower baseline x64 sign-extension (cbw, cwde, cdqe, cqo, movsx) and add-with-carry (adc) instructions in tools/ffx_version_query.py, preserving upper bits on 16-bit writes, zero-extending 32-bit writes, and propagating carry-in/carry-out and ZF on adc.
  • Add a source-built MASM fixture (tests/cpu/sign_ext_adc.asm, tests/cpu/sign_ext_adc.def) and differential test (tests/cpu/sign_ext_adc.py) wired into CMakeLists.txt as cpu_aot_sign_ext_adc, verifying all 11 exports against both the native DLL and a reference model.
  • Classify sign_ext_adc -> cpu_aot_sign_ext_adc in tools/form_coverage.py (+6 Integer mnemonics in docs/coverage/x64_zen2.tsv) and document the test in docs/experiments.md.

Verification

Tested on Windows 11 (VS 2022 Build Tools 17.14, MSVC 19.44, ML64 14.44, Windows SDK 10.0.26100, Python 3.12):

  • Before the change, cmake --build --preset dev --target cpu_sign_ext_adc_lifted failed with:
    ValueError: unsupported query operation at 0x1003: cbw
    
  • After the change:
    • cmake --build --preset dev --target cpu_sign_ext_adc_lifted succeeded.
    • ctest --preset dev --no-tests=error -R "^(cpu_aot_sign_ext_adc|cpu_aot_shift_count|cpu_aot_version_query|cpu_aot_address_size)$" -V: 4/4 passed (646 sign-extension and ADC cases (CBW, CWDE, CDQE, CQO, MOVSX, ADC) matched native and translated DLLs).
    • python -B tests/form_coverage_check.py: form coverage checks passed.

Evidence and follow-up

  • Adds six baseline x64 Integer mnemonics (adc, cbw, cdqe, cqo, cwde, movsx) to docs/coverage/x64_zen2.tsv coverage; all six are part of baseline x86-64 and require no optional CPUID feature gate.
  • All binaries are source-built via MASM and CMake; no game files or external dumps are included.

Checklist

  • Focused, single-purpose change
  • Source-built test that fails without the change and passes with it
  • Verified locally on Windows
**@⁠Vonsek** on GitHub · 2026-11-21 22:16 UTC · [original](https://github.com/R0Y00/Xbox2Windows/pull/326) `Vonsek:ag/cpu-lower-sign-ext-adc` → `main` · +260 −4 · 6 files · 2 commits · merged 2026-11-22 03:52 UTC ## Change - Lower baseline x64 sign-extension (`cbw`, `cwde`, `cdqe`, `cqo`, `movsx`) and add-with-carry (`adc`) instructions in `tools/ffx_version_query.py`, preserving upper bits on 16-bit writes, zero-extending 32-bit writes, and propagating carry-in/carry-out and ZF on `adc`. - Add a source-built MASM fixture (`tests/cpu/sign_ext_adc.asm`, `tests/cpu/sign_ext_adc.def`) and differential test (`tests/cpu/sign_ext_adc.py`) wired into `CMakeLists.txt` as `cpu_aot_sign_ext_adc`, verifying all 11 exports against both the native DLL and a reference model. - Classify `sign_ext_adc` -> `cpu_aot_sign_ext_adc` in `tools/form_coverage.py` (+6 Integer mnemonics in `docs/coverage/x64_zen2.tsv`) and document the test in `docs/experiments.md`. ## Verification Tested on Windows 11 (VS 2022 Build Tools 17.14, MSVC 19.44, ML64 14.44, Windows SDK 10.0.26100, Python 3.12): - Before the change, `cmake --build --preset dev --target cpu_sign_ext_adc_lifted` failed with: ```text ValueError: unsupported query operation at 0x1003: cbw ``` - After the change: - `cmake --build --preset dev --target cpu_sign_ext_adc_lifted` succeeded. - `ctest --preset dev --no-tests=error -R "^(cpu_aot_sign_ext_adc|cpu_aot_shift_count|cpu_aot_version_query|cpu_aot_address_size)$" -V`: 4/4 passed (`646 sign-extension and ADC cases (CBW, CWDE, CDQE, CQO, MOVSX, ADC) matched native and translated DLLs`). - `python -B tests/form_coverage_check.py`: `form coverage checks passed`. ## Evidence and follow-up - Adds six baseline x64 Integer mnemonics (`adc`, `cbw`, `cdqe`, `cqo`, `cwde`, `movsx`) to `docs/coverage/x64_zen2.tsv` coverage; all six are part of baseline x86-64 and require no optional CPUID feature gate. - All binaries are source-built via MASM and CMake; no game files or external dumps are included. ## Checklist - [x] Focused, single-purpose change - [x] Source-built test that fails without the change and passes with it - [x] Verified locally on Windows
Add lowering for baseline x64 sign-extension instructions (cbw, cwde,
cdqe, cqo, movsx) and add-with-carry (adc) in tools/ffx_version_query.py,
preserving upper bits on 16-bit writes, zero-extending 32-bit writes,
and propagating carry-in/carry-out and ZF on adc.

Add a source-built MASM differential fixture
(tests/cpu/sign_ext_adc.asm, tests/cpu/sign_ext_adc.def,
tests/cpu/sign_ext_adc.py) registered as cpu_aot_sign_ext_adc in
CMakeLists.txt, classified in tools/form_coverage.py, and documented in
docs/experiments.md.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 21:43:10 +00:00
github manually merged commit 2e7a3a95ed into gh-pr/326/base 2026-11-26 21:43:11 +00:00
Author
Owner

@⁠chatgpt-codex-connector[bot] on GitHub · 2026-11-21 22:21 UTC · original · edited 2026-11-21 22:24 UTC

Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-21T22:24:06.239359Z f3355b7 Draft marked ready
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@⁠codex review" or "@⁠codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

**@⁠chatgpt-codex-connector[bot]** on GitHub · 2026-11-21 22:21 UTC · [original](https://github.com/R0Y00/Xbox2Windows/pull/326#issuecomment-7070127499) · edited 2026-11-21 22:24 UTC <!-- codex-pull-request-review-summary --> <!-- codex-review-state:v1 {"code_review":{"commit_sha":"f3355b7b6937d431d8e6039715da56fe95d03db8","has_any_findings":false,"has_unresolved_findings":false,"status":"completed"},"security_review":{"commit_sha":null,"has_any_findings":null,"has_unresolved_findings":null,"status":null}} --> <details> <summary><strong>Codex Review Summary</strong>: ✅ Completed</summary> This comment shows the latest Codex review activity on this pull request. | Review | Status | Commit | Review trigger | | --- | --- | --- | --- | | 📝 **Code Review** | ✅ **Completed** <relative-time datetime="2026-11-21T22:24:06.239359Z">2026-11-21T22:24:06.239359Z</relative-time> | `f3355b7` | Draft marked ready | <details> <summary>ℹ️ About Codex in GitHub</summary> <br/> [Your team has set up Codex to review pull requests in this repo](https://chatgpt.com/codex/cloud/settings/general). Reviews are triggered when you - Open a pull request for review - Mark a draft as ready - Comment "@⁠codex review" or "@⁠codex security review". Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. </details> </details>
Author
Owner

@⁠R0Y00 on GitHub · 2026-11-22 02:56 UTC · original

A test merge of f9fdea0 against main conflicts in CMakeLists.txt, docs/experiments.md and tools/form_coverage.py. Keep the existing fixture registrations and add the sign-extension/ADC target and its coverage entry alongside them. Please refresh the branch and rerun the relevant fixture and Windows CI.

**@⁠R0Y00** on GitHub · 2026-11-22 02:56 UTC · [original](https://github.com/R0Y00/Xbox2Windows/pull/326#issuecomment-7073228506) A test merge of `f9fdea0` against main conflicts in `CMakeLists.txt`, `docs/experiments.md` and `tools/form_coverage.py`. Keep the existing fixture registrations and add the sign-extension/ADC target and its coverage entry alongside them. Please refresh the branch and rerun the relevant fixture and Windows CI.
Author
Owner

@⁠R0Y00 on GitHub · 2026-11-22 03:07 UTC · original

For your overlapping CPU and shader branches, please refresh only #326 first. Its last review identified conflicts in the CMake fixture list, coverage registration and experiment notes. I’ll review the reconciled commit and confirm which branch is next after it lands. Earlier rebase requests on your other branches can wait, including #169 and #303.

**@⁠R0Y00** on GitHub · 2026-11-22 03:07 UTC · [original](https://github.com/R0Y00/Xbox2Windows/pull/326#issuecomment-7073346022) For your overlapping CPU and shader branches, please refresh only #326 first. Its last review identified conflicts in the CMake fixture list, coverage registration and experiment notes. I’ll review the reconciled commit and confirm which branch is next after it lands. Earlier rebase requests on your other branches can wait, including #169 and #303.
Author
Owner

@⁠R0Y00 on GitHub · 2026-11-22 03:33 UTC · original

#425 and #430 have landed. #326 is still first in your queue. A trial merge against dec705f found one additional conflict in tools/ffx_version_query.py, alongside the CMake, coverage and experiment entries already discussed. Please refresh just this branch on current main and preserve the landed shared-lifter cases.

**@⁠R0Y00** on GitHub · 2026-11-22 03:33 UTC · [original](https://github.com/R0Y00/Xbox2Windows/pull/326#issuecomment-7073618172) #425 and #430 have landed. #326 is still first in your queue. A trial merge against `dec705f` found one additional conflict in `tools/ffx_version_query.py`, alongside the CMake, coverage and experiment entries already discussed. Please refresh just this branch on current main and preserve the landed shared-lifter cases.
Author
Owner

@⁠R0Y00 on GitHub · 2026-11-22 03:49 UTC · original

@⁠Vonsek, I reconciled the four conflicts on your branch using maintainer edits in 2e7a3a9. The first line of tests/cpu/sign_ext_adc.asm now reads ; coverage: source cpu_aot_sign_ext_adc, matching the original CTest registration. The PR no longer changes tools/form_coverage.py. On Windows x64, cpu_aot_sign_ext_adc and cpu_aot_rotates_shifts both passed, as did tests/form_coverage_check.py. I also checked this fixture’s classification for pass, fail, skip and absent test results. Your branch is updated; no further rebase is needed for this migration.

**@⁠R0Y00** on GitHub · 2026-11-22 03:49 UTC · [original](https://github.com/R0Y00/Xbox2Windows/pull/326#issuecomment-7073803658) @⁠Vonsek, I reconciled the four conflicts on your branch using maintainer edits in `2e7a3a9`. The first line of `tests/cpu/sign_ext_adc.asm` now reads `; coverage: source cpu_aot_sign_ext_adc`, matching the original CTest registration. The PR no longer changes `tools/form_coverage.py`. On Windows x64, `cpu_aot_sign_ext_adc` and `cpu_aot_rotates_shifts` both passed, as did `tests/form_coverage_check.py`. I also checked this fixture’s classification for pass, fail, skip and absent test results. Your branch is updated; no further rebase is needed for this migration.
This discussion has been locked. Commenting is limited to contributors.
No description provided.