cpu: Get rid of the redundant PhysRegIndex type.

It was defined to be effectively the same type as RegIndex, which is a
uint16_t. Having two types for essentially the same thing (which the
compiler would treat as equivalent) adds unnecessary complexity.

Change-Id: Ibf6badc19e3b0a27c3bc3e68def1e686dbef3ea8
Reviewed-on: https://gem5-review.googlesource.com/c/public/gem5/+/45228
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Giacomo Travaglini <giacomo.travaglini@arm.com>
Maintainer: Giacomo Travaglini <giacomo.travaglini@arm.com>
This commit is contained in:
Gabe Black
2021-05-02 05:56:00 -07:00
parent 8f0b33612e
commit f2d3011333
5 changed files with 20 additions and 27 deletions

View File

@@ -87,27 +87,27 @@ class DependencyGraph
void reset();
/** Inserts an instruction to be dependent on the given index. */
void insert(PhysRegIndex idx, const DynInstPtr &new_inst);
void insert(RegIndex idx, const DynInstPtr &new_inst);
/** Sets the producing instruction of a given register. */
void setInst(PhysRegIndex idx, const DynInstPtr &new_inst)
void setInst(RegIndex idx, const DynInstPtr &new_inst)
{ dependGraph[idx].inst = new_inst; }
/** Clears the producing instruction. */
void clearInst(PhysRegIndex idx)
void clearInst(RegIndex idx)
{ dependGraph[idx].inst = NULL; }
/** Removes an instruction from a single linked list. */
void remove(PhysRegIndex idx, const DynInstPtr &inst_to_remove);
void remove(RegIndex idx, const DynInstPtr &inst_to_remove);
/** Removes and returns the newest dependent of a specific register. */
DynInstPtr pop(PhysRegIndex idx);
DynInstPtr pop(RegIndex idx);
/** Checks if the entire dependency graph is empty. */
bool empty() const;
/** Checks if there are any dependents on a specific register. */
bool empty(PhysRegIndex idx) const { return !dependGraph[idx].next; }
bool empty(RegIndex idx) const { return !dependGraph[idx].next; }
/** Debugging function to dump out the dependency graph.
*/
@@ -179,8 +179,7 @@ DependencyGraph<DynInstPtr>::reset()
template <class DynInstPtr>
void
DependencyGraph<DynInstPtr>::insert(PhysRegIndex idx,
const DynInstPtr &new_inst)
DependencyGraph<DynInstPtr>::insert(RegIndex idx, const DynInstPtr &new_inst)
{
//Add this new, dependent instruction at the head of the dependency
//chain.
@@ -200,7 +199,7 @@ DependencyGraph<DynInstPtr>::insert(PhysRegIndex idx,
template <class DynInstPtr>
void
DependencyGraph<DynInstPtr>::remove(PhysRegIndex idx,
DependencyGraph<DynInstPtr>::remove(RegIndex idx,
const DynInstPtr &inst_to_remove)
{
DepEntry *prev = &dependGraph[idx];
@@ -238,7 +237,7 @@ DependencyGraph<DynInstPtr>::remove(PhysRegIndex idx,
template <class DynInstPtr>
DynInstPtr
DependencyGraph<DynInstPtr>::pop(PhysRegIndex idx)
DependencyGraph<DynInstPtr>::pop(RegIndex idx)
{
DepEntry *node;
node = dependGraph[idx].next;

View File

@@ -87,7 +87,7 @@ class ElasticTrace : public ProbeListenerObject
public:
typedef typename O3CPUImpl::DynInstPtr DynInstPtr;
typedef typename O3CPUImpl::DynInstConstPtr DynInstConstPtr;
typedef typename std::pair<InstSeqNum, PhysRegIndex> SeqNumRegPair;
typedef typename std::pair<InstSeqNum, RegIndex> SeqNumRegPair;
/** Trace record types corresponding to instruction node types */
typedef ProtoMessage::InstDepRecord::RecordType RecordType;
@@ -239,7 +239,7 @@ class ElasticTrace : public ProbeListenerObject
* After Write dependencies. The key is the renamed physical register and
* the value is the instruction sequence number of its last producer.
*/
std::unordered_map<PhysRegIndex, InstSeqNum> physRegDepMap;
std::unordered_map<RegIndex, InstSeqNum> physRegDepMap;
/**
* @defgroup TraceInfo Struct for a record in the instruction dependency

View File

@@ -72,8 +72,8 @@ PhysRegFile::PhysRegFile(unsigned _numPhysicalIntRegs,
+ _numPhysicalCCRegs),
vecMode(vmode)
{
PhysRegIndex phys_reg;
PhysRegIndex flat_reg_idx = 0;
RegIndex phys_reg;
RegIndex flat_reg_idx = 0;
// The initial batch of registers are the integer ones
for (phys_reg = 0; phys_reg < numPhysicalIntRegs; phys_reg++) {

View File

@@ -62,7 +62,7 @@ class ROB
typedef typename Impl::O3CPU O3CPU;
typedef typename Impl::DynInstPtr DynInstPtr;
typedef std::pair<RegIndex, PhysRegIndex> UnmapInfo;
typedef std::pair<RegIndex, RegIndex> UnmapInfo;
typedef typename std::list<DynInstPtr>::iterator InstIt;
/** Possible ROB statuses. */

View File

@@ -188,12 +188,6 @@ class RegId
}
};
/** Physical register index type.
* Although the Impl might be a better for this, but there are a few classes
* that need this typedef yet are not templated on the Impl.
*/
using PhysRegIndex = short int;
/** Physical register ID.
* Like a register ID but physical. The inheritance is private because the
* only relationship between this types is functional, and it is done to
@@ -201,7 +195,7 @@ using PhysRegIndex = short int;
class PhysRegId : private RegId
{
private:
PhysRegIndex flatIdx;
RegIndex flatIdx;
int numPinnedWritesToComplete;
bool pinned;
@@ -211,15 +205,15 @@ class PhysRegId : private RegId
{}
/** Scalar PhysRegId constructor. */
explicit PhysRegId(RegClass _regClass, PhysRegIndex _regIdx,
PhysRegIndex _flatIdx)
explicit PhysRegId(RegClass _regClass, RegIndex _regIdx,
RegIndex _flatIdx)
: RegId(_regClass, _regIdx), flatIdx(_flatIdx),
numPinnedWritesToComplete(0), pinned(false)
{}
/** Vector PhysRegId constructor (w/ elemIndex). */
explicit PhysRegId(RegClass _regClass, PhysRegIndex _regIdx,
ElemIndex elem_idx, PhysRegIndex flat_idx)
explicit PhysRegId(RegClass _regClass, RegIndex _regIdx,
ElemIndex elem_idx, RegIndex flat_idx)
: RegId(_regClass, _regIdx, elem_idx), flatIdx(flat_idx),
numPinnedWritesToComplete(0), pinned(false)
{}
@@ -263,7 +257,7 @@ class PhysRegId : private RegId
bool isFixedMapping() const { return !isRenameable(); }
/** Flat index accessor */
const PhysRegIndex& flatIndex() const { return flatIdx; }
const RegIndex& flatIndex() const { return flatIdx; }
static PhysRegId
elemId(PhysRegId* vid, ElemIndex elem)