x64_recomp: decode opcode 0x90 forms (X64-RECOMP-PRIMARY-90) #847

Merged
KernelSmoker merged 1 commit from upstream-pr/847 into main 2026-11-25 21:39:49 +00:00
KernelSmoker commented 2026-11-24 14:31:09 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by KernelSmoker on 2026-11-24T14:31:09Z.


Claimed in the coordination issue as: X64-RECOMP-PRIMARY-90 — https://github.com/ubiquitarianism/leonida/issues/14#issuecomment-7134430737

What and why

Opcode 0x90 was missing from the primary opcode table, so the decoder returned op_90 before its existing NOP/PAUSE/REX.B handling. Add the table entry and cover plain NOP, F3 90 PAUSE, and 41 90 XCHG r8,RAX. The REX.B form also needed a fixed RAX operand so the extension applies only to the opcode-embedded register.

Tested

  • python3 -I tests/test_x64_recomp.py: 33 tests run; 7 passed, 26 skipped because qemu-system-aarch64 is not installed.
  • python3 -I -m py_compile tools/x64_recomp.py tests/test_x64_recomp.py: passed.
  • git diff --check: passed.
  • Synthetic instruction bytes only; no game files used.

GPUs tested: n/a (CPU-only decoder tests)

AI-assisted: yes

