de6e324bdseparate emu thread10d3daf86Roms List improvements95d202f37Let's make the rom list process on a separate thread so the emulator doesnt take ages to load.fc306967fWow the ROM Header was just completely busted. Game list view works nowbad1691eefuck this shit2b59e5f46game list in progressd26417b83remappable inputs in progressac4af8106inpute72abc240update readme430139dc9Qt6 frontend3080d4d45Fix this small bug too08cd13b85Cop0 unused functions do not actually pose a threat (as per manual). They don't do anything, so shall we.61bb4fb44make idle loop detection a little more specific with where the load goesb037de4c3SAZDFsdff12e81e73eneed to figure out why n64-systemtest loops indefinitely at some address that appears to be valid (i think it's me not invalidating the cache properly)204f0e13bidle skipping seems to work!cb8bb634asdkfjlasdf58e5c89c1Fix compilation issue on my machine (no idea)24fb2898eattempting more serious idle skipping214719577Place rsp.Step inside cached interpreter. Gains about 3 more fpsbb97dcc23mmmmm920b77d38wjkhasdfjhkasdf430ccdab4it's a start...4f42a673aCached interpreter plays Mario 64. Start looking into RSP as wellc9a030787idle skipping works!5fbda03cenew idea366637abaIdle skipping... maybe?609fa2fb0Cache instructions implemented but broken lmao. Commented out for nowe140a6d12- Stop using inheritance for CPU, instead use composition. - Introduce KAIZEN_JIT_ENABLED optional define instead of relying on __aarch64__ and the like. - More cache work68e613057prep cache impl811b4d809fix clang formatfda755f7didkd5024ebbfsmall MI refactor in preparation of (eventually) implementing the RDRAM interface properly694b45341Merge commit '206dcdedf195fb320913584180edb12c7731e396' as 'external/SDL'206dcdedfSquashed 'external/SDL/' content from commit 4d17b99d0a4d16e1cb4need to update sdl848b19920Fix compilation errordb61b5299Merge commit 'e94a94559f28e49678fbcf72199a5258137b0fe9' as 'external/imgui'e94a94559Squashed 'external/imgui/' content from commit 02e9b8cac52edb3757need to update imguic1a705e86Emulate weird JALR behaviour4b4c32f4bFix exception for "unusable COP1" in 4 instructions i missed accidentally (again)df5828142Bug putting 0s in the log everywheref8b580048Make isviewer a sink to file8241e9735Fix exception for "unusable COP1" in 4 instructions i missed accidentallyb29715f20small changesd9a620bc1make use of my new small utility library0d1aa938eAdd 'external/ircolib/' from commit 'ce3cd726c8df8388d554abf8bb55d55020eb4450'e64eb40b3Fuck git git-subtree-dir: external/ircolib git-subtree-split:de6e324bde
5.5 KiB
Refactor guide
This is a step by step overview how to refactor an architecture.
It can also be used to add a new architecture module. As long as it is supported by LLVM or a fork of it.
Please always contact us in the Auto-Sync tracking issue before working on a module. We can provide support and save you a lot of time.
Don't hesitate to ask any questions in our Telegram Community channel.
Especially if you feel stuck or struggle to understand where an issue is coming from. The update process is, although already simplified, relatively complex.
Refactoring
Note:
-
If we talk about C++ files in the steps below, we always refer to the files in the LLVM repo.
-
PrinterCapstoneis the class defined inllvm-capstone/llvm/utils/TabelGen/PrinterCapstone.cpp -
Always attempt to make the translated C file behave as closely as possible to the original C++ file! This greatly helps debugging and assures that Capstone behaves almost exactly the same as original LLVM.
-
Prepare
- Read
CONTRIBUTING.md - Read
docs/ARCHITECTURE.md - Read
suite/auto-sync/README.md - Read
suite/auto-sync/ARCHITECTURE.md - Read
suite/auto-sync/intro.md- Delete all files in
arch/<ARCH>/, except theARCHModule.*andARCHMapping.*. cd suite/auto-sync/
- Delete all files in
- Read
-
Generate
incfilespip install -e .- Clone and build
llvm-tblgen(see docs) - Quickly check options of the updater
ASUpdater -h- Add Arch name in
Target.py - In llvm-capstone handle arch in
PrinterCapstone.cpp::decoderEmitterEmitFieldFromInstruction()(add decoder function) - Generate:
ASUpdater -s IncGen -a ARCH- Errors? Check if the error message tells you what to do. If no hint exists, ask us.
- Check if
incfiles inbuildlook good.
- Add Arch name in
-
Translation and Patching
- Check for template functions in
<ARCH>InstPrinter.cppand<ARCH>Disassember.cpp - Copy new config in
arch_conf.json(LoongArch for a minimal example).- Don't forget to add
ARCHIntPrinter.cppto the list of theAddCSDetailtests!
- Don't forget to add
- Add as a minimum the
<ARCH>InstPrinter.cpp,<ARCH>InstPrinter.hand<ARCH>Disassembler.cppto the translation list.- Tip: The variables use in there are defined in
path_vars.json
- Tip: The variables use in there are defined in
- Add architecture specific includes in
Patches/Includes.py. Copy the code from another architecture for the beginning. - Prepare API header (
<arch>.h) for patching:- Check the generated
incfiles. Files names like<ARCH>GenCS<something>Enum.inccontain enumerations for the header. Those get patched into the main header file of the architecture. - Remove old values and add
// generated content <...> begincomments for patching. Checkoutlongarch.has example.
- Check the generated
- Commit all changes so far.
- The next step will write to the
arch/andinclude/capstone/<arch>.hheader!- Run generation, translation and copy/patch the files:
ASUpdater -a <ARCH> -w --copy-translated -s IncGen Translate PatchArchHeader
- Run generation, translation and copy/patch the files:
- Check for template functions in
-
Clean up
-
Check: All necessary files
- Arch header:
- Invalid characters in enum identifiers? Replace char in
PrinterCapstone::normalizedMnemonic
- Invalid characters in enum identifiers? Replace char in
- In
arch/<ARCH>- Missing identifier/symbols? -> Check if they are somewhere in the generated files. If yes, included them and update
Include.py. If not, you have to find the LLVM source file where they are defined and add it to thearch_config.jsonto translate it.- OR it needs the
SystemOperands.incfile. Also can be generated by adding the arch to the list ininc_gen.json.
- OR it needs the
- Missing identifier/symbols? -> Check if they are somewhere in the generated files. If yes, included them and update
- Note: When you start the next step, you likely don't want to generate, translate and copy files again. Because your had-made fixes get overwritten. So ensure you no longer use the
-wflag for theASUpdaterand you checked thoroughly that all necessary files got translated!
- Arch header:
- Commit to save changes so far.
-
Remove and fix C++ syntax
- Remove all obvious irrelevant C++ code from the translated files (e.g. class initializes)
- Double check non-obvious cases, if they are important. Rember: removing something might lead to bugs later!
- If in doubt, ask us.
- If you fix the same syntax over and over again, consider adding a Patch for the
CppTranslator. - Common problems:
- Missing namespace prefix
unsigned GR32Regs[]should beunsigned ARCH_GR32Regs[]. Seenamespace begin/endcomments in the code.
- Missing namespace prefix
- TODO: Add more.
- If in doubt, check the original C++ file in the LLVM repo.
-
-
Make it build
- Add
ARCHLinkage.hand the functions in theInstPrinter.c,ArchDisassembler.c. - Add essential code in
ARCHMapping.c. Esential is everything not releated to details. - If unsure how to do Capstone <-> LLVM code things, always check LoongArch. If LoongArch doesn't handle this case, check Mips, SystemZ
- Add
-
Run tests & Fixing bugs
- Update regression MC tests: Map LLVM
mattrandmcpunames to the CS identifiers if necessary. -> Edit themcupdater.jsonconfig file. - Update tests:
ASUpdater -s MCUpdate -a Arch -w- Run MC tests:
cstest tests/MC/Arch
- Run MC tests:
- Update regression MC tests: Map LLVM
-
Add details
- Effectively copy behavior from
LoongArchMapping.corSystemZMapping.cbut change values. - Changes to the API (structs in
arch.h) are only allowed if it was wrong before. Otherwise only extensions. - Don't forget to update the Python bindings.
- Run detail tests to check results.
- Run detail tests with coverage.
ArchMapping.cshould be covered near 100%
- Effectively copy behavior from