mirror of
https://github.com/ubiquitarianism/leonida.git
synced 2026-11-26 23:55:52 +01:00
[PR #1213] x64_recomp: std/cld direction flag, reverse string ops, and lods emitter (X64-RECOMP-STD-STR) #1247
Labels
No labels
bug
pull-request
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
starred/leonida#1247
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
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?
📋 Pull Request Information
Original PR: https://github.com/ubiquitarianism/leonida/pull/1213
Author: @IlyassRS3
Created: 11/24/2026
Status: 🔄 Open
Base:
main← Head:feat/x64-recomp-std-str📝 Commits (1)
944e675x64_recomp: std/cld direction flag, reverse string ops, and lods emitter (X64-RECOMP-STD-STR)📊 Changes
2 files changed (+235 additions, -22 deletions)
View changed files
➕
tests/test_x64_recomp_std_str.py(+184 -0)📝
tools/x64_recomp.py(+51 -22)📄 Description
Claimed in the coordination issue as: X64-RECOMP-STD-STR (https://github.com/ubiquitarianism/leonida/issues/14#issuecomment-7143502030)
What and why
Completes the
std(DF=1) gap listed in Next Step #2 ofdocs/mobile.md(along with the missinglodsemitter and cross-blockscas/cmpsflag materialization) intools/x64_recomp.py(independent of#1174,#1202,#1205, and#1211, and 3-way-merges cleanly with all openx64_recompPRs):CTX_DF = 0x20):cldclearsctx.dfandstdsetsctx.df = 1without touchingNZCV;pushfincludes bit 10 (DF) andpopfrestoresctx.dffrom bit 10._str_step): computes+sz(whenDF=0) or-sz(whenDF=1) viasz - (df << sz.bit_length())in 3 instructions without modifyingNZCV, so live flags survive acrossstd,cld,movs,stos,lods, and zero-countrep scas/cmps.movs/stos/scas/cmpsand newlods: supportslodsb/lodsw/lodsd/lodsq(preserving upper bytes ofraxfor 8/16-bit and zero-extending for 32-bit) and overlapping backwardrep movs, backwardrep stos, backwardrepne scas, and backwardrepe cmps.scas/cmps: stashes the unshifted difference (_stash_res) and calls_maybe_mkflagswhen at least one iteration executes, so cross-blockjcc/setccafterscas/cmpssees up-to-dateCTX_EFLAGSwhilercx == 0stays a no-op.tests/test_x64_recomp_std_str.py): verifies translation plus 4 end-to-end execution suites covering overlapping backwardrep movsb, backwardrep stosd+ forward/backwardlodsb/lodsd, backwardrepne scasb/repe cmpsbwith cross-block flags,std; pushf; cld; popfDF round-trip, andNZCVpreservation.Tested
main:tests/test_x64_recomp_std_str.py,tests/test_ci_registration.py,tests/test_text_write_line_endings.py,compileall,make_game.py --help,check_no_game_data.py: all passed.#1174,#1202,#1205, and#1211in a scratch clone):tests/test_x64_recomp_std_str.py5/5 passed,tests/test_x64_recomp_rcl_rcr.py5/5 passed,tests/test_x64_recomp_bitops.py9/9 passed,tests/test_x64_recomp_sse.py16/16 passed,tests/test_x64_recomp.py46/46 passed (81/81 total).git apply --check) against openx64_recompPRs#847,#950,#1120,#1121, and clean 3-way merge with#1174,#1202,#1205, and#1211.GPUs tested: n/a (CPU x86-64 -> arm64 recompiler; tested natively on Apple M5 arm64, macOS 27.2.1)
AI-assisted: yes
Checklist
mainand merges cleanly (a conflicting pull request is labeledneeds rebase).docs/design.md, with how it was confirmed.🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.