Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/3118"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Imported from ubiquitarianism/leonida. Originally posted by MoonEyes on 2026-12-02T11:45:49Z.
Claimed in the coordination issue as: X64-RECOMP-IN-IMM8, X64-RECOMP-SIMD-TABLE and X64-RECOMP-INSERTQ-IMM8 (the claims of the original author, https://github.com/ProjectLeonida/mandy/issues/14#issuecomment-7149745585, https://github.com/ProjectLeonida/mandy/issues/14#issuecomment-7149569635 and https://github.com/ProjectLeonida/mandy/issues/14#issuecomment-7144092346)
Depends on: #1120 (merged)
Depends on: #1121 (merged)
What and why
Carry of #1488, #1485 and #1246 (kett1m), all in conflict with
mainsincetests/test_x64_recomp.pychanged on both sides (the three PRs also conflict with each other there). #1485 says it depends on #1488, so one grouped pull request. This branch ismainmerged with the head of each PR, in the order #1488, #1485, #1246, so the authors' commits are kept (git merge-base --is-ancestorholds for all three heads). My only change is the three merges: in each one the conflict was the same block oftests/test_x64_recomp.py, and I kept main's tests and the PR's new tests side by side. No change totools/x64_recomp.pyordocs/mobile.mdbeyond the authors'.The changes themselves are the authors':
E4-E7(immediate-portin/out) took no operand byte and decoded one byte short; they now read their imm8 (EC-EFstay one byte). Thedocs/mobile.mdnote no longer quotes retail-image addresses (the maintainer's request on #1488, fixed in the author's last commit).0FSIMD opcode ranges skipped eight ModRM opcodes (7C/7D,D0,D7,E6,E7,F0,F7), which decoded as unknown and left the walk one byte early; they are now in the table.0F 78(insertq/extrq) reads two imm8 bytes, not one;tests/test_recomp_census.pygains the census checks.Tested
Windows 11, no GPU, no game files, on current
main(40ac04183) plus this branch:python -I tests/test_x64_recomp.py: 54 tests, OK (34 skipped: noqemu-system-aarch64).python -I tests/test_recomp_census.py: 15 tests, OK.tests/test_x64_recomp*.pyfile andtests/test_recomp_census.py, one by one withpython -I: 22 files, 22 OK.tools/x64_recomp.py:test_x64_recomp.py3 failures (test_in_out_immediate_port_consumes_imm8,test_simd_opcodes_outside_the_ranges_carry_modrm,test_sse4a_0f78_two_imm8),test_recomp_census.py2 failures (test_insertq_census_has_no_resync_garbage,test_insertq_fn1_decodes_to_end). The tool was restored afterwards and the tree is clean.python -I scripts/check_no_game_data.py docs/mobile.md tests/test_recomp_census.py tests/test_x64_recomp.py tools/x64_recomp.py: clean.GPUs tested: n/a (decoder unit tests only)
AI-assisted: yes. Author: Claude Opus (Claude Code). Reviewer: a separate read-only Claude Opus reviewer agent.
Checklist
mainand merges cleanly.docs/design.md. (n/a: x64 decoder fixes, no translator rule)Supersedes #1488, #1485 and #1246 once merged; the originals stay open until a maintainer decides.
Generated by Claude Code
Imported from ubiquitarianism/leonida. Originally posted by Kal0s-design on 2026-12-02T12:56:06Z.
Ran natively on Windows 11, Python 3.13, head
1ca3e4a98merged into currentmain(23a51c494), no conflicts.py -3.13 -I tests/test_x64_recomp.py: OK (skipped=34, noqemu-system-aarch64here).py -3.13 -I tests/test_recomp_census.py: OK.The body already shows red on main, so I checked the decoder lengths against an independent disassembler instead. Throwaway buffer: every
0F xxopcode (except the 38/3A escapes) with no prefix,66,F2andF3, each with five ModRM forms (register,[rax], SIB + disp8, RIP + disp32, disp32), plusE4..E7andEC..EFwith and without66. 5,076 encodings, each in its own 32-byte slot padded withnop. Lengths compared with GNU objdump 2.46 (-b binary -mi386:x86-64), only on encodings objdump does not print as(bad)(3,570 of them):All the opcodes this PR adds now match objdump on their valid forms:
66/F27C,7D,D0;D7,F7(MMX register form and66register form);E6with66,F2,F3;E7memory form;F2 F0memory form;66 0F 78 /0 ib ibandF2 0F 78 /r ib ib(6 bytes);E4..E7(2 bytes). The 10 encodings that drop out of the "different length" row are exactlyin/outimm8 and the two SSE4a register forms.The 85 left are not from this PR:
66 0F 80..8F(Jcc with an operand-size prefix): the decoder gives rel32 (7 bytes, Intel ignores66here in 64-bit mode), objdump gives rel16 (5 bytes, AMD behaviour). Compilers don't emit this.0F 78(VMREAD): the decoder still reads an imm8 there, so it comes out 1 byte too long (4 vs 3 for a register operand). The new comment says VMREAD keeps the entry; that entry isEv Ib. VMREAD is VMX-root only so it won't show up in game code, but the comment could say the length is wrong for it.Two small notes, neither blocking:
66 0F 78andF2 0F 78with a memory ModRM (mod != 3) are invalid (objdump prints(bad)), but the decoder accepts them as 8-byte instructions with two imm8. Only matters if the walk lands in data.0F A4/A5/AC/AD, i.e.shld/shrd(48 0F A4 C2 05decodes asop0f_a4, unknown). Those do show up in compiled x64 code (128-bit shifts), so they look like a good next table entry. Out of scope here.Not checked: the qemu-backed tests (no qemu here), VEX/EVEX and
0F 38/0F 3Amaps, real executables (no game files used).GPUs tested: n/a (CPU-only tests).
AI-assisted: yes (Claude Code).
Imported from ubiquitarianism/leonida. Originally posted by fiestorra on 2026-12-02T23:29:52Z.
VERIFY-3118 — Windows nativo:
red then greenen las tres piezas del decodificador1ca3e4a98— a merge of #1246 intocarry/x64:tools/x64_recomp.py(+6),tests/test_recomp_census.py(+39),tests/test_x64_recomp.py(+22/−1)Ran at the head
Negative control:
git apply -Rof the commit does not apply (the branch also carries a mergedmainon the same file), so I putmain's version oftools/x64_recomp.pyback and re-ran:Five bite, one per piece of the change.
What the change is, in three pieces:
7C/7D(haddp*/hsubp*),D0(addsubp*),D7(pmovmskb),E6(cvt*dq2pd/pd2dq),E7(movntdq),F0(lddqu),F7(maskmovdqu) — listed explicitly, with the reason in a comment.in/outwith an immediate port (E4–E7) now consume theirimm8— a one-byte omission that desynchronises everything after it.F2 0F 78 /r ib ib(insertq) and66 0F 78 /0 ib ib(extrq) read two imm8, not one — and the comment handles the collision: without a mandatory prefix0F 78is IntelVMREAD, which the decoder does not model, so it keeps the entry. That sentence is why the testtest_sse4a_0f78_two_imm8can exist at all.Why the census test is the interesting one:
test_insertq_census_has_no_resync_garbagedoes not check one instruction — it checks that the decoder did not desynchronise, which is what a wrong operand length does. That is the failure mode of a decoder, and it is tested as a property rather than an example.What I could not test
Written with an AI assistant.