mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2025-01-09 15:49:25 +01:00
PowerPC: Remove GPR macro.
This commit is contained in:
parent
ba1b624e1b
commit
8fccefa3aa
@ -449,7 +449,7 @@ PPCDebugInterface::GetMemoryAddressFromInstruction(const std::string& instructio
|
||||
if (is_reg == offset_match[0])
|
||||
{
|
||||
const int register_index = std::stoi(offset_match.substr(1), nullptr, 10);
|
||||
offset = (register_index == 0 ? 0 : GPR(register_index));
|
||||
offset = (register_index == 0 ? 0 : PowerPC::ppcState.gpr[register_index]);
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -468,7 +468,7 @@ PPCDebugInterface::GetMemoryAddressFromInstruction(const std::string& instructio
|
||||
else
|
||||
i = std::stoi(register_match, nullptr, 10);
|
||||
|
||||
const u32 base_address = GPR(i);
|
||||
const u32 base_address = PowerPC::ppcState.gpr[i];
|
||||
|
||||
if (!match.str(1).empty())
|
||||
return base_address - offset;
|
||||
|
@ -259,12 +259,13 @@ void RunCodeHandler()
|
||||
// The codehandler will STMW all of the GPR registers, but we need to fix the Stack's Red
|
||||
// Zone, the LR, PC (return address) and the volatile floating point registers.
|
||||
// Build a function call stack frame.
|
||||
u32 SFP = GPR(1); // Stack Frame Pointer
|
||||
GPR(1) -= 256; // Stack's Red Zone
|
||||
GPR(1) -= 16 + 2 * 14 * sizeof(u64); // Our stack frame (HLE_Misc::GeckoReturnTrampoline)
|
||||
GPR(1) -= 8; // Fake stack frame for codehandler
|
||||
GPR(1) &= 0xFFFFFFF0; // Align stack to 16bytes
|
||||
u32 SP = GPR(1); // Stack Pointer
|
||||
u32 SFP = PowerPC::ppcState.gpr[1]; // Stack Frame Pointer
|
||||
PowerPC::ppcState.gpr[1] -= 256; // Stack's Red Zone
|
||||
PowerPC::ppcState.gpr[1] -= 16 + 2 * 14 * sizeof(u64); // Our stack frame
|
||||
// (HLE_Misc::GeckoReturnTrampoline)
|
||||
PowerPC::ppcState.gpr[1] -= 8; // Fake stack frame for codehandler
|
||||
PowerPC::ppcState.gpr[1] &= 0xFFFFFFF0; // Align stack to 16bytes
|
||||
u32 SP = PowerPC::ppcState.gpr[1]; // Stack Pointer
|
||||
PowerPC::HostWrite_U32(SP + 8, SP);
|
||||
// SP + 4 is reserved for the codehandler to save LR to the stack.
|
||||
PowerPC::HostWrite_U32(SFP, SP + 8); // Real stack frame
|
||||
|
@ -56,8 +56,8 @@ void GeckoCodeHandlerICacheFlush()
|
||||
void GeckoReturnTrampoline()
|
||||
{
|
||||
// Stack frame is built in GeckoCode.cpp, Gecko::RunCodeHandler.
|
||||
u32 SP = GPR(1);
|
||||
GPR(1) = PowerPC::HostRead_U32(SP + 8);
|
||||
u32 SP = PowerPC::ppcState.gpr[1];
|
||||
PowerPC::ppcState.gpr[1] = PowerPC::HostRead_U32(SP + 8);
|
||||
PowerPC::ppcState.npc = PowerPC::HostRead_U32(SP + 12);
|
||||
LR = PowerPC::HostRead_U32(SP + 16);
|
||||
PowerPC::ppcState.cr.Set(PowerPC::HostRead_U32(SP + 20));
|
||||
|
@ -49,11 +49,11 @@ void HLE_GeneralDebugPrint(ParameterType parameter_type)
|
||||
std::string report_message;
|
||||
|
||||
// Is gpr3 pointing to a pointer (including nullptr) rather than an ASCII string
|
||||
if (PowerPC::HostIsRAMAddress(GPR(3)) &&
|
||||
(PowerPC::HostIsRAMAddress(PowerPC::HostRead_U32(GPR(3))) ||
|
||||
PowerPC::HostRead_U32(GPR(3)) == 0))
|
||||
if (PowerPC::HostIsRAMAddress(PowerPC::ppcState.gpr[3]) &&
|
||||
(PowerPC::HostIsRAMAddress(PowerPC::HostRead_U32(PowerPC::ppcState.gpr[3])) ||
|
||||
PowerPC::HostRead_U32(PowerPC::ppcState.gpr[3]) == 0))
|
||||
{
|
||||
if (PowerPC::HostIsRAMAddress(GPR(4)))
|
||||
if (PowerPC::HostIsRAMAddress(PowerPC::ppcState.gpr[4]))
|
||||
{
|
||||
// ___blank(void* this, const char* fmt, ...);
|
||||
report_message = GetStringVA(4, parameter_type);
|
||||
@ -66,7 +66,7 @@ void HLE_GeneralDebugPrint(ParameterType parameter_type)
|
||||
}
|
||||
else
|
||||
{
|
||||
if (PowerPC::HostIsRAMAddress(GPR(3)))
|
||||
if (PowerPC::HostIsRAMAddress(PowerPC::ppcState.gpr[3]))
|
||||
{
|
||||
// ___blank(const char* fmt, ...);
|
||||
report_message = GetStringVA(3, parameter_type);
|
||||
@ -100,9 +100,9 @@ void HLE_GeneralDebugVPrint()
|
||||
void HLE_write_console()
|
||||
{
|
||||
std::string report_message = GetStringVA(4);
|
||||
if (PowerPC::HostIsRAMAddress(GPR(5)))
|
||||
if (PowerPC::HostIsRAMAddress(PowerPC::ppcState.gpr[5]))
|
||||
{
|
||||
const u32 size = PowerPC::Read_U32(GPR(5));
|
||||
const u32 size = PowerPC::Read_U32(PowerPC::ppcState.gpr[5]);
|
||||
if (size > report_message.size())
|
||||
WARN_LOG_FMT(OSREPORT_HLE, "__write_console uses an invalid size of {:#010x}", size);
|
||||
else if (size == 0)
|
||||
@ -124,7 +124,7 @@ void HLE_write_console()
|
||||
// Log (v)dprintf message if fd is 1 (stdout) or 2 (stderr)
|
||||
void HLE_LogDPrint(ParameterType parameter_type)
|
||||
{
|
||||
if (GPR(3) != 1 && GPR(3) != 2)
|
||||
if (PowerPC::ppcState.gpr[3] != 1 && PowerPC::ppcState.gpr[3] != 2)
|
||||
return;
|
||||
|
||||
std::string report_message = GetStringVA(4, parameter_type);
|
||||
@ -153,15 +153,16 @@ void HLE_LogFPrint(ParameterType parameter_type)
|
||||
// The structure FILE is implementation defined.
|
||||
// Both libogc and Dolphin SDK seem to store the fd at the same address.
|
||||
int fd = -1;
|
||||
if (PowerPC::HostIsRAMAddress(GPR(3)) && PowerPC::HostIsRAMAddress(GPR(3) + 0xF))
|
||||
if (PowerPC::HostIsRAMAddress(PowerPC::ppcState.gpr[3]) &&
|
||||
PowerPC::HostIsRAMAddress(PowerPC::ppcState.gpr[3] + 0xF))
|
||||
{
|
||||
// The fd is stored as a short at FILE+0xE.
|
||||
fd = static_cast<short>(PowerPC::HostRead_U16(GPR(3) + 0xE));
|
||||
fd = static_cast<short>(PowerPC::HostRead_U16(PowerPC::ppcState.gpr[3] + 0xE));
|
||||
}
|
||||
if (fd != 1 && fd != 2)
|
||||
{
|
||||
// On RVL SDK it seems stored at FILE+0x2.
|
||||
fd = static_cast<short>(PowerPC::HostRead_U16(GPR(3) + 0x2));
|
||||
fd = static_cast<short>(PowerPC::HostRead_U16(PowerPC::ppcState.gpr[3] + 0x2));
|
||||
}
|
||||
if (fd != 1 && fd != 2)
|
||||
return;
|
||||
@ -190,10 +191,11 @@ std::string GetStringVA(u32 str_reg, ParameterType parameter_type)
|
||||
{
|
||||
std::string ArgumentBuffer;
|
||||
std::string result;
|
||||
std::string string = PowerPC::HostGetString(GPR(str_reg));
|
||||
auto ap = parameter_type == ParameterType::VariableArgumentList ?
|
||||
std::make_unique<HLE::SystemVABI::VAListStruct>(GPR(str_reg + 1)) :
|
||||
std::make_unique<HLE::SystemVABI::VAList>(GPR(1) + 0x8, str_reg + 1);
|
||||
std::string string = PowerPC::HostGetString(PowerPC::ppcState.gpr[str_reg]);
|
||||
auto ap =
|
||||
parameter_type == ParameterType::VariableArgumentList ?
|
||||
std::make_unique<HLE::SystemVABI::VAListStruct>(PowerPC::ppcState.gpr[str_reg + 1]) :
|
||||
std::make_unique<HLE::SystemVABI::VAList>(PowerPC::ppcState.gpr[1] + 0x8, str_reg + 1);
|
||||
|
||||
for (size_t i = 0; i < string.size(); i++)
|
||||
{
|
||||
|
@ -9,7 +9,7 @@ HLE::SystemVABI::VAList::~VAList() = default;
|
||||
|
||||
u32 HLE::SystemVABI::VAList::GetGPR(u32 gpr) const
|
||||
{
|
||||
return GPR(gpr);
|
||||
return PowerPC::ppcState.gpr[gpr];
|
||||
}
|
||||
|
||||
double HLE::SystemVABI::VAList::GetFPR(u32 fpr) const
|
||||
|
@ -280,7 +280,7 @@ static bool IsStackSane()
|
||||
DEBUG_ASSERT(PowerPC::ppcState.msr.DR && PowerPC::ppcState.msr.IR);
|
||||
|
||||
// Check the stack pointer
|
||||
u32 SP = GPR(1);
|
||||
u32 SP = PowerPC::ppcState.gpr[1];
|
||||
if (!PowerPC::HostIsRAMAddress(SP))
|
||||
return false;
|
||||
|
||||
|
@ -246,9 +246,9 @@ void Expression::SynchronizeBindings(SynchronizeDirection dir) const
|
||||
break;
|
||||
case VarBindingType::GPR:
|
||||
if (dir == SynchronizeDirection::From)
|
||||
v->value = static_cast<double>(GPR(bind->index));
|
||||
v->value = static_cast<double>(PowerPC::ppcState.gpr[bind->index]);
|
||||
else
|
||||
GPR(bind->index) = static_cast<u32>(static_cast<s64>(v->value));
|
||||
PowerPC::ppcState.gpr[bind->index] = static_cast<u32>(static_cast<s64>(v->value));
|
||||
break;
|
||||
case VarBindingType::FPR:
|
||||
if (dir == SynchronizeDirection::From)
|
||||
|
@ -410,7 +410,7 @@ static void ReadRegister()
|
||||
|
||||
if (id < 32)
|
||||
{
|
||||
wbe32hex(reply, GPR(id));
|
||||
wbe32hex(reply, PowerPC::ppcState.gpr[id]);
|
||||
}
|
||||
else if (id >= 32 && id < 64)
|
||||
{
|
||||
@ -585,7 +585,7 @@ static void ReadRegisters()
|
||||
|
||||
for (i = 0; i < 32; i++)
|
||||
{
|
||||
wbe32hex(bufptr + i * 8, GPR(i));
|
||||
wbe32hex(bufptr + i * 8, PowerPC::ppcState.gpr[i]);
|
||||
}
|
||||
bufptr += 32 * 8;
|
||||
|
||||
@ -599,7 +599,7 @@ static void WriteRegisters()
|
||||
|
||||
for (i = 0; i < 32; i++)
|
||||
{
|
||||
GPR(i) = re32hex(bufptr + i * 8);
|
||||
PowerPC::ppcState.gpr[i] = re32hex(bufptr + i * 8);
|
||||
}
|
||||
bufptr += 32 * 8;
|
||||
|
||||
@ -622,7 +622,7 @@ static void WriteRegister()
|
||||
|
||||
if (id < 32)
|
||||
{
|
||||
GPR(id) = re32hex(bufptr);
|
||||
PowerPC::ppcState.gpr[id] = re32hex(bufptr);
|
||||
}
|
||||
else if (id >= 32 && id < 64)
|
||||
{
|
||||
@ -1123,7 +1123,7 @@ void SendSignal(Signal signal)
|
||||
{
|
||||
char bfr[128] = {};
|
||||
fmt::format_to(bfr, "T{:02x}{:02x}:{:08x};{:02x}:{:08x};", static_cast<u8>(signal), 64,
|
||||
PowerPC::ppcState.pc, 1, GPR(1));
|
||||
PowerPC::ppcState.pc, 1, PowerPC::ppcState.gpr[1]);
|
||||
SendReply(bfr);
|
||||
}
|
||||
} // namespace GDBStub
|
||||
|
@ -642,8 +642,11 @@ void CheckBreakPoints()
|
||||
NOTICE_LOG_FMT(MEMMAP,
|
||||
"BP {:08x} {}({:08x} {:08x} {:08x} {:08x} {:08x} {:08x} {:08x} {:08x} {:08x} "
|
||||
"{:08x}) LR={:08x}",
|
||||
PowerPC::ppcState.pc, g_symbolDB.GetDescription(PowerPC::ppcState.pc), GPR(3),
|
||||
GPR(4), GPR(5), GPR(6), GPR(7), GPR(8), GPR(9), GPR(10), GPR(11), GPR(12), LR);
|
||||
PowerPC::ppcState.pc, g_symbolDB.GetDescription(PowerPC::ppcState.pc),
|
||||
PowerPC::ppcState.gpr[3], PowerPC::ppcState.gpr[4], PowerPC::ppcState.gpr[5],
|
||||
PowerPC::ppcState.gpr[6], PowerPC::ppcState.gpr[7], PowerPC::ppcState.gpr[8],
|
||||
PowerPC::ppcState.gpr[9], PowerPC::ppcState.gpr[10], PowerPC::ppcState.gpr[11],
|
||||
PowerPC::ppcState.gpr[12], LR);
|
||||
}
|
||||
if (PowerPC::breakpoints.IsTempBreakPoint(PowerPC::ppcState.pc))
|
||||
PowerPC::breakpoints.Remove(PowerPC::ppcState.pc);
|
||||
|
@ -245,7 +245,6 @@ void UpdatePerformanceMonitor(u32 cycles, u32 num_load_stores, u32 num_fp_inst);
|
||||
#define THRM1(ppc_state) ((UReg_THRM12&)(ppc_state).spr[SPR_THRM1])
|
||||
#define THRM2(ppc_state) ((UReg_THRM12&)(ppc_state).spr[SPR_THRM2])
|
||||
#define THRM3(ppc_state) ((UReg_THRM3&)(ppc_state).spr[SPR_THRM3])
|
||||
#define GPR(n) PowerPC::ppcState.gpr[n]
|
||||
|
||||
#define rGPR PowerPC::ppcState.gpr
|
||||
#define rSPR(i) PowerPC::ppcState.spr[i]
|
||||
|
@ -314,8 +314,8 @@ void RegisterWidget::PopulateTable()
|
||||
{
|
||||
// General purpose registers (int)
|
||||
AddRegister(
|
||||
i, 0, RegisterType::gpr, "r" + std::to_string(i), [i] { return GPR(i); },
|
||||
[i](u64 value) { GPR(i) = value; });
|
||||
i, 0, RegisterType::gpr, "r" + std::to_string(i), [i] { return PowerPC::ppcState.gpr[i]; },
|
||||
[i](u64 value) { PowerPC::ppcState.gpr[i] = value; });
|
||||
|
||||
// Floating point registers (double)
|
||||
AddRegister(
|
||||
|
Loading…
x
Reference in New Issue
Block a user