RegCache: make state clear optional on flushes

This commit is contained in:
degasus 2014-06-02 14:21:40 +02:00
parent 38c3812a60
commit 0cd9eea99e
2 changed files with 18 additions and 18 deletions

View File

@ -255,7 +255,7 @@ void RegCache::BindToRegister(int i, bool doLoad, bool makeDirty)
} }
} }
void RegCache::StoreFromRegister(int i) void RegCache::StoreFromRegister(int i, bool clearState)
{ {
if (regs[i].away) if (regs[i].away)
{ {
@ -263,11 +263,14 @@ void RegCache::StoreFromRegister(int i)
if (regs[i].location.IsSimpleReg()) if (regs[i].location.IsSimpleReg())
{ {
X64Reg xr = RX(i); X64Reg xr = RX(i);
doStore = xregs[xr].dirty;
if(clearState)
{
xregs[xr].free = true; xregs[xr].free = true;
xregs[xr].ppcReg = -1; xregs[xr].ppcReg = -1;
doStore = xregs[xr].dirty;
xregs[xr].dirty = false; xregs[xr].dirty = false;
} }
}
else else
{ {
//must be immediate - do nothing //must be immediate - do nothing
@ -276,9 +279,12 @@ void RegCache::StoreFromRegister(int i)
OpArg newLoc = GetDefaultLocation(i); OpArg newLoc = GetDefaultLocation(i);
if (doStore) if (doStore)
StoreRegister(i, newLoc); StoreRegister(i, newLoc);
if(clearState)
{
regs[i].location = newLoc; regs[i].location = newLoc;
regs[i].away = false; regs[i].away = false;
} }
}
} }
void GPRRegCache::LoadRegister(int preg, X64Reg newLoc) void GPRRegCache::LoadRegister(int preg, X64Reg newLoc)
@ -305,7 +311,7 @@ void FPURegCache::StoreRegister(int preg, OpArg newLoc)
emit->MOVAPD(newLoc, regs[preg].location.GetSimpleReg()); emit->MOVAPD(newLoc, regs[preg].location.GetSimpleReg());
} }
void RegCache::Flush() void RegCache::Flush(bool clearState)
{ {
for (int i = 0; i < (int)xregs.size(); i++) for (int i = 0; i < (int)xregs.size(); i++)
{ {
@ -321,15 +327,9 @@ void RegCache::Flush()
} }
if (regs[i].away) if (regs[i].away)
{ {
if (regs[i].location.IsSimpleReg()) if (regs[i].location.IsSimpleReg() || regs[i].location.IsImm())
{ {
X64Reg xr = RX(i); StoreFromRegister(i, clearState);
StoreFromRegister(i);
xregs[xr].dirty = false;
}
else if (regs[i].location.IsImm())
{
StoreFromRegister(i);
} }
else else
{ {

View File

@ -63,15 +63,15 @@ public:
FlushR(reg1); FlushR(reg2); FlushR(reg1); FlushR(reg2);
LockX(reg1); LockX(reg2); LockX(reg1); LockX(reg2);
} }
virtual void Flush(); void Flush(bool clearState = true);
virtual void Flush(PPCAnalyst::CodeOp *op) {Flush();} void Flush(PPCAnalyst::CodeOp *op) {Flush();}
int SanityCheck() const; int SanityCheck() const;
void KillImmediate(int preg, bool doLoad, bool makeDirty); void KillImmediate(int preg, bool doLoad, bool makeDirty);
//TODO - instead of doload, use "read", "write" //TODO - instead of doload, use "read", "write"
//read only will not set dirty flag //read only will not set dirty flag
void BindToRegister(int preg, bool doLoad = true, bool makeDirty = true); void BindToRegister(int preg, bool doLoad = true, bool makeDirty = true);
void StoreFromRegister(int preg); void StoreFromRegister(int preg, bool clearState = true);
virtual void StoreRegister(int preg, OpArg newLoc) = 0; virtual void StoreRegister(int preg, OpArg newLoc) = 0;
virtual void LoadRegister(int preg, X64Reg newLoc) = 0; virtual void LoadRegister(int preg, X64Reg newLoc) = 0;