mirror of
https://github.com/ran-j/PS2Recomp.git
synced 2026-09-26 08:51:05 -04:00
Feature/agressive recompiler (#146)
* feat: added guestBranchKind enum to categorize branch types feat: added missingFunctionPolicy enum to define behaviors for missing function scenarios refactor: added handle guest branches and report missing functions feat lookupFunction to utilize new dispatch logic and improve error handling for unregistered functions * fix: fix test conflict * feat: added debug sound driver logs * feat: emmiter for return * feat: added recompiler reporter feat: added strict diagnostics flag for heavy debug calls * feat: staticc table insted of hashmap for runtime * feat: back file to ignore * feat: explode code across helpers and classes * feat: update codegen test feat: better guest nop check * feat: fix link problem on linux * feat: fix Segmentation fault * feat: added recompile replace for DMA and MMIO feat: added a clean memory helpers feat: use memory helpers across the project feat: fix ucrt on msvc * feat: undo messup merge
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
#include "ps2recomp/Emitters/function_emitter.h"
|
||||
#include "ps2recomp/code_generator.h"
|
||||
#include "ps2recomp/gif_dma_kick_analyzer.h"
|
||||
#include "ps2recomp/instructions.h"
|
||||
#include "ps2recomp/r5900_decoder.h"
|
||||
#include "ps2recomp/recompiler_reporter.h"
|
||||
@@ -69,6 +70,8 @@ namespace ps2recomp
|
||||
}
|
||||
|
||||
const std::unordered_set<uint32_t> &internalTargets = analysisResult.entryPoints;
|
||||
ConstantRegisterState constantRegisters;
|
||||
GifDmaKickPlan gifDmaKickPlan{};
|
||||
ss << "// Function: " << function.name << "\n";
|
||||
ss << "// Address: 0x" << std::hex << function.start << " - 0x" << function.end << std::dec << "\n";
|
||||
|
||||
@@ -106,6 +109,7 @@ namespace ps2recomp
|
||||
|
||||
if (internalTargets.contains(inst.address))
|
||||
{
|
||||
constantRegisters.clear();
|
||||
ss << "label_" << std::hex << inst.address << std::dec << ":\n";
|
||||
}
|
||||
|
||||
@@ -145,24 +149,65 @@ namespace ps2recomp
|
||||
ss << "label_" << std::hex << delaySlot->address << std::dec << ":\n";
|
||||
}
|
||||
|
||||
ss << cg.handleBranchDelaySlots(inst, *delaySlot, function, analysisResult);
|
||||
if (gifDmaKickPlan.valid &&
|
||||
gifDmaKickPlan.completesInDelaySlot &&
|
||||
gifDmaKickPlan.branchIndex == i &&
|
||||
hasDecodedDelaySlot)
|
||||
{
|
||||
ss << cg.handleBranchDelaySlots(
|
||||
inst,
|
||||
*delaySlot,
|
||||
function,
|
||||
analysisResult,
|
||||
gifDmaDelaySlotOverride(*delaySlot, gifDmaKickPlan, cg.m_emitInstructionComments));
|
||||
gifDmaKickPlan = {};
|
||||
}
|
||||
else
|
||||
{
|
||||
ss << cg.handleBranchDelaySlots(inst, *delaySlot, function, analysisResult);
|
||||
}
|
||||
|
||||
if (hasDecodedDelaySlot)
|
||||
{
|
||||
++i; // Skip delay slot instruction (handled inside branch logic)
|
||||
}
|
||||
constantRegisters.clear();
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!gifDmaKickPlan.valid)
|
||||
{
|
||||
gifDmaKickPlan = tryBuildGifDmaKickPlan(instructions, i, constantRegisters, internalTargets);
|
||||
}
|
||||
|
||||
if (gifDmaKickPlan.suppresses(i))
|
||||
{
|
||||
const size_t slot = gifDmaKickPlan.slotFor(i);
|
||||
emitGifDmaCapture(ss, gifDmaKickPlan, slot, " ");
|
||||
|
||||
if (gifDmaKickPlan.completesAt(i))
|
||||
{
|
||||
ss << " ctx->pc = 0x" << std::hex << inst.address << "u;\n"
|
||||
<< std::dec;
|
||||
ss << " " << gifDmaKickCall(gifDmaKickPlan) << "\n";
|
||||
gifDmaKickPlan = {};
|
||||
}
|
||||
|
||||
updateConstantRegisters(inst, constantRegisters);
|
||||
continue;
|
||||
}
|
||||
|
||||
ss << " ctx->pc = 0x" << std::hex << inst.address << "u;\n"
|
||||
<< std::dec;
|
||||
|
||||
ss << " " << cg.translateInstruction(inst);
|
||||
const MemoryAccessHint memoryHint = resolveMemoryAccessHint(inst, constantRegisters);
|
||||
ss << " " << cg.translateInstruction(inst, memoryHint);
|
||||
if (inst.isMmio)
|
||||
{
|
||||
ss << " // MMIO: 0x" << std::hex << inst.mmioAddress << std::dec;
|
||||
}
|
||||
ss << "\n";
|
||||
|
||||
updateConstantRegisters(inst, constantRegisters);
|
||||
}
|
||||
}
|
||||
catch (const std::exception &e)
|
||||
|
||||
Reference in New Issue
Block a user