PowerPC/MMU: Refactor to class, move to System.
This commit is contained in:
51 files changed
+1314
-1149
No files matched your search
@@ -64,8 +64,8 @@ void Interpreter::UpdatePC()
|
||||
m_ppc_state.pc = m_ppc_state.npc;
|
||||
}
|
||||
|
||||
Interpreter::Interpreter(Core::System& system, PowerPC::PowerPCState& ppc_state)
|
||||
: m_system(system), m_ppc_state(ppc_state)
|
||||
Interpreter::Interpreter(Core::System& system, PowerPC::PowerPCState& ppc_state, PowerPC::MMU& mmu)
|
||||
: m_system(system), m_ppc_state(ppc_state), m_mmu(mmu)
|
||||
{
|
||||
}
|
||||
|
||||
@@ -124,7 +124,7 @@ int Interpreter::SingleStepInner()
|
||||
}
|
||||
|
||||
m_ppc_state.npc = m_ppc_state.pc + sizeof(UGeckoInstruction);
|
||||
m_prev_inst.hex = PowerPC::Read_Opcode(m_ppc_state.pc);
|
||||
m_prev_inst.hex = m_mmu.Read_Opcode(m_ppc_state.pc);
|
||||
|
||||
const GekkoOPInfo* opinfo = PPCTables::GetOpInfo(m_prev_inst);
|
||||
|
||||
@@ -316,7 +316,7 @@ void Interpreter::unknown_instruction(Interpreter& interpreter, UGeckoInstructio
|
||||
Core::CPUThreadGuard guard(system);
|
||||
|
||||
const u32 last_pc = interpreter.m_last_pc;
|
||||
const u32 opcode = PowerPC::HostRead_U32(guard, last_pc);
|
||||
const u32 opcode = PowerPC::MMU::HostRead_U32(guard, last_pc);
|
||||
const std::string disasm = Common::GekkoDisassembler::Disassemble(opcode, last_pc);
|
||||
NOTICE_LOG_FMT(POWERPC, "Last PC = {:08x} : {}", last_pc, disasm);
|
||||
Dolphin_Debugger::PrintCallstack(system, guard, Common::Log::LogType::POWERPC,
|
||||
|
||||
@@ -15,13 +15,14 @@ class System;
|
||||
}
|
||||
namespace PowerPC
|
||||
{
|
||||
class MMU;
|
||||
struct PowerPCState;
|
||||
}
|
||||
} // namespace PowerPC
|
||||
|
||||
class Interpreter : public CPUCoreBase
|
||||
{
|
||||
public:
|
||||
Interpreter(Core::System& system, PowerPC::PowerPCState& ppc_state);
|
||||
Interpreter(Core::System& system, PowerPC::PowerPCState& ppc_state, PowerPC::MMU& mmu);
|
||||
Interpreter(const Interpreter&) = delete;
|
||||
Interpreter(Interpreter&&) = delete;
|
||||
Interpreter& operator=(const Interpreter&) = delete;
|
||||
@@ -312,6 +313,7 @@ private:
|
||||
|
||||
Core::System& m_system;
|
||||
PowerPC::PowerPCState& m_ppc_state;
|
||||
PowerPC::MMU& m_mmu;
|
||||
|
||||
UGeckoInstruction m_prev_inst{};
|
||||
u32 m_last_pc = 0;
|
||||
|
||||
@@ -41,7 +41,7 @@ static u32 Helper_Get_EA_UX(const PowerPC::PowerPCState& ppcs, const UGeckoInstr
|
||||
void Interpreter::lbz(Interpreter& interpreter, UGeckoInstruction inst)
|
||||
{
|
||||
auto& ppc_state = interpreter.m_ppc_state;
|
||||
const u32 temp = PowerPC::Read_U8(Helper_Get_EA(ppc_state, inst));
|
||||
const u32 temp = interpreter.m_mmu.Read_U8(Helper_Get_EA(ppc_state, inst));
|
||||
|
||||
if (!(ppc_state.Exceptions & EXCEPTION_DSI))
|
||||
ppc_state.gpr[inst.RD] = temp;
|
||||
@@ -51,7 +51,7 @@ void Interpreter::lbzu(Interpreter& interpreter, UGeckoInstruction inst)
|
||||
{
|
||||
auto& ppc_state = interpreter.m_ppc_state;
|
||||
const u32 address = Helper_Get_EA_U(ppc_state, inst);
|
||||
const u32 temp = PowerPC::Read_U8(address);
|
||||
const u32 temp = interpreter.m_mmu.Read_U8(address);
|
||||
|
||||
if (!(ppc_state.Exceptions & EXCEPTION_DSI))
|
||||
{
|
||||
@@ -71,7 +71,7 @@ void Interpreter::lfd(Interpreter& interpreter, UGeckoInstruction inst)
|
||||
return;
|
||||
}
|
||||
|
||||
const u64 temp = PowerPC::Read_U64(address);
|
||||
const u64 temp = interpreter.m_mmu.Read_U64(address);
|
||||
|
||||
if (!(ppc_state.Exceptions & EXCEPTION_DSI))
|
||||
ppc_state.ps[inst.FD].SetPS0(temp);
|
||||
@@ -88,7 +88,7 @@ void Interpreter::lfdu(Interpreter& interpreter, UGeckoInstruction inst)
|
||||
return;
|
||||
}
|
||||
|
||||
const u64 temp = PowerPC::Read_U64(address);
|
||||
const u64 temp = interpreter.m_mmu.Read_U64(address);
|
||||
|
||||
if (!(ppc_state.Exceptions & EXCEPTION_DSI))
|
||||
{
|
||||
@@ -108,7 +108,7 @@ void Interpreter::lfdux(Interpreter& interpreter, UGeckoInstruction inst)
|
||||
return;
|
||||
}
|
||||
|
||||
const u64 temp = PowerPC::Read_U64(address);
|
||||
const u64 temp = interpreter.m_mmu.Read_U64(address);
|
||||
|
||||
if (!(ppc_state.Exceptions & EXCEPTION_DSI))
|
||||
{
|
||||
@@ -128,7 +128,7 @@ void Interpreter::lfdx(Interpreter& interpreter, UGeckoInstruction inst)
|
||||
return;
|
||||
}
|
||||
|
||||
const u64 temp = PowerPC::Read_U64(address);
|
||||
const u64 temp = interpreter.m_mmu.Read_U64(address);
|
||||
|
||||
if (!(ppc_state.Exceptions & EXCEPTION_DSI))
|
||||
ppc_state.ps[inst.FD].SetPS0(temp);
|
||||
@@ -145,7 +145,7 @@ void Interpreter::lfs(Interpreter& interpreter, UGeckoInstruction inst)
|
||||
return;
|
||||
}
|
||||
|
||||
const u32 temp = PowerPC::Read_U32(address);
|
||||
const u32 temp = interpreter.m_mmu.Read_U32(address);
|
||||
|
||||
if (!(ppc_state.Exceptions & EXCEPTION_DSI))
|
||||
{
|
||||
@@ -165,7 +165,7 @@ void Interpreter::lfsu(Interpreter& interpreter, UGeckoInstruction inst)
|
||||
return;
|
||||
}
|
||||
|
||||
const u32 temp = PowerPC::Read_U32(address);
|
||||
const u32 temp = interpreter.m_mmu.Read_U32(address);
|
||||
|
||||
if (!(ppc_state.Exceptions & EXCEPTION_DSI))
|
||||
{
|
||||
@@ -186,7 +186,7 @@ void Interpreter::lfsux(Interpreter& interpreter, UGeckoInstruction inst)
|
||||
return;
|
||||
}
|
||||
|
||||
const u32 temp = PowerPC::Read_U32(address);
|
||||
const u32 temp = interpreter.m_mmu.Read_U32(address);
|
||||
|
||||
if (!(ppc_state.Exceptions & EXCEPTION_DSI))
|
||||
{
|
||||
@@ -207,7 +207,7 @@ void Interpreter::lfsx(Interpreter& interpreter, UGeckoInstruction inst)
|
||||
return;
|
||||
}
|
||||
|
||||
const u32 temp = PowerPC::Read_U32(address);
|
||||
const u32 temp = interpreter.m_mmu.Read_U32(address);
|
||||
|
||||
if (!(ppc_state.Exceptions & EXCEPTION_DSI))
|
||||
{
|
||||
@@ -219,7 +219,7 @@ void Interpreter::lfsx(Interpreter& interpreter, UGeckoInstruction inst)
|
||||
void Interpreter::lha(Interpreter& interpreter, UGeckoInstruction inst)
|
||||
{
|
||||
auto& ppc_state = interpreter.m_ppc_state;
|
||||
const u32 temp = u32(s32(s16(PowerPC::Read_U16(Helper_Get_EA(ppc_state, inst)))));
|
||||
const u32 temp = u32(s32(s16(interpreter.m_mmu.Read_U16(Helper_Get_EA(ppc_state, inst)))));
|
||||
|
||||
if (!(ppc_state.Exceptions & EXCEPTION_DSI))
|
||||
{
|
||||
@@ -231,7 +231,7 @@ void Interpreter::lhau(Interpreter& interpreter, UGeckoInstruction inst)
|
||||
{
|
||||
auto& ppc_state = interpreter.m_ppc_state;
|
||||
const u32 address = Helper_Get_EA_U(ppc_state, inst);
|
||||
const u32 temp = u32(s32(s16(PowerPC::Read_U16(address))));
|
||||
const u32 temp = u32(s32(s16(interpreter.m_mmu.Read_U16(address))));
|
||||
|
||||
if (!(ppc_state.Exceptions & EXCEPTION_DSI))
|
||||
{
|
||||
@@ -243,7 +243,7 @@ void Interpreter::lhau(Interpreter& interpreter, UGeckoInstruction inst)
|
||||
void Interpreter::lhz(Interpreter& interpreter, UGeckoInstruction inst)
|
||||
{
|
||||
auto& ppc_state = interpreter.m_ppc_state;
|
||||
const u32 temp = PowerPC::Read_U16(Helper_Get_EA(ppc_state, inst));
|
||||
const u32 temp = interpreter.m_mmu.Read_U16(Helper_Get_EA(ppc_state, inst));
|
||||
|
||||
if (!(ppc_state.Exceptions & EXCEPTION_DSI))
|
||||
{
|
||||
@@ -255,7 +255,7 @@ void Interpreter::lhzu(Interpreter& interpreter, UGeckoInstruction inst)
|
||||
{
|
||||
auto& ppc_state = interpreter.m_ppc_state;
|
||||
const u32 address = Helper_Get_EA_U(ppc_state, inst);
|
||||
const u32 temp = PowerPC::Read_U16(address);
|
||||
const u32 temp = interpreter.m_mmu.Read_U16(address);
|
||||
|
||||
if (!(ppc_state.Exceptions & EXCEPTION_DSI))
|
||||
{
|
||||
@@ -278,7 +278,7 @@ void Interpreter::lmw(Interpreter& interpreter, UGeckoInstruction inst)
|
||||
|
||||
for (u32 i = inst.RD; i <= 31; i++, address += 4)
|
||||
{
|
||||
const u32 temp_reg = PowerPC::Read_U32(address);
|
||||
const u32 temp_reg = interpreter.m_mmu.Read_U32(address);
|
||||
|
||||
if ((ppc_state.Exceptions & EXCEPTION_DSI) != 0)
|
||||
{
|
||||
@@ -307,7 +307,7 @@ void Interpreter::stmw(Interpreter& interpreter, UGeckoInstruction inst)
|
||||
|
||||
for (u32 i = inst.RS; i <= 31; i++, address += 4)
|
||||
{
|
||||
PowerPC::Write_U32(ppc_state.gpr[i], address);
|
||||
interpreter.m_mmu.Write_U32(ppc_state.gpr[i], address);
|
||||
if ((ppc_state.Exceptions & EXCEPTION_DSI) != 0)
|
||||
{
|
||||
PanicAlertFmt("DSI exception in stmw");
|
||||
@@ -321,7 +321,7 @@ void Interpreter::lwz(Interpreter& interpreter, UGeckoInstruction inst)
|
||||
{
|
||||
auto& ppc_state = interpreter.m_ppc_state;
|
||||
const u32 address = Helper_Get_EA(ppc_state, inst);
|
||||
const u32 temp = PowerPC::Read_U32(address);
|
||||
const u32 temp = interpreter.m_mmu.Read_U32(address);
|
||||
|
||||
if (!(ppc_state.Exceptions & EXCEPTION_DSI))
|
||||
{
|
||||
@@ -333,7 +333,7 @@ void Interpreter::lwzu(Interpreter& interpreter, UGeckoInstruction inst)
|
||||
{
|
||||
auto& ppc_state = interpreter.m_ppc_state;
|
||||
const u32 address = Helper_Get_EA_U(ppc_state, inst);
|
||||
const u32 temp = PowerPC::Read_U32(address);
|
||||
const u32 temp = interpreter.m_mmu.Read_U32(address);
|
||||
|
||||
if (!(ppc_state.Exceptions & EXCEPTION_DSI))
|
||||
{
|
||||
@@ -345,7 +345,7 @@ void Interpreter::lwzu(Interpreter& interpreter, UGeckoInstruction inst)
|
||||
void Interpreter::stb(Interpreter& interpreter, UGeckoInstruction inst)
|
||||
{
|
||||
auto& ppc_state = interpreter.m_ppc_state;
|
||||
PowerPC::Write_U8(ppc_state.gpr[inst.RS], Helper_Get_EA(ppc_state, inst));
|
||||
interpreter.m_mmu.Write_U8(ppc_state.gpr[inst.RS], Helper_Get_EA(ppc_state, inst));
|
||||
}
|
||||
|
||||
void Interpreter::stbu(Interpreter& interpreter, UGeckoInstruction inst)
|
||||
@@ -353,7 +353,7 @@ void Interpreter::stbu(Interpreter& interpreter, UGeckoInstruction inst)
|
||||
auto& ppc_state = interpreter.m_ppc_state;
|
||||
const u32 address = Helper_Get_EA_U(ppc_state, inst);
|
||||
|
||||
PowerPC::Write_U8(ppc_state.gpr[inst.RS], address);
|
||||
interpreter.m_mmu.Write_U8(ppc_state.gpr[inst.RS], address);
|
||||
if (!(ppc_state.Exceptions & EXCEPTION_DSI))
|
||||
{
|
||||
ppc_state.gpr[inst.RA] = address;
|
||||
@@ -371,7 +371,7 @@ void Interpreter::stfd(Interpreter& interpreter, UGeckoInstruction inst)
|
||||
return;
|
||||
}
|
||||
|
||||
PowerPC::Write_U64(ppc_state.ps[inst.FS].PS0AsU64(), address);
|
||||
interpreter.m_mmu.Write_U64(ppc_state.ps[inst.FS].PS0AsU64(), address);
|
||||
}
|
||||
|
||||
void Interpreter::stfdu(Interpreter& interpreter, UGeckoInstruction inst)
|
||||
@@ -385,7 +385,7 @@ void Interpreter::stfdu(Interpreter& interpreter, UGeckoInstruction inst)
|
||||
return;
|
||||
}
|
||||
|
||||
PowerPC::Write_U64(ppc_state.ps[inst.FS].PS0AsU64(), address);
|
||||
interpreter.m_mmu.Write_U64(ppc_state.ps[inst.FS].PS0AsU64(), address);
|
||||
if (!(ppc_state.Exceptions & EXCEPTION_DSI))
|
||||
{
|
||||
ppc_state.gpr[inst.RA] = address;
|
||||
@@ -403,7 +403,7 @@ void Interpreter::stfs(Interpreter& interpreter, UGeckoInstruction inst)
|
||||
return;
|
||||
}
|
||||
|
||||
PowerPC::Write_U32(ConvertToSingle(ppc_state.ps[inst.FS].PS0AsU64()), address);
|
||||
interpreter.m_mmu.Write_U32(ConvertToSingle(ppc_state.ps[inst.FS].PS0AsU64()), address);
|
||||
}
|
||||
|
||||
void Interpreter::stfsu(Interpreter& interpreter, UGeckoInstruction inst)
|
||||
@@ -417,7 +417,7 @@ void Interpreter::stfsu(Interpreter& interpreter, UGeckoInstruction inst)
|
||||
return;
|
||||
}
|
||||
|
||||
PowerPC::Write_U32(ConvertToSingle(ppc_state.ps[inst.FS].PS0AsU64()), address);
|
||||
interpreter.m_mmu.Write_U32(ConvertToSingle(ppc_state.ps[inst.FS].PS0AsU64()), address);
|
||||
if (!(ppc_state.Exceptions & EXCEPTION_DSI))
|
||||
{
|
||||
ppc_state.gpr[inst.RA] = address;
|
||||
@@ -427,7 +427,7 @@ void Interpreter::stfsu(Interpreter& interpreter, UGeckoInstruction inst)
|
||||
void Interpreter::sth(Interpreter& interpreter, UGeckoInstruction inst)
|
||||
{
|
||||
auto& ppc_state = interpreter.m_ppc_state;
|
||||
PowerPC::Write_U16(ppc_state.gpr[inst.RS], Helper_Get_EA(ppc_state, inst));
|
||||
interpreter.m_mmu.Write_U16(ppc_state.gpr[inst.RS], Helper_Get_EA(ppc_state, inst));
|
||||
}
|
||||
|
||||
void Interpreter::sthu(Interpreter& interpreter, UGeckoInstruction inst)
|
||||
@@ -435,7 +435,7 @@ void Interpreter::sthu(Interpreter& interpreter, UGeckoInstruction inst)
|
||||
auto& ppc_state = interpreter.m_ppc_state;
|
||||
const u32 address = Helper_Get_EA_U(ppc_state, inst);
|
||||
|
||||
PowerPC::Write_U16(ppc_state.gpr[inst.RS], address);
|
||||
interpreter.m_mmu.Write_U16(ppc_state.gpr[inst.RS], address);
|
||||
if (!(ppc_state.Exceptions & EXCEPTION_DSI))
|
||||
{
|
||||
ppc_state.gpr[inst.RA] = address;
|
||||
@@ -445,7 +445,7 @@ void Interpreter::sthu(Interpreter& interpreter, UGeckoInstruction inst)
|
||||
void Interpreter::stw(Interpreter& interpreter, UGeckoInstruction inst)
|
||||
{
|
||||
auto& ppc_state = interpreter.m_ppc_state;
|
||||
PowerPC::Write_U32(ppc_state.gpr[inst.RS], Helper_Get_EA(ppc_state, inst));
|
||||
interpreter.m_mmu.Write_U32(ppc_state.gpr[inst.RS], Helper_Get_EA(ppc_state, inst));
|
||||
}
|
||||
|
||||
void Interpreter::stwu(Interpreter& interpreter, UGeckoInstruction inst)
|
||||
@@ -453,7 +453,7 @@ void Interpreter::stwu(Interpreter& interpreter, UGeckoInstruction inst)
|
||||
auto& ppc_state = interpreter.m_ppc_state;
|
||||
const u32 address = Helper_Get_EA_U(ppc_state, inst);
|
||||
|
||||
PowerPC::Write_U32(ppc_state.gpr[inst.RS], address);
|
||||
interpreter.m_mmu.Write_U32(ppc_state.gpr[inst.RS], address);
|
||||
if (!(ppc_state.Exceptions & EXCEPTION_DSI))
|
||||
{
|
||||
ppc_state.gpr[inst.RA] = address;
|
||||
@@ -478,7 +478,7 @@ void Interpreter::dcbf(Interpreter& interpreter, UGeckoInstruction inst)
|
||||
return;
|
||||
}
|
||||
|
||||
PowerPC::FlushDCacheLine(address);
|
||||
interpreter.m_mmu.FlushDCacheLine(address);
|
||||
}
|
||||
|
||||
void Interpreter::dcbi(Interpreter& interpreter, UGeckoInstruction inst)
|
||||
@@ -500,7 +500,7 @@ void Interpreter::dcbi(Interpreter& interpreter, UGeckoInstruction inst)
|
||||
return;
|
||||
}
|
||||
|
||||
PowerPC::InvalidateDCacheLine(address);
|
||||
interpreter.m_mmu.InvalidateDCacheLine(address);
|
||||
}
|
||||
|
||||
void Interpreter::dcbst(Interpreter& interpreter, UGeckoInstruction inst)
|
||||
@@ -516,7 +516,7 @@ void Interpreter::dcbst(Interpreter& interpreter, UGeckoInstruction inst)
|
||||
return;
|
||||
}
|
||||
|
||||
PowerPC::StoreDCacheLine(address);
|
||||
interpreter.m_mmu.StoreDCacheLine(address);
|
||||
}
|
||||
|
||||
// These instructions hint that it might be optimal to prefetch the specified cache line into the
|
||||
@@ -553,7 +553,7 @@ void Interpreter::dcbz(Interpreter& interpreter, UGeckoInstruction inst)
|
||||
}
|
||||
}
|
||||
|
||||
PowerPC::ClearDCacheLine(dcbz_addr & (~31));
|
||||
interpreter.m_mmu.ClearDCacheLine(dcbz_addr & (~31));
|
||||
}
|
||||
|
||||
void Interpreter::dcbz_l(Interpreter& interpreter, UGeckoInstruction inst)
|
||||
@@ -573,7 +573,7 @@ void Interpreter::dcbz_l(Interpreter& interpreter, UGeckoInstruction inst)
|
||||
return;
|
||||
}
|
||||
|
||||
PowerPC::ClearDCacheLine(address & (~31));
|
||||
interpreter.m_mmu.ClearDCacheLine(address & (~31));
|
||||
}
|
||||
|
||||
// eciwx/ecowx technically should access the specified device
|
||||
@@ -595,7 +595,7 @@ void Interpreter::eciwx(Interpreter& interpreter, UGeckoInstruction inst)
|
||||
return;
|
||||
}
|
||||
|
||||
ppc_state.gpr[inst.RD] = PowerPC::Read_U32(EA);
|
||||
ppc_state.gpr[inst.RD] = interpreter.m_mmu.Read_U32(EA);
|
||||
}
|
||||
|
||||
void Interpreter::ecowx(Interpreter& interpreter, UGeckoInstruction inst)
|
||||
@@ -615,7 +615,7 @@ void Interpreter::ecowx(Interpreter& interpreter, UGeckoInstruction inst)
|
||||
return;
|
||||
}
|
||||
|
||||
PowerPC::Write_U32(ppc_state.gpr[inst.RS], EA);
|
||||
interpreter.m_mmu.Write_U32(ppc_state.gpr[inst.RS], EA);
|
||||
}
|
||||
|
||||
void Interpreter::eieio(Interpreter& interpreter, UGeckoInstruction inst)
|
||||
@@ -638,7 +638,7 @@ void Interpreter::lbzux(Interpreter& interpreter, UGeckoInstruction inst)
|
||||
{
|
||||
auto& ppc_state = interpreter.m_ppc_state;
|
||||
const u32 address = Helper_Get_EA_UX(ppc_state, inst);
|
||||
const u32 temp = PowerPC::Read_U8(address);
|
||||
const u32 temp = interpreter.m_mmu.Read_U8(address);
|
||||
|
||||
if (!(ppc_state.Exceptions & EXCEPTION_DSI))
|
||||
{
|
||||
@@ -650,7 +650,7 @@ void Interpreter::lbzux(Interpreter& interpreter, UGeckoInstruction inst)
|
||||
void Interpreter::lbzx(Interpreter& interpreter, UGeckoInstruction inst)
|
||||
{
|
||||
auto& ppc_state = interpreter.m_ppc_state;
|
||||
const u32 temp = PowerPC::Read_U8(Helper_Get_EA_X(ppc_state, inst));
|
||||
const u32 temp = interpreter.m_mmu.Read_U8(Helper_Get_EA_X(ppc_state, inst));
|
||||
|
||||
if (!(ppc_state.Exceptions & EXCEPTION_DSI))
|
||||
{
|
||||
@@ -662,7 +662,7 @@ void Interpreter::lhaux(Interpreter& interpreter, UGeckoInstruction inst)
|
||||
{
|
||||
auto& ppc_state = interpreter.m_ppc_state;
|
||||
const u32 address = Helper_Get_EA_UX(ppc_state, inst);
|
||||
const s32 temp = s32{s16(PowerPC::Read_U16(address))};
|
||||
const s32 temp = s32{s16(interpreter.m_mmu.Read_U16(address))};
|
||||
|
||||
if (!(ppc_state.Exceptions & EXCEPTION_DSI))
|
||||
{
|
||||
@@ -674,7 +674,7 @@ void Interpreter::lhaux(Interpreter& interpreter, UGeckoInstruction inst)
|
||||
void Interpreter::lhax(Interpreter& interpreter, UGeckoInstruction inst)
|
||||
{
|
||||
auto& ppc_state = interpreter.m_ppc_state;
|
||||
const s32 temp = s32{s16(PowerPC::Read_U16(Helper_Get_EA_X(ppc_state, inst)))};
|
||||
const s32 temp = s32{s16(interpreter.m_mmu.Read_U16(Helper_Get_EA_X(ppc_state, inst)))};
|
||||
|
||||
if (!(ppc_state.Exceptions & EXCEPTION_DSI))
|
||||
{
|
||||
@@ -685,7 +685,7 @@ void Interpreter::lhax(Interpreter& interpreter, UGeckoInstruction inst)
|
||||
void Interpreter::lhbrx(Interpreter& interpreter, UGeckoInstruction inst)
|
||||
{
|
||||
auto& ppc_state = interpreter.m_ppc_state;
|
||||
const u32 temp = Common::swap16(PowerPC::Read_U16(Helper_Get_EA_X(ppc_state, inst)));
|
||||
const u32 temp = Common::swap16(interpreter.m_mmu.Read_U16(Helper_Get_EA_X(ppc_state, inst)));
|
||||
|
||||
if (!(ppc_state.Exceptions & EXCEPTION_DSI))
|
||||
{
|
||||
@@ -697,7 +697,7 @@ void Interpreter::lhzux(Interpreter& interpreter, UGeckoInstruction inst)
|
||||
{
|
||||
auto& ppc_state = interpreter.m_ppc_state;
|
||||
const u32 address = Helper_Get_EA_UX(ppc_state, inst);
|
||||
const u32 temp = PowerPC::Read_U16(address);
|
||||
const u32 temp = interpreter.m_mmu.Read_U16(address);
|
||||
|
||||
if (!(ppc_state.Exceptions & EXCEPTION_DSI))
|
||||
{
|
||||
@@ -709,7 +709,7 @@ void Interpreter::lhzux(Interpreter& interpreter, UGeckoInstruction inst)
|
||||
void Interpreter::lhzx(Interpreter& interpreter, UGeckoInstruction inst)
|
||||
{
|
||||
auto& ppc_state = interpreter.m_ppc_state;
|
||||
const u32 temp = PowerPC::Read_U16(Helper_Get_EA_X(ppc_state, inst));
|
||||
const u32 temp = interpreter.m_mmu.Read_U16(Helper_Get_EA_X(ppc_state, inst));
|
||||
|
||||
if (!(ppc_state.Exceptions & EXCEPTION_DSI))
|
||||
{
|
||||
@@ -738,7 +738,7 @@ void Interpreter::lswx(Interpreter& interpreter, UGeckoInstruction inst)
|
||||
if ((n & 0b11) == 0)
|
||||
ppc_state.gpr[reg] = 0;
|
||||
|
||||
const u32 temp_value = PowerPC::Read_U8(EA) << (24 - offset);
|
||||
const u32 temp_value = interpreter.m_mmu.Read_U8(EA) << (24 - offset);
|
||||
// Not64 (Homebrew N64 Emulator for Wii) triggers the following case.
|
||||
if ((ppc_state.Exceptions & EXCEPTION_DSI) != 0)
|
||||
{
|
||||
@@ -754,7 +754,7 @@ void Interpreter::lswx(Interpreter& interpreter, UGeckoInstruction inst)
|
||||
void Interpreter::lwbrx(Interpreter& interpreter, UGeckoInstruction inst)
|
||||
{
|
||||
auto& ppc_state = interpreter.m_ppc_state;
|
||||
const u32 temp = Common::swap32(PowerPC::Read_U32(Helper_Get_EA_X(ppc_state, inst)));
|
||||
const u32 temp = Common::swap32(interpreter.m_mmu.Read_U32(Helper_Get_EA_X(ppc_state, inst)));
|
||||
|
||||
if (!(ppc_state.Exceptions & EXCEPTION_DSI))
|
||||
{
|
||||
@@ -766,7 +766,7 @@ void Interpreter::lwzux(Interpreter& interpreter, UGeckoInstruction inst)
|
||||
{
|
||||
auto& ppc_state = interpreter.m_ppc_state;
|
||||
const u32 address = Helper_Get_EA_UX(ppc_state, inst);
|
||||
const u32 temp = PowerPC::Read_U32(address);
|
||||
const u32 temp = interpreter.m_mmu.Read_U32(address);
|
||||
|
||||
if (!(ppc_state.Exceptions & EXCEPTION_DSI))
|
||||
{
|
||||
@@ -779,7 +779,7 @@ void Interpreter::lwzx(Interpreter& interpreter, UGeckoInstruction inst)
|
||||
{
|
||||
auto& ppc_state = interpreter.m_ppc_state;
|
||||
const u32 address = Helper_Get_EA_X(ppc_state, inst);
|
||||
const u32 temp = PowerPC::Read_U32(address);
|
||||
const u32 temp = interpreter.m_mmu.Read_U32(address);
|
||||
|
||||
if (!(ppc_state.Exceptions & EXCEPTION_DSI))
|
||||
{
|
||||
@@ -792,7 +792,7 @@ void Interpreter::stbux(Interpreter& interpreter, UGeckoInstruction inst)
|
||||
auto& ppc_state = interpreter.m_ppc_state;
|
||||
const u32 address = Helper_Get_EA_UX(ppc_state, inst);
|
||||
|
||||
PowerPC::Write_U8(ppc_state.gpr[inst.RS], address);
|
||||
interpreter.m_mmu.Write_U8(ppc_state.gpr[inst.RS], address);
|
||||
if (!(ppc_state.Exceptions & EXCEPTION_DSI))
|
||||
{
|
||||
ppc_state.gpr[inst.RA] = address;
|
||||
@@ -802,7 +802,7 @@ void Interpreter::stbux(Interpreter& interpreter, UGeckoInstruction inst)
|
||||
void Interpreter::stbx(Interpreter& interpreter, UGeckoInstruction inst)
|
||||
{
|
||||
auto& ppc_state = interpreter.m_ppc_state;
|
||||
PowerPC::Write_U8(ppc_state.gpr[inst.RS], Helper_Get_EA_X(ppc_state, inst));
|
||||
interpreter.m_mmu.Write_U8(ppc_state.gpr[inst.RS], Helper_Get_EA_X(ppc_state, inst));
|
||||
}
|
||||
|
||||
void Interpreter::stfdux(Interpreter& interpreter, UGeckoInstruction inst)
|
||||
@@ -816,7 +816,7 @@ void Interpreter::stfdux(Interpreter& interpreter, UGeckoInstruction inst)
|
||||
return;
|
||||
}
|
||||
|
||||
PowerPC::Write_U64(ppc_state.ps[inst.FS].PS0AsU64(), address);
|
||||
interpreter.m_mmu.Write_U64(ppc_state.ps[inst.FS].PS0AsU64(), address);
|
||||
if (!(ppc_state.Exceptions & EXCEPTION_DSI))
|
||||
{
|
||||
ppc_state.gpr[inst.RA] = address;
|
||||
@@ -834,7 +834,7 @@ void Interpreter::stfdx(Interpreter& interpreter, UGeckoInstruction inst)
|
||||
return;
|
||||
}
|
||||
|
||||
PowerPC::Write_U64(ppc_state.ps[inst.FS].PS0AsU64(), address);
|
||||
interpreter.m_mmu.Write_U64(ppc_state.ps[inst.FS].PS0AsU64(), address);
|
||||
}
|
||||
|
||||
// Stores Floating points into Integers indeXed
|
||||
@@ -849,7 +849,7 @@ void Interpreter::stfiwx(Interpreter& interpreter, UGeckoInstruction inst)
|
||||
return;
|
||||
}
|
||||
|
||||
PowerPC::Write_U32(ppc_state.ps[inst.FS].PS0AsU32(), address);
|
||||
interpreter.m_mmu.Write_U32(ppc_state.ps[inst.FS].PS0AsU32(), address);
|
||||
}
|
||||
|
||||
void Interpreter::stfsux(Interpreter& interpreter, UGeckoInstruction inst)
|
||||
@@ -863,7 +863,7 @@ void Interpreter::stfsux(Interpreter& interpreter, UGeckoInstruction inst)
|
||||
return;
|
||||
}
|
||||
|
||||
PowerPC::Write_U32(ConvertToSingle(ppc_state.ps[inst.FS].PS0AsU64()), address);
|
||||
interpreter.m_mmu.Write_U32(ConvertToSingle(ppc_state.ps[inst.FS].PS0AsU64()), address);
|
||||
if (!(ppc_state.Exceptions & EXCEPTION_DSI))
|
||||
{
|
||||
ppc_state.gpr[inst.RA] = address;
|
||||
@@ -881,13 +881,13 @@ void Interpreter::stfsx(Interpreter& interpreter, UGeckoInstruction inst)
|
||||
return;
|
||||
}
|
||||
|
||||
PowerPC::Write_U32(ConvertToSingle(ppc_state.ps[inst.FS].PS0AsU64()), address);
|
||||
interpreter.m_mmu.Write_U32(ConvertToSingle(ppc_state.ps[inst.FS].PS0AsU64()), address);
|
||||
}
|
||||
|
||||
void Interpreter::sthbrx(Interpreter& interpreter, UGeckoInstruction inst)
|
||||
{
|
||||
auto& ppc_state = interpreter.m_ppc_state;
|
||||
PowerPC::Write_U16_Swap(ppc_state.gpr[inst.RS], Helper_Get_EA_X(ppc_state, inst));
|
||||
interpreter.m_mmu.Write_U16_Swap(ppc_state.gpr[inst.RS], Helper_Get_EA_X(ppc_state, inst));
|
||||
}
|
||||
|
||||
void Interpreter::sthux(Interpreter& interpreter, UGeckoInstruction inst)
|
||||
@@ -895,7 +895,7 @@ void Interpreter::sthux(Interpreter& interpreter, UGeckoInstruction inst)
|
||||
auto& ppc_state = interpreter.m_ppc_state;
|
||||
const u32 address = Helper_Get_EA_UX(ppc_state, inst);
|
||||
|
||||
PowerPC::Write_U16(ppc_state.gpr[inst.RS], address);
|
||||
interpreter.m_mmu.Write_U16(ppc_state.gpr[inst.RS], address);
|
||||
if (!(ppc_state.Exceptions & EXCEPTION_DSI))
|
||||
{
|
||||
ppc_state.gpr[inst.RA] = address;
|
||||
@@ -905,7 +905,7 @@ void Interpreter::sthux(Interpreter& interpreter, UGeckoInstruction inst)
|
||||
void Interpreter::sthx(Interpreter& interpreter, UGeckoInstruction inst)
|
||||
{
|
||||
auto& ppc_state = interpreter.m_ppc_state;
|
||||
PowerPC::Write_U16(ppc_state.gpr[inst.RS], Helper_Get_EA_X(ppc_state, inst));
|
||||
interpreter.m_mmu.Write_U16(ppc_state.gpr[inst.RS], Helper_Get_EA_X(ppc_state, inst));
|
||||
}
|
||||
|
||||
// lswi - bizarro string instruction
|
||||
@@ -938,7 +938,7 @@ void Interpreter::lswi(Interpreter& interpreter, UGeckoInstruction inst)
|
||||
ppc_state.gpr[r] = 0;
|
||||
}
|
||||
|
||||
const u32 temp_value = PowerPC::Read_U8(EA) << (24 - i);
|
||||
const u32 temp_value = interpreter.m_mmu.Read_U8(EA) << (24 - i);
|
||||
if ((ppc_state.Exceptions & EXCEPTION_DSI) != 0)
|
||||
{
|
||||
PanicAlertFmt("DSI exception in lsw.");
|
||||
@@ -984,7 +984,7 @@ void Interpreter::stswi(Interpreter& interpreter, UGeckoInstruction inst)
|
||||
r++;
|
||||
r &= 31;
|
||||
}
|
||||
PowerPC::Write_U8((ppc_state.gpr[r] >> (24 - i)) & 0xFF, EA);
|
||||
interpreter.m_mmu.Write_U8((ppc_state.gpr[r] >> (24 - i)) & 0xFF, EA);
|
||||
if ((ppc_state.Exceptions & EXCEPTION_DSI) != 0)
|
||||
{
|
||||
return;
|
||||
@@ -1016,7 +1016,7 @@ void Interpreter::stswx(Interpreter& interpreter, UGeckoInstruction inst)
|
||||
|
||||
while (n > 0)
|
||||
{
|
||||
PowerPC::Write_U8((ppc_state.gpr[r] >> (24 - i)) & 0xFF, EA);
|
||||
interpreter.m_mmu.Write_U8((ppc_state.gpr[r] >> (24 - i)) & 0xFF, EA);
|
||||
|
||||
EA++;
|
||||
n--;
|
||||
@@ -1034,7 +1034,7 @@ void Interpreter::stwbrx(Interpreter& interpreter, UGeckoInstruction inst)
|
||||
auto& ppc_state = interpreter.m_ppc_state;
|
||||
const u32 address = Helper_Get_EA_X(ppc_state, inst);
|
||||
|
||||
PowerPC::Write_U32_Swap(ppc_state.gpr[inst.RS], address);
|
||||
interpreter.m_mmu.Write_U32_Swap(ppc_state.gpr[inst.RS], address);
|
||||
}
|
||||
|
||||
// The following two instructions are for SMP communications. On a single
|
||||
@@ -1051,7 +1051,7 @@ void Interpreter::lwarx(Interpreter& interpreter, UGeckoInstruction inst)
|
||||
return;
|
||||
}
|
||||
|
||||
const u32 temp = PowerPC::Read_U32(address);
|
||||
const u32 temp = interpreter.m_mmu.Read_U32(address);
|
||||
|
||||
if (!(ppc_state.Exceptions & EXCEPTION_DSI))
|
||||
{
|
||||
@@ -1077,7 +1077,7 @@ void Interpreter::stwcxd(Interpreter& interpreter, UGeckoInstruction inst)
|
||||
{
|
||||
if (address == ppc_state.reserve_address)
|
||||
{
|
||||
PowerPC::Write_U32(ppc_state.gpr[inst.RS], address);
|
||||
interpreter.m_mmu.Write_U32(ppc_state.gpr[inst.RS], address);
|
||||
if (!(ppc_state.Exceptions & EXCEPTION_DSI))
|
||||
{
|
||||
ppc_state.reserve = false;
|
||||
@@ -1095,7 +1095,7 @@ void Interpreter::stwux(Interpreter& interpreter, UGeckoInstruction inst)
|
||||
auto& ppc_state = interpreter.m_ppc_state;
|
||||
const u32 address = Helper_Get_EA_UX(ppc_state, inst);
|
||||
|
||||
PowerPC::Write_U32(ppc_state.gpr[inst.RS], address);
|
||||
interpreter.m_mmu.Write_U32(ppc_state.gpr[inst.RS], address);
|
||||
if (!(ppc_state.Exceptions & EXCEPTION_DSI))
|
||||
{
|
||||
ppc_state.gpr[inst.RA] = address;
|
||||
@@ -1107,7 +1107,7 @@ void Interpreter::stwx(Interpreter& interpreter, UGeckoInstruction inst)
|
||||
auto& ppc_state = interpreter.m_ppc_state;
|
||||
const u32 address = Helper_Get_EA_X(ppc_state, inst);
|
||||
|
||||
PowerPC::Write_U32(ppc_state.gpr[inst.RS], address);
|
||||
interpreter.m_mmu.Write_U32(ppc_state.gpr[inst.RS], address);
|
||||
}
|
||||
|
||||
void Interpreter::sync(Interpreter& interpreter, UGeckoInstruction inst)
|
||||
@@ -1127,7 +1127,7 @@ void Interpreter::tlbie(Interpreter& interpreter, UGeckoInstruction inst)
|
||||
// Invalidate TLB entry
|
||||
const u32 address = ppc_state.gpr[inst.RB];
|
||||
|
||||
PowerPC::InvalidateTLBEntry(address);
|
||||
interpreter.m_mmu.InvalidateTLBEntry(address);
|
||||
}
|
||||
|
||||
void Interpreter::tlbsync(Interpreter& interpreter, UGeckoInstruction inst)
|
||||
|
||||
@@ -16,6 +16,7 @@
|
||||
#include "Core/PowerPC/Interpreter/Interpreter_FPUtils.h"
|
||||
#include "Core/PowerPC/MMU.h"
|
||||
#include "Core/PowerPC/PowerPC.h"
|
||||
#include "Core/System.h"
|
||||
|
||||
// dequantize table
|
||||
const float m_dequantizeTable[] = {
|
||||
@@ -68,111 +69,111 @@ SType ScaleAndClamp(double ps, u32 st_scale)
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
static T ReadUnpaired(u32 addr);
|
||||
static T ReadUnpaired(PowerPC::MMU& mmu, u32 addr);
|
||||
|
||||
template <>
|
||||
u8 ReadUnpaired<u8>(u32 addr)
|
||||
u8 ReadUnpaired<u8>(PowerPC::MMU& mmu, u32 addr)
|
||||
{
|
||||
return PowerPC::Read_U8(addr);
|
||||
return mmu.Read_U8(addr);
|
||||
}
|
||||
|
||||
template <>
|
||||
u16 ReadUnpaired<u16>(u32 addr)
|
||||
u16 ReadUnpaired<u16>(PowerPC::MMU& mmu, u32 addr)
|
||||
{
|
||||
return PowerPC::Read_U16(addr);
|
||||
return mmu.Read_U16(addr);
|
||||
}
|
||||
|
||||
template <>
|
||||
u32 ReadUnpaired<u32>(u32 addr)
|
||||
u32 ReadUnpaired<u32>(PowerPC::MMU& mmu, u32 addr)
|
||||
{
|
||||
return PowerPC::Read_U32(addr);
|
||||
return mmu.Read_U32(addr);
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
static std::pair<T, T> ReadPair(u32 addr);
|
||||
static std::pair<T, T> ReadPair(PowerPC::MMU& mmu, u32 addr);
|
||||
|
||||
template <>
|
||||
std::pair<u8, u8> ReadPair<u8>(u32 addr)
|
||||
std::pair<u8, u8> ReadPair<u8>(PowerPC::MMU& mmu, u32 addr)
|
||||
{
|
||||
const u16 val = PowerPC::Read_U16(addr);
|
||||
const u16 val = mmu.Read_U16(addr);
|
||||
return {u8(val >> 8), u8(val)};
|
||||
}
|
||||
|
||||
template <>
|
||||
std::pair<u16, u16> ReadPair<u16>(u32 addr)
|
||||
std::pair<u16, u16> ReadPair<u16>(PowerPC::MMU& mmu, u32 addr)
|
||||
{
|
||||
const u32 val = PowerPC::Read_U32(addr);
|
||||
const u32 val = mmu.Read_U32(addr);
|
||||
return {u16(val >> 16), u16(val)};
|
||||
}
|
||||
|
||||
template <>
|
||||
std::pair<u32, u32> ReadPair<u32>(u32 addr)
|
||||
std::pair<u32, u32> ReadPair<u32>(PowerPC::MMU& mmu, u32 addr)
|
||||
{
|
||||
const u64 val = PowerPC::Read_U64(addr);
|
||||
const u64 val = mmu.Read_U64(addr);
|
||||
return {u32(val >> 32), u32(val)};
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
static void WriteUnpaired(T val, u32 addr);
|
||||
static void WriteUnpaired(PowerPC::MMU& mmu, T val, u32 addr);
|
||||
|
||||
template <>
|
||||
void WriteUnpaired<u8>(u8 val, u32 addr)
|
||||
void WriteUnpaired<u8>(PowerPC::MMU& mmu, u8 val, u32 addr)
|
||||
{
|
||||
PowerPC::Write_U8(val, addr);
|
||||
mmu.Write_U8(val, addr);
|
||||
}
|
||||
|
||||
template <>
|
||||
void WriteUnpaired<u16>(u16 val, u32 addr)
|
||||
void WriteUnpaired<u16>(PowerPC::MMU& mmu, u16 val, u32 addr)
|
||||
{
|
||||
PowerPC::Write_U16(val, addr);
|
||||
mmu.Write_U16(val, addr);
|
||||
}
|
||||
|
||||
template <>
|
||||
void WriteUnpaired<u32>(u32 val, u32 addr)
|
||||
void WriteUnpaired<u32>(PowerPC::MMU& mmu, u32 val, u32 addr)
|
||||
{
|
||||
PowerPC::Write_U32(val, addr);
|
||||
mmu.Write_U32(val, addr);
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
static void WritePair(T val1, T val2, u32 addr);
|
||||
static void WritePair(PowerPC::MMU& mmu, T val1, T val2, u32 addr);
|
||||
|
||||
template <>
|
||||
void WritePair<u8>(u8 val1, u8 val2, u32 addr)
|
||||
void WritePair<u8>(PowerPC::MMU& mmu, u8 val1, u8 val2, u32 addr)
|
||||
{
|
||||
PowerPC::Write_U16((u16{val1} << 8) | u16{val2}, addr);
|
||||
mmu.Write_U16((u16{val1} << 8) | u16{val2}, addr);
|
||||
}
|
||||
|
||||
template <>
|
||||
void WritePair<u16>(u16 val1, u16 val2, u32 addr)
|
||||
void WritePair<u16>(PowerPC::MMU& mmu, u16 val1, u16 val2, u32 addr)
|
||||
{
|
||||
PowerPC::Write_U32((u32{val1} << 16) | u32{val2}, addr);
|
||||
mmu.Write_U32((u32{val1} << 16) | u32{val2}, addr);
|
||||
}
|
||||
|
||||
template <>
|
||||
void WritePair<u32>(u32 val1, u32 val2, u32 addr)
|
||||
void WritePair<u32>(PowerPC::MMU& mmu, u32 val1, u32 val2, u32 addr)
|
||||
{
|
||||
PowerPC::Write_U64((u64{val1} << 32) | u64{val2}, addr);
|
||||
mmu.Write_U64((u64{val1} << 32) | u64{val2}, addr);
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
void QuantizeAndStore(double ps0, double ps1, u32 addr, u32 instW, u32 st_scale)
|
||||
void QuantizeAndStore(PowerPC::MMU& mmu, double ps0, double ps1, u32 addr, u32 instW, u32 st_scale)
|
||||
{
|
||||
using U = std::make_unsigned_t<T>;
|
||||
|
||||
const U conv_ps0 = U(ScaleAndClamp<T>(ps0, st_scale));
|
||||
if (instW)
|
||||
{
|
||||
WriteUnpaired<U>(conv_ps0, addr);
|
||||
WriteUnpaired<U>(mmu, conv_ps0, addr);
|
||||
}
|
||||
else
|
||||
{
|
||||
const U conv_ps1 = U(ScaleAndClamp<T>(ps1, st_scale));
|
||||
WritePair<U>(conv_ps0, conv_ps1, addr);
|
||||
WritePair<U>(mmu, conv_ps0, conv_ps1, addr);
|
||||
}
|
||||
}
|
||||
|
||||
static void Helper_Quantize(const PowerPC::PowerPCState* ppcs, u32 addr, u32 instI, u32 instRS,
|
||||
u32 instW)
|
||||
static void Helper_Quantize(PowerPC::MMU& mmu, const PowerPC::PowerPCState* ppcs, u32 addr,
|
||||
u32 instI, u32 instRS, u32 instW)
|
||||
{
|
||||
const UGQR gqr(ppcs->spr[SPR_GQR0 + instI]);
|
||||
const EQuantizeType st_type = gqr.st_type;
|
||||
@@ -190,32 +191,32 @@ static void Helper_Quantize(const PowerPC::PowerPCState* ppcs, u32 addr, u32 ins
|
||||
|
||||
if (instW != 0)
|
||||
{
|
||||
WriteUnpaired<u32>(conv_ps0, addr);
|
||||
WriteUnpaired<u32>(mmu, conv_ps0, addr);
|
||||
}
|
||||
else
|
||||
{
|
||||
const u64 integral_ps1 = Common::BitCast<u64>(ps1);
|
||||
const u32 conv_ps1 = ConvertToSingleFTZ(integral_ps1);
|
||||
|
||||
WritePair<u32>(conv_ps0, conv_ps1, addr);
|
||||
WritePair<u32>(mmu, conv_ps0, conv_ps1, addr);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
case QUANTIZE_U8:
|
||||
QuantizeAndStore<u8>(ps0, ps1, addr, instW, st_scale);
|
||||
QuantizeAndStore<u8>(mmu, ps0, ps1, addr, instW, st_scale);
|
||||
break;
|
||||
|
||||
case QUANTIZE_U16:
|
||||
QuantizeAndStore<u16>(ps0, ps1, addr, instW, st_scale);
|
||||
QuantizeAndStore<u16>(mmu, ps0, ps1, addr, instW, st_scale);
|
||||
break;
|
||||
|
||||
case QUANTIZE_S8:
|
||||
QuantizeAndStore<s8>(ps0, ps1, addr, instW, st_scale);
|
||||
QuantizeAndStore<s8>(mmu, ps0, ps1, addr, instW, st_scale);
|
||||
break;
|
||||
|
||||
case QUANTIZE_S16:
|
||||
QuantizeAndStore<s16>(ps0, ps1, addr, instW, st_scale);
|
||||
QuantizeAndStore<s16>(mmu, ps0, ps1, addr, instW, st_scale);
|
||||
break;
|
||||
|
||||
case QUANTIZE_INVALID1:
|
||||
@@ -227,20 +228,20 @@ static void Helper_Quantize(const PowerPC::PowerPCState* ppcs, u32 addr, u32 ins
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
std::pair<double, double> LoadAndDequantize(u32 addr, u32 instW, u32 ld_scale)
|
||||
std::pair<double, double> LoadAndDequantize(PowerPC::MMU& mmu, u32 addr, u32 instW, u32 ld_scale)
|
||||
{
|
||||
using U = std::make_unsigned_t<T>;
|
||||
|
||||
float ps0, ps1;
|
||||
if (instW != 0)
|
||||
{
|
||||
const U value = ReadUnpaired<U>(addr);
|
||||
const U value = ReadUnpaired<U>(mmu, addr);
|
||||
ps0 = float(T(value)) * m_dequantizeTable[ld_scale];
|
||||
ps1 = 1.0f;
|
||||
}
|
||||
else
|
||||
{
|
||||
const auto [first, second] = ReadPair<U>(addr);
|
||||
const auto [first, second] = ReadPair<U>(mmu, addr);
|
||||
ps0 = float(T(first)) * m_dequantizeTable[ld_scale];
|
||||
ps1 = float(T(second)) * m_dequantizeTable[ld_scale];
|
||||
}
|
||||
@@ -248,8 +249,8 @@ std::pair<double, double> LoadAndDequantize(u32 addr, u32 instW, u32 ld_scale)
|
||||
return {static_cast<double>(ps0), static_cast<double>(ps1)};
|
||||
}
|
||||
|
||||
static void Helper_Dequantize(PowerPC::PowerPCState* ppcs, u32 addr, u32 instI, u32 instRD,
|
||||
u32 instW)
|
||||
static void Helper_Dequantize(PowerPC::MMU& mmu, PowerPC::PowerPCState* ppcs, u32 addr, u32 instI,
|
||||
u32 instRD, u32 instW)
|
||||
{
|
||||
const UGQR gqr(ppcs->spr[SPR_GQR0 + instI]);
|
||||
const EQuantizeType ld_type = gqr.ld_type;
|
||||
@@ -263,32 +264,32 @@ static void Helper_Dequantize(PowerPC::PowerPCState* ppcs, u32 addr, u32 instI,
|
||||
case QUANTIZE_FLOAT:
|
||||
if (instW != 0)
|
||||
{
|
||||
const u32 value = ReadUnpaired<u32>(addr);
|
||||
const u32 value = ReadUnpaired<u32>(mmu, addr);
|
||||
ps0 = Common::BitCast<double>(ConvertToDouble(value));
|
||||
ps1 = 1.0;
|
||||
}
|
||||
else
|
||||
{
|
||||
const auto [first, second] = ReadPair<u32>(addr);
|
||||
const auto [first, second] = ReadPair<u32>(mmu, addr);
|
||||
ps0 = Common::BitCast<double>(ConvertToDouble(first));
|
||||
ps1 = Common::BitCast<double>(ConvertToDouble(second));
|
||||
}
|
||||
break;
|
||||
|
||||
case QUANTIZE_U8:
|
||||
std::tie(ps0, ps1) = LoadAndDequantize<u8>(addr, instW, ld_scale);
|
||||
std::tie(ps0, ps1) = LoadAndDequantize<u8>(mmu, addr, instW, ld_scale);
|
||||
break;
|
||||
|
||||
case QUANTIZE_U16:
|
||||
std::tie(ps0, ps1) = LoadAndDequantize<u16>(addr, instW, ld_scale);
|
||||
std::tie(ps0, ps1) = LoadAndDequantize<u16>(mmu, addr, instW, ld_scale);
|
||||
break;
|
||||
|
||||
case QUANTIZE_S8:
|
||||
std::tie(ps0, ps1) = LoadAndDequantize<s8>(addr, instW, ld_scale);
|
||||
std::tie(ps0, ps1) = LoadAndDequantize<s8>(mmu, addr, instW, ld_scale);
|
||||
break;
|
||||
|
||||
case QUANTIZE_S16:
|
||||
std::tie(ps0, ps1) = LoadAndDequantize<s16>(addr, instW, ld_scale);
|
||||
std::tie(ps0, ps1) = LoadAndDequantize<s16>(mmu, addr, instW, ld_scale);
|
||||
break;
|
||||
|
||||
case QUANTIZE_INVALID1:
|
||||
@@ -318,7 +319,7 @@ void Interpreter::psq_l(Interpreter& interpreter, UGeckoInstruction inst)
|
||||
}
|
||||
|
||||
const u32 EA = inst.RA ? (ppc_state.gpr[inst.RA] + u32(inst.SIMM_12)) : u32(inst.SIMM_12);
|
||||
Helper_Dequantize(&ppc_state, EA, inst.I, inst.RD, inst.W);
|
||||
Helper_Dequantize(interpreter.m_mmu, &ppc_state, EA, inst.I, inst.RD, inst.W);
|
||||
}
|
||||
|
||||
void Interpreter::psq_lu(Interpreter& interpreter, UGeckoInstruction inst)
|
||||
@@ -331,7 +332,7 @@ void Interpreter::psq_lu(Interpreter& interpreter, UGeckoInstruction inst)
|
||||
}
|
||||
|
||||
const u32 EA = ppc_state.gpr[inst.RA] + u32(inst.SIMM_12);
|
||||
Helper_Dequantize(&ppc_state, EA, inst.I, inst.RD, inst.W);
|
||||
Helper_Dequantize(interpreter.m_mmu, &ppc_state, EA, inst.I, inst.RD, inst.W);
|
||||
|
||||
if ((ppc_state.Exceptions & EXCEPTION_DSI) != 0)
|
||||
{
|
||||
@@ -351,7 +352,7 @@ void Interpreter::psq_st(Interpreter& interpreter, UGeckoInstruction inst)
|
||||
}
|
||||
|
||||
const u32 EA = inst.RA ? (ppc_state.gpr[inst.RA] + u32(inst.SIMM_12)) : u32(inst.SIMM_12);
|
||||
Helper_Quantize(&ppc_state, EA, inst.I, inst.RS, inst.W);
|
||||
Helper_Quantize(interpreter.m_mmu, &ppc_state, EA, inst.I, inst.RS, inst.W);
|
||||
}
|
||||
|
||||
void Interpreter::psq_stu(Interpreter& interpreter, UGeckoInstruction inst)
|
||||
@@ -364,7 +365,7 @@ void Interpreter::psq_stu(Interpreter& interpreter, UGeckoInstruction inst)
|
||||
}
|
||||
|
||||
const u32 EA = ppc_state.gpr[inst.RA] + u32(inst.SIMM_12);
|
||||
Helper_Quantize(&ppc_state, EA, inst.I, inst.RS, inst.W);
|
||||
Helper_Quantize(interpreter.m_mmu, &ppc_state, EA, inst.I, inst.RS, inst.W);
|
||||
|
||||
if ((ppc_state.Exceptions & EXCEPTION_DSI) != 0)
|
||||
{
|
||||
@@ -379,7 +380,7 @@ void Interpreter::psq_lx(Interpreter& interpreter, UGeckoInstruction inst)
|
||||
auto& ppc_state = interpreter.m_ppc_state;
|
||||
const u32 EA =
|
||||
inst.RA ? (ppc_state.gpr[inst.RA] + ppc_state.gpr[inst.RB]) : ppc_state.gpr[inst.RB];
|
||||
Helper_Dequantize(&ppc_state, EA, inst.Ix, inst.RD, inst.Wx);
|
||||
Helper_Dequantize(interpreter.m_mmu, &ppc_state, EA, inst.Ix, inst.RD, inst.Wx);
|
||||
}
|
||||
|
||||
void Interpreter::psq_stx(Interpreter& interpreter, UGeckoInstruction inst)
|
||||
@@ -387,14 +388,14 @@ void Interpreter::psq_stx(Interpreter& interpreter, UGeckoInstruction inst)
|
||||
auto& ppc_state = interpreter.m_ppc_state;
|
||||
const u32 EA =
|
||||
inst.RA ? (ppc_state.gpr[inst.RA] + ppc_state.gpr[inst.RB]) : ppc_state.gpr[inst.RB];
|
||||
Helper_Quantize(&ppc_state, EA, inst.Ix, inst.RS, inst.Wx);
|
||||
Helper_Quantize(interpreter.m_mmu, &ppc_state, EA, inst.Ix, inst.RS, inst.Wx);
|
||||
}
|
||||
|
||||
void Interpreter::psq_lux(Interpreter& interpreter, UGeckoInstruction inst)
|
||||
{
|
||||
auto& ppc_state = interpreter.m_ppc_state;
|
||||
const u32 EA = ppc_state.gpr[inst.RA] + ppc_state.gpr[inst.RB];
|
||||
Helper_Dequantize(&ppc_state, EA, inst.Ix, inst.RD, inst.Wx);
|
||||
Helper_Dequantize(interpreter.m_mmu, &ppc_state, EA, inst.Ix, inst.RD, inst.Wx);
|
||||
|
||||
if ((ppc_state.Exceptions & EXCEPTION_DSI) != 0)
|
||||
{
|
||||
@@ -408,7 +409,7 @@ void Interpreter::psq_stux(Interpreter& interpreter, UGeckoInstruction inst)
|
||||
{
|
||||
auto& ppc_state = interpreter.m_ppc_state;
|
||||
const u32 EA = ppc_state.gpr[inst.RA] + ppc_state.gpr[inst.RB];
|
||||
Helper_Quantize(&ppc_state, EA, inst.Ix, inst.RS, inst.Wx);
|
||||
Helper_Quantize(interpreter.m_mmu, &ppc_state, EA, inst.Ix, inst.RS, inst.Wx);
|
||||
|
||||
if ((ppc_state.Exceptions & EXCEPTION_DSI) != 0)
|
||||
{
|
||||
|
||||
@@ -379,8 +379,8 @@ void Interpreter::mtspr(Interpreter& interpreter, UGeckoInstruction inst)
|
||||
if (old_value != ppc_state.spr[index])
|
||||
{
|
||||
INFO_LOG_FMT(POWERPC, "HID4 updated {:x} {:x}", old_value, ppc_state.spr[index]);
|
||||
PowerPC::IBATUpdated();
|
||||
PowerPC::DBATUpdated();
|
||||
interpreter.m_mmu.IBATUpdated();
|
||||
interpreter.m_mmu.DBATUpdated();
|
||||
}
|
||||
break;
|
||||
|
||||
@@ -414,9 +414,9 @@ void Interpreter::mtspr(Interpreter& interpreter, UGeckoInstruction inst)
|
||||
if (length == 0)
|
||||
length = 128;
|
||||
if (DMAL(ppc_state).DMA_LD)
|
||||
PowerPC::DMA_MemoryToLC(cache_address, mem_address, length);
|
||||
interpreter.m_mmu.DMA_MemoryToLC(cache_address, mem_address, length);
|
||||
else
|
||||
PowerPC::DMA_LCToMemory(mem_address, cache_address, length);
|
||||
interpreter.m_mmu.DMA_LCToMemory(mem_address, cache_address, length);
|
||||
}
|
||||
DMAL(ppc_state).DMA_T = 0;
|
||||
break;
|
||||
@@ -436,7 +436,7 @@ void Interpreter::mtspr(Interpreter& interpreter, UGeckoInstruction inst)
|
||||
|
||||
// Page table base etc
|
||||
case SPR_SDR:
|
||||
PowerPC::SDRUpdated();
|
||||
interpreter.m_mmu.SDRUpdated();
|
||||
break;
|
||||
|
||||
case SPR_XER:
|
||||
@@ -462,7 +462,7 @@ void Interpreter::mtspr(Interpreter& interpreter, UGeckoInstruction inst)
|
||||
if (old_value != ppc_state.spr[index])
|
||||
{
|
||||
INFO_LOG_FMT(POWERPC, "DBAT updated {} {:x} {:x}", index, old_value, ppc_state.spr[index]);
|
||||
PowerPC::DBATUpdated();
|
||||
interpreter.m_mmu.DBATUpdated();
|
||||
}
|
||||
break;
|
||||
|
||||
@@ -485,7 +485,7 @@ void Interpreter::mtspr(Interpreter& interpreter, UGeckoInstruction inst)
|
||||
if (old_value != ppc_state.spr[index])
|
||||
{
|
||||
INFO_LOG_FMT(POWERPC, "IBAT updated {} {:x} {:x}", index, old_value, ppc_state.spr[index]);
|
||||
PowerPC::IBATUpdated();
|
||||
interpreter.m_mmu.IBATUpdated();
|
||||
}
|
||||
break;
|
||||
|
||||
|
||||
Reference in new issue
Block a user