gem5
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
rename.hh
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2012 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  // Typedefs from the ISA.
90 
91  // A deque is used to queue the instructions. Barrier insts must
92  // be added to the front of the queue, which is the only reason for
93  // using a deque instead of a queue. (Most other stages use a
94  // queue)
96 
97  public:
104  };
105 
115  };
116 
117  private:
120 
122  ThreadStatus renameStatus[Impl::MaxThreads];
123 
133 
134  public:
136  DefaultRename(O3CPU *_cpu, DerivO3CPUParams *params);
137 
139  std::string name() const;
140 
142  void regStats();
143 
145  void regProbePoints();
146 
149 
152 
155 
157  void setIEWStage(IEW *iew_stage)
158  { iew_ptr = iew_stage; }
159 
161  void setCommitStage(Commit *commit_stage)
162  { commit_ptr = commit_stage; }
163 
164  private:
167 
170 
171  public:
173  void startupStage();
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(DynInstPtr &inst, ThreadID tid);
259 
261  inline void renameDestRegs(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, RegIndex _archReg,
305  PhysRegIndex _newPhysReg, PhysRegIndex _prevPhysReg)
306  : instSeqNum(_instSeqNum), archReg(_archReg),
307  newPhysReg(_newPhysReg), prevPhysReg(_prevPhysReg)
308  {
309  }
310 
319  };
320 
325 
328 
331 
334 
337 
340 
343 
346 
349 
352 
354  InstQueue insts[Impl::MaxThreads];
355 
357  InstQueue skidBuffer[Impl::MaxThreads];
358 
360  RenameMap *renameMap[Impl::MaxThreads];
361 
364 
367 
370 
374  int instsInProgress[Impl::MaxThreads];
375 
379  int loadsInProgress[Impl::MaxThreads];
380 
384  int storesInProgress[Impl::MaxThreads];
385 
390 
394  struct FreeEntries {
395  unsigned iqEntries;
396  unsigned robEntries;
397  unsigned lqEntries;
398  unsigned sqEntries;
399  };
400 
404  FreeEntries freeEntries[Impl::MaxThreads];
405 
410  bool emptyROB[Impl::MaxThreads];
411 
413  struct Stalls {
414  bool iew;
415  bool commit;
416  };
417 
419  Stalls stalls[Impl::MaxThreads];
420 
422  DynInstPtr serializeInst[Impl::MaxThreads];
423 
427  bool serializeOnNextInst[Impl::MaxThreads];
428 
431 
434 
437 
439  unsigned renameWidth;
440 
444  unsigned commitWidth;
445 
449  unsigned toIEWIndex;
450 
453 
457 
461 
464 
466  unsigned skidBufferMax;
467 
469 
473  enum FullSource {
475  IQ,
476  LQ,
477  SQ,
479  };
480 
484  inline void incrFullStat(const FullSource &source);
485 
529 };
530 
531 #endif // __CPU_O3_RENAME_HH__
Structures whose free entries impact the amount of instructions that can be renamed.
Definition: rename.hh:394
void setScoreboard(Scoreboard *_scoreboard)
Sets pointer to the scoreboard.
Definition: rename_impl.hh:294
ThreadStatus
Individual thread status.
Definition: rename.hh:107
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:433
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:888
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:430
RenameStatus _status
Rename status.
Definition: rename.hh:119
DefaultRename handles both single threaded and SMT rename.
Definition: rename.hh:70
PhysRegIndex newPhysReg
The new physical register that the arch.
Definition: rename.hh:316
RenameMap * renameMap[Impl::MaxThreads]
Rename map interface.
Definition: rename.hh:360
TimeBuffer< RenameStruct >::wire toIEW
Wire to write any information heading to IEW.
Definition: rename.hh:345
ProbePointArg< DynInstPtr > * ppRename
To probe when register renaming for an instruction is complete.
Definition: rename.hh:127
CPUPol::Commit Commit
Definition: rename.hh:86
void setFreeList(FreeList *fl_ptr)
Sets pointer to the free list.
Definition: rename_impl.hh:287
std::list< ThreadID > * activeThreads
Pointer to the list of active threads.
Definition: rename.hh:366
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:404
void setRenameQueue(TimeBuffer< RenameStruct > *rq_ptr)
Sets pointer to time buffer used to communicate to the next stage.
Definition: rename_impl.hh:214
TimeBuffer< TimeStruct > * timeBuffer
Pointer to main time buffer used for backwards communication.
Definition: rename.hh:330
PhysRegIndex prevPhysReg
The old physical register that the arch.
Definition: rename.hh:318
bool block(ThreadID tid)
Switches rename to blocking, and signals back that rename has become blocked.
Definition: rename_impl.hh:854
bool isDrained() const
Has the stage drained?
Definition: rename_impl.hh:301
void renameDestRegs(DynInstPtr &inst, ThreadID tid)
Renames the destination registers of an instruction.
PhysRegIndex maxPhysicalRegs
Definition: rename.hh:468
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:166
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
bool serializeOnNextInst[Impl::MaxThreads]
Records if rename needs to serialize on the next instruction for any thread.
Definition: rename.hh:427
void regProbePoints()
Registers probes.
Definition: rename_impl.hh:189
Stalls stalls[Impl::MaxThreads]
Tracks which stages are telling decode to stall.
Definition: rename.hh:419
bool wroteToTimeBuffer
Variable that tracks if decode has written to the time buffer this cycle.
Definition: rename.hh:389
void renameSrcRegs(DynInstPtr &inst, ThreadID tid)
Renames the source registers of an instruction.
Stats::Scalar renamedSerializing
Number of serialize instructions handled.
Definition: rename.hh:524
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:348
bool resumeSerialize
Whether or not rename needs to resume a serialize instruction after squashing.
Definition: rename.hh:456
unsigned commitWidth
Commit width, in instructions.
Definition: rename.hh:444
void doSquash(const InstSeqNum &squash_seq_num, ThreadID tid)
Executes actual squash, removing squashed instructions.
Definition: rename_impl.hh:909
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:526
Scoreboard * scoreboard
Pointer to the scoreboard.
Definition: rename.hh:369
This is a simple scalar statistic, like a counter.
Definition: statistics.hh:2475
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:161
unsigned toIEWIndex
The index of the instruction in the time buffer to IEW that rename is currently using.
Definition: rename.hh:449
TimeBuffer< TimeStruct >::wire fromCommit
Wire to get commit's output from backwards time buffer.
Definition: rename.hh:336
Stats::Scalar renameUnblockCycles
Stat for total number of cycles spent unblocking.
Definition: rename.hh:497
void regStats()
Registers statistics.
Definition: rename_impl.hh:92
std::pair< InstSeqNum, short int > SeqNumRegPair
Probe points.
Definition: rename.hh:125
TimeBuffer< RenameStruct > * renameQueue
Rename instruction queue.
Definition: rename.hh:342
void renameInsts(ThreadID tid)
Renames instructions for the given thread.
Definition: rename_impl.hh:504
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:379
Impl::O3CPU O3CPU
Definition: rename.hh:76
Implements a simple scoreboard to track which registers are ready.
Definition: scoreboard.hh:56
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:324
uint8_t RegIndex
Definition: registers.hh:46
bool skidsEmpty()
Returns if all of the skid buffers are empty.
Definition: rename_impl.hh:798
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's rename history.
Definition: rename_impl.hh:958
Stats::Scalar renameCommittedMaps
Stat for total number of committed renaming mappings.
Definition: rename.hh:520
void drainSanityCheck() const
Perform sanity checks after a drain.
Definition: rename_impl.hh:323
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:169
void readFreeEntries(ThreadID tid)
Gets the number of free entries for a specific thread.
O3CPU * cpu
Pointer to CPU.
Definition: rename.hh:327
void takeOverFrom()
Takes over from another CPU's thread.
Definition: rename_impl.hh:316
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:747
uint64_t InstSeqNum
Definition: inst_seq.hh:40
TimeBuffer< DecodeStruct >::wire fromDecode
Wire to get decode's output from decode queue.
Definition: rename.hh:351
RenameStatus
Overall rename status.
Definition: rename.hh:101
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:132
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:335
ThreadID numThreads
The number of threads active in rename.
Definition: rename.hh:463
InstQueue skidBuffer[Impl::MaxThreads]
Skid buffer between rename and decode.
Definition: rename.hh:357
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:374
Stats::Scalar renameBlockCycles
Stat for total number of cycles spent blocking.
Definition: rename.hh:491
TimeBuffer< TimeStruct >::wire fromIEW
Wire to get IEW's output from backwards time buffer.
Definition: rename.hh:333
Stats::Scalar renameRenameLookups
Stat for total number of source register rename lookups.
Definition: rename.hh:516
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:241
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:171
Stats::Scalar fpRenameLookups
Definition: rename.hh:518
void rename(bool &status_change, ThreadID tid)
Determines what to do based on rename's current status.
Definition: rename_impl.hh:450
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:384
bool blockThisCycle
Whether or not rename needs to block this cycle.
Definition: rename.hh:452
void setActiveThreads(std::list< ThreadID > *at_ptr)
Sets pointer to list of active threads.
Definition: rename_impl.hh:271
void tick()
Ticks rename, which processes all input signals and attempts to rename as many instructions as possib...
Definition: rename_impl.hh:386
TheISA::RegIndex RegIndex
Definition: rename.hh:89
std::string name() const
Returns the name of rename.
Definition: rename_impl.hh:85
TimeBuffer< TimeStruct >::wire toDecode
Wire to write infromation heading to previous stages.
Definition: rename.hh:339
RegIndex archReg
The architectural register index that was renamed.
Definition: rename.hh:314
bool emptyROB[Impl::MaxThreads]
Records if the ROB is empty.
Definition: rename.hh:410
unsigned commitToRenameDelay
Delay between commit and rename, in ticks.
Definition: rename.hh:436
InstQueue insts[Impl::MaxThreads]
Queue of all instructions coming from decode this cycle.
Definition: rename.hh:354
short int PhysRegIndex
Definition: comm.hh:57
void startupStage()
Initializes variables for the stage.
Definition: rename_impl.hh:234
void setTimeBuffer(TimeBuffer< TimeStruct > *tb_ptr)
Sets the main backwards communication time buffer pointer.
Definition: rename_impl.hh:198
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:522
void sortInsts()
Separates instructions from decode into individual lists of instructions sorted by thread...
Definition: rename_impl.hh:782
void setRenameMap(RenameMap rm_ptr[Impl::MaxThreads])
Sets pointer to rename maps (per-thread structures).
Definition: rename_impl.hh:279
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:466
FreeList * freeList
Free list interface.
Definition: rename.hh:363
DefaultRename(O3CPU *_cpu, DerivO3CPUParams *params)
DefaultRename constructor.
Definition: rename_impl.hh:63
void updateStatus()
Updates overall rename status based on all of the threads' statuses.
Definition: rename_impl.hh:815
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:413
Stats::Scalar renameSkidInsts
Number of instructions inserted into skid buffers.
Definition: rename.hh:528
CPUPol::IEW IEW
Definition: rename.hh:85
unsigned renameWidth
Rename width, in instructions.
Definition: rename.hh:439
DynInstPtr serializeInst[Impl::MaxThreads]
The serialize instruction that rename has stalled on.
Definition: rename.hh:422
bool resumeUnblocking
Whether or not rename needs to resume clearing out the skidbuffer after squashing.
Definition: rename.hh:460
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:95
void setDecodeQueue(TimeBuffer< DecodeStruct > *dq_ptr)
Sets pointer to time buffer coming from decode.
Definition: rename_impl.hh:224
InstSeqNum instSeqNum
The sequence number of the instruction that renamed.
Definition: rename.hh:312
void setIEWStage(IEW *iew_stage)
Sets pointer to IEW stage.
Definition: rename.hh:157
ThreadStatus renameStatus[Impl::MaxThreads]
Per-thread status.
Definition: rename.hh:122
RenameHistory(InstSeqNum _instSeqNum, RegIndex _archReg, PhysRegIndex _newPhysReg, PhysRegIndex _prevPhysReg)
Definition: rename.hh:304
Stats::Scalar renameIdleCycles
Stat for total number of cycles spent idle.
Definition: rename.hh:489

Generated on Fri Jun 9 2017 13:03:44 for gem5 by doxygen 1.8.6