gem5  v19.0.0.0
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
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  * Authors: Kevin Lim
42  */
43 
44 #ifndef __CPU_O3_RENAME_HH__
45 #define __CPU_O3_RENAME_HH__
46 
47 #include <list>
48 #include <utility>
49 
50 #include "base/statistics.hh"
51 #include "config/the_isa.hh"
52 #include "cpu/timebuf.hh"
53 #include "sim/probe/probe.hh"
54 
55 struct DerivO3CPUParams;
56 
69 template<class Impl>
71 {
72  public:
73  // Typedefs from the Impl.
74  typedef typename Impl::CPUPol CPUPol;
75  typedef typename Impl::DynInstPtr DynInstPtr;
76  typedef typename Impl::O3CPU O3CPU;
77 
78  // Typedefs from the CPUPol
79  typedef typename CPUPol::DecodeStruct DecodeStruct;
80  typedef typename CPUPol::RenameStruct RenameStruct;
81  typedef typename CPUPol::TimeStruct TimeStruct;
82  typedef typename CPUPol::FreeList FreeList;
83  typedef typename CPUPol::RenameMap RenameMap;
84  // These are used only for initialization.
85  typedef typename CPUPol::IEW IEW;
86  typedef typename CPUPol::Commit Commit;
87 
88  // A deque is used to queue the instructions. Barrier insts must
89  // be added to the front of the queue, which is the only reason for
90  // using a deque instead of a queue. (Most other stages use a
91  // queue)
93 
94  public:
98  enum RenameStatus {
101  };
102 
112  };
113 
114  private:
117 
119  ThreadStatus renameStatus[Impl::MaxThreads];
120 
130 
131  public:
133  DefaultRename(O3CPU *_cpu, DerivO3CPUParams *params);
134 
136  std::string name() const;
137 
139  void regStats();
140 
142  void regProbePoints();
143 
146 
149 
152 
154  void setIEWStage(IEW *iew_stage)
155  { iew_ptr = iew_stage; }
156 
158  void setCommitStage(Commit *commit_stage)
159  { commit_ptr = commit_stage; }
160 
161  private:
163  IEW *iew_ptr;
164 
166  Commit *commit_ptr;
167 
168  public:
170  void startupStage();
171 
173  void clearStates(ThreadID tid);
174 
177 
179  void setRenameMap(RenameMap rm_ptr[Impl::MaxThreads]);
180 
182  void setFreeList(FreeList *fl_ptr);
183 
185  void setScoreboard(Scoreboard *_scoreboard);
186 
188  void drainSanityCheck() const;
189 
191  bool isDrained() const;
192 
194  void takeOverFrom();
195 
197  void squash(const InstSeqNum &squash_seq_num, ThreadID tid);
198 
202  void tick();
203 
205  void dumpHistory();
206 
207  private:
209  void resetStage();
210 
216  void rename(bool &status_change, ThreadID tid);
217 
221  void renameInsts(ThreadID tid);
222 
226  void skidInsert(ThreadID tid);
227 
231  void sortInsts();
232 
234  bool skidsEmpty();
235 
237  void updateStatus();
238 
243  bool block(ThreadID tid);
244 
249  bool unblock(ThreadID tid);
250 
252  void doSquash(const InstSeqNum &squash_seq_num, ThreadID tid);
253 
255  void removeFromHistory(InstSeqNum inst_seq_num, ThreadID tid);
256 
258  inline void renameSrcRegs(const DynInstPtr &inst, ThreadID tid);
259 
261  inline void renameDestRegs(const DynInstPtr &inst, ThreadID tid);
262 
264  inline int calcFreeROBEntries(ThreadID tid);
265 
267  inline int calcFreeIQEntries(ThreadID tid);
268 
270  inline int calcFreeLQEntries(ThreadID tid);
271 
273  inline int calcFreeSQEntries(ThreadID tid);
274 
276  unsigned validInsts();
277 
279  void readStallSignals(ThreadID tid);
280 
282  bool checkStall(ThreadID tid);
283 
285  void readFreeEntries(ThreadID tid);
286 
289 
297  void serializeAfter(InstQueue &inst_list, ThreadID tid);
298 
303  struct RenameHistory {
304  RenameHistory(InstSeqNum _instSeqNum, const RegId& _archReg,
305  PhysRegIdPtr _newPhysReg,
306  PhysRegIdPtr _prevPhysReg)
307  : instSeqNum(_instSeqNum), archReg(_archReg),
308  newPhysReg(_newPhysReg), prevPhysReg(_prevPhysReg)
309  {
310  }
311 
321  };
322 
327 
329  O3CPU *cpu;
330 
333 
336 
339 
342 
345 
348 
351 
354 
356  InstQueue insts[Impl::MaxThreads];
357 
359  InstQueue skidBuffer[Impl::MaxThreads];
360 
362  RenameMap *renameMap[Impl::MaxThreads];
363 
365  FreeList *freeList;
366 
369 
372 
376  int instsInProgress[Impl::MaxThreads];
377 
381  int loadsInProgress[Impl::MaxThreads];
382 
386  int storesInProgress[Impl::MaxThreads];
387 
392 
396  struct FreeEntries {
397  unsigned iqEntries;
398  unsigned robEntries;
399  unsigned lqEntries;
400  unsigned sqEntries;
401  };
402 
406  FreeEntries freeEntries[Impl::MaxThreads];
407 
412  bool emptyROB[Impl::MaxThreads];
413 
415  struct Stalls {
416  bool iew;
417  bool commit;
418  };
419 
421  Stalls stalls[Impl::MaxThreads];
422 
424  DynInstPtr serializeInst[Impl::MaxThreads];
425 
429  bool serializeOnNextInst[Impl::MaxThreads];
430 
433 
436 
439 
441  unsigned renameWidth;
442 
446  unsigned commitWidth;
447 
451  unsigned toIEWIndex;
452 
455 
459 
463 
466 
468  unsigned skidBufferMax;
469 
473  enum FullSource {
475  IQ,
476  LQ,
477  SQ,
479  };
480 
484  inline void incrFullStat(const FullSource &source);
485 
531 };
532 
533 #endif // __CPU_O3_RENAME_HH__
PhysRegIdPtr newPhysReg
The new physical register that the arch.
Definition: rename.hh:317
Structures whose free entries impact the amount of instructions that can be renamed.
Definition: rename.hh:396
void setScoreboard(Scoreboard *_scoreboard)
Sets pointer to the scoreboard.
Definition: rename_impl.hh:334
ThreadStatus
Individual thread status.
Definition: rename.hh:104
Stats::Scalar renameFullRegistersEvents
Stat for total number of times that rename runs out of free registers to use to rename.
Definition: rename.hh:512
int decodeToRenameDelay
Delay between decode and rename, in ticks.
Definition: rename.hh:435
void readStallSignals(ThreadID tid)
Reads signals telling rename to block/unblock.
bool unblock(ThreadID tid)
Switches rename to unblocking if the skid buffer is empty, and signals back that rename has unblocked...
Definition: rename_impl.hh:944
Impl::DynInstPtr DynInstPtr
Definition: rename.hh:75
Stats::Scalar renameRunCycles
Stat for total number of cycles spent running normally.
Definition: rename.hh:495
int iewToRenameDelay
Delay between iew and rename, in ticks.
Definition: rename.hh:432
RenameStatus _status
Rename status.
Definition: rename.hh:116
DefaultRename handles both single threaded and SMT rename.
Definition: rename.hh:70
RenameMap * renameMap[Impl::MaxThreads]
Rename map interface.
Definition: rename.hh:362
TimeBuffer< RenameStruct >::wire toIEW
Wire to write any information heading to IEW.
Definition: rename.hh:347
ProbePointArg< DynInstPtr > * ppRename
To probe when register renaming for an instruction is complete.
Definition: rename.hh:124
CPUPol::Commit Commit
Definition: rename.hh:86
void setFreeList(FreeList *fl_ptr)
Sets pointer to the free list.
Definition: rename_impl.hh:327
void drainSanityCheck() const
Perform sanity checks after a drain.
Definition: rename_impl.hh:363
std::list< ThreadID > * activeThreads
Pointer to the list of active threads.
Definition: rename.hh:368
STL pair class.
Definition: stl.hh:61
FreeEntries freeEntries[Impl::MaxThreads]
Per-thread tracking of the number of free entries of back-end structures.
Definition: rename.hh:406
void setRenameQueue(TimeBuffer< RenameStruct > *rq_ptr)
Sets pointer to time buffer used to communicate to the next stage.
Definition: rename_impl.hh:232
TimeBuffer< TimeStruct > * timeBuffer
Pointer to main time buffer used for backwards communication.
Definition: rename.hh:332
bool block(ThreadID tid)
Switches rename to blocking, and signals back that rename has become blocked.
Definition: rename_impl.hh:910
void clearStates(ThreadID tid)
Clear all thread-specific states.
Definition: rename_impl.hh:259
std::string name() const
Returns the name of rename.
Definition: rename_impl.hh:95
Stats::Scalar renameRenamedOperands
Stat for total number of renamed destination registers.
Definition: rename.hh:514
IEW * iew_ptr
Pointer to IEW stage.
Definition: rename.hh:163
Stats::Scalar renameROBFullEvents
Stat for total number of times that the ROB starts a stall in rename.
Definition: rename.hh:503
CPUPol::TimeStruct TimeStruct
Definition: rename.hh:81
void renameDestRegs(const DynInstPtr &inst, ThreadID tid)
Renames the destination registers of an instruction.
bool serializeOnNextInst[Impl::MaxThreads]
Records if rename needs to serialize on the next instruction for any thread.
Definition: rename.hh:429
void regProbePoints()
Registers probes.
Definition: rename_impl.hh:207
Stalls stalls[Impl::MaxThreads]
Tracks which stages are telling decode to stall.
Definition: rename.hh:421
bool wroteToTimeBuffer
Variable that tracks if decode has written to the time buffer this cycle.
Definition: rename.hh:391
Stats::Scalar renamedSerializing
Number of serialize instructions handled.
Definition: rename.hh:526
PhysRegIdPtr prevPhysReg
The old physical register that the arch.
Definition: rename.hh:320
int calcFreeSQEntries(ThreadID tid)
Calculates the number of free SQ entries for a specific thread.
TimeBuffer< DecodeStruct > * decodeQueue
Decode instruction queue interface.
Definition: rename.hh:350
bool resumeSerialize
Whether or not rename needs to resume a serialize instruction after squashing.
Definition: rename.hh:458
unsigned commitWidth
Commit width, in instructions.
Definition: rename.hh:446
void doSquash(const InstSeqNum &squash_seq_num, ThreadID tid)
Executes actual squash, removing squashed instructions.
Definition: rename_impl.hh:965
Stats::Scalar renameSquashedInsts
Stat for total number of squashed instructions that rename discards.
Definition: rename.hh:501
CPUPol::FreeList FreeList
Definition: rename.hh:82
unsigned validInsts()
Returns the number of valid instructions coming from decode.
void dumpHistory()
Debugging function used to dump history buffer of renamings.
Declaration of Statistics objects.
Stats::Scalar renamedTempSerializing
Number of instructions marked as temporarily serializing.
Definition: rename.hh:528
Scoreboard * scoreboard
Pointer to the scoreboard.
Definition: rename.hh:371
This is a simple scalar statistic, like a counter.
Definition: statistics.hh:2508
void renameSrcRegs(const DynInstPtr &inst, ThreadID tid)
Renames the source registers of an instruction.
Impl::CPUPol CPUPol
Definition: rename.hh:74
bool checkSignalsAndUpdate(ThreadID tid)
Checks the signals and updates the status.
void setCommitStage(Commit *commit_stage)
Sets pointer to commit stage.
Definition: rename.hh:158
unsigned toIEWIndex
The index of the instruction in the time buffer to IEW that rename is currently using.
Definition: rename.hh:451
TimeBuffer< TimeStruct >::wire fromCommit
Wire to get commit&#39;s output from backwards time buffer.
Definition: rename.hh:338
RenameHistory(InstSeqNum _instSeqNum, const RegId &_archReg, PhysRegIdPtr _newPhysReg, PhysRegIdPtr _prevPhysReg)
Definition: rename.hh:304
Stats::Scalar renameUnblockCycles
Stat for total number of cycles spent unblocking.
Definition: rename.hh:497
void regStats()
Registers statistics.
Definition: rename_impl.hh:102
TimeBuffer< RenameStruct > * renameQueue
Rename instruction queue.
Definition: rename.hh:344
void renameInsts(ThreadID tid)
Renames instructions for the given thread.
Definition: rename_impl.hh:549
int loadsInProgress[Impl::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:381
Impl::O3CPU O3CPU
Definition: rename.hh:76
Implements a simple scoreboard to track which registers are ready.
Definition: scoreboard.hh:52
std::list< RenameHistory > historyBuffer[Impl::MaxThreads]
A per-thread list of all destination register renames, used to either undo rename mappings or free ol...
Definition: rename.hh:326
bool skidsEmpty()
Returns if all of the skid buffers are empty.
Definition: rename_impl.hh:854
Stats::Scalar renameIQFullEvents
Stat for total number of times that the IQ starts a stall in rename.
Definition: rename.hh:505
void removeFromHistory(InstSeqNum inst_seq_num, ThreadID tid)
Removes a committed instruction&#39;s rename history.
Stats::Scalar renameCommittedMaps
Stat for total number of committed renaming mappings.
Definition: rename.hh:522
std::pair< InstSeqNum, PhysRegIdPtr > SeqNumRegPair
Probe points.
Definition: rename.hh:122
Stats::Scalar renameRenamedInsts
Stat for total number of renamed instructions.
Definition: rename.hh:499
CPUPol::RenameMap RenameMap
Definition: rename.hh:83
Holds the information for each destination register rename.
Definition: rename.hh:303
Commit * commit_ptr
Pointer to commit stage.
Definition: rename.hh:166
void readFreeEntries(ThreadID tid)
Gets the number of free entries for a specific thread.
O3CPU * cpu
Pointer to CPU.
Definition: rename.hh:329
void takeOverFrom()
Takes over from another CPU&#39;s thread.
Definition: rename_impl.hh:356
void skidInsert(ThreadID tid)
Inserts unused instructions from a given thread into the skid buffer, to be renamed once rename unblo...
Definition: rename_impl.hh:803
uint64_t InstSeqNum
Definition: inst_seq.hh:40
TimeBuffer< DecodeStruct >::wire fromDecode
Wire to get decode&#39;s output from decode queue.
Definition: rename.hh:353
bool isDrained() const
Has the stage drained?
Definition: rename_impl.hh:341
RenameStatus
Overall rename status.
Definition: rename.hh:98
FullSource
Enum to record the source of a structure full stall.
Definition: rename.hh:473
int calcFreeROBEntries(ThreadID tid)
Calculates the number of free ROB entries for a specific thread.
Stats::Scalar renameSquashCycles
Stat for total number of cycles spent squashing.
Definition: rename.hh:487
ProbePointArg< SeqNumRegPair > * ppSquashInRename
To probe when an instruction is squashed and the register mapping for it needs to be undone...
Definition: rename.hh:129
Stats::Scalar renameSerializeStallCycles
Stat for total number of cycles spent stalling for a serializing inst.
Definition: rename.hh:493
void squash(const InstSeqNum &squash_seq_num, ThreadID tid)
Squashes all instructions in a thread.
Definition: rename_impl.hh:375
ThreadID numThreads
The number of threads active in rename.
Definition: rename.hh:465
InstQueue skidBuffer[Impl::MaxThreads]
Skid buffer between rename and decode.
Definition: rename.hh:359
int instsInProgress[Impl::MaxThreads]
Count of instructions in progress that have been sent off to the IQ and ROB, but are not yet included...
Definition: rename.hh:376
Stats::Scalar renameBlockCycles
Stat for total number of cycles spent blocking.
Definition: rename.hh:491
TimeBuffer< TimeStruct >::wire fromIEW
Wire to get IEW&#39;s output from backwards time buffer.
Definition: rename.hh:335
Stats::Scalar renameRenameLookups
Stat for total number of source register rename lookups.
Definition: rename.hh:516
RegId archReg
The architectural register index that was renamed.
Definition: rename.hh:315
Stats::Scalar renameLQFullEvents
Stat for total number of times that the LQ starts a stall in rename.
Definition: rename.hh:507
CPUPol::DecodeStruct DecodeStruct
Definition: rename.hh:79
void resetStage()
Reset this pipeline stage.
Definition: rename_impl.hh:281
Physical register ID.
Definition: reg_class.hh:229
Stats::Scalar renameSQFullEvents
Stat for total number of times that the SQ starts a stall in rename.
Definition: rename.hh:509
int16_t ThreadID
Thread index/ID type.
Definition: types.hh:227
Stats::Scalar fpRenameLookups
Definition: rename.hh:518
void rename(bool &status_change, ThreadID tid)
Determines what to do based on rename&#39;s current status.
Definition: rename_impl.hh:493
int calcFreeLQEntries(ThreadID tid)
Calculates the number of free LQ entries for a specific thread.
int storesInProgress[Impl::MaxThreads]
Count of Store instructions in progress that have been sent off to the IQ and ROB, but are not yet included in their occupancy counts.
Definition: rename.hh:386
bool blockThisCycle
Whether or not rename needs to block this cycle.
Definition: rename.hh:454
void setActiveThreads(std::list< ThreadID > *at_ptr)
Sets pointer to list of active threads.
Definition: rename_impl.hh:311
void tick()
Ticks rename, which processes all input signals and attempts to rename as many instructions as possib...
Definition: rename_impl.hh:429
TimeBuffer< TimeStruct >::wire toDecode
Wire to write infromation heading to previous stages.
Definition: rename.hh:341
bool emptyROB[Impl::MaxThreads]
Records if the ROB is empty.
Definition: rename.hh:412
unsigned commitToRenameDelay
Delay between commit and rename, in ticks.
Definition: rename.hh:438
InstQueue insts[Impl::MaxThreads]
Queue of all instructions coming from decode this cycle.
Definition: rename.hh:356
void startupStage()
Initializes variables for the stage.
Definition: rename_impl.hh:252
void setTimeBuffer(TimeBuffer< TimeStruct > *tb_ptr)
Sets the main backwards communication time buffer pointer.
Definition: rename_impl.hh:216
int calcFreeIQEntries(ThreadID tid)
Calculates the number of free IQ entries for a specific thread.
Stats::Scalar renameUndoneMaps
Stat for total number of mappings that were undone due to a squash.
Definition: rename.hh:524
Stats::Scalar vecRenameLookups
Definition: rename.hh:519
void sortInsts()
Separates instructions from decode into individual lists of instructions sorted by thread...
Definition: rename_impl.hh:838
void setRenameMap(RenameMap rm_ptr[Impl::MaxThreads])
Sets pointer to rename maps (per-thread structures).
Definition: rename_impl.hh:319
Register ID: describe an architectural register with its class and index.
Definition: reg_class.hh:79
void incrFullStat(const FullSource &source)
Function used to increment the stat that corresponds to the source of the stall.
unsigned skidBufferMax
The maximum skid buffer size.
Definition: rename.hh:468
FreeList * freeList
Free list interface.
Definition: rename.hh:365
Stats::Scalar vecPredRenameLookups
Definition: rename.hh:520
DefaultRename(O3CPU *_cpu, DerivO3CPUParams *params)
DefaultRename constructor.
Definition: rename_impl.hh:63
void updateStatus()
Updates overall rename status based on all of the threads&#39; statuses.
Definition: rename_impl.hh:871
void serializeAfter(InstQueue &inst_list, ThreadID tid)
Either serializes on the next instruction available in the InstQueue, or records that it must seriali...
CPUPol::RenameStruct RenameStruct
Definition: rename.hh:80
Source of possible stalls.
Definition: rename.hh:415
Stats::Scalar renameSkidInsts
Number of instructions inserted into skid buffers.
Definition: rename.hh:530
CPUPol::IEW IEW
Definition: rename.hh:85
unsigned renameWidth
Rename width, in instructions.
Definition: rename.hh:441
DynInstPtr serializeInst[Impl::MaxThreads]
The serialize instruction that rename has stalled on.
Definition: rename.hh:424
bool resumeUnblocking
Whether or not rename needs to resume clearing out the skidbuffer after squashing.
Definition: rename.hh:462
bool checkStall(ThreadID tid)
Checks if any stages are telling rename to block.
Stats::Scalar intRenameLookups
Definition: rename.hh:517
std::deque< DynInstPtr > InstQueue
Definition: rename.hh:92
void setDecodeQueue(TimeBuffer< DecodeStruct > *dq_ptr)
Sets pointer to time buffer coming from decode.
Definition: rename_impl.hh:242
InstSeqNum instSeqNum
The sequence number of the instruction that renamed.
Definition: rename.hh:313
void setIEWStage(IEW *iew_stage)
Sets pointer to IEW stage.
Definition: rename.hh:154
ThreadStatus renameStatus[Impl::MaxThreads]
Per-thread status.
Definition: rename.hh:119
Stats::Scalar renameIdleCycles
Stat for total number of cycles spent idle.
Definition: rename.hh:489

Generated on Fri Feb 28 2020 16:26:59 for gem5 by doxygen 1.8.13