Try to reuse temp regs for better caching.

This commit is contained in:
Unknown W. Brackets 2013-02-18 00:32:42 -08:00
parent 6855398add
commit 0bfc380575
3 changed files with 9 additions and 6 deletions

View File

@ -431,6 +431,7 @@ void Jit::Comp_VecDo3(u32 op) {
if (xmmop == NULL)
{
fpr.ReleaseSpillLocks();
Comp_Generic(op);
return;
}

View File

@ -27,7 +27,6 @@ FPURegCache::FPURegCache() : emit(0), mips(0) {
memset(regs, 0, sizeof(regs));
memset(xregs, 0, sizeof(xregs));
vregs = regs + 32;
tempRoundRobin = 0;
}
void FPURegCache::Start(MIPSState *mips, MIPSAnalyst::AnalysisResults &stats) {
@ -40,6 +39,7 @@ void FPURegCache::Start(MIPSState *mips, MIPSAnalyst::AnalysisResults &stats) {
regs[i].location = GetDefaultLocation(i);
regs[i].away = false;
regs[i].locked = false;
regs[i].tempLocked = false;
}
}
@ -144,8 +144,10 @@ void FPURegCache::DiscardR(int i) {
xregs[xr].mipsReg = -1;
regs[i].location = GetDefaultLocation(i);
regs[i].away = false;
regs[i].tempLocked = false;
} else {
// _assert_msg_(DYNA_REC,0,"already stored");
regs[i].tempLocked = false;
}
}
@ -154,10 +156,9 @@ bool FPURegCache::IsTempX(X64Reg xr) {
}
int FPURegCache::GetTempR() {
for (int i = 0; i < NUM_TEMPS; ++i) {
// Make sure we don't give out the same one over and over, even if not locked.
int r = TEMP0 + (tempRoundRobin++ + i) % NUM_TEMPS;
if (!regs[r].away) {
for (int r = TEMP0; r < TEMP0 + NUM_TEMPS; ++r) {
if (!regs[r].away && !regs[r].tempLocked) {
regs[r].tempLocked = true;
return r;
}
}

View File

@ -53,6 +53,8 @@ struct MIPSCachedFPReg {
OpArg location;
bool away; // value not in source register
bool locked;
// Only for temp regs.
bool tempLocked;
};
enum {
@ -140,7 +142,6 @@ private:
// TEMP0, etc. are swapped in here if necessary (e.g. on x86.)
static u32 tempValues[NUM_TEMPS];
int tempRoundRobin;
XEmitter *emit;
};