Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

jit: Discard unused regs before a syscall #7545

Merged
merged 1 commit into from
Mar 1, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 2 additions & 3 deletions Core/HLE/HLE.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -358,9 +358,8 @@ inline static void SetDeadbeefRegs()
currentMIPS->r[MIPS_REG_COMPILER_SCRATCH] = 0xDEADBEEF;
// Set all the arguments and temp regs.
memcpy(&currentMIPS->r[MIPS_REG_A0], deadbeefRegs, sizeof(deadbeefRegs));
// Using a magic number since there's confusion/disagreement on reg names.
currentMIPS->r[24] = 0xDEADBEEF;
currentMIPS->r[25] = 0xDEADBEEF;
currentMIPS->r[MIPS_REG_T8] = 0xDEADBEEF;
currentMIPS->r[MIPS_REG_T9] = 0xDEADBEEF;

currentMIPS->lo = 0xDEADBEEF;
currentMIPS->hi = 0xDEADBEEF;
Expand Down
16 changes: 16 additions & 0 deletions Core/MIPS/ARM/ArmCompBranch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -582,6 +582,22 @@ void ArmJit::Comp_JumpReg(MIPSOpcode op)

void ArmJit::Comp_Syscall(MIPSOpcode op)
{
if (!g_Config.bSkipDeadbeefFilling)
{
// All of these will be overwritten with DEADBEEF anyway.
gpr.DiscardR(MIPS_REG_COMPILER_SCRATCH);
// We need to keep A0 - T3, which are used for args.
gpr.DiscardR(MIPS_REG_T4);
gpr.DiscardR(MIPS_REG_T5);
gpr.DiscardR(MIPS_REG_T6);
gpr.DiscardR(MIPS_REG_T7);
gpr.DiscardR(MIPS_REG_T8);
gpr.DiscardR(MIPS_REG_T9);

gpr.DiscardR(MIPS_REG_HI);
gpr.DiscardR(MIPS_REG_LO);
}

// If we're in a delay slot, this is off by one.
const int offset = js.inDelaySlot ? -1 : 0;
WriteDownCount(offset);
Expand Down
16 changes: 15 additions & 1 deletion Core/MIPS/x86/CompBranch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -752,7 +752,21 @@ void Jit::Comp_JumpReg(MIPSOpcode op)

void Jit::Comp_Syscall(MIPSOpcode op)
{
// TODO: Maybe discard v0, v1, and some temps? Definitely at?
if (!g_Config.bSkipDeadbeefFilling)
{
// All of these will be overwritten with DEADBEEF anyway.
gpr.DiscardR(MIPS_REG_COMPILER_SCRATCH);
// We need to keep A0 - T3, which are used for args.
gpr.DiscardR(MIPS_REG_T4);
gpr.DiscardR(MIPS_REG_T5);
gpr.DiscardR(MIPS_REG_T6);
gpr.DiscardR(MIPS_REG_T7);
gpr.DiscardR(MIPS_REG_T8);
gpr.DiscardR(MIPS_REG_T9);

gpr.DiscardR(MIPS_REG_HI);
gpr.DiscardR(MIPS_REG_LO);
}
FlushAll();

// If we're in a delay slot, this is off by one.
Expand Down
15 changes: 15 additions & 0 deletions Core/MIPS/x86/RegCache.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -241,6 +241,21 @@ void GPRRegCache::DiscardRegContentsIfCached(MIPSGPReg preg) {
}
}

void GPRRegCache::DiscardR(MIPSGPReg preg) {
if (regs[preg].away) {
if (regs[preg].location.IsSimpleReg()) {
DiscardRegContentsIfCached(preg);
} else {
regs[preg].away = false;
if (preg == MIPS_REG_ZERO) {
regs[preg].location = Imm32(0);
} else {
regs[preg].location = GetDefaultLocation(preg);
}
}
}
}


void GPRRegCache::SetImm(MIPSGPReg preg, u32 immValue) {
// ZERO is always zero. Let's just make sure.
Expand Down
1 change: 1 addition & 0 deletions Core/MIPS/x86/RegCache.h
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ class GPRRegCache
void Start(MIPSState *mips, MIPSComp::JitState *js, MIPSComp::JitOptions *jo, MIPSAnalyst::AnalysisResults &stats);

void DiscardRegContentsIfCached(MIPSGPReg preg);
void DiscardR(MIPSGPReg preg);
void SetEmitter(Gen::XEmitter *emitter) {emit = emitter;}

void FlushR(Gen::X64Reg reg);
Expand Down