feat(ps5lift): add ps5lift, a static recompiler for PS5 executables #15806

Closed
oberonlift wants to merge 7 commits from upstream-pr/15806 into main
oberonlift commented 2026-11-04 16:24:15 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by oberonlift on 2026-11-04T16:24:15Z.


Merge after #15798 and #15805. Until they merge, this PR also shows #15797's and #15798's changes; oberonlift/AnyPS5#15 shows only its own.

ps5lift is a static recompiler for PS5 executables: it lifts a game's x86-64 code to LLVM IR and compiles it ahead of time to aarch64, which runs on Linux against AnyPS5's own libraries with no interpreter or JIT. It runs AnyPS5's PS5-style test programs and a homebrew media player to its home screen; commercial games are not playable yet. Branch ps5lift-preview merges all of its PRs (how to try it); native Apple Silicon support is coming along fast. It is a separate approach from the ARM64 compiler in #5021; #1835 has an introduction.

This is the lifter itself. It needs only its runtime, #15798, and #15805 for the convention check; a follow-up connects it to AnyPS5's libraries, which #15797 and #15799 to #15804 make build for a lifted program.

What

ps5lift lifts a PS5 executable's x86-64 code to LLVM IR and compiles it to native code, so the program runs on an aarch64 Linux host without an x86 emulator.

  • Lifter (ps5lift/lifter): reads the image with AnyPS5's ELF reader, finds the functions with Zydis from the entry point, exports, relocation targets and .eh_frame, recovers jump tables, lifts each function to an LLVM function over the guest register state and compiles the program in parts, a thread each. By default it keeps x86 memory ordering with acquire loads and release stores and reproduces x86's floating-point results bit for bit.
  • Jump tables: a guard compares at the guarded register's width, so a byte-indexed switch with more than 128 cases keeps its table.
  • Returns that move RSP: a return that leaves RSP elsewhere resumes the frame it reaches: callee-popped arguments, returning by a jump to the return address, and jumps into code on another frame, matched to a call by the stack slot the ret popped.
  • Tests: x86-64 test programs, from integer code to SSE4.1, AVX2, FMA, F16C, MMX, x87, setjmp, threads, callbacks and modules, are lifted at -O0 to -O3 and their output compared with the native programs'. Further tests check that the runtime is linked again after an interrupted build and that a runtime built for a CPU without SVE contains no SVE instructions. On a host other than Linux the tests only lift.
  • Tooling: tools/ps5lift.py runs the test programs, builds the runtime for the CPU the lifted code targets and times a memory benchmark natively and lifted.
  • CI: the workflow also builds ps5lift and runs its tests on GitHub's Linux arm64 runner.
  • Documents: docs/dev/PS5LIFT.md says how to build and use ps5lift, docs/dev/PS5LIFT_DESIGN.md describes its design and implementation, and its known gaps are a ps5lift section of the technical debt.
  • System LLVM: ps5lift builds against LLVM 18 or newer from the system (find_package(LLVM) in ps5lift/CMakeLists.txt). #15805 lets the convention check accept that; until it merges, this is the one line the check reports.

Tested

On a DGX Spark (aarch64 Linux, NVIDIA GB10, LLVM 18), built from current main with #15797, #15798 and this PR: all 55 tests pass. The convention check passes with #15805's script, and with main's reports only the LLVM line.

Checklist

  • Based on current main; no other open PR implements the same functions
  • One topic per PR; follow-ups go in a new PR
  • No comments in code except technical debt
  • Unimplemented paths throw (NotImplemented_nid_no_patch); silent stubs are listed under Silent stubs in their library's technical debt file
  • No notes, investigation .md files or images added to the repository (attach them to this PR)
  • New third-party code is a submodule built from source: Zydis; LLVM comes from the system (see System LLVM above)
  • Generic behaviour, not specific to one title
  • Depends on: #15805, #15798
  • Fixes: none
  • Unblocks: none
  • GPUs tested: n/a
  • AI-assisted: yes

🤖 Generated with Claude Code

<!-- greyfinch-sync:boykopovar/AnyPS5:issue:5157738963 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/15806). Originally posted by [oberonlift](https://github.com/oberonlift) on 2026-11-04T16:24:15Z. --- **Merge after #15798 and #15805.** Until they merge, this PR also shows #15797's and #15798's changes; oberonlift/AnyPS5#15 shows only its own. **ps5lift** is a static recompiler for PS5 executables: it lifts a game's x86-64 code to LLVM IR and compiles it ahead of time to aarch64, which runs on Linux against AnyPS5's own libraries with no interpreter or JIT. It runs AnyPS5's PS5-style test programs and a homebrew media player to its home screen; commercial games are not playable yet. Branch [`ps5lift-preview`](https://github.com/oberonlift/AnyPS5/tree/ps5lift-preview) merges all of its PRs ([how to try it](https://github.com/oberonlift/AnyPS5/blob/ps5lift-preview/PS5LIFT_PREVIEW.md)); native Apple Silicon support is coming along fast. It is a separate approach from the ARM64 compiler in #5021; #1835 has an introduction. This is the lifter itself. It needs only its runtime, #15798, and #15805 for the convention check; a follow-up connects it to AnyPS5's libraries, which #15797 and #15799 to #15804 make build for a lifted program. ### What ps5lift lifts a PS5 executable's x86-64 code to LLVM IR and compiles it to native code, so the program runs on an aarch64 Linux host without an x86 emulator. - **Lifter** (`ps5lift/lifter`): reads the image with AnyPS5's ELF reader, finds the functions with Zydis from the entry point, exports, relocation targets and `.eh_frame`, recovers jump tables, lifts each function to an LLVM function over the guest register state and compiles the program in parts, a thread each. By default it keeps x86 memory ordering with acquire loads and release stores and reproduces x86's floating-point results bit for bit. - **Jump tables**: a guard compares at the guarded register's width, so a byte-indexed switch with more than 128 cases keeps its table. - **Returns that move RSP**: a return that leaves RSP elsewhere resumes the frame it reaches: callee-popped arguments, returning by a jump to the return address, and jumps into code on another frame, matched to a call by the stack slot the `ret` popped. - **Tests**: x86-64 test programs, from integer code to SSE4.1, AVX2, FMA, F16C, MMX, x87, `setjmp`, threads, callbacks and modules, are lifted at -O0 to -O3 and their output compared with the native programs'. Further tests check that the runtime is linked again after an interrupted build and that a runtime built for a CPU without SVE contains no SVE instructions. On a host other than Linux the tests only lift. - **Tooling**: `tools/ps5lift.py` runs the test programs, builds the runtime for the CPU the lifted code targets and times a memory benchmark natively and lifted. - **CI**: the workflow also builds ps5lift and runs its tests on GitHub's Linux arm64 runner. - **Documents**: `docs/dev/PS5LIFT.md` says how to build and use ps5lift, `docs/dev/PS5LIFT_DESIGN.md` describes its design and implementation, and its known gaps are a ps5lift section of the technical debt. - **System LLVM**: ps5lift builds against LLVM 18 or newer from the system (`find_package(LLVM)` in `ps5lift/CMakeLists.txt`). #15805 lets the convention check accept that; until it merges, this is the one line the check reports. ### Tested On a DGX Spark (aarch64 Linux, NVIDIA GB10, LLVM 18), built from current `main` with #15797, #15798 and this PR: all 55 tests pass. The convention check passes with #15805's script, and with `main`'s reports only the LLVM line. ### Checklist - [x] Based on current `main`; no other open PR implements the same functions - [x] One topic per PR; follow-ups go in a new PR - [x] No comments in code except [technical debt](https://github.com/boykopovar/AnyPS5/blob/main/docs/dev/CONVENTIONS.md) - [x] Unimplemented paths throw (`NotImplemented_nid_no_patch`); silent stubs are listed under Silent stubs in their library's [technical debt](https://github.com/boykopovar/AnyPS5/tree/main/docs/dev/debt) file - [x] No notes, investigation `.md` files or images added to the repository (attach them to this PR) - [x] New third-party code is a submodule built from source: Zydis; LLVM comes from the system (see System LLVM above) - [x] Generic behaviour, not specific to one title - [x] Depends on: #15805, #15798 - [x] Fixes: none - [x] Unblocks: none - [x] GPUs tested: n/a - [x] AI-assisted: yes 🤖 Generated with [Claude Code](https://claude.com/claude-code)

Pull request closed

Sign in to join this conversation.
No reviewers
No labels
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Reference
boykopovar/AnyPS5!15806
No description provided.