diff --git a/Source/Core/Core/PowerPC/Interpreter/Interpreter_LoadStore.cpp b/Source/Core/Core/PowerPC/Interpreter/Interpreter_LoadStore.cpp index b81f8908ad..1decfd5f8e 100644 --- a/Source/Core/Core/PowerPC/Interpreter/Interpreter_LoadStore.cpp +++ b/Source/Core/Core/PowerPC/Interpreter/Interpreter_LoadStore.cpp @@ -39,27 +39,30 @@ static u32 Helper_Get_EA_UX(const PowerPC::PowerPCState& ppcs, const UGeckoInstr void Interpreter::lbz(Interpreter& interpreter, UGeckoInstruction inst) { - const u32 temp = PowerPC::Read_U8(Helper_Get_EA(PowerPC::ppcState, inst)); + auto& ppc_state = interpreter.m_ppc_state; + const u32 temp = PowerPC::Read_U8(Helper_Get_EA(ppc_state, inst)); - if (!(PowerPC::ppcState.Exceptions & EXCEPTION_DSI)) - PowerPC::ppcState.gpr[inst.RD] = temp; + if (!(ppc_state.Exceptions & EXCEPTION_DSI)) + ppc_state.gpr[inst.RD] = temp; } void Interpreter::lbzu(Interpreter& interpreter, UGeckoInstruction inst) { - const u32 address = Helper_Get_EA_U(PowerPC::ppcState, 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); - if (!(PowerPC::ppcState.Exceptions & EXCEPTION_DSI)) + if (!(ppc_state.Exceptions & EXCEPTION_DSI)) { - PowerPC::ppcState.gpr[inst.RD] = temp; - PowerPC::ppcState.gpr[inst.RA] = address; + ppc_state.gpr[inst.RD] = temp; + ppc_state.gpr[inst.RA] = address; } } void Interpreter::lfd(Interpreter& interpreter, UGeckoInstruction inst) { - const u32 address = Helper_Get_EA(PowerPC::ppcState, inst); + auto& ppc_state = interpreter.m_ppc_state; + const u32 address = Helper_Get_EA(ppc_state, inst); if ((address & 0b11) != 0) { @@ -69,13 +72,14 @@ void Interpreter::lfd(Interpreter& interpreter, UGeckoInstruction inst) const u64 temp = PowerPC::Read_U64(address); - if (!(PowerPC::ppcState.Exceptions & EXCEPTION_DSI)) - PowerPC::ppcState.ps[inst.FD].SetPS0(temp); + if (!(ppc_state.Exceptions & EXCEPTION_DSI)) + ppc_state.ps[inst.FD].SetPS0(temp); } void Interpreter::lfdu(Interpreter& interpreter, UGeckoInstruction inst) { - const u32 address = Helper_Get_EA_U(PowerPC::ppcState, inst); + auto& ppc_state = interpreter.m_ppc_state; + const u32 address = Helper_Get_EA_U(ppc_state, inst); if ((address & 0b11) != 0) { @@ -85,16 +89,17 @@ void Interpreter::lfdu(Interpreter& interpreter, UGeckoInstruction inst) const u64 temp = PowerPC::Read_U64(address); - if (!(PowerPC::ppcState.Exceptions & EXCEPTION_DSI)) + if (!(ppc_state.Exceptions & EXCEPTION_DSI)) { - PowerPC::ppcState.ps[inst.FD].SetPS0(temp); - PowerPC::ppcState.gpr[inst.RA] = address; + ppc_state.ps[inst.FD].SetPS0(temp); + ppc_state.gpr[inst.RA] = address; } } void Interpreter::lfdux(Interpreter& interpreter, UGeckoInstruction inst) { - const u32 address = Helper_Get_EA_UX(PowerPC::ppcState, inst); + auto& ppc_state = interpreter.m_ppc_state; + const u32 address = Helper_Get_EA_UX(ppc_state, inst); if ((address & 0b11) != 0) { @@ -104,16 +109,17 @@ void Interpreter::lfdux(Interpreter& interpreter, UGeckoInstruction inst) const u64 temp = PowerPC::Read_U64(address); - if (!(PowerPC::ppcState.Exceptions & EXCEPTION_DSI)) + if (!(ppc_state.Exceptions & EXCEPTION_DSI)) { - PowerPC::ppcState.ps[inst.FD].SetPS0(temp); - PowerPC::ppcState.gpr[inst.RA] = address; + ppc_state.ps[inst.FD].SetPS0(temp); + ppc_state.gpr[inst.RA] = address; } } void Interpreter::lfdx(Interpreter& interpreter, UGeckoInstruction inst) { - const u32 address = Helper_Get_EA_X(PowerPC::ppcState, inst); + auto& ppc_state = interpreter.m_ppc_state; + const u32 address = Helper_Get_EA_X(ppc_state, inst); if ((address & 0b11) != 0) { @@ -123,13 +129,14 @@ void Interpreter::lfdx(Interpreter& interpreter, UGeckoInstruction inst) const u64 temp = PowerPC::Read_U64(address); - if (!(PowerPC::ppcState.Exceptions & EXCEPTION_DSI)) - PowerPC::ppcState.ps[inst.FD].SetPS0(temp); + if (!(ppc_state.Exceptions & EXCEPTION_DSI)) + ppc_state.ps[inst.FD].SetPS0(temp); } void Interpreter::lfs(Interpreter& interpreter, UGeckoInstruction inst) { - const u32 address = Helper_Get_EA(PowerPC::ppcState, inst); + auto& ppc_state = interpreter.m_ppc_state; + const u32 address = Helper_Get_EA(ppc_state, inst); if ((address & 0b11) != 0) { @@ -139,16 +146,17 @@ void Interpreter::lfs(Interpreter& interpreter, UGeckoInstruction inst) const u32 temp = PowerPC::Read_U32(address); - if (!(PowerPC::ppcState.Exceptions & EXCEPTION_DSI)) + if (!(ppc_state.Exceptions & EXCEPTION_DSI)) { const u64 value = ConvertToDouble(temp); - PowerPC::ppcState.ps[inst.FD].Fill(value); + ppc_state.ps[inst.FD].Fill(value); } } void Interpreter::lfsu(Interpreter& interpreter, UGeckoInstruction inst) { - const u32 address = Helper_Get_EA_U(PowerPC::ppcState, inst); + auto& ppc_state = interpreter.m_ppc_state; + const u32 address = Helper_Get_EA_U(ppc_state, inst); if ((address & 0b11) != 0) { @@ -158,17 +166,18 @@ void Interpreter::lfsu(Interpreter& interpreter, UGeckoInstruction inst) const u32 temp = PowerPC::Read_U32(address); - if (!(PowerPC::ppcState.Exceptions & EXCEPTION_DSI)) + if (!(ppc_state.Exceptions & EXCEPTION_DSI)) { const u64 value = ConvertToDouble(temp); - PowerPC::ppcState.ps[inst.FD].Fill(value); - PowerPC::ppcState.gpr[inst.RA] = address; + ppc_state.ps[inst.FD].Fill(value); + ppc_state.gpr[inst.RA] = address; } } void Interpreter::lfsux(Interpreter& interpreter, UGeckoInstruction inst) { - const u32 address = Helper_Get_EA_UX(PowerPC::ppcState, inst); + auto& ppc_state = interpreter.m_ppc_state; + const u32 address = Helper_Get_EA_UX(ppc_state, inst); if ((address & 0b11) != 0) { @@ -178,17 +187,18 @@ void Interpreter::lfsux(Interpreter& interpreter, UGeckoInstruction inst) const u32 temp = PowerPC::Read_U32(address); - if (!(PowerPC::ppcState.Exceptions & EXCEPTION_DSI)) + if (!(ppc_state.Exceptions & EXCEPTION_DSI)) { const u64 value = ConvertToDouble(temp); - PowerPC::ppcState.ps[inst.FD].Fill(value); - PowerPC::ppcState.gpr[inst.RA] = address; + ppc_state.ps[inst.FD].Fill(value); + ppc_state.gpr[inst.RA] = address; } } void Interpreter::lfsx(Interpreter& interpreter, UGeckoInstruction inst) { - const u32 address = Helper_Get_EA_X(PowerPC::ppcState, inst); + auto& ppc_state = interpreter.m_ppc_state; + const u32 address = Helper_Get_EA_X(ppc_state, inst); if ((address & 0b11) != 0) { @@ -198,63 +208,68 @@ void Interpreter::lfsx(Interpreter& interpreter, UGeckoInstruction inst) const u32 temp = PowerPC::Read_U32(address); - if (!(PowerPC::ppcState.Exceptions & EXCEPTION_DSI)) + if (!(ppc_state.Exceptions & EXCEPTION_DSI)) { const u64 value = ConvertToDouble(temp); - PowerPC::ppcState.ps[inst.FD].Fill(value); + ppc_state.ps[inst.FD].Fill(value); } } void Interpreter::lha(Interpreter& interpreter, UGeckoInstruction inst) { - const u32 temp = u32(s32(s16(PowerPC::Read_U16(Helper_Get_EA(PowerPC::ppcState, inst))))); + auto& ppc_state = interpreter.m_ppc_state; + const u32 temp = u32(s32(s16(PowerPC::Read_U16(Helper_Get_EA(ppc_state, inst))))); - if (!(PowerPC::ppcState.Exceptions & EXCEPTION_DSI)) + if (!(ppc_state.Exceptions & EXCEPTION_DSI)) { - PowerPC::ppcState.gpr[inst.RD] = temp; + ppc_state.gpr[inst.RD] = temp; } } void Interpreter::lhau(Interpreter& interpreter, UGeckoInstruction inst) { - const u32 address = Helper_Get_EA_U(PowerPC::ppcState, 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)))); - if (!(PowerPC::ppcState.Exceptions & EXCEPTION_DSI)) + if (!(ppc_state.Exceptions & EXCEPTION_DSI)) { - PowerPC::ppcState.gpr[inst.RD] = temp; - PowerPC::ppcState.gpr[inst.RA] = address; + ppc_state.gpr[inst.RD] = temp; + ppc_state.gpr[inst.RA] = address; } } void Interpreter::lhz(Interpreter& interpreter, UGeckoInstruction inst) { - const u32 temp = PowerPC::Read_U16(Helper_Get_EA(PowerPC::ppcState, inst)); + auto& ppc_state = interpreter.m_ppc_state; + const u32 temp = PowerPC::Read_U16(Helper_Get_EA(ppc_state, inst)); - if (!(PowerPC::ppcState.Exceptions & EXCEPTION_DSI)) + if (!(ppc_state.Exceptions & EXCEPTION_DSI)) { - PowerPC::ppcState.gpr[inst.RD] = temp; + ppc_state.gpr[inst.RD] = temp; } } void Interpreter::lhzu(Interpreter& interpreter, UGeckoInstruction inst) { - const u32 address = Helper_Get_EA_U(PowerPC::ppcState, 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); - if (!(PowerPC::ppcState.Exceptions & EXCEPTION_DSI)) + if (!(ppc_state.Exceptions & EXCEPTION_DSI)) { - PowerPC::ppcState.gpr[inst.RD] = temp; - PowerPC::ppcState.gpr[inst.RA] = address; + ppc_state.gpr[inst.RD] = temp; + ppc_state.gpr[inst.RA] = address; } } // FIXME: lmw should do a total rollback if a DSI occurs void Interpreter::lmw(Interpreter& interpreter, UGeckoInstruction inst) { - u32 address = Helper_Get_EA(PowerPC::ppcState, inst); + auto& ppc_state = interpreter.m_ppc_state; + u32 address = Helper_Get_EA(ppc_state, inst); - if ((address & 0b11) != 0 || PowerPC::ppcState.msr.LE) + if ((address & 0b11) != 0 || ppc_state.msr.LE) { GenerateAlignmentException(address); return; @@ -264,7 +279,7 @@ void Interpreter::lmw(Interpreter& interpreter, UGeckoInstruction inst) { const u32 temp_reg = PowerPC::Read_U32(address); - if ((PowerPC::ppcState.Exceptions & EXCEPTION_DSI) != 0) + if ((ppc_state.Exceptions & EXCEPTION_DSI) != 0) { PanicAlertFmt("DSI exception in lmw"); NOTICE_LOG_FMT(POWERPC, "DSI exception in lmw"); @@ -272,7 +287,7 @@ void Interpreter::lmw(Interpreter& interpreter, UGeckoInstruction inst) } else { - PowerPC::ppcState.gpr[i] = temp_reg; + ppc_state.gpr[i] = temp_reg; } } } @@ -280,9 +295,10 @@ void Interpreter::lmw(Interpreter& interpreter, UGeckoInstruction inst) // FIXME: stmw should do a total rollback if a DSI occurs void Interpreter::stmw(Interpreter& interpreter, UGeckoInstruction inst) { - u32 address = Helper_Get_EA(PowerPC::ppcState, inst); + auto& ppc_state = interpreter.m_ppc_state; + u32 address = Helper_Get_EA(ppc_state, inst); - if ((address & 0b11) != 0 || PowerPC::ppcState.msr.LE) + if ((address & 0b11) != 0 || ppc_state.msr.LE) { GenerateAlignmentException(address); return; @@ -290,8 +306,8 @@ void Interpreter::stmw(Interpreter& interpreter, UGeckoInstruction inst) for (u32 i = inst.RS; i <= 31; i++, address += 4) { - PowerPC::Write_U32(PowerPC::ppcState.gpr[i], address); - if ((PowerPC::ppcState.Exceptions & EXCEPTION_DSI) != 0) + PowerPC::Write_U32(ppc_state.gpr[i], address); + if ((ppc_state.Exceptions & EXCEPTION_DSI) != 0) { PanicAlertFmt("DSI exception in stmw"); NOTICE_LOG_FMT(POWERPC, "DSI exception in stmw"); @@ -302,46 +318,51 @@ void Interpreter::stmw(Interpreter& interpreter, UGeckoInstruction inst) void Interpreter::lwz(Interpreter& interpreter, UGeckoInstruction inst) { - const u32 address = Helper_Get_EA(PowerPC::ppcState, inst); + auto& ppc_state = interpreter.m_ppc_state; + const u32 address = Helper_Get_EA(ppc_state, inst); const u32 temp = PowerPC::Read_U32(address); - if (!(PowerPC::ppcState.Exceptions & EXCEPTION_DSI)) + if (!(ppc_state.Exceptions & EXCEPTION_DSI)) { - PowerPC::ppcState.gpr[inst.RD] = temp; + ppc_state.gpr[inst.RD] = temp; } } void Interpreter::lwzu(Interpreter& interpreter, UGeckoInstruction inst) { - const u32 address = Helper_Get_EA_U(PowerPC::ppcState, 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); - if (!(PowerPC::ppcState.Exceptions & EXCEPTION_DSI)) + if (!(ppc_state.Exceptions & EXCEPTION_DSI)) { - PowerPC::ppcState.gpr[inst.RD] = temp; - PowerPC::ppcState.gpr[inst.RA] = address; + ppc_state.gpr[inst.RD] = temp; + ppc_state.gpr[inst.RA] = address; } } void Interpreter::stb(Interpreter& interpreter, UGeckoInstruction inst) { - PowerPC::Write_U8(PowerPC::ppcState.gpr[inst.RS], Helper_Get_EA(PowerPC::ppcState, inst)); + auto& ppc_state = interpreter.m_ppc_state; + PowerPC::Write_U8(ppc_state.gpr[inst.RS], Helper_Get_EA(ppc_state, inst)); } void Interpreter::stbu(Interpreter& interpreter, UGeckoInstruction inst) { - const u32 address = Helper_Get_EA_U(PowerPC::ppcState, inst); + auto& ppc_state = interpreter.m_ppc_state; + const u32 address = Helper_Get_EA_U(ppc_state, inst); - PowerPC::Write_U8(PowerPC::ppcState.gpr[inst.RS], address); - if (!(PowerPC::ppcState.Exceptions & EXCEPTION_DSI)) + PowerPC::Write_U8(ppc_state.gpr[inst.RS], address); + if (!(ppc_state.Exceptions & EXCEPTION_DSI)) { - PowerPC::ppcState.gpr[inst.RA] = address; + ppc_state.gpr[inst.RA] = address; } } void Interpreter::stfd(Interpreter& interpreter, UGeckoInstruction inst) { - const u32 address = Helper_Get_EA(PowerPC::ppcState, inst); + auto& ppc_state = interpreter.m_ppc_state; + const u32 address = Helper_Get_EA(ppc_state, inst); if ((address & 0b11) != 0) { @@ -349,12 +370,13 @@ void Interpreter::stfd(Interpreter& interpreter, UGeckoInstruction inst) return; } - PowerPC::Write_U64(PowerPC::ppcState.ps[inst.FS].PS0AsU64(), address); + PowerPC::Write_U64(ppc_state.ps[inst.FS].PS0AsU64(), address); } void Interpreter::stfdu(Interpreter& interpreter, UGeckoInstruction inst) { - const u32 address = Helper_Get_EA_U(PowerPC::ppcState, inst); + auto& ppc_state = interpreter.m_ppc_state; + const u32 address = Helper_Get_EA_U(ppc_state, inst); if ((address & 0b11) != 0) { @@ -362,16 +384,17 @@ void Interpreter::stfdu(Interpreter& interpreter, UGeckoInstruction inst) return; } - PowerPC::Write_U64(PowerPC::ppcState.ps[inst.FS].PS0AsU64(), address); - if (!(PowerPC::ppcState.Exceptions & EXCEPTION_DSI)) + PowerPC::Write_U64(ppc_state.ps[inst.FS].PS0AsU64(), address); + if (!(ppc_state.Exceptions & EXCEPTION_DSI)) { - PowerPC::ppcState.gpr[inst.RA] = address; + ppc_state.gpr[inst.RA] = address; } } void Interpreter::stfs(Interpreter& interpreter, UGeckoInstruction inst) { - const u32 address = Helper_Get_EA(PowerPC::ppcState, inst); + auto& ppc_state = interpreter.m_ppc_state; + const u32 address = Helper_Get_EA(ppc_state, inst); if ((address & 0b11) != 0) { @@ -379,12 +402,13 @@ void Interpreter::stfs(Interpreter& interpreter, UGeckoInstruction inst) return; } - PowerPC::Write_U32(ConvertToSingle(PowerPC::ppcState.ps[inst.FS].PS0AsU64()), address); + PowerPC::Write_U32(ConvertToSingle(ppc_state.ps[inst.FS].PS0AsU64()), address); } void Interpreter::stfsu(Interpreter& interpreter, UGeckoInstruction inst) { - const u32 address = Helper_Get_EA_U(PowerPC::ppcState, inst); + auto& ppc_state = interpreter.m_ppc_state; + const u32 address = Helper_Get_EA_U(ppc_state, inst); if ((address & 0b11) != 0) { @@ -392,42 +416,46 @@ void Interpreter::stfsu(Interpreter& interpreter, UGeckoInstruction inst) return; } - PowerPC::Write_U32(ConvertToSingle(PowerPC::ppcState.ps[inst.FS].PS0AsU64()), address); - if (!(PowerPC::ppcState.Exceptions & EXCEPTION_DSI)) + PowerPC::Write_U32(ConvertToSingle(ppc_state.ps[inst.FS].PS0AsU64()), address); + if (!(ppc_state.Exceptions & EXCEPTION_DSI)) { - PowerPC::ppcState.gpr[inst.RA] = address; + ppc_state.gpr[inst.RA] = address; } } void Interpreter::sth(Interpreter& interpreter, UGeckoInstruction inst) { - PowerPC::Write_U16(PowerPC::ppcState.gpr[inst.RS], Helper_Get_EA(PowerPC::ppcState, inst)); + auto& ppc_state = interpreter.m_ppc_state; + PowerPC::Write_U16(ppc_state.gpr[inst.RS], Helper_Get_EA(ppc_state, inst)); } void Interpreter::sthu(Interpreter& interpreter, UGeckoInstruction inst) { - const u32 address = Helper_Get_EA_U(PowerPC::ppcState, inst); + auto& ppc_state = interpreter.m_ppc_state; + const u32 address = Helper_Get_EA_U(ppc_state, inst); - PowerPC::Write_U16(PowerPC::ppcState.gpr[inst.RS], address); - if (!(PowerPC::ppcState.Exceptions & EXCEPTION_DSI)) + PowerPC::Write_U16(ppc_state.gpr[inst.RS], address); + if (!(ppc_state.Exceptions & EXCEPTION_DSI)) { - PowerPC::ppcState.gpr[inst.RA] = address; + ppc_state.gpr[inst.RA] = address; } } void Interpreter::stw(Interpreter& interpreter, UGeckoInstruction inst) { - PowerPC::Write_U32(PowerPC::ppcState.gpr[inst.RS], Helper_Get_EA(PowerPC::ppcState, inst)); + auto& ppc_state = interpreter.m_ppc_state; + PowerPC::Write_U32(ppc_state.gpr[inst.RS], Helper_Get_EA(ppc_state, inst)); } void Interpreter::stwu(Interpreter& interpreter, UGeckoInstruction inst) { - const u32 address = Helper_Get_EA_U(PowerPC::ppcState, inst); + auto& ppc_state = interpreter.m_ppc_state; + const u32 address = Helper_Get_EA_U(ppc_state, inst); - PowerPC::Write_U32(PowerPC::ppcState.gpr[inst.RS], address); - if (!(PowerPC::ppcState.Exceptions & EXCEPTION_DSI)) + PowerPC::Write_U32(ppc_state.gpr[inst.RS], address); + if (!(ppc_state.Exceptions & EXCEPTION_DSI)) { - PowerPC::ppcState.gpr[inst.RA] = address; + ppc_state.gpr[inst.RA] = address; } } @@ -438,8 +466,9 @@ void Interpreter::dcba(Interpreter& interpreter, UGeckoInstruction inst) void Interpreter::dcbf(Interpreter& interpreter, UGeckoInstruction inst) { - const u32 address = Helper_Get_EA_X(PowerPC::ppcState, inst); - if (!PowerPC::ppcState.m_enable_dcache) + auto& ppc_state = interpreter.m_ppc_state; + const u32 address = Helper_Get_EA_X(ppc_state, inst); + if (!ppc_state.m_enable_dcache) { // Invalidate the JIT cache here as a heuristic to compensate for // the lack of precise L1 icache emulation in the JIT. (Portable software @@ -453,14 +482,15 @@ void Interpreter::dcbf(Interpreter& interpreter, UGeckoInstruction inst) void Interpreter::dcbi(Interpreter& interpreter, UGeckoInstruction inst) { - if (PowerPC::ppcState.msr.PR) + auto& ppc_state = interpreter.m_ppc_state; + if (ppc_state.msr.PR) { GenerateProgramException(ProgramExceptionCause::PrivilegedInstruction); return; } - const u32 address = Helper_Get_EA_X(PowerPC::ppcState, inst); - if (!PowerPC::ppcState.m_enable_dcache) + const u32 address = Helper_Get_EA_X(ppc_state, inst); + if (!ppc_state.m_enable_dcache) { // Invalidate the JIT cache here as a heuristic to compensate for // the lack of precise L1 icache emulation in the JIT. (Portable software @@ -474,8 +504,9 @@ void Interpreter::dcbi(Interpreter& interpreter, UGeckoInstruction inst) void Interpreter::dcbst(Interpreter& interpreter, UGeckoInstruction inst) { - const u32 address = Helper_Get_EA_X(PowerPC::ppcState, inst); - if (!PowerPC::ppcState.m_enable_dcache) + auto& ppc_state = interpreter.m_ppc_state; + const u32 address = Helper_Get_EA_X(ppc_state, inst); + if (!ppc_state.m_enable_dcache) { // Invalidate the JIT cache here as a heuristic to compensate for // the lack of precise L1 icache emulation in the JIT. (Portable software @@ -501,15 +532,16 @@ void Interpreter::dcbtst(Interpreter& interpreter, UGeckoInstruction inst) void Interpreter::dcbz(Interpreter& interpreter, UGeckoInstruction inst) { - const u32 dcbz_addr = Helper_Get_EA_X(PowerPC::ppcState, inst); + auto& ppc_state = interpreter.m_ppc_state; + const u32 dcbz_addr = Helper_Get_EA_X(ppc_state, inst); - if (!HID0(PowerPC::ppcState).DCE) + if (!HID0(ppc_state).DCE) { GenerateAlignmentException(dcbz_addr); return; } - if (!PowerPC::ppcState.m_enable_dcache) + if (!ppc_state.m_enable_dcache) { // Hack to stop dcbz/dcbi over low MEM1 trashing memory. This is not needed if data cache // emulation is enabled. @@ -525,15 +557,16 @@ void Interpreter::dcbz(Interpreter& interpreter, UGeckoInstruction inst) void Interpreter::dcbz_l(Interpreter& interpreter, UGeckoInstruction inst) { - if (!HID2(PowerPC::ppcState).LCE) + auto& ppc_state = interpreter.m_ppc_state; + if (!HID2(ppc_state).LCE) { GenerateProgramException(ProgramExceptionCause::IllegalInstruction); return; } - const u32 address = Helper_Get_EA_X(PowerPC::ppcState, inst); + const u32 address = Helper_Get_EA_X(ppc_state, inst); - if (!HID0(PowerPC::ppcState).DCE) + if (!HID0(ppc_state).DCE) { GenerateAlignmentException(address); return; @@ -546,9 +579,10 @@ void Interpreter::dcbz_l(Interpreter& interpreter, UGeckoInstruction inst) // We just do it instantly from ppc...and hey, it works! :D void Interpreter::eciwx(Interpreter& interpreter, UGeckoInstruction inst) { - const u32 EA = Helper_Get_EA_X(PowerPC::ppcState, inst); + auto& ppc_state = interpreter.m_ppc_state; + const u32 EA = Helper_Get_EA_X(ppc_state, inst); - if ((PowerPC::ppcState.spr[SPR_EAR] & 0x80000000) == 0) + if ((ppc_state.spr[SPR_EAR] & 0x80000000) == 0) { GenerateDSIException(EA); return; @@ -560,14 +594,15 @@ void Interpreter::eciwx(Interpreter& interpreter, UGeckoInstruction inst) return; } - PowerPC::ppcState.gpr[inst.RD] = PowerPC::Read_U32(EA); + ppc_state.gpr[inst.RD] = PowerPC::Read_U32(EA); } void Interpreter::ecowx(Interpreter& interpreter, UGeckoInstruction inst) { - const u32 EA = Helper_Get_EA_X(PowerPC::ppcState, inst); + auto& ppc_state = interpreter.m_ppc_state; + const u32 EA = Helper_Get_EA_X(ppc_state, inst); - if ((PowerPC::ppcState.spr[SPR_EAR] & 0x80000000) == 0) + if ((ppc_state.spr[SPR_EAR] & 0x80000000) == 0) { GenerateDSIException(EA); return; @@ -579,7 +614,7 @@ void Interpreter::ecowx(Interpreter& interpreter, UGeckoInstruction inst) return; } - PowerPC::Write_U32(PowerPC::ppcState.gpr[inst.RS], EA); + PowerPC::Write_U32(ppc_state.gpr[inst.RS], EA); } void Interpreter::eieio(Interpreter& interpreter, UGeckoInstruction inst) @@ -593,114 +628,123 @@ void Interpreter::eieio(Interpreter& interpreter, UGeckoInstruction inst) void Interpreter::icbi(Interpreter& interpreter, UGeckoInstruction inst) { // TODO: Raise DSI if translation fails (except for direct-store segments). - const u32 address = Helper_Get_EA_X(PowerPC::ppcState, inst); - PowerPC::ppcState.iCache.Invalidate(address); + auto& ppc_state = interpreter.m_ppc_state; + const u32 address = Helper_Get_EA_X(ppc_state, inst); + ppc_state.iCache.Invalidate(address); } void Interpreter::lbzux(Interpreter& interpreter, UGeckoInstruction inst) { - const u32 address = Helper_Get_EA_UX(PowerPC::ppcState, 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); - if (!(PowerPC::ppcState.Exceptions & EXCEPTION_DSI)) + if (!(ppc_state.Exceptions & EXCEPTION_DSI)) { - PowerPC::ppcState.gpr[inst.RD] = temp; - PowerPC::ppcState.gpr[inst.RA] = address; + ppc_state.gpr[inst.RD] = temp; + ppc_state.gpr[inst.RA] = address; } } void Interpreter::lbzx(Interpreter& interpreter, UGeckoInstruction inst) { - const u32 temp = PowerPC::Read_U8(Helper_Get_EA_X(PowerPC::ppcState, inst)); + auto& ppc_state = interpreter.m_ppc_state; + const u32 temp = PowerPC::Read_U8(Helper_Get_EA_X(ppc_state, inst)); - if (!(PowerPC::ppcState.Exceptions & EXCEPTION_DSI)) + if (!(ppc_state.Exceptions & EXCEPTION_DSI)) { - PowerPC::ppcState.gpr[inst.RD] = temp; + ppc_state.gpr[inst.RD] = temp; } } void Interpreter::lhaux(Interpreter& interpreter, UGeckoInstruction inst) { - const u32 address = Helper_Get_EA_UX(PowerPC::ppcState, 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))}; - if (!(PowerPC::ppcState.Exceptions & EXCEPTION_DSI)) + if (!(ppc_state.Exceptions & EXCEPTION_DSI)) { - PowerPC::ppcState.gpr[inst.RD] = u32(temp); - PowerPC::ppcState.gpr[inst.RA] = address; + ppc_state.gpr[inst.RD] = u32(temp); + ppc_state.gpr[inst.RA] = address; } } void Interpreter::lhax(Interpreter& interpreter, UGeckoInstruction inst) { - const s32 temp = s32{s16(PowerPC::Read_U16(Helper_Get_EA_X(PowerPC::ppcState, inst)))}; + auto& ppc_state = interpreter.m_ppc_state; + const s32 temp = s32{s16(PowerPC::Read_U16(Helper_Get_EA_X(ppc_state, inst)))}; - if (!(PowerPC::ppcState.Exceptions & EXCEPTION_DSI)) + if (!(ppc_state.Exceptions & EXCEPTION_DSI)) { - PowerPC::ppcState.gpr[inst.RD] = u32(temp); + ppc_state.gpr[inst.RD] = u32(temp); } } void Interpreter::lhbrx(Interpreter& interpreter, UGeckoInstruction inst) { - const u32 temp = Common::swap16(PowerPC::Read_U16(Helper_Get_EA_X(PowerPC::ppcState, inst))); + auto& ppc_state = interpreter.m_ppc_state; + const u32 temp = Common::swap16(PowerPC::Read_U16(Helper_Get_EA_X(ppc_state, inst))); - if (!(PowerPC::ppcState.Exceptions & EXCEPTION_DSI)) + if (!(ppc_state.Exceptions & EXCEPTION_DSI)) { - PowerPC::ppcState.gpr[inst.RD] = temp; + ppc_state.gpr[inst.RD] = temp; } } void Interpreter::lhzux(Interpreter& interpreter, UGeckoInstruction inst) { - const u32 address = Helper_Get_EA_UX(PowerPC::ppcState, 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); - if (!(PowerPC::ppcState.Exceptions & EXCEPTION_DSI)) + if (!(ppc_state.Exceptions & EXCEPTION_DSI)) { - PowerPC::ppcState.gpr[inst.RD] = temp; - PowerPC::ppcState.gpr[inst.RA] = address; + ppc_state.gpr[inst.RD] = temp; + ppc_state.gpr[inst.RA] = address; } } void Interpreter::lhzx(Interpreter& interpreter, UGeckoInstruction inst) { - const u32 temp = PowerPC::Read_U16(Helper_Get_EA_X(PowerPC::ppcState, inst)); + auto& ppc_state = interpreter.m_ppc_state; + const u32 temp = PowerPC::Read_U16(Helper_Get_EA_X(ppc_state, inst)); - if (!(PowerPC::ppcState.Exceptions & EXCEPTION_DSI)) + if (!(ppc_state.Exceptions & EXCEPTION_DSI)) { - PowerPC::ppcState.gpr[inst.RD] = temp; + ppc_state.gpr[inst.RD] = temp; } } // FIXME: Should rollback if a DSI occurs void Interpreter::lswx(Interpreter& interpreter, UGeckoInstruction inst) { - u32 EA = Helper_Get_EA_X(PowerPC::ppcState, inst); + auto& ppc_state = interpreter.m_ppc_state; + u32 EA = Helper_Get_EA_X(ppc_state, inst); - if (PowerPC::ppcState.msr.LE) + if (ppc_state.msr.LE) { GenerateAlignmentException(EA); return; } // Confirmed by hardware test that the zero case doesn't zero gpr[r] - for (u32 n = 0; n < static_cast(PowerPC::ppcState.xer_stringctrl); n++) + for (u32 n = 0; n < static_cast(ppc_state.xer_stringctrl); n++) { const u32 reg = (inst.RD + (n >> 2)) & 0x1f; const u32 offset = (n & 3) << 3; if ((n & 0b11) == 0) - PowerPC::ppcState.gpr[reg] = 0; + ppc_state.gpr[reg] = 0; const u32 temp_value = PowerPC::Read_U8(EA) << (24 - offset); // Not64 (Homebrew N64 Emulator for Wii) triggers the following case. - if ((PowerPC::ppcState.Exceptions & EXCEPTION_DSI) != 0) + if ((ppc_state.Exceptions & EXCEPTION_DSI) != 0) { NOTICE_LOG_FMT(POWERPC, "DSI exception in lswx"); return; } - PowerPC::ppcState.gpr[reg] |= temp_value; + ppc_state.gpr[reg] |= temp_value; EA++; } @@ -708,56 +752,62 @@ void Interpreter::lswx(Interpreter& interpreter, UGeckoInstruction inst) void Interpreter::lwbrx(Interpreter& interpreter, UGeckoInstruction inst) { - const u32 temp = Common::swap32(PowerPC::Read_U32(Helper_Get_EA_X(PowerPC::ppcState, inst))); + auto& ppc_state = interpreter.m_ppc_state; + const u32 temp = Common::swap32(PowerPC::Read_U32(Helper_Get_EA_X(ppc_state, inst))); - if (!(PowerPC::ppcState.Exceptions & EXCEPTION_DSI)) + if (!(ppc_state.Exceptions & EXCEPTION_DSI)) { - PowerPC::ppcState.gpr[inst.RD] = temp; + ppc_state.gpr[inst.RD] = temp; } } void Interpreter::lwzux(Interpreter& interpreter, UGeckoInstruction inst) { - const u32 address = Helper_Get_EA_UX(PowerPC::ppcState, 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); - if (!(PowerPC::ppcState.Exceptions & EXCEPTION_DSI)) + if (!(ppc_state.Exceptions & EXCEPTION_DSI)) { - PowerPC::ppcState.gpr[inst.RD] = temp; - PowerPC::ppcState.gpr[inst.RA] = address; + ppc_state.gpr[inst.RD] = temp; + ppc_state.gpr[inst.RA] = address; } } void Interpreter::lwzx(Interpreter& interpreter, UGeckoInstruction inst) { - const u32 address = Helper_Get_EA_X(PowerPC::ppcState, 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); - if (!(PowerPC::ppcState.Exceptions & EXCEPTION_DSI)) + if (!(ppc_state.Exceptions & EXCEPTION_DSI)) { - PowerPC::ppcState.gpr[inst.RD] = temp; + ppc_state.gpr[inst.RD] = temp; } } void Interpreter::stbux(Interpreter& interpreter, UGeckoInstruction inst) { - const u32 address = Helper_Get_EA_UX(PowerPC::ppcState, inst); + auto& ppc_state = interpreter.m_ppc_state; + const u32 address = Helper_Get_EA_UX(ppc_state, inst); - PowerPC::Write_U8(PowerPC::ppcState.gpr[inst.RS], address); - if (!(PowerPC::ppcState.Exceptions & EXCEPTION_DSI)) + PowerPC::Write_U8(ppc_state.gpr[inst.RS], address); + if (!(ppc_state.Exceptions & EXCEPTION_DSI)) { - PowerPC::ppcState.gpr[inst.RA] = address; + ppc_state.gpr[inst.RA] = address; } } void Interpreter::stbx(Interpreter& interpreter, UGeckoInstruction inst) { - PowerPC::Write_U8(PowerPC::ppcState.gpr[inst.RS], Helper_Get_EA_X(PowerPC::ppcState, inst)); + auto& ppc_state = interpreter.m_ppc_state; + PowerPC::Write_U8(ppc_state.gpr[inst.RS], Helper_Get_EA_X(ppc_state, inst)); } void Interpreter::stfdux(Interpreter& interpreter, UGeckoInstruction inst) { - const u32 address = Helper_Get_EA_UX(PowerPC::ppcState, inst); + auto& ppc_state = interpreter.m_ppc_state; + const u32 address = Helper_Get_EA_UX(ppc_state, inst); if ((address & 0b11) != 0) { @@ -765,16 +815,17 @@ void Interpreter::stfdux(Interpreter& interpreter, UGeckoInstruction inst) return; } - PowerPC::Write_U64(PowerPC::ppcState.ps[inst.FS].PS0AsU64(), address); - if (!(PowerPC::ppcState.Exceptions & EXCEPTION_DSI)) + PowerPC::Write_U64(ppc_state.ps[inst.FS].PS0AsU64(), address); + if (!(ppc_state.Exceptions & EXCEPTION_DSI)) { - PowerPC::ppcState.gpr[inst.RA] = address; + ppc_state.gpr[inst.RA] = address; } } void Interpreter::stfdx(Interpreter& interpreter, UGeckoInstruction inst) { - const u32 address = Helper_Get_EA_X(PowerPC::ppcState, inst); + auto& ppc_state = interpreter.m_ppc_state; + const u32 address = Helper_Get_EA_X(ppc_state, inst); if ((address & 0b11) != 0) { @@ -782,13 +833,14 @@ void Interpreter::stfdx(Interpreter& interpreter, UGeckoInstruction inst) return; } - PowerPC::Write_U64(PowerPC::ppcState.ps[inst.FS].PS0AsU64(), address); + PowerPC::Write_U64(ppc_state.ps[inst.FS].PS0AsU64(), address); } // Stores Floating points into Integers indeXed void Interpreter::stfiwx(Interpreter& interpreter, UGeckoInstruction inst) { - const u32 address = Helper_Get_EA_X(PowerPC::ppcState, inst); + auto& ppc_state = interpreter.m_ppc_state; + const u32 address = Helper_Get_EA_X(ppc_state, inst); if ((address & 0b11) != 0) { @@ -796,12 +848,13 @@ void Interpreter::stfiwx(Interpreter& interpreter, UGeckoInstruction inst) return; } - PowerPC::Write_U32(PowerPC::ppcState.ps[inst.FS].PS0AsU32(), address); + PowerPC::Write_U32(ppc_state.ps[inst.FS].PS0AsU32(), address); } void Interpreter::stfsux(Interpreter& interpreter, UGeckoInstruction inst) { - const u32 address = Helper_Get_EA_UX(PowerPC::ppcState, inst); + auto& ppc_state = interpreter.m_ppc_state; + const u32 address = Helper_Get_EA_UX(ppc_state, inst); if ((address & 0b11) != 0) { @@ -809,16 +862,17 @@ void Interpreter::stfsux(Interpreter& interpreter, UGeckoInstruction inst) return; } - PowerPC::Write_U32(ConvertToSingle(PowerPC::ppcState.ps[inst.FS].PS0AsU64()), address); - if (!(PowerPC::ppcState.Exceptions & EXCEPTION_DSI)) + PowerPC::Write_U32(ConvertToSingle(ppc_state.ps[inst.FS].PS0AsU64()), address); + if (!(ppc_state.Exceptions & EXCEPTION_DSI)) { - PowerPC::ppcState.gpr[inst.RA] = address; + ppc_state.gpr[inst.RA] = address; } } void Interpreter::stfsx(Interpreter& interpreter, UGeckoInstruction inst) { - const u32 address = Helper_Get_EA_X(PowerPC::ppcState, inst); + auto& ppc_state = interpreter.m_ppc_state; + const u32 address = Helper_Get_EA_X(ppc_state, inst); if ((address & 0b11) != 0) { @@ -826,39 +880,43 @@ void Interpreter::stfsx(Interpreter& interpreter, UGeckoInstruction inst) return; } - PowerPC::Write_U32(ConvertToSingle(PowerPC::ppcState.ps[inst.FS].PS0AsU64()), address); + PowerPC::Write_U32(ConvertToSingle(ppc_state.ps[inst.FS].PS0AsU64()), address); } void Interpreter::sthbrx(Interpreter& interpreter, UGeckoInstruction inst) { - PowerPC::Write_U16_Swap(PowerPC::ppcState.gpr[inst.RS], Helper_Get_EA_X(PowerPC::ppcState, inst)); + auto& ppc_state = interpreter.m_ppc_state; + PowerPC::Write_U16_Swap(ppc_state.gpr[inst.RS], Helper_Get_EA_X(ppc_state, inst)); } void Interpreter::sthux(Interpreter& interpreter, UGeckoInstruction inst) { - const u32 address = Helper_Get_EA_UX(PowerPC::ppcState, inst); + auto& ppc_state = interpreter.m_ppc_state; + const u32 address = Helper_Get_EA_UX(ppc_state, inst); - PowerPC::Write_U16(PowerPC::ppcState.gpr[inst.RS], address); - if (!(PowerPC::ppcState.Exceptions & EXCEPTION_DSI)) + PowerPC::Write_U16(ppc_state.gpr[inst.RS], address); + if (!(ppc_state.Exceptions & EXCEPTION_DSI)) { - PowerPC::ppcState.gpr[inst.RA] = address; + ppc_state.gpr[inst.RA] = address; } } void Interpreter::sthx(Interpreter& interpreter, UGeckoInstruction inst) { - PowerPC::Write_U16(PowerPC::ppcState.gpr[inst.RS], Helper_Get_EA_X(PowerPC::ppcState, inst)); + auto& ppc_state = interpreter.m_ppc_state; + PowerPC::Write_U16(ppc_state.gpr[inst.RS], Helper_Get_EA_X(ppc_state, inst)); } // lswi - bizarro string instruction // FIXME: Should rollback if a DSI occurs void Interpreter::lswi(Interpreter& interpreter, UGeckoInstruction inst) { + auto& ppc_state = interpreter.m_ppc_state; u32 EA = 0; if (inst.RA != 0) - EA = PowerPC::ppcState.gpr[inst.RA]; + EA = ppc_state.gpr[inst.RA]; - if (PowerPC::ppcState.msr.LE) + if (ppc_state.msr.LE) { GenerateAlignmentException(EA); return; @@ -876,17 +934,17 @@ void Interpreter::lswi(Interpreter& interpreter, UGeckoInstruction inst) { r++; r &= 31; - PowerPC::ppcState.gpr[r] = 0; + ppc_state.gpr[r] = 0; } const u32 temp_value = PowerPC::Read_U8(EA) << (24 - i); - if ((PowerPC::ppcState.Exceptions & EXCEPTION_DSI) != 0) + if ((ppc_state.Exceptions & EXCEPTION_DSI) != 0) { PanicAlertFmt("DSI exception in lsw."); return; } - PowerPC::ppcState.gpr[r] |= temp_value; + ppc_state.gpr[r] |= temp_value; i += 8; if (i == 32) @@ -901,11 +959,12 @@ void Interpreter::lswi(Interpreter& interpreter, UGeckoInstruction inst) // FIXME: Should rollback if a DSI occurs void Interpreter::stswi(Interpreter& interpreter, UGeckoInstruction inst) { + auto& ppc_state = interpreter.m_ppc_state; u32 EA = 0; if (inst.RA != 0) - EA = PowerPC::ppcState.gpr[inst.RA]; + EA = ppc_state.gpr[inst.RA]; - if (PowerPC::ppcState.msr.LE) + if (ppc_state.msr.LE) { GenerateAlignmentException(EA); return; @@ -924,8 +983,8 @@ void Interpreter::stswi(Interpreter& interpreter, UGeckoInstruction inst) r++; r &= 31; } - PowerPC::Write_U8((PowerPC::ppcState.gpr[r] >> (24 - i)) & 0xFF, EA); - if ((PowerPC::ppcState.Exceptions & EXCEPTION_DSI) != 0) + PowerPC::Write_U8((ppc_state.gpr[r] >> (24 - i)) & 0xFF, EA); + if ((ppc_state.Exceptions & EXCEPTION_DSI) != 0) { return; } @@ -941,21 +1000,22 @@ void Interpreter::stswi(Interpreter& interpreter, UGeckoInstruction inst) // TODO: is this right? is it DSI interruptible? void Interpreter::stswx(Interpreter& interpreter, UGeckoInstruction inst) { - u32 EA = Helper_Get_EA_X(PowerPC::ppcState, inst); + auto& ppc_state = interpreter.m_ppc_state; + u32 EA = Helper_Get_EA_X(ppc_state, inst); - if (PowerPC::ppcState.msr.LE) + if (ppc_state.msr.LE) { GenerateAlignmentException(EA); return; } - u32 n = u8(PowerPC::ppcState.xer_stringctrl); + u32 n = u8(ppc_state.xer_stringctrl); u32 r = inst.RS; u32 i = 0; while (n > 0) { - PowerPC::Write_U8((PowerPC::ppcState.gpr[r] >> (24 - i)) & 0xFF, EA); + PowerPC::Write_U8((ppc_state.gpr[r] >> (24 - i)) & 0xFF, EA); EA++; n--; @@ -970,9 +1030,10 @@ void Interpreter::stswx(Interpreter& interpreter, UGeckoInstruction inst) void Interpreter::stwbrx(Interpreter& interpreter, UGeckoInstruction inst) { - const u32 address = Helper_Get_EA_X(PowerPC::ppcState, inst); + auto& ppc_state = interpreter.m_ppc_state; + const u32 address = Helper_Get_EA_X(ppc_state, inst); - PowerPC::Write_U32_Swap(PowerPC::ppcState.gpr[inst.RS], address); + PowerPC::Write_U32_Swap(ppc_state.gpr[inst.RS], address); } // The following two instructions are for SMP communications. On a single @@ -980,7 +1041,8 @@ void Interpreter::stwbrx(Interpreter& interpreter, UGeckoInstruction inst) void Interpreter::lwarx(Interpreter& interpreter, UGeckoInstruction inst) { - const u32 address = Helper_Get_EA_X(PowerPC::ppcState, inst); + auto& ppc_state = interpreter.m_ppc_state; + const u32 address = Helper_Get_EA_X(ppc_state, inst); if ((address & 0b11) != 0) { @@ -990,18 +1052,19 @@ void Interpreter::lwarx(Interpreter& interpreter, UGeckoInstruction inst) const u32 temp = PowerPC::Read_U32(address); - if (!(PowerPC::ppcState.Exceptions & EXCEPTION_DSI)) + if (!(ppc_state.Exceptions & EXCEPTION_DSI)) { - PowerPC::ppcState.gpr[inst.RD] = temp; - PowerPC::ppcState.reserve = true; - PowerPC::ppcState.reserve_address = address; + ppc_state.gpr[inst.RD] = temp; + ppc_state.reserve = true; + ppc_state.reserve_address = address; } } // Stores Word Conditional indeXed void Interpreter::stwcxd(Interpreter& interpreter, UGeckoInstruction inst) { - const u32 address = Helper_Get_EA_X(PowerPC::ppcState, inst); + auto& ppc_state = interpreter.m_ppc_state; + const u32 address = Helper_Get_EA_X(ppc_state, inst); if ((address & 0b11) != 0) { @@ -1009,39 +1072,41 @@ void Interpreter::stwcxd(Interpreter& interpreter, UGeckoInstruction inst) return; } - if (PowerPC::ppcState.reserve) + if (ppc_state.reserve) { - if (address == PowerPC::ppcState.reserve_address) + if (address == ppc_state.reserve_address) { - PowerPC::Write_U32(PowerPC::ppcState.gpr[inst.RS], address); - if (!(PowerPC::ppcState.Exceptions & EXCEPTION_DSI)) + PowerPC::Write_U32(ppc_state.gpr[inst.RS], address); + if (!(ppc_state.Exceptions & EXCEPTION_DSI)) { - PowerPC::ppcState.reserve = false; - PowerPC::ppcState.cr.SetField(0, 2 | PowerPC::ppcState.GetXER_SO()); + ppc_state.reserve = false; + ppc_state.cr.SetField(0, 2 | ppc_state.GetXER_SO()); return; } } } - PowerPC::ppcState.cr.SetField(0, PowerPC::ppcState.GetXER_SO()); + ppc_state.cr.SetField(0, ppc_state.GetXER_SO()); } void Interpreter::stwux(Interpreter& interpreter, UGeckoInstruction inst) { - const u32 address = Helper_Get_EA_UX(PowerPC::ppcState, inst); + auto& ppc_state = interpreter.m_ppc_state; + const u32 address = Helper_Get_EA_UX(ppc_state, inst); - PowerPC::Write_U32(PowerPC::ppcState.gpr[inst.RS], address); - if (!(PowerPC::ppcState.Exceptions & EXCEPTION_DSI)) + PowerPC::Write_U32(ppc_state.gpr[inst.RS], address); + if (!(ppc_state.Exceptions & EXCEPTION_DSI)) { - PowerPC::ppcState.gpr[inst.RA] = address; + ppc_state.gpr[inst.RA] = address; } } void Interpreter::stwx(Interpreter& interpreter, UGeckoInstruction inst) { - const u32 address = Helper_Get_EA_X(PowerPC::ppcState, inst); + auto& ppc_state = interpreter.m_ppc_state; + const u32 address = Helper_Get_EA_X(ppc_state, inst); - PowerPC::Write_U32(PowerPC::ppcState.gpr[inst.RS], address); + PowerPC::Write_U32(ppc_state.gpr[inst.RS], address); } void Interpreter::sync(Interpreter& interpreter, UGeckoInstruction inst) @@ -1051,21 +1116,23 @@ void Interpreter::sync(Interpreter& interpreter, UGeckoInstruction inst) void Interpreter::tlbie(Interpreter& interpreter, UGeckoInstruction inst) { - if (PowerPC::ppcState.msr.PR) + auto& ppc_state = interpreter.m_ppc_state; + if (ppc_state.msr.PR) { GenerateProgramException(ProgramExceptionCause::PrivilegedInstruction); return; } // Invalidate TLB entry - const u32 address = PowerPC::ppcState.gpr[inst.RB]; + const u32 address = ppc_state.gpr[inst.RB]; PowerPC::InvalidateTLBEntry(address); } void Interpreter::tlbsync(Interpreter& interpreter, UGeckoInstruction inst) { - if (PowerPC::ppcState.msr.PR) + auto& ppc_state = interpreter.m_ppc_state; + if (ppc_state.msr.PR) { GenerateProgramException(ProgramExceptionCause::PrivilegedInstruction); }