mirror of
https://github.com/ubiquitarianism/leonida.git
synced 2026-11-26 23:30:53 +01:00
[PR #1349] x64_recomp: add shld and shrd double-precision shift emitters #1379
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#1379
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/1349
Author: @IlyassRS3
Created: 11/24/2026
Status: 🔄 Open
Base:
main← Head:feat/x64-recomp-shld-shrd📝 Commits (1)
395103bx64_recomp: add shld and shrd double-precision shift emitters📊 Changes
2 files changed (+349 additions, -1 deletions)
View changed files
➕
tests/test_x64_recomp_shld_shrd.py(+253 -0)📝
tools/x64_recomp.py(+96 -1)📄 Description
Item ID:
X64-RECOMP-SHLD-SHRDSummary
Adds decoding, classification, and ARM64 code generation for x86-64 double-precision shifts
shld(0F A4imm8 /0F A5CL) andshrd(0F ACimm8 /0F ADCL) intools/x64_recomp.py:OFtable): adds0xA4(shld,Ev,Gv,Ib),0xA5(shld,Ev,Gv,CL),0xAC(shrd,Ev,Gv,Ib), and0xAD(shrd,Ev,Gv,CL).shld/shrdinFLAG_WRITERS("NZCVP") and classifies them asins.kind = "dshift"._emit_dshift):ctx.eflags).EXTR(extr(rd, src, dst, 32-c)/extr(rd, dst, src, c)withc &= 31orc &= 63).CLvariable counts: computes(dst << c) | ((src >> 1) >> (W - 1 - c))(and symmetric right shift) soc == 0/c == W - 1never produce an out-of-range shift width.0x66) operands: concatenates(dst << 16) | src(or(src << 16) | dstforshrd) in a 32-bit register and masks count& 31(matching Intel/AMD hardware behavior whencount == 16, wheredstbecomessrcandCFreceives bit 0 ofdstforshld/ bit 15 ofdstforshrd).SF,ZF,CF,OF,PF): computes the exact last-shifted-out bit intoCF(bitW - cforshld, bitc - 1forshrd),OF = old_sign ^ new_sign(for 1-bit shifts), updates live ARMNZCVandCTX_PF, and when flags are materialized writesctx.eflagspreservingAF.dst == src,dst == rcx, and[base+disp]memory operands, including 128-bit__shiftleft128/__shiftright128pairs).Tests (
tests/test_x64_recomp_shld_shrd.py)EXTRemission, and verifyingFLAG_WRITERS& classification).CL+ count==0 flag preservation, 16-bit imm &CLincludingcount == 16, and memory operands / register aliasing (dst == src,dst == rcx) / 128-bit__shiftleft128.Verification
python3 -I tests/test_x64_recomp_shld_shrd.py— 6 tests (3 static OK, 3 exec skipped without native runner)python3 -I tests/test_x64_recomp.py— OKpython3 -m compileall -q make_game.py tools tests— OKpython3 -I scripts/check_no_game_data.py tools/x64_recomp.py tests/test_x64_recomp_shld_shrd.py— OKpython3 -I tests/test_ci_registration.py— 15/15 OKpython3 -I tests/test_text_write_line_endings.py— 3/3 OKtools/x64_recomp.pytoupstream/mainfails all 3 static test methods (14 failures).x64_recompPRs, 0 conflicts):tests/test_x64_recomp_shld_shrd.py: 6/6 passed (0 skipped)x64_recomptest suites combined: 148/148 passed (0 skipped)AI-assisted: yes
🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.