summaryrefslogtreecommitdiff
path: root/src/arch/mips/regfile/int_regfile.cc
diff options
context:
space:
mode:
authorKorey Sewell <ksewell@umich.edu>2008-10-06 02:07:04 -0400
committerKorey Sewell <ksewell@umich.edu>2008-10-06 02:07:04 -0400
commit6c046a28dc6624f57655e5106568721972cbae1e (patch)
treedb4595c0b996ce080acd4d78afccc58c3e0460d3 /src/arch/mips/regfile/int_regfile.cc
parentb25755993bbc04be0235975e2967533995a493f0 (diff)
downloadgem5-6c046a28dc6624f57655e5106568721972cbae1e.tar.xz
fix shadow set bugs in MIPS code that caused out of bounds access...
panic rdpgpr/wrpgpr instructions until a better impl. of MIPS shadow sets is available.
Diffstat (limited to 'src/arch/mips/regfile/int_regfile.cc')
-rw-r--r--src/arch/mips/regfile/int_regfile.cc35
1 files changed, 18 insertions, 17 deletions
diff --git a/src/arch/mips/regfile/int_regfile.cc b/src/arch/mips/regfile/int_regfile.cc
index 4ffbcdfb8..88de4be94 100644
--- a/src/arch/mips/regfile/int_regfile.cc
+++ b/src/arch/mips/regfile/int_regfile.cc
@@ -44,6 +44,12 @@ IntRegFile::clear()
currShadowSet=0;
}
+int
+IntRegFile::readShadowSet()
+{
+ return currShadowSet;
+}
+
void
IntRegFile::setShadowSet(int css)
{
@@ -54,21 +60,17 @@ IntRegFile::setShadowSet(int css)
IntReg
IntRegFile::readReg(int intReg)
{
- if (intReg < NumIntRegs) {
+ if (intReg < NumIntArchRegs) {
// Regular GPR Read
DPRINTF(MipsPRA, "Reading Reg: %d, CurrShadowSet: %d\n", intReg,
- currShadowSet);
+ currShadowSet);
- if (intReg >= NumIntArchRegs * NumShadowRegSets) {
- return regs[intReg + NumIntRegs * currShadowSet];
- } else {
- int index = intReg + NumIntArchRegs * currShadowSet;
- index = index % NumIntArchRegs;
- return regs[index];
- }
+ return regs[intReg + NumIntArchRegs * currShadowSet];
} else {
- // Read from shadow GPR .. probably called by RDPGPR
- return regs[intReg];
+ unsigned special_reg_num = intReg - NumIntArchRegs;
+
+ // Read A Special Reg
+ return regs[TotalArchRegs + special_reg_num];
}
}
@@ -76,13 +78,12 @@ Fault
IntRegFile::setReg(int intReg, const IntReg &val)
{
if (intReg != ZeroReg) {
- if (intReg < NumIntRegs) {
- if (intReg >= NumIntArchRegs * NumShadowRegSets)
- regs[intReg] = val;
- else
- regs[intReg + NumIntRegs * currShadowSet] = val;
+ if (intReg < NumIntArchRegs) {
+ regs[intReg + NumIntArchRegs * currShadowSet] = val;
} else {
- regs[intReg] = val;
+ unsigned special_reg_num = intReg - NumIntArchRegs;
+
+ regs[TotalArchRegs + special_reg_num] = val;
}
}