From f2d30113332b80467293b3bcba4b2e3f06d79395 Mon Sep 17 00:00:00 2001 From: Gabe Black Date: Sun, 2 May 2021 05:56:00 -0700 Subject: [PATCH] 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 Reviewed-by: Giacomo Travaglini Maintainer: Giacomo Travaglini --- src/cpu/o3/dep_graph.hh | 19 +++++++++---------- src/cpu/o3/probe/elastic_trace.hh | 4 ++-- src/cpu/o3/regfile.cc | 4 ++-- src/cpu/o3/rob.hh | 2 +- src/cpu/reg_class.hh | 18 ++++++------------ 5 files changed, 20 insertions(+), 27 deletions(-) diff --git a/src/cpu/o3/dep_graph.hh b/src/cpu/o3/dep_graph.hh index 1100742d29..c34e8d9604 100644 --- a/src/cpu/o3/dep_graph.hh +++ b/src/cpu/o3/dep_graph.hh @@ -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::reset() template void -DependencyGraph::insert(PhysRegIndex idx, - const DynInstPtr &new_inst) +DependencyGraph::insert(RegIndex idx, const DynInstPtr &new_inst) { //Add this new, dependent instruction at the head of the dependency //chain. @@ -200,7 +199,7 @@ DependencyGraph::insert(PhysRegIndex idx, template void -DependencyGraph::remove(PhysRegIndex idx, +DependencyGraph::remove(RegIndex idx, const DynInstPtr &inst_to_remove) { DepEntry *prev = &dependGraph[idx]; @@ -238,7 +237,7 @@ DependencyGraph::remove(PhysRegIndex idx, template DynInstPtr -DependencyGraph::pop(PhysRegIndex idx) +DependencyGraph::pop(RegIndex idx) { DepEntry *node; node = dependGraph[idx].next; diff --git a/src/cpu/o3/probe/elastic_trace.hh b/src/cpu/o3/probe/elastic_trace.hh index 24148b7d9d..fb802d5fd0 100644 --- a/src/cpu/o3/probe/elastic_trace.hh +++ b/src/cpu/o3/probe/elastic_trace.hh @@ -87,7 +87,7 @@ class ElasticTrace : public ProbeListenerObject public: typedef typename O3CPUImpl::DynInstPtr DynInstPtr; typedef typename O3CPUImpl::DynInstConstPtr DynInstConstPtr; - typedef typename std::pair SeqNumRegPair; + typedef typename std::pair 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 physRegDepMap; + std::unordered_map physRegDepMap; /** * @defgroup TraceInfo Struct for a record in the instruction dependency diff --git a/src/cpu/o3/regfile.cc b/src/cpu/o3/regfile.cc index 8871b48bf9..bdbea303d1 100644 --- a/src/cpu/o3/regfile.cc +++ b/src/cpu/o3/regfile.cc @@ -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++) { diff --git a/src/cpu/o3/rob.hh b/src/cpu/o3/rob.hh index 6d972eb729..ba5e027176 100644 --- a/src/cpu/o3/rob.hh +++ b/src/cpu/o3/rob.hh @@ -62,7 +62,7 @@ class ROB typedef typename Impl::O3CPU O3CPU; typedef typename Impl::DynInstPtr DynInstPtr; - typedef std::pair UnmapInfo; + typedef std::pair UnmapInfo; typedef typename std::list::iterator InstIt; /** Possible ROB statuses. */ diff --git a/src/cpu/reg_class.hh b/src/cpu/reg_class.hh index 7081409ce2..36c4206fa6 100644 --- a/src/cpu/reg_class.hh +++ b/src/cpu/reg_class.hh @@ -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)