Repository navigation
jit: translate ADD/SUB (shifted register) second operand - #109
Open
bluetoe-99 wants to merge 2 commits into
Open
bluetoe-99 wants to merge 2 commits into
bluetoe-99 wants to merge 2 commits into
Conversation
bluetoe-99
force-pushed
the
feature/tier1-add-sub-shifted
branch
2 times, most recently
from
October 29, 2026 19:21
48edd76 to
9a7c193
Compare
The add/subtract (shifted register) encodings were rejected whenever the shift amount was non-zero, so ADD Xd, Xn, Xm, LSL #s - one of the most common address-arithmetic forms in real AArch64 code - never compiled, and shifted SUB, CMP and CMN failed the whole block too. Fold the shifted operand into a scratch copy of Rm (the idiom translate_and_reg uses) so the guest Rm mapping survives. For the rd == 31 flags-only case the arithmetic folds into Rn's host copy and its mapping is invalidated, the same clobber idiom the existing rd == rm subtraction collision uses. 32-bit W shifted operands (the shift macros do not perform 32-bit windowing) and ROR/reserved shift types stay cleanly rejected. Signed-off-by: bluetoe-99 <102478736+bluetoe-99@users.noreply.github.com>
Twelve engine-level tests: LSL/LSR/ASR shifted operands including LSL pound-emu#63, the rd == rm and rd == rn aliases, shifted CMP/CMN flag state, no-clobber sentinels proving the scratch folding leaves Rd, Rn and the stack pointer untouched, and two unshifted regressions. Signed-off-by: bluetoe-99 <102478736+bluetoe-99@users.noreply.github.com>
bluetoe-99
force-pushed
the
feature/tier1-add-sub-shifted
branch
from
October 29, 2026 19:46
9a7c193 to
5f93db4
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Tier 1 rejects every ADD/SUB (shifted register) encoding whose shift amount is non-zero ("does not support shift amounts != 0 yet"), so
ADD X8, X9, X10, LSL #4, and shiftedSUB,CMP,CMNtoo, never compile. These are some of the most common address-arithmetic forms in real AArch64 code.This translates the shifted operand for 64-bit (X) operands the way
translate_and_regalready does it: copyRminto a scratch register and fold the shift there, so the guestRmmapping survives. For therd == 31flags-only case the scratch holds the shifted operand, so the arithmetic folds intoRn's host copy and its mapping is invalidated. That is the same clobber trick the existingrd == rmsubtraction collision uses.Still cleanly rejected, unchanged: 32-bit (W) shifted operands (the shift macros do not do 32-bit windowing) and
RORor reserved shift types.Part of #76.
Verification
de07fcaa:465 | 38 failed | 28171 skipped | 6 errorsbecomes473 | 38 failed | 28163 skipped | 6 errors. The 38-failure and 6-error seed sets are byte-identical.test_bal_tier1_add_sub.c(12 tests): LSL/LSR/ASR, LSL [ENGINE] Make Debugging Guest Code Easier Without GDB #63,rd == rmandrd == rnaliases, shifted CMP/CMN flag state with no-clobber sentinels onRd,Rnand SP, and two unshifted regressions.