Merge pull request #718 from pcercuei/update-lightrec-20230224
[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
cb72ea13 20can also be added.
a59e5536 21
22* __Lazy compilation__.
23If Lightrec detects a block of code that would be very hard to
24compile properly (e.g. a branch with a branch in its delay slot),
25the block is marked as not compilable, and will always be emulated
26with the built-in interpreter. This allows to keep the code emitter
27simple and easy to understand.
28
29* __Run-time profiling__.
30The generated code will gather run-time information about the I/O access
31(whether they hit RAM, or hardware registers).
32The code generator will then use this information to generate direct
33read/writes to the emulated memories, instead of jumping to C for
34every call.
35
36* __Threaded compilation__.
37When entering a loading zone, where a lot of code has to be compiled,
38we don't want the compilation process to slow down the pace of emulation.
39To avoid that, the code compiler optionally runs on a thread, and the
40main loop will emulate the blocks that have not been compiled yet with
41the interpreter. This helps to drastically reduce the stutter that
42typically happens when a lot of new code is run.
43
44## Emulators
45
46Lightrec has been ported to the following emulators:
47
cb72ea13 48* [__PCSX-ReArmed__ (libretro)](https://github.com/libretro/pcsx_rearmed)
a59e5536 49
50* [__pcsx4all__ (my own fork)](https://github.com/pcercuei/pcsx4all)
51
ba3814c1
PC
52* [__Beetle__ (libretro)](https://github.com/libretro/beetle-psx-libretro/)
53
cb72ea13
PC
54* [__CubeSX/WiiSX__](https://github.com/emukidid/pcsxgc/)
55
ba3814c1 56[![Star History Chart](https://api.star-history.com/svg?repos=pcercuei/lightrec&type=Date)](https://star-history.com/#pcercuei/lightrec&Date)