From 209f1d79a9ce983cd0da4471fe04176ab557733b Mon Sep 17 00:00:00 2001 From: Henrik Rydgard Date: Wed, 9 Jan 2013 23:14:21 +0100 Subject: [PATCH] SpillLock is now per MIPS register instead of per ARM register. Fix array size. --- Core/MIPS/ARM/ArmRegCache.cpp | 14 +++++++------- Core/MIPS/ARM/ArmRegCache.h | 6 +++--- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/Core/MIPS/ARM/ArmRegCache.cpp b/Core/MIPS/ARM/ArmRegCache.cpp index cd1a05400e..5a2487204f 100644 --- a/Core/MIPS/ARM/ArmRegCache.cpp +++ b/Core/MIPS/ARM/ArmRegCache.cpp @@ -33,13 +33,13 @@ void ArmRegCache::Init(ARMXEmitter *emitter) { void ArmRegCache::Start(MIPSAnalyst::AnalysisResults &stats) { for (int i = 0; i < 16; i++) { ar[i].mipsReg = -1; - ar[i].spillLock = false; ar[i].isDirty = false; } for (int i = 0; i < NUM_MIPSREG; i++) { mr[i].loc = ML_MEM; mr[i].reg = INVALID_REG; mr[i].imm = -1; + mr[i].spillLock = false; } } @@ -101,7 +101,7 @@ allocate: int bestToSpill = -1; for (int i = 0; i < allocCount; i++) { int reg = allocOrder[i]; - if (ar[reg].spillLock) + if (ar[reg].mipsReg != -1 && mr[ar[reg].mipsReg].spillLock) continue; bestToSpill = reg; break; @@ -213,14 +213,14 @@ int ArmRegCache::GetMipsRegOffset(MIPSReg r) { } void ArmRegCache::SpillLock(MIPSReg r1, MIPSReg r2, MIPSReg r3) { - if (mr[r1].loc == ML_ARMREG) ar[mr[r1].reg].spillLock = true; - if (r2 != -1 && mr[r2].loc == ML_ARMREG) ar[mr[r2].reg].spillLock = true; - if (r3 != -1 && mr[r3].loc == ML_ARMREG) ar[mr[r3].reg].spillLock = true; + mr[r1].spillLock = true; + if (r2 != -1) mr[r2].spillLock = true; + if (r3 != -1) mr[r3].spillLock = true; } void ArmRegCache::ReleaseSpillLocks() { - for (int i = 0; i < NUM_ARMREG; i++) { - ar[i].spillLock = false; + for (int i = 0; i < NUM_MIPSREG; i++) { + mr[i].spillLock = false; } } diff --git a/Core/MIPS/ARM/ArmRegCache.h b/Core/MIPS/ARM/ArmRegCache.h index 127396ddc4..8154c93c8f 100644 --- a/Core/MIPS/ARM/ArmRegCache.h +++ b/Core/MIPS/ARM/ArmRegCache.h @@ -41,7 +41,6 @@ typedef int MIPSReg; struct RegARM { int mipsReg; // if -1, no mipsreg attached. bool isDirty; // Should the register be written back? - bool spillLock; // if true, this register cannot be spilled. }; enum RegMIPSLoc { @@ -56,6 +55,7 @@ struct RegMIPS { // Data (only one of these is used, depending on loc. Could make a union). u32 imm; ARMReg reg; + bool spillLock; // if true, this register cannot be spilled. // If loc == ML_MEM, it's back in its location in the CPU context struct. }; @@ -108,6 +108,6 @@ private: NUM_MIPSREG = TOTAL_MAPPABLE_MIPSREGS, }; - RegARM ar[16]; - RegMIPS mr[32]; + RegARM ar[NUM_ARMREG]; + RegMIPS mr[NUM_MIPSREG]; };