<!-- greyfinch-sync:ubiquitarianism/leonida:issue:5474128171 --> Imported from [ubiquitarianism/leonida](https://github.com/ubiquitarianism/leonida/pull/847). Originally posted by [KernelSmoker](https://github.com/KernelSmoker) on 2026-11-24T14:31:09Z. --- Claimed in the coordination issue as: X64-RECOMP-PRIMARY-90 — https://github.com/ubiquitarianism/leonida/issues/14#issuecomment-7134430737 ### What and why Opcode `0x90` was missing from the primary opcode table, so the decoder returned `op_90` before its existing NOP/PAUSE/REX.B handling. Add the table entry and cover plain NOP, `F3 90` PAUSE, and `41 90` XCHG r8,RAX. The REX.B form also needed a fixed RAX operand so the extension applies only to the opcode-embedded register. ### Tested - `python3 -I tests/test_x64_recomp.py`: 33 tests run; 7 passed, 26 skipped because `qemu-system-aarch64` is not installed. - `python3 -I -m py_compile tools/x64_recomp.py tests/test_x64_recomp.py`: passed. - `git diff --check`: passed. - Synthetic instruction bytes only; no game files used. GPUs tested: n/a (CPU-only decoder tests) AI-assisted: yes
abnalstlll-byte commented 2026-11-24 14:32:59 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by abnalstlll-byte on 2026-11-24T14:32:59Z.

Review: APPROVED


Clean-Room Peer Review for PR #847 (tools/x64_recomp: add primary table entry for 0x90)

Fantastic follow-up and implementation:

  • Root Cause & Decoder Entry:
    • Setting PRIMARY[0x90] = ("nop", "") ensures decode_one() properly reaches the if op == 0x90: branch instead of early-exiting with an unknown op_90 instruction.
    • Correctly implements fixed RAX operand Rq for REX.B + 0x90 (xchg r8, rax), ensuring REX.B only extends the embedded register operand and leaves the implicit accumulator intact.
    • Resolves standalone nop (\x90), spinlock pause (\xf3\x90), and extended exchange (\x41\x90).
  • Unit Test Coverage:
    • tests/test_x64_recomp.py::test_opcode_90_nop_pause_and_rex_xchg cleanly verifies all three encodings.
  • Clean-room verification: Standard library only, LF line endings, 0 external dependencies.

LGTM! Verified and approved.

<!-- greyfinch-sync:ubiquitarianism/leonida:review:6041142709 --> Imported from [ubiquitarianism/leonida](https://github.com/ubiquitarianism/leonida/pull/847#pullrequestreview-6041142709). Originally posted by [abnalstlll-byte](https://github.com/abnalstlll-byte) on 2026-11-24T14:32:59Z. **Review:** APPROVED --- ### Clean-Room Peer Review for PR #847 (tools/x64_recomp: add primary table entry for 0x90) Fantastic follow-up and implementation: - **Root Cause & Decoder Entry**: - Setting `PRIMARY[0x90] = ("nop", "")` ensures `decode_one()` properly reaches the `if op == 0x90:` branch instead of early-exiting with an unknown `op_90` instruction. - Correctly implements fixed RAX operand `Rq` for `REX.B + 0x90` (`xchg r8, rax`), ensuring REX.B only extends the embedded register operand and leaves the implicit accumulator intact. - Resolves standalone `nop` (`\x90`), spinlock `pause` (`\xf3\x90`), and extended exchange (`\x41\x90`). - **Unit Test Coverage**: - `tests/test_x64_recomp.py::test_opcode_90_nop_pause_and_rex_xchg` cleanly verifies all three encodings. - **Clean-room verification**: Standard library only, LF line endings, 0 external dependencies. LGTM! Verified and approved.
abnalstlll-byte commented 2026-11-24 14:36:56 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by abnalstlll-byte on 2026-11-24T14:36:56Z.

Review: APPROVED


Clean-room verified (zero game data). Correct fix for x86-64 recomp opcode 0x90 forms: populates PRIMARY[0x90] so nop, pause, and rex.b xchg r8, rax are properly decoded rather than treated as unknown opcodes. Tests pass (tests/test_x64_recomp.py: 32 tests, 6 passed, 26 skipped on Windows).

<!-- greyfinch-sync:ubiquitarianism/leonida:review:6041225392 --> Imported from [ubiquitarianism/leonida](https://github.com/ubiquitarianism/leonida/pull/847#pullrequestreview-6041225392). Originally posted by [abnalstlll-byte](https://github.com/abnalstlll-byte) on 2026-11-24T14:36:56Z. **Review:** APPROVED --- Clean-room verified (zero game data). Correct fix for x86-64 recomp opcode 0x90 forms: populates PRIMARY[0x90] so nop, pause, and rex.b xchg r8, rax are properly decoded rather than treated as unknown opcodes. Tests pass (tests/test_x64_recomp.py: 32 tests, 6 passed, 26 skipped on Windows).
tiguan26 commented 2026-11-25 03:56:13 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by tiguan26 on 2026-11-25T03:56:13Z.

Review: APPROVED


Approving. Merged into current main with no conflicts; the PR's tests pass (Linux, Python 3.13). 0x90 needs to stay in the table to reach the NOP/PAUSE/XCHG special case, and with REX.B it is xchg r8, rax: the opcode register is extended by REX.B while the fixed accumulator is not, which the new R operand type models.

AI-assisted (Claude).

<!-- greyfinch-sync:ubiquitarianism/leonida:review:6051641458 --> Imported from [ubiquitarianism/leonida](https://github.com/ubiquitarianism/leonida/pull/847#pullrequestreview-6051641458). Originally posted by [tiguan26](https://github.com/tiguan26) on 2026-11-25T03:56:13Z. **Review:** APPROVED --- Approving. Merged into current main with no conflicts; the PR's tests pass (Linux, Python 3.13). 0x90 needs to stay in the table to reach the NOP/PAUSE/XCHG special case, and with REX.B it is xchg r8, rax: the opcode register is extended by REX.B while the fixed accumulator is not, which the new R operand type models. AI-assisted (Claude).
aslan2142 commented 2026-11-25 21:39:52 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by aslan2142 on 2026-11-25T21:39:52Z.


Merged, thanks! The new 0x90 forms decode as expected, and the new tests fail on main and pass with this.

  • Checked on main 24d8af66a + be7478f5b: the semantic suite passes (491 files, 6,312 tests, 0 files failed); test_x64_recomp pass; the 15 docs and writer tests pass; check_no_game_data.py is clean on the 2 changed files.

AI-assisted (Claude Code, Claude Opus 5.5).

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7175378220 --> Imported from [ubiquitarianism/leonida](https://github.com/ubiquitarianism/leonida/pull/847#issuecomment-7175378220). Originally posted by [aslan2142](https://github.com/aslan2142) on 2026-11-25T21:39:52Z. --- Merged, thanks! The new `0x90` forms decode as expected, and the new tests fail on `main` and pass with this. - **Checked on `main` `24d8af66a` + `be7478f5b`:** the semantic suite passes (491 files, 6,312 tests, 0 files failed); `test_x64_recomp` pass; the 15 docs and writer tests pass; `check_no_game_data.py` is clean on the 2 changed files. 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!847
No description provided.