Actually mark scratch registers + comment out branches for now + rework compilation loop a bit

This commit is contained in:
irisz64
2025-07-07 15:54:04 +02:00
parent f91b0d0242
commit d072d37733
3 changed files with 114 additions and 199 deletions

View File

@@ -72,11 +72,9 @@ int JIT::Step() {
code.setProtectModeRW();
u32 instructionsInBlock = 0;
u32 instruction = 0;
bool instrEndsBlock = false;
bool instrInDelaySlot = false;
bool branchWasLikely = false;
bool blockEndsOnBranch = false;
code.sub(code.rsp, 8);
code.push(code.rbp);
@@ -84,7 +82,7 @@ int JIT::Step() {
//cs_insn *insn;
Util::trace("\tMIPS code (guest PC = 0x{:016X}):", blockPC);
while (!instrInDelaySlot) {
while (!instrEndsBlock) {
// CheckCompareInterrupt();
if (check_address_error(0b11, u64(blockPC))) [[unlikely]] {
@@ -104,7 +102,7 @@ int JIT::Step() {
static_cast<int>(Cop0::GetTLBExceptionCode(regs.cop0.tlbError, Cop0::LOAD)), static_cast<u64>(blockPC));
}
const u32 instruction = mem.Read<u32>(regs, paddr);
instruction = mem.Read<u32>(regs, paddr);
/*u32 bswapped = bswap(instruction);
auto count = cs_disasm(disassemblerMips, reinterpret_cast<const u8 *>(&bswapped), 4, blockPC, 0, &insn);
@@ -127,29 +125,19 @@ int JIT::Step() {
instructionsInBlock++;
Emit(instruction);
instrInDelaySlot = instrEndsBlock;
instrEndsBlock = InstrEndsBlock(instruction);
if (instrEndsBlock) {
branchWasLikely = IsBranchLikely(instruction);
}
if (instrInDelaySlot) {
blockEndsOnBranch = true;
}
if (instrInDelaySlot && branchWasLikely) {
branchWasLikely = false;
code.L(branch_likely_not_taken);
code.mov(code.rax, blockPC);
code.mov(REG(qword, pc), code.rax);
}
}
// emit code to store the value of pc
if (!blockEndsOnBranch) {
code.mov(code.rax, blockPC);
code.mov(REG(qword, pc), code.rax);
}
instruction = mem.Read<u32>(regs, paddr);
instrEndsBlock = InstrEndsBlock(instruction);
if(instrEndsBlock)
Util::panic("Branch in delay slot - YOU SHOULD KILL YOURSELF, NOW!!!");
blockOldPC = blockPC;
blockPC = blockNextPC;
blockNextPC += 4;
instructionsInBlock++;
Emit(instruction);
code.mov(code.rax, instructionsInBlock);
code.pop(code.rbp);