psxmem: Add support for Lightrec's custom mem init sequence
[pcsx_rearmed.git] / deps / lightrec / README.md
CommitLineData
a59e5536 1
2# Lightrec
3
4Lightrec is a MIPS-to-everything dynamic recompiler for
5PlayStation emulators, using
6[GNU Lightning](https://www.gnu.org/software/lightning/)
7as the code emitter.
8
9As such, in theory it should be able to run on every CPU that Lightning
10can generate code for; including, but not limited to, __x86__, __x86_64__,
11__ARM__, __Aarch64__, __MIPS__, __PowerPC__ and __Risc-V__.
12
13## Features
14
15* __High-level optimizations__. The MIPS code is first pre-compiled into
16a form of Intermediate Representation (IR).
17Basically, just a single-linked list of structures representing the
18instructions. On that list, several optimization steps are performed:
19instructions are modified, reordered, tagged; new meta-instructions
20can be added, for instance to tell the code generator that a certain
21register won't be used anymore.
22
23* __Lazy compilation__.
24If Lightrec detects a block of code that would be very hard to
25compile properly (e.g. a branch with a branch in its delay slot),
26the block is marked as not compilable, and will always be emulated
27with the built-in interpreter. This allows to keep the code emitter
28simple and easy to understand.
29
30* __Run-time profiling__.
31The generated code will gather run-time information about the I/O access
32(whether they hit RAM, or hardware registers).
33The code generator will then use this information to generate direct
34read/writes to the emulated memories, instead of jumping to C for
35every call.
36
37* __Threaded compilation__.
38When entering a loading zone, where a lot of code has to be compiled,
39we don't want the compilation process to slow down the pace of emulation.
40To avoid that, the code compiler optionally runs on a thread, and the
41main loop will emulate the blocks that have not been compiled yet with
42the interpreter. This helps to drastically reduce the stutter that
43typically happens when a lot of new code is run.
44
45## Emulators
46
47Lightrec has been ported to the following emulators:
48
49* [__PCSX-ReArmed__ (my own fork)](https://github.com/pcercuei/pcsx_rearmed)
50
51* [__pcsx4all__ (my own fork)](https://github.com/pcercuei/pcsx4all)
52
53* [__Beetle__ (libretro)](https://github.com/libretro/beetle-psx-libretro/)