gem5  v22.1.0.0
rename.hh
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2012, 2017 ARM Limited
3  * All rights reserved
4  *
5  * The license below extends only to copyright in the software and shall
6  * not be construed as granting a license to any other intellectual
7  * property including but not limited to intellectual property relating
8  * to a hardware implementation of the functionality of the software
9  * licensed hereunder. You may use the software subject to the license
10  * terms below provided that you ensure that this notice is replicated
11  * unmodified and in its entirety in all distributions of the software,
12  * modified or unmodified, in source code or in binary form.
13  *
14  * Copyright (c) 2004-2006 The Regents of The University of Michigan
15  * Copyright (c) 2013 Advanced Micro Devices, Inc.
16  * All rights reserved.
17  *
18  * Redistribution and use in source and binary forms, with or without
19  * modification, are permitted provided that the following conditions are
20  * met: redistributions of source code must retain the above copyright
21  * notice, this list of conditions and the following disclaimer;
22  * redistributions in binary form must reproduce the above copyright
23  * notice, this list of conditions and the following disclaimer in the
24  * documentation and/or other materials provided with the distribution;
25  * neither the name of the copyright holders nor the names of its
26  * contributors may be used to endorse or promote products derived from
27  * this software without specific prior written permission.
28  *
29  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
30  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
31  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
32  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
33  * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
34  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
35  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
36  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
37  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
38  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
39  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
40  */
41 
42 #ifndef __CPU_O3_RENAME_HH__
43 #define __CPU_O3_RENAME_HH__
44 
45 #include <list>
46 #include <utility>
47 
48 #include "base/statistics.hh"
49 #include "cpu/o3/comm.hh"
50 #include "cpu/o3/commit.hh"
51 #include "cpu/o3/dyn_inst_ptr.hh"
52 #include "cpu/o3/free_list.hh"
53 #include "cpu/o3/iew.hh"
54 #include "cpu/o3/limits.hh"
55 #include "cpu/timebuf.hh"
56 #include "sim/probe/probe.hh"
57 
58 namespace gem5
59 {
60 
61 struct BaseO3CPUParams;
62 
63 namespace o3
64 {
65 
78 class Rename
79 {
80  public:
81  // A deque is used to queue the instructions. Barrier insts must
82  // be added to the front of the queue, which is the only reason for
83  // using a deque instead of a queue. (Most other stages use a
84  // queue)
86 
87  public:
92  {
94  Inactive
95  };
96 
99  {
107  };
108 
109  private:
112 
115 
125 
126  public:
128  Rename(CPU *_cpu, const BaseO3CPUParams &params);
129 
131  std::string name() const;
132 
134  void regProbePoints();
135 
138 
141 
144 
146  void setIEWStage(IEW *iew_stage) { iew_ptr = iew_stage; }
147 
149  void
150  setCommitStage(Commit *commit_stage)
151  {
152  commit_ptr = commit_stage;
153  }
154 
155  private:
158 
161 
162  public:
164  void startupStage();
165 
167  void clearStates(ThreadID tid);
168 
171 
174 
176  void setFreeList(UnifiedFreeList *fl_ptr);
177 
179  void setScoreboard(Scoreboard *_scoreboard);
180 
182  void drainSanityCheck() const;
183 
185  bool isDrained() const;
186 
188  void takeOverFrom();
189 
191  void squash(const InstSeqNum &squash_seq_num, ThreadID tid);
192 
196  void tick();
197 
199  void dumpHistory();
200 
201  private:
203  void resetStage();
204 
210  void rename(bool &status_change, ThreadID tid);
211 
215  void renameInsts(ThreadID tid);
216 
220  void skidInsert(ThreadID tid);
221 
225  void sortInsts();
226 
228  bool skidsEmpty();
229 
231  void updateStatus();
232 
237  bool block(ThreadID tid);
238 
243  bool unblock(ThreadID tid);
244 
246  void doSquash(const InstSeqNum &squash_seq_num, ThreadID tid);
247 
249  void removeFromHistory(InstSeqNum inst_seq_num, ThreadID tid);
250 
252  void renameSrcRegs(const DynInstPtr &inst, ThreadID tid);
253 
255  void renameDestRegs(const DynInstPtr &inst, ThreadID tid);
256 
258  int calcFreeROBEntries(ThreadID tid);
259 
261  int calcFreeIQEntries(ThreadID tid);
262 
264  int calcFreeLQEntries(ThreadID tid);
265 
267  int calcFreeSQEntries(ThreadID tid);
268 
270  unsigned validInsts();
271 
273  void readStallSignals(ThreadID tid);
274 
276  bool checkStall(ThreadID tid);
277 
279  void readFreeEntries(ThreadID tid);
280 
283 
291  void serializeAfter(InstQueue &inst_list, ThreadID tid);
292 
298  {
299  RenameHistory(InstSeqNum _instSeqNum, const RegId& _archReg,
300  PhysRegIdPtr _newPhysReg,
301  PhysRegIdPtr _prevPhysReg)
302  : instSeqNum(_instSeqNum), archReg(_archReg),
303  newPhysReg(_newPhysReg), prevPhysReg(_prevPhysReg)
304  {
305  }
306 
316  };
317 
322 
325 
328 
331 
334 
337 
340 
343 
346 
349 
352 
355 
358 
361 
364 
367 
372 
377 
382 
387 
391  struct FreeEntries
392  {
393  unsigned iqEntries;
394  unsigned robEntries;
395  unsigned lqEntries;
396  unsigned sqEntries;
397  };
398 
403 
409 
411  struct Stalls
412  {
413  bool iew;
414  bool commit;
415  };
416 
419 
422 
427 
430 
433 
436 
438  unsigned renameWidth;
439 
443  unsigned toIEWIndex;
444 
447 
451 
455 
458 
460  unsigned skidBufferMax;
461 
466  {
468  IQ,
469  LQ,
470  SQ,
471  NONE
472  };
473 
477  void incrFullStat(const FullSource &source);
478 
480  {
482 
535  } stats;
536 };
537 
538 } // namespace o3
539 } // namespace gem5
540 
541 #endif // __CPU_O3_RENAME_HH__
Physical register ID.
Definition: reg_class.hh:392
ProbePointArg generates a point for the class of Arg.
Definition: probe.hh:264
Register ID: describe an architectural register with its class and index.
Definition: reg_class.hh:91
O3CPU class, has each of the stages (fetch through commit) within it, as well as all of the time buff...
Definition: cpu.hh:94
Commit handles single threaded and SMT commit.
Definition: commit.hh:92
IEW handles both single threaded and SMT IEW (issue/execute/writeback).
Definition: iew.hh:88
Rename handles both single threaded and SMT rename.
Definition: rename.hh:79
DynInstPtr serializeInst[MaxThreads]
The serialize instruction that rename has stalled on.
Definition: rename.hh:421
void incrFullStat(const FullSource &source)
Function used to increment the stat that corresponds to the source of the stall.
Definition: rename.cc:1382
ThreadID numThreads
The number of threads active in rename.
Definition: rename.hh:457
TimeBuffer< RenameStruct >::wire toIEW
Wire to write any information heading to IEW.
Definition: rename.hh:342
void sortInsts()
Separates instructions from decode into individual lists of instructions sorted by thread.
Definition: rename.cc:790
void setCommitStage(Commit *commit_stage)
Sets pointer to commit stage.
Definition: rename.hh:150
ThreadStatus renameStatus[MaxThreads]
Per-thread status.
Definition: rename.hh:114
Rename(CPU *_cpu, const BaseO3CPUParams &params)
Rename constructor.
Definition: rename.cc:61
TimeBuffer< TimeStruct >::wire toDecode
Wire to write infromation heading to previous stages.
Definition: rename.hh:336
TimeBuffer< RenameStruct > * renameQueue
Rename instruction queue.
Definition: rename.hh:339
unsigned commitToRenameDelay
Delay between commit and rename, in ticks.
Definition: rename.hh:435
int storesInProgress[MaxThreads]
Count of Store instructions in progress that have been sent off to the IQ and ROB,...
Definition: rename.hh:381
ThreadStatus
Individual thread status.
Definition: rename.hh:99
int instsInProgress[MaxThreads]
Count of instructions in progress that have been sent off to the IQ and ROB, but are not yet included...
Definition: rename.hh:371
int calcFreeIQEntries(ThreadID tid)
Calculates the number of free IQ entries for a specific thread.
Definition: rename.cc:1141
void startupStage()
Initializes variables for the stage.
Definition: rename.cc:221
ProbePointArg< DynInstPtr > * ppRename
To probe when register renaming for an instruction is complete.
Definition: rename.hh:119
bool blockThisCycle
Whether or not rename needs to block this cycle.
Definition: rename.hh:446
void renameSrcRegs(const DynInstPtr &inst, ThreadID tid)
Renames the source registers of an instruction.
Definition: rename.cc:1006
void doSquash(const InstSeqNum &squash_seq_num, ThreadID tid)
Executes actual squash, removing squashed instructions.
Definition: rename.cc:912
void renameDestRegs(const DynInstPtr &inst, ThreadID tid)
Renames the destination registers of an instruction.
Definition: rename.cc:1076
unsigned skidBufferMax
The maximum skid buffer size.
Definition: rename.hh:460
std::list< ThreadID > * activeThreads
Pointer to the list of active threads.
Definition: rename.hh:363
UnifiedFreeList * freeList
Free list interface.
Definition: rename.hh:360
void tick()
Ticks rename, which processes all input signals and attempts to rename as many instructions as possib...
Definition: rename.cc:389
void readFreeEntries(ThreadID tid)
Gets the number of free entries for a specific thread.
Definition: rename.cc:1234
std::deque< DynInstPtr > InstQueue
Definition: rename.hh:85
int calcFreeROBEntries(ThreadID tid)
Calculates the number of free ROB entries for a specific thread.
Definition: rename.cc:1130
int iewToRenameDelay
Delay between iew and rename, in ticks.
Definition: rename.hh:429
RenameStatus _status
Rename status.
Definition: rename.hh:111
void renameInsts(ThreadID tid)
Renames instructions for the given thread.
Definition: rename.cc:507
void setFreeList(UnifiedFreeList *fl_ptr)
Sets pointer to the free list.
Definition: rename.cc:293
std::pair< InstSeqNum, PhysRegIdPtr > SeqNumRegPair
Probe points.
Definition: rename.hh:117
bool emptyROB[MaxThreads]
Records if the ROB is empty.
Definition: rename.hh:408
void rename(bool &status_change, ThreadID tid)
Determines what to do based on rename's current status.
Definition: rename.cc:452
TimeBuffer< TimeStruct >::wire fromIEW
Wire to get IEW's output from backwards time buffer.
Definition: rename.hh:330
std::string name() const
Returns the name of rename.
Definition: rename.cc:92
std::list< RenameHistory > historyBuffer[MaxThreads]
A per-thread list of all destination register renames, used to either undo rename mappings or free ol...
Definition: rename.hh:321
TimeBuffer< DecodeStruct >::wire fromDecode
Wire to get decode's output from decode queue.
Definition: rename.hh:348
void serializeAfter(InstQueue &inst_list, ThreadID tid)
Either serializes on the next instruction available in the InstQueue, or records that it must seriali...
Definition: rename.cc:1369
gem5::o3::Rename::RenameStats stats
TimeBuffer< DecodeStruct > * decodeQueue
Decode instruction queue interface.
Definition: rename.hh:345
unsigned renameWidth
Rename width, in instructions.
Definition: rename.hh:438
void setIEWStage(IEW *iew_stage)
Sets pointer to IEW stage.
Definition: rename.hh:146
bool resumeUnblocking
Whether or not rename needs to resume clearing out the skidbuffer after squashing.
Definition: rename.hh:454
InstQueue skidBuffer[MaxThreads]
Skid buffer between rename and decode.
Definition: rename.hh:354
Scoreboard * scoreboard
Pointer to the scoreboard.
Definition: rename.hh:366
void drainSanityCheck() const
Perform sanity checks after a drain.
Definition: rename.cc:325
bool skidsEmpty()
Returns if all of the skid buffers are empty.
Definition: rename.cc:805
IEW * iew_ptr
Pointer to IEW stage.
Definition: rename.hh:157
int calcFreeSQEntries(ThreadID tid)
Calculates the number of free SQ entries for a specific thread.
Definition: rename.cc:1165
void dumpHistory()
Debugging function used to dump history buffer of renamings.
Definition: rename.cc:1404
FullSource
Enum to record the source of a structure full stall.
Definition: rename.hh:466
UnifiedRenameMap * renameMap[MaxThreads]
Rename map interface.
Definition: rename.hh:357
bool block(ThreadID tid)
Switches rename to blocking, and signals back that rename has become blocked.
Definition: rename.cc:859
int loadsInProgress[MaxThreads]
Count of Load instructions in progress that have been sent off to the IQ and ROB, but are not yet inc...
Definition: rename.hh:376
TimeBuffer< TimeStruct >::wire fromCommit
Wire to get commit's output from backwards time buffer.
Definition: rename.hh:333
bool unblock(ThreadID tid)
Switches rename to unblocking if the skid buffer is empty, and signals back that rename has unblocked...
Definition: rename.cc:892
TimeBuffer< TimeStruct > * timeBuffer
Pointer to main time buffer used for backwards communication.
Definition: rename.hh:327
unsigned toIEWIndex
The index of the instruction in the time buffer to IEW that rename is currently using.
Definition: rename.hh:443
RenameStatus
Overall rename status.
Definition: rename.hh:92
void removeFromHistory(InstSeqNum inst_seq_num, ThreadID tid)
Removes a committed instruction's rename history.
Definition: rename.cc:957
void setTimeBuffer(TimeBuffer< TimeStruct > *tb_ptr)
Sets the main backwards communication time buffer pointer.
Definition: rename.cc:188
void takeOverFrom()
Takes over from another CPU's thread.
Definition: rename.cc:319
void setRenameMap(UnifiedRenameMap rm_ptr[MaxThreads])
Sets pointer to rename maps (per-thread structures).
Definition: rename.cc:286
Stalls stalls[MaxThreads]
Tracks which stages are telling decode to stall.
Definition: rename.hh:418
void regProbePoints()
Registers probes.
Definition: rename.cc:179
void setActiveThreads(std::list< ThreadID > *at_ptr)
Sets pointer to list of active threads.
Definition: rename.cc:279
void resetStage()
Reset this pipeline stage.
Definition: rename.cc:248
bool checkStall(ThreadID tid)
Checks if any stages are telling rename to block.
Definition: rename.cc:1203
InstQueue insts[MaxThreads]
Queue of all instructions coming from decode this cycle.
Definition: rename.hh:351
void skidInsert(ThreadID tid)
Inserts unused instructions from a given thread into the skid buffer, to be renamed once rename unblo...
Definition: rename.cc:757
void readStallSignals(ThreadID tid)
Reads signals telling rename to block/unblock.
Definition: rename.cc:1190
void updateStatus()
Updates overall rename status based on all of the threads' statuses.
Definition: rename.cc:821
bool checkSignalsAndUpdate(ThreadID tid)
Checks the signals and updates the status.
Definition: rename.cc:1270
void squash(const InstSeqNum &squash_seq_num, ThreadID tid)
Squashes all instructions in a thread.
Definition: rename.cc:336
bool isDrained() const
Has the stage drained?
Definition: rename.cc:305
void setScoreboard(Scoreboard *_scoreboard)
Sets pointer to the scoreboard.
Definition: rename.cc:299
FreeEntries freeEntries[MaxThreads]
Per-thread tracking of the number of free entries of back-end structures.
Definition: rename.hh:402
int calcFreeLQEntries(ThreadID tid)
Calculates the number of free LQ entries for a specific thread.
Definition: rename.cc:1152
Commit * commit_ptr
Pointer to commit stage.
Definition: rename.hh:160
bool serializeOnNextInst[MaxThreads]
Records if rename needs to serialize on the next instruction for any thread.
Definition: rename.hh:426
ProbePointArg< SeqNumRegPair > * ppSquashInRename
To probe when an instruction is squashed and the register mapping for it needs to be undone.
Definition: rename.hh:124
int decodeToRenameDelay
Delay between decode and rename, in ticks.
Definition: rename.hh:432
CPU * cpu
Pointer to CPU.
Definition: rename.hh:324
void clearStates(ThreadID tid)
Clear all thread-specific states.
Definition: rename.cc:227
bool wroteToTimeBuffer
Variable that tracks if decode has written to the time buffer this cycle.
Definition: rename.hh:386
void setDecodeQueue(TimeBuffer< DecodeStruct > *dq_ptr)
Sets pointer to time buffer coming from decode.
Definition: rename.cc:212
bool resumeSerialize
Whether or not rename needs to resume a serialize instruction after squashing.
Definition: rename.hh:450
void setRenameQueue(TimeBuffer< RenameStruct > *rq_ptr)
Sets pointer to time buffer used to communicate to the next stage.
Definition: rename.cc:203
unsigned validInsts()
Returns the number of valid instructions coming from decode.
Definition: rename.cc:1177
Implements a simple scoreboard to track which registers are ready.
Definition: scoreboard.hh:55
FreeList class that simply holds the list of free integer and floating point registers.
Definition: free_list.hh:125
Unified register rename map for all classes of registers.
Definition: rename_map.hh:169
Statistics container.
Definition: group.hh:94
This is a simple scalar statistic, like a counter.
Definition: statistics.hh:1931
STL pair class.
Definition: stl.hh:58
static constexpr int MaxThreads
Definition: limits.hh:38
Reference material can be found at the JEDEC website: UFS standard http://www.jedec....
int16_t ThreadID
Thread index/ID type.
Definition: types.hh:235
uint64_t InstSeqNum
Definition: inst_seq.hh:40
Declaration of Statistics objects.
Structures whose free entries impact the amount of instructions that can be renamed.
Definition: rename.hh:392
Holds the information for each destination register rename.
Definition: rename.hh:298
RenameHistory(InstSeqNum _instSeqNum, const RegId &_archReg, PhysRegIdPtr _newPhysReg, PhysRegIdPtr _prevPhysReg)
Definition: rename.hh:299
InstSeqNum instSeqNum
The sequence number of the instruction that renamed.
Definition: rename.hh:308
RegId archReg
The architectural register index that was renamed.
Definition: rename.hh:310
PhysRegIdPtr newPhysReg
The new physical register that the arch.
Definition: rename.hh:312
PhysRegIdPtr prevPhysReg
The old physical register that the arch.
Definition: rename.hh:315
statistics::Scalar blockCycles
Stat for total number of cycles spent blocking.
Definition: rename.hh:488
statistics::Scalar ROBFullEvents
Stat for total number of times that the ROB starts a stall in rename.
Definition: rename.hh:503
statistics::Scalar renamedOperands
Stat for total number of renamed destination registers.
Definition: rename.hh:517
statistics::Scalar fpLookups
Definition: rename.hh:521
statistics::Scalar fullRegistersEvents
Stat for total number of times that rename runs out of free registers to use to rename.
Definition: rename.hh:515
statistics::Scalar squashedInsts
Stat for total number of squashed instructions that rename discards.
Definition: rename.hh:500
statistics::Scalar IQFullEvents
Stat for total number of times that the IQ starts a stall in rename.
Definition: rename.hh:506
statistics::Scalar vecPredLookups
Definition: rename.hh:523
statistics::Scalar squashCycles
Stat for total number of cycles spent squashing.
Definition: rename.hh:484
statistics::Scalar renamedInsts
Stat for total number of renamed instructions.
Definition: rename.hh:497
statistics::Scalar LQFullEvents
Stat for total number of times that the LQ starts a stall in rename.
Definition: rename.hh:509
statistics::Scalar lookups
Stat for total number of source register rename lookups.
Definition: rename.hh:519
statistics::Scalar vecLookups
Definition: rename.hh:522
statistics::Scalar tempSerializing
Number of instructions marked as temporarily serializing.
Definition: rename.hh:532
statistics::Scalar serializing
Number of serialize instructions handled.
Definition: rename.hh:530
statistics::Scalar undoneMaps
Stat for total number of mappings that were undone due to a squash.
Definition: rename.hh:528
statistics::Scalar runCycles
Stat for total number of cycles spent running normally.
Definition: rename.hh:493
statistics::Scalar committedMaps
Stat for total number of committed renaming mappings.
Definition: rename.hh:525
statistics::Scalar intLookups
Definition: rename.hh:520
statistics::Scalar unblockCycles
Stat for total number of cycles spent unblocking.
Definition: rename.hh:495
statistics::Scalar idleCycles
Stat for total number of cycles spent idle.
Definition: rename.hh:486
RenameStats(statistics::Group *parent)
Definition: rename.cc:97
statistics::Scalar SQFullEvents
Stat for total number of times that the SQ starts a stall in rename.
Definition: rename.hh:512
statistics::Scalar skidInsts
Number of instructions inserted into skid buffers.
Definition: rename.hh:534
statistics::Scalar serializeStallCycles
Stat for total number of cycles spent stalling for a serializing inst.
Definition: rename.hh:491
Source of possible stalls.
Definition: rename.hh:412

Generated on Wed Dec 21 2022 10:22:31 for gem5 by doxygen 1.9.1