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

Merged
Vonsek merged 2 commits from upstream-pr/326 into main 2026-11-22 03:52:59 +00:00
Vonsek commented 2026-11-21 22:16:44 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by Vonsek on 2026-11-21T22:16:44Z.


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
<!-- greyfinch-sync:R0Y00/Xbox2Windows:issue:6535112993 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/326). Originally posted by [Vonsek](https://github.com/Vonsek) on 2026-11-21T22:16:44Z. --- ## 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
upstream-sync closed this pull request 2026-11-24 06:42:26 +00:00
chatgpt-codex-connector[bot commented 2026-11-24 06:48:08 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by chatgpt-codex-connector[bot] on 2026-11-21T22:21:47Z.


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.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7070127499 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/326#issuecomment-7070127499). Originally posted by [chatgpt-codex-connector[bot]](https://github.com/chatgpt-codex-connector%5Bbot%5D) on 2026-11-21T22:21:47Z. --- <!-- 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>
R0Y00 commented 2026-11-24 06:48:20 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by R0Y00 on 2026-11-22T02:56:35Z.


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.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7073228506 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/326#issuecomment-7073228506). Originally posted by [R0Y00](https://github.com/R0Y00) on 2026-11-22T02:56:35Z. --- 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 commented 2026-11-24 06:48:20 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by R0Y00 on 2026-11-22T03:07:59Z.


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.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7073346022 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/326#issuecomment-7073346022). Originally posted by [R0Y00](https://github.com/R0Y00) on 2026-11-22T03:07:59Z. --- 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 commented 2026-11-24 06:48:22 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by R0Y00 on 2026-11-22T03:33:39Z.


#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.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7073618172 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/326#issuecomment-7073618172). Originally posted by [R0Y00](https://github.com/R0Y00) on 2026-11-22T03:33:39Z. --- #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 commented 2026-11-24 06:48:23 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by R0Y00 on 2026-11-22T03:49:21Z.


@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.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7073803658 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/326#issuecomment-7073803658). Originally posted by [R0Y00](https://github.com/R0Y00) on 2026-11-22T03:49:21Z. --- @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.
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
R0Y00/Xbox2Windows!321
No description provided.