Repository navigation
cpu: lower XLATB in the shared lifter - #415
Merged
Merged
Conversation
Lower AL = [RBX + AL] with AL zero-extended, bits 8 to 63 of RAX and the flags unchanged. The 67h form uses EBX and wraps the sum at 32 bits; REX.W does not change the operation. tests/cpu/xlatb.asm builds four exports that run on a permutation table in a page below 4 GiB. The check compares RAX and ZF/CF for 21504 cases against the native DLL and a reference, and three mutated translations must mismatch. AI-assisted (Claude Code).
5 tasks done
5 tasks done
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.
Change
Advances CPU translation coverage. XLATB is an independent problem:
lower()rejects it today, and no open PR or issue claims it. I checked the diffs of the opencpu:PRs for the mnemonic. There is no prerequisite PR.The shared interface is
lower()intools/ffx_version_query.pyandCPU_FIXTURESintools/form_coverage.py. #287, #289, #291, #326, #328, #331, #335, #368, #379, #386, #403 and #412 also extend these. This change adds oneelifbranch afterM.CALL, at an anchor none of them uses.docs/experiments.md. Both add a paragraph after the address-size paragraph. I'll rebase whichever of the two lands second.Lowering.
xlatbloads AL from RBX + AL, with AL zero-extended. Bits 8 to 63 of RAX and the flags are unchanged.address()would add all of RAX, so the branch builds the address itself.48 d7decodes to the sameXLAT_M8and lowers the same way.Fixture
tests/cpu/xlatb.asmbuilds four exports:xlat_basic,xlat_rexw(db 48h),xlat_addr32(db 67h) andxlat_twice(two lookups in a row).emitasserts the number ofXLAT_M8instructions in each export and their base register (RBX, or EBX for the 67h form).Check.
tests/cpu/xlatb.py checkcommits a page below 4 GiB, fills it with0xccand places a 256-byte permutation table in the middle.Negative controls. Three translations of the same image are mutated after lowering, and each must mismatch. A control that faults counts as a mismatch: ctypes reports the access violation as
OSError.signednoaddr32clearOn
main,lower()rejectsd7 c3withunsupported query operation at 0x1000: xlatband67 d7 c3with... xlat byte ptr [ebx].Verification
Tested at
d8c6c25on6549244. Windows 11 build 26200, MSVC 19.50.35720, Windows SDK 10.0.26100.0, Python 3.13, AMD Ryzen 7 7700.ctest --preset dev --no-tests=error --output-junit <repo>/out/test-results.xmlgives 144 passed, 1 failed and 2 capability skips (bvh_wave64_warp,wave_shuffle_warp). The run includes the GPU tests. The failure isgpu_alias_lookup_writes_hardware, the RDNA 4 array-atomics probe recorded in gpu_alias_lookup_writes_hardware: array atomics probe reads 256 per buffer on RX 9070 XT #369 and docs: record the RDNA 4 array-atomics probe measurements #383, which fails the same way onmain. This change touches no GPU code.tests/form_coverage_check.pyandtests/docs_links_check.pypass.d8c6c25in the fork'sWindows checksrun 44968451823.Coverage.
python tools/form_coverage.py out/test-results.xmlgives x64 56 of 948 forms, 55 withoutcpu_aot_xlatb. The added form isxlatb.Evidence
The fixture is synthetic and original to this repository (MIT).
docs/experiments.mddocuments the lowering, the fixture and its controls.Checklist
AI-assisted (Claude Code).