mirror of
https://github.com/hedge-dev/XenonRecomp.git
synced 2025-07-22 21:17:14 +00:00
Add several config options for more efficient code generation.
This commit is contained in:
@@ -11,6 +11,14 @@ int main(int argc, char* argv[])
|
||||
if (strstr(argv[1], ".xex") != nullptr)
|
||||
{
|
||||
SWARecompiler recompiler;
|
||||
recompiler.config.skipLr = true;
|
||||
recompiler.config.ctrAsLocalVariable = true;
|
||||
recompiler.config.xerAsLocalVariable = true;
|
||||
recompiler.config.reservedRegisterAsLocalVariable = true;
|
||||
recompiler.config.skipMsr = true;
|
||||
recompiler.config.crRegistersAsLocalVariables = true;
|
||||
recompiler.config.nonArgumentRegistersAsLocalVariables = true;
|
||||
recompiler.config.nonVolatileRegistersAsLocalVariables = true;
|
||||
|
||||
std::println("Loading executable...");
|
||||
recompiler.LoadExecutable(argv[1]);
|
||||
|
File diff suppressed because it is too large
Load Diff
@@ -7,6 +7,33 @@ struct SwitchTable
|
||||
std::vector<size_t> labels;
|
||||
};
|
||||
|
||||
struct RecompilerLocalVariables
|
||||
{
|
||||
bool ctr{};
|
||||
bool xer{};
|
||||
bool reserved{};
|
||||
bool cr[8]{};
|
||||
bool r[32]{};
|
||||
bool f[32]{};
|
||||
bool v[128]{};
|
||||
bool env{};
|
||||
bool temp{};
|
||||
bool vTemp{};
|
||||
bool ea{};
|
||||
};
|
||||
|
||||
struct RecompilerConfig
|
||||
{
|
||||
bool skipLr = false;
|
||||
bool ctrAsLocalVariable = false;
|
||||
bool xerAsLocalVariable = false;
|
||||
bool reservedRegisterAsLocalVariable = false;
|
||||
bool skipMsr = false;
|
||||
bool crRegistersAsLocalVariables = false;
|
||||
bool nonArgumentRegistersAsLocalVariables = false;
|
||||
bool nonVolatileRegistersAsLocalVariables = false;
|
||||
};
|
||||
|
||||
struct Recompiler
|
||||
{
|
||||
Image image;
|
||||
@@ -15,8 +42,10 @@ struct Recompiler
|
||||
std::string out;
|
||||
size_t cppFileIndex = 0;
|
||||
std::vector<uint8_t> temp;
|
||||
std::string tempString;
|
||||
uint32_t setJmpAddress = 0;
|
||||
uint32_t longJmpAddress = 0;
|
||||
RecompilerConfig config;
|
||||
|
||||
void LoadSwitchTables(const char* filePath);
|
||||
void LoadExecutable(const char* filePath);
|
||||
@@ -34,7 +63,12 @@ struct Recompiler
|
||||
out += '\n';
|
||||
}
|
||||
|
||||
bool Recompile(const Function& fn, uint32_t base, const ppc_insn& insn, std::unordered_map<size_t, SwitchTable>::iterator& switchTable);
|
||||
bool Recompile(
|
||||
const Function& fn,
|
||||
uint32_t base,
|
||||
const ppc_insn& insn,
|
||||
std::unordered_map<size_t, SwitchTable>::iterator& switchTable,
|
||||
RecompilerLocalVariables& localVariables);
|
||||
|
||||
bool Recompile(const Function& fn);
|
||||
|
||||
|
@@ -45,6 +45,7 @@ void TestRecompiler::RecompileTests(const char* srcDirectoryPath, const char* ds
|
||||
auto stem = file.path().stem().string();
|
||||
recompiler.Analyse(stem);
|
||||
|
||||
recompiler.println("#define PPC_CONFIG_H_INCLUDED");
|
||||
recompiler.println("#include <ppc_context.h>\n");
|
||||
recompiler.println("#define __debugbreak()\n");
|
||||
|
||||
@@ -95,6 +96,7 @@ void TestRecompiler::RecompileTests(const char* srcDirectoryPath, const char* ds
|
||||
FILE* file = fopen(std::format("{}/main.cpp", dstDirectoryPath).c_str(), "w");
|
||||
std::string main;
|
||||
|
||||
std::println(file, "#define PPC_CONFIG_H_INCLUDED");
|
||||
std::println(file, "#include <ppc_context.h>");
|
||||
std::println(file, "#include <Windows.h>");
|
||||
std::println(file, "#include <print>\n");
|
||||
|
Reference in New Issue
Block a user