cpu,arch-arm: Use a sentry class valid for invalid RegIds.

The default constructor for RegId would initialize it with the
IntRegClass and register index 0. This is arbitrary and
indistinguishable from a real ID to the first integer register.

Instead, add a new class type constant InvalidRegClass, and use that to
initialize an otherwise uninitialized RegId.

Also, fill out some enums that needed to handle that value to silence
compiler warnings.

Change-Id: I3b58559f41adc1da5f661121225dbd389230e3af
Reviewed-on: https://gem5-review.googlesource.com/c/public/gem5/+/49710
Reviewed-by: Giacomo Travaglini <giacomo.travaglini@arm.com>
Maintainer: Giacomo Travaglini <giacomo.travaglini@arm.com>
Tested-by: kokoro <noreply+kokoro@google.com>
This commit is contained in:
Gabe Black
2021-08-14 02:50:25 -07:00
parent 092d33f3f5
commit ec4d6c0daf
3 changed files with 9 additions and 4 deletions

View File

@@ -666,8 +666,10 @@ namespace ArmISA
return RegId(CCRegClass, flattenCCIndex(regId.index()));
case MiscRegClass:
return RegId(MiscRegClass, flattenMiscIndex(regId.index()));
case InvalidRegClass:
return RegId();
}
return RegId();
panic("Unrecognized register class %d.", regId.classValue());
}
int

View File

@@ -189,6 +189,8 @@ PhysRegFile::getRegIds(RegClassType cls)
return std::make_pair(ccRegIds.begin(), ccRegIds.end());
case MiscRegClass:
return std::make_pair(miscRegIds.begin(), miscRegIds.end());
case InvalidRegClass:
panic("Tried to get register IDs for the invalid class.");
}
/* There is no way to make an empty iterator */
return std::make_pair(PhysIds::iterator(),

View File

@@ -63,7 +63,8 @@ enum RegClassType
VecElemClass,
VecPredRegClass,
CCRegClass, ///< Condition-code register
MiscRegClass ///< Control (misc) register
MiscRegClass, ///< Control (misc) register
InvalidRegClass = -1
};
class RegId;
@@ -136,7 +137,7 @@ class RegId
friend struct std::hash<RegId>;
public:
RegId() : RegId(IntRegClass, 0) {}
RegId() : RegId(InvalidRegClass, 0) {}
explicit RegId(RegClassType reg_class, RegIndex reg_idx)
: regClass(reg_class), regIdx(reg_idx), numPinnedWrites(0)
@@ -235,7 +236,7 @@ class PhysRegId : private RegId
bool pinned;
public:
explicit PhysRegId() : RegId(IntRegClass, -1), flatIdx(-1),
explicit PhysRegId() : RegId(InvalidRegClass, -1), flatIdx(-1),
numPinnedWritesToComplete(0)
{}