mirror of
https://github.com/ubiquitarianism/leonida.git
synced 2026-11-27 00:20:53 +01:00
[PR #1211] x64_recomp: rcl and rcr rotate-through-carry emitters (X64-RECOMP-RCL-RCR) #1243
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#1243
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/1211
Author: @IlyassRS3
Created: 11/24/2026
Status: 🔄 Open
Base:
main← Head:feat/x64-recomp-rcl-rcr📝 Commits (1)
621aaeex64_recomp: rcl and rcr rotate-through-carry emitters (X64-RECOMP-RCL-RCR)📊 Changes
2 files changed (+360 additions, -1 deletions)
View changed files
➕
tests/test_x64_recomp_rcl_rcr.py(+238 -0)📝
tools/x64_recomp.py(+122 -1)📄 Description
Claimed in the coordination issue as: X64-RECOMP-RCL-RCR (https://github.com/ubiquitarianism/leonida/issues/14#issuecomment-7143389193)
What and why
Implements the
rclandrcrrotate-through-carry emitters called out in Next Step #2 ofdocs/mobile.mdinsidetools/x64_recomp.py(independent of#1174,#1202, and#1205, and conflict-free with all openx64_recompPRs):_emit_rcl_rcr): supports 8/16/32/64-bit registers (including high-byteah/ch/dh/bh), memory operands, immediate count1/imm8, and variableCLcounts (includingdst == rcx, e.g.,rcl ecx, cl).& 0x3Ffor 64-bit,& 0x1Ffor 8/16/32-bit) and reduces modulowidth + 1(% 9for 8-bit,% 17for 16-bit) without clobberingNZCVso effective count0leaves both destination and all flags untouched.(orig >> 1) >> (width - c)(rcl) and(orig << 1) << (width - c)(rcr) soc = 1andc = widthnever trigger arm64 shift-by-64 wraparound.CFfromSUB_KIND(inverted armC),ADD_KIND(armC),ucomis*/comis*(lt), or materializedCTX_EFLAGS; writes outgoingCFwithout clobberingN/Z/V, and updatesOF(V) when effective count is1(MSB(res) ^ new_CFforrcl,MSB(res) ^ MSB-1(res)forrcr).tests/test_x64_recomp_rcl_rcr.py): covers translation of all 27 forms plus 4 end-to-end execution test suites exercising 8/16/32/64-bitimm/CL, mod-9/mod-17 wrap, zero-count no-op, multi-word shift chaining,subborrow chaining, high-byteah, memory operands,rcl ecx, cl, and count-1OF.Tested
main:tests/test_x64_recomp_rcl_rcr.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.(width + 1)-bit rotation across all 7,168(width, value, cf, count)combinations: 100% match.#1174,#1202, and#1205in a scratch checkout):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 (76/76 total).git apply --check) against openx64_recompPRs#847,#950,#1120,#1121,#1174,#1202, and#1205.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.