loader: emulate immediate SSE4a instructions on macOS #635
No reviewers
Labels
No labels
bug
documentation
duplicate
enhancement
GPU
GUI
help wanted
question
Shaders
Video
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/KytyPS5--KytyPS5!635
Loading…
Reference in a new issue
No description provided.
Delete branch "gh-pr/635/head"
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?
@carbonimax on GitHub · 2026-09-16 12:12 UTC · original
carbonimax:fix/macos-sse4a-exception→main· +283 −6 · 3 files · 2 commits · merged 2026-09-17 07:23 UTCOn macOS,
TryEmulate()always returned false, so an immediate SSE4a instruction such as66 0f 78 c2 28 00(EXTRQ xmm2, 40, 0) terminated the game with SIGILL under Rosetta even though its emulation already existed.Add access to Darwin's saved RIP and XMM registers and reuse the existing immediate EXTRQ/INSERTQ implementation. Other instruction emulation remains unchanged. This is separate from #467, which adds register-form SSE4a support.
Validation on Apple M4 Pro running the x86_64 build under Rosetta:
kyty_emulator,shader_cfg_tests, and the newmacos_sse4a_teststarget.shader_cfg, andmacos_sse4a.AI assistance: DeepSeek generated the implementation and regression tests; Codex reviewed the changes, requested test corrections, and ran local build, test, and game checks.
Summary by CodeRabbit
New Features
Tests
@coderabbitai[bot] on GitHub · 2026-09-16 12:12 UTC · original · edited 2026-09-17 07:13 UTC
📝 Walkthrough
Walkthrough
The emulator now supports Darwin saved contexts and Apple SSE4a emulation. A macOS test suite validates instruction handling and refusal paths. CMake builds and registers the test conditionally, then attaches it to
kyty_tests.Changes
macOS SSE4a emulation
src/loader/x64InstructionEmulator.cppucontext_taccess, XMM register mappings, instruction-pointer updates, Apple SSE4a support, and platform-specific instruction guards.tests/macosSse4aTests.cppEXTRQ,INSERTQ, high-register variants, unknown instructions, invalid contexts, exception handling, and refusal paths.CMakeLists.txtkyty_tests.Priority: ➖ Normal
Estimated code review effort: 3 (Moderate) | ~30 minutes
Change: Bug fix
Sequence Diagram(s)
Merge Risk: 🟠 High · up to
4d7a1Native arm64 macOS builds fail after this change, so the architecture guard or arm64 context implementation must be fixed before merging.
🚥 Pre-merge checks | ✅ 4 | ❌ 1
❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
Full details: Docstring Coverage
Explanation
Docstring coverage is 8.82% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 34 functions across 3 files. (1 skipped: 1 unsupported.)
✨ Finishing Touches
🧪 Generate unit tests (beta)
Comment
@coderabbitai helpto get the list of available commands.@coderabbitai[bot] on GitHub · 2026-09-17 07:13 UTC · original · reviewed
🤖 Prompt for all review comments with AI agents
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Advanced
Run ID:
a87a7a44-6046-4a16-8398-5881567370d0📥 Commits
Reviewing files that changed from the base of the PR and between
6bcc0e6a51and4d7a119a45.📒 Files selected for processing (3)
CMakeLists.txtsrc/loader/x64InstructionEmulator.cpptests/macosSse4aTests.cpp🚧 Files skipped from review as they are similar to previous changes (1)
Included review availability: Your plan provides up to 10 included reviews per hour; 9 remain after this review.