mirror of
https://github.com/hrydgard/ppsspp.git
synced 2026-10-01 14:58:14 +00:00
Add a codegen tool to generate a fast switch-tree interpreter dispatcher
MIPSTables.cpp has walked a tree of tables on every single interpreted instruction since forever, with a standing TODO asking for exactly this: "generate smart dispatcher functions from above tables instead of this slow method." GenerateInterpreterDispatch() does that - it walks the same tables MIPSGetInstruction() walks at runtime, but resolves the walk into a nested switch tree once, at generation time, with each leaf calling straight into the existing MIPSInt::Int_* handlers and returning that instruction's fixed cycle count. Anything not covered (invalid opcodes, and the handful of instructions with no interpreter implemented at all, e.g. tge/tlt/teq) falls back to the existing MIPSInterpret()/MIPSGetInstructionCycleEstimate() slow path, so the result is total over all 32-bit inputs, same as the table-walking path. Wired up via a new headless --generate-interpreter-dispatch flag, which prints the generated Core/MIPS/InterpreterDispatch.cpp source to stdout and exits. Also widens CmdLine.cpp's --help column formatting, which silently truncated any option name longer than 24 characters - the new option's name was the first to hit it. Co-Authored-By: Claude Sonnet 5 <[email protected]> Claude-Session: https://claude.ai/code/session_019SKhm9wKEQzRUsx9mTrrtQ
This commit is contained in:
1 parent
d718bda178
commit
65495c76c0
5 files changed
+162
-4
No files matched your search
@@ -54,6 +54,7 @@
|
||||
#include "Core/Core.h"
|
||||
#include "Core/CoreTiming.h"
|
||||
#include "Core/EmuThread.h"
|
||||
#include "Core/MIPS/MIPSTables.h"
|
||||
#include "Core/System.h"
|
||||
#include "Core/WebServer.h"
|
||||
#include "Core/HLE/sceUtility.h"
|
||||
@@ -550,6 +551,12 @@ int main(int argc, const char* argv[]) {
|
||||
break;
|
||||
}
|
||||
|
||||
if (cmdLineOptions.generateInterpreterDispatch.value_or(false)) {
|
||||
std::string code = GenerateInterpreterDispatch();
|
||||
fwrite(code.data(), 1, code.size(), stdout);
|
||||
return 0;
|
||||
}
|
||||
|
||||
// Needed before any sockets can be used (WSAStartup on Windows) - without this, the
|
||||
// WebSocket debugger silently fails to listen. Only done when requested since headless
|
||||
// otherwise has no use for networking.
|
||||
|
||||
Reference in new issue
Block a user