rename.hh revision 2733
12810SN/A/* 212724Snikos.nikoleris@arm.com * Copyright (c) 2004-2006 The Regents of The University of Michigan 38856Sandreas.hansson@arm.com * All rights reserved. 48856Sandreas.hansson@arm.com * 58856Sandreas.hansson@arm.com * Redistribution and use in source and binary forms, with or without 68856Sandreas.hansson@arm.com * modification, are permitted provided that the following conditions are 78856Sandreas.hansson@arm.com * met: redistributions of source code must retain the above copyright 88856Sandreas.hansson@arm.com * notice, this list of conditions and the following disclaimer; 98856Sandreas.hansson@arm.com * redistributions in binary form must reproduce the above copyright 108856Sandreas.hansson@arm.com * notice, this list of conditions and the following disclaimer in the 118856Sandreas.hansson@arm.com * documentation and/or other materials provided with the distribution; 128856Sandreas.hansson@arm.com * neither the name of the copyright holders nor the names of its 138856Sandreas.hansson@arm.com * contributors may be used to endorse or promote products derived from 142810SN/A * this software without specific prior written permission. 152810SN/A * 162810SN/A * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 172810SN/A * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 182810SN/A * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 192810SN/A * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 202810SN/A * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 212810SN/A * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 222810SN/A * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 232810SN/A * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 242810SN/A * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 252810SN/A * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 262810SN/A * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 272810SN/A * 282810SN/A * Authors: Kevin Lim 292810SN/A */ 302810SN/A 312810SN/A#ifndef __CPU_O3_RENAME_HH__ 322810SN/A#define __CPU_O3_RENAME_HH__ 332810SN/A 342810SN/A#include <list> 352810SN/A 362810SN/A#include "base/statistics.hh" 372810SN/A#include "base/timebuf.hh" 382810SN/A 392810SN/A/** 402810SN/A * DefaultRename handles both single threaded and SMT rename. Its 4112724Snikos.nikoleris@arm.com * width is specified by the parameters; each cycle it tries to rename 422810SN/A * that many instructions. It holds onto the rename history of all 432810SN/A * instructions with destination registers, storing the 442810SN/A * arch. register, the new physical register, and the old physical 452810SN/A * register, to allow for undoing of mappings if squashing happens, or 462810SN/A * freeing up registers upon commit. Rename handles blocking if the 472810SN/A * ROB, IQ, or LSQ is going to be full. Rename also handles barriers, 482810SN/A * and does so by stalling on the instruction until the ROB is empty 4911486Snikos.nikoleris@arm.com * and there are no instructions in flight to the ROB. 5011486Snikos.nikoleris@arm.com */ 5112724Snikos.nikoleris@arm.comtemplate<class Impl> 5212724Snikos.nikoleris@arm.comclass DefaultRename 538232Snate@binkert.org{ 5412724Snikos.nikoleris@arm.com public: 5512724Snikos.nikoleris@arm.com // Typedefs from the Impl. 5611486Snikos.nikoleris@arm.com typedef typename Impl::CPUPol CPUPol; 5712724Snikos.nikoleris@arm.com typedef typename Impl::DynInstPtr DynInstPtr; 5812724Snikos.nikoleris@arm.com typedef typename Impl::O3CPU O3CPU; 5912724Snikos.nikoleris@arm.com typedef typename Impl::Params Params; 6012724Snikos.nikoleris@arm.com 6112724Snikos.nikoleris@arm.com // Typedefs from the CPUPol 6212724Snikos.nikoleris@arm.com typedef typename CPUPol::DecodeStruct DecodeStruct; 6312724Snikos.nikoleris@arm.com typedef typename CPUPol::RenameStruct RenameStruct; 642810SN/A typedef typename CPUPol::TimeStruct TimeStruct; 652810SN/A typedef typename CPUPol::FreeList FreeList; 662810SN/A typedef typename CPUPol::RenameMap RenameMap; 678856Sandreas.hansson@arm.com // These are used only for initialization. 688856Sandreas.hansson@arm.com typedef typename CPUPol::IEW IEW; 698856Sandreas.hansson@arm.com typedef typename CPUPol::Commit Commit; 708922Swilliam.wang@arm.com 7112084Sspwilson2@wisc.edu // Typedefs from the ISA. 7212084Sspwilson2@wisc.edu typedef TheISA::RegIndex RegIndex; 738856Sandreas.hansson@arm.com 748856Sandreas.hansson@arm.com // A list is used to queue the instructions. Barrier insts must 754475SN/A // be added to the front of the list, which is the only reason for 7611053Sandreas.hansson@arm.com // using a list instead of a queue. (Most other stages use a 775034SN/A // queue) 7812724Snikos.nikoleris@arm.com typedef std::list<DynInstPtr> InstQueue; 7912724Snikos.nikoleris@arm.com 8011377Sandreas.hansson@arm.com public: 8111377Sandreas.hansson@arm.com /** Overall rename status. Used to determine if the CPU can 8212724Snikos.nikoleris@arm.com * deschedule itself due to a lack of activity. 8312724Snikos.nikoleris@arm.com */ 8412724Snikos.nikoleris@arm.com enum RenameStatus { 8512724Snikos.nikoleris@arm.com Active, 8612724Snikos.nikoleris@arm.com Inactive 8712724Snikos.nikoleris@arm.com }; 8812724Snikos.nikoleris@arm.com 8912724Snikos.nikoleris@arm.com /** Individual thread status. */ 9011053Sandreas.hansson@arm.com enum ThreadStatus { 9111722Ssophiane.senni@gmail.com Running, 9211722Ssophiane.senni@gmail.com Idle, 9311722Ssophiane.senni@gmail.com StartSquash, 9411722Ssophiane.senni@gmail.com Squashing, 959263Smrinmoy.ghosh@arm.com Blocked, 965034SN/A Unblocking, 9711331Sandreas.hansson@arm.com SerializeStall 9812724Snikos.nikoleris@arm.com }; 9910884Sandreas.hansson@arm.com 1004626SN/A private: 10110360Sandreas.hansson@arm.com /** Rename status. */ 10211484Snikos.nikoleris@arm.com RenameStatus _status; 1035034SN/A 1048883SAli.Saidi@ARM.com /** Per-thread status. */ 1058833Sdam.sunwoo@arm.com ThreadStatus renameStatus[Impl::MaxThreads]; 1064458SN/A 10711377Sandreas.hansson@arm.com public: 10811377Sandreas.hansson@arm.com /** DefaultRename constructor. */ 10911377Sandreas.hansson@arm.com DefaultRename(Params *params); 11011377Sandreas.hansson@arm.com 11111377Sandreas.hansson@arm.com /** Returns the name of rename. */ 11211377Sandreas.hansson@arm.com std::string name() const; 11311331Sandreas.hansson@arm.com 11411331Sandreas.hansson@arm.com /** Registers statistics. */ 11512724Snikos.nikoleris@arm.com void regStats(); 11612730Sodanrc@yahoo.com.br 11712724Snikos.nikoleris@arm.com /** Sets CPU pointer. */ 11812724Snikos.nikoleris@arm.com void setCPU(O3CPU *cpu_ptr); 11912724Snikos.nikoleris@arm.com 12012724Snikos.nikoleris@arm.com /** Sets the main backwards communication time buffer pointer. */ 12112724Snikos.nikoleris@arm.com void setTimeBuffer(TimeBuffer<TimeStruct> *tb_ptr); 12212724Snikos.nikoleris@arm.com 12312724Snikos.nikoleris@arm.com /** Sets pointer to time buffer used to communicate to the next stage. */ 12412724Snikos.nikoleris@arm.com void setRenameQueue(TimeBuffer<RenameStruct> *rq_ptr); 12512724Snikos.nikoleris@arm.com 12612724Snikos.nikoleris@arm.com /** Sets pointer to time buffer coming from decode. */ 12712724Snikos.nikoleris@arm.com void setDecodeQueue(TimeBuffer<DecodeStruct> *dq_ptr); 1282810SN/A 1292810SN/A /** Sets pointer to IEW stage. Used only for initialization. */ 1303013SN/A void setIEWStage(IEW *iew_stage) 1318856Sandreas.hansson@arm.com { iew_ptr = iew_stage; } 1322810SN/A 1333013SN/A /** Sets pointer to commit stage. Used only for initialization. */ 13410714Sandreas.hansson@arm.com void setCommitStage(Commit *commit_stage) 1352810SN/A { commit_ptr = commit_stage; } 1369614Srene.dejong@arm.com 1379614Srene.dejong@arm.com private: 1389614Srene.dejong@arm.com /** Pointer to IEW stage. Used only for initialization. */ 13910345SCurtis.Dunham@arm.com IEW *iew_ptr; 14010714Sandreas.hansson@arm.com 14110345SCurtis.Dunham@arm.com /** Pointer to commit stage. Used only for initialization. */ 1429614Srene.dejong@arm.com Commit *commit_ptr; 1432810SN/A 1442810SN/A public: 1452810SN/A /** Initializes variables for the stage. */ 1468856Sandreas.hansson@arm.com void initStage(); 1472810SN/A 1483013SN/A /** Sets pointer to list of active threads. */ 14910714Sandreas.hansson@arm.com void setActiveThreads(std::list<unsigned> *at_ptr); 1503013SN/A 1518856Sandreas.hansson@arm.com /** Sets pointer to rename maps (per-thread structures). */ 15210714Sandreas.hansson@arm.com void setRenameMap(RenameMap rm_ptr[Impl::MaxThreads]); 1538922Swilliam.wang@arm.com 1542897SN/A /** Sets pointer to the free list. */ 1552810SN/A void setFreeList(FreeList *fl_ptr); 1562810SN/A 15710344Sandreas.hansson@arm.com /** Sets pointer to the scoreboard. */ 15810344Sandreas.hansson@arm.com void setScoreboard(Scoreboard *_scoreboard); 15910344Sandreas.hansson@arm.com 16010714Sandreas.hansson@arm.com /** Switches out the rename stage. */ 16110344Sandreas.hansson@arm.com void switchOut(); 16210344Sandreas.hansson@arm.com 16310344Sandreas.hansson@arm.com /** Completes the switch out. */ 16410713Sandreas.hansson@arm.com void doSwitchOut(); 16510344Sandreas.hansson@arm.com 1662844SN/A /** Takes over from another CPU's thread. */ 16712730Sodanrc@yahoo.com.br void takeOverFrom(); 16812730Sodanrc@yahoo.com.br 16912730Sodanrc@yahoo.com.br /** Squashes all instructions in a thread. */ 17012730Sodanrc@yahoo.com.br void squash(unsigned tid); 17112730Sodanrc@yahoo.com.br 17212730Sodanrc@yahoo.com.br /** Ticks rename, which processes all input signals and attempts to rename 17312730Sodanrc@yahoo.com.br * as many instructions as possible. 17412730Sodanrc@yahoo.com.br */ 17512730Sodanrc@yahoo.com.br void tick(); 17612730Sodanrc@yahoo.com.br 1772810SN/A /** Debugging function used to dump history buffer of renamings. */ 1782858SN/A void dumpHistory(); 1792858SN/A 18012724Snikos.nikoleris@arm.com private: 1818922Swilliam.wang@arm.com /** Determines what to do based on rename's current status. 18212724Snikos.nikoleris@arm.com * @param status_change rename() sets this variable if there was a status 18312724Snikos.nikoleris@arm.com * change (ie switching from blocking to unblocking). 1842858SN/A * @param tid Thread id to rename instructions from. 1852858SN/A */ 1869294Sandreas.hansson@arm.com void rename(bool &status_change, unsigned tid); 1879294Sandreas.hansson@arm.com 1888922Swilliam.wang@arm.com /** Renames instructions for the given thread. Also handles serializing 1898922Swilliam.wang@arm.com * instructions. 19012724Snikos.nikoleris@arm.com */ 1918922Swilliam.wang@arm.com void renameInsts(unsigned tid); 1928922Swilliam.wang@arm.com 1938922Swilliam.wang@arm.com /** Inserts unused instructions from a given thread into the skid buffer, 1948922Swilliam.wang@arm.com * to be renamed once rename unblocks. 1958922Swilliam.wang@arm.com */ 1969294Sandreas.hansson@arm.com void skidInsert(unsigned tid); 1979294Sandreas.hansson@arm.com 1988922Swilliam.wang@arm.com /** Separates instructions from decode into individual lists of instructions 1998922Swilliam.wang@arm.com * sorted by thread. 20012724Snikos.nikoleris@arm.com */ 2018922Swilliam.wang@arm.com void sortInsts(); 2028922Swilliam.wang@arm.com 2038922Swilliam.wang@arm.com /** Returns if all of the skid buffers are empty. */ 2048922Swilliam.wang@arm.com bool skidsEmpty(); 2054628SN/A 20610821Sandreas.hansson@arm.com /** Updates overall rename status based on all of the threads' statuses. */ 20710821Sandreas.hansson@arm.com void updateStatus(); 20810821Sandreas.hansson@arm.com 20910821Sandreas.hansson@arm.com /** Switches rename to blocking, and signals back that rename has become 21010821Sandreas.hansson@arm.com * blocked. 21110821Sandreas.hansson@arm.com * @return Returns true if there is a status change. 21210821Sandreas.hansson@arm.com */ 21310821Sandreas.hansson@arm.com bool block(unsigned tid); 21410821Sandreas.hansson@arm.com 21510821Sandreas.hansson@arm.com /** Switches rename to unblocking if the skid buffer is empty, and signals 21610821Sandreas.hansson@arm.com * back that rename has unblocked. 2172858SN/A * @return Returns true if there is a status change. 21812724Snikos.nikoleris@arm.com */ 21912724Snikos.nikoleris@arm.com bool unblock(unsigned tid); 22012724Snikos.nikoleris@arm.com 22112724Snikos.nikoleris@arm.com /** Executes actual squash, removing squashed instructions. */ 22212724Snikos.nikoleris@arm.com void doSquash(unsigned tid); 22312724Snikos.nikoleris@arm.com 22412724Snikos.nikoleris@arm.com /** Removes a committed instruction's rename history. */ 22512724Snikos.nikoleris@arm.com void removeFromHistory(InstSeqNum inst_seq_num, unsigned tid); 22612724Snikos.nikoleris@arm.com 22712724Snikos.nikoleris@arm.com /** Renames the source registers of an instruction. */ 22812724Snikos.nikoleris@arm.com inline void renameSrcRegs(DynInstPtr &inst, unsigned tid); 22912724Snikos.nikoleris@arm.com 23012724Snikos.nikoleris@arm.com /** Renames the destination registers of an instruction. */ 23112724Snikos.nikoleris@arm.com inline void renameDestRegs(DynInstPtr &inst, unsigned tid); 23212724Snikos.nikoleris@arm.com 23312724Snikos.nikoleris@arm.com /** Calculates the number of free ROB entries for a specific thread. */ 23412724Snikos.nikoleris@arm.com inline int calcFreeROBEntries(unsigned tid); 23512724Snikos.nikoleris@arm.com 23612724Snikos.nikoleris@arm.com /** Calculates the number of free IQ entries for a specific thread. */ 23712724Snikos.nikoleris@arm.com inline int calcFreeIQEntries(unsigned tid); 23812724Snikos.nikoleris@arm.com 23912724Snikos.nikoleris@arm.com /** Calculates the number of free LSQ entries for a specific thread. */ 24012724Snikos.nikoleris@arm.com inline int calcFreeLSQEntries(unsigned tid); 24112724Snikos.nikoleris@arm.com 24212724Snikos.nikoleris@arm.com /** Returns the number of valid instructions coming from decode. */ 24312724Snikos.nikoleris@arm.com unsigned validInsts(); 24412724Snikos.nikoleris@arm.com 24512724Snikos.nikoleris@arm.com /** Reads signals telling rename to block/unblock. */ 24612724Snikos.nikoleris@arm.com void readStallSignals(unsigned tid); 24712724Snikos.nikoleris@arm.com 24812724Snikos.nikoleris@arm.com /** Checks if any stages are telling rename to block. */ 24912724Snikos.nikoleris@arm.com bool checkStall(unsigned tid); 25012724Snikos.nikoleris@arm.com 25112724Snikos.nikoleris@arm.com /** Gets the number of free entries for a specific thread. */ 25212724Snikos.nikoleris@arm.com void readFreeEntries(unsigned tid); 25312724Snikos.nikoleris@arm.com 25412724Snikos.nikoleris@arm.com /** Checks the signals and updates the status. */ 25512724Snikos.nikoleris@arm.com bool checkSignalsAndUpdate(unsigned tid); 25612724Snikos.nikoleris@arm.com 25712724Snikos.nikoleris@arm.com /** Either serializes on the next instruction available in the InstQueue, 25812724Snikos.nikoleris@arm.com * or records that it must serialize on the next instruction to enter 25912724Snikos.nikoleris@arm.com * rename. 26012724Snikos.nikoleris@arm.com * @param inst_list The list of younger, unprocessed instructions for the 26112724Snikos.nikoleris@arm.com * thread that has the serializeAfter instruction. 26212724Snikos.nikoleris@arm.com * @param tid The thread id. 26312724Snikos.nikoleris@arm.com */ 26412724Snikos.nikoleris@arm.com void serializeAfter(InstQueue &inst_list, unsigned tid); 26512724Snikos.nikoleris@arm.com 26612724Snikos.nikoleris@arm.com /** Holds the information for each destination register rename. It holds 26712724Snikos.nikoleris@arm.com * the instruction's sequence number, the arch register, the old physical 26812724Snikos.nikoleris@arm.com * register for that arch. register, and the new physical register. 26912724Snikos.nikoleris@arm.com */ 27012724Snikos.nikoleris@arm.com struct RenameHistory { 27112724Snikos.nikoleris@arm.com RenameHistory(InstSeqNum _instSeqNum, RegIndex _archReg, 27212724Snikos.nikoleris@arm.com PhysRegIndex _newPhysReg, PhysRegIndex _prevPhysReg) 27312724Snikos.nikoleris@arm.com : instSeqNum(_instSeqNum), archReg(_archReg), 27412724Snikos.nikoleris@arm.com newPhysReg(_newPhysReg), prevPhysReg(_prevPhysReg) 27512724Snikos.nikoleris@arm.com { 27612724Snikos.nikoleris@arm.com } 27712724Snikos.nikoleris@arm.com 27812724Snikos.nikoleris@arm.com /** The sequence number of the instruction that renamed. */ 27912724Snikos.nikoleris@arm.com InstSeqNum instSeqNum; 28012724Snikos.nikoleris@arm.com /** The architectural register index that was renamed. */ 28112724Snikos.nikoleris@arm.com RegIndex archReg; 28212724Snikos.nikoleris@arm.com /** The new physical register that the arch. register is renamed to. */ 28312724Snikos.nikoleris@arm.com PhysRegIndex newPhysReg; 28412724Snikos.nikoleris@arm.com /** The old physical register that the arch. register was renamed to. */ 28512724Snikos.nikoleris@arm.com PhysRegIndex prevPhysReg; 28612724Snikos.nikoleris@arm.com }; 28712724Snikos.nikoleris@arm.com 28812724Snikos.nikoleris@arm.com /** A per-thread list of all destination register renames, used to either 28912724Snikos.nikoleris@arm.com * undo rename mappings or free old physical registers. 29012724Snikos.nikoleris@arm.com */ 29112724Snikos.nikoleris@arm.com std::list<RenameHistory> historyBuffer[Impl::MaxThreads]; 29212724Snikos.nikoleris@arm.com 29312724Snikos.nikoleris@arm.com /** Pointer to CPU. */ 29412724Snikos.nikoleris@arm.com O3CPU *cpu; 29512724Snikos.nikoleris@arm.com 29612724Snikos.nikoleris@arm.com /** Pointer to main time buffer used for backwards communication. */ 29712724Snikos.nikoleris@arm.com TimeBuffer<TimeStruct> *timeBuffer; 29812724Snikos.nikoleris@arm.com 29912724Snikos.nikoleris@arm.com /** Wire to get IEW's output from backwards time buffer. */ 30012724Snikos.nikoleris@arm.com typename TimeBuffer<TimeStruct>::wire fromIEW; 30112724Snikos.nikoleris@arm.com 30212724Snikos.nikoleris@arm.com /** Wire to get commit's output from backwards time buffer. */ 30312724Snikos.nikoleris@arm.com typename TimeBuffer<TimeStruct>::wire fromCommit; 30412724Snikos.nikoleris@arm.com 30512724Snikos.nikoleris@arm.com /** Wire to write infromation heading to previous stages. */ 30612724Snikos.nikoleris@arm.com typename TimeBuffer<TimeStruct>::wire toDecode; 30712724Snikos.nikoleris@arm.com 30812724Snikos.nikoleris@arm.com /** Rename instruction queue. */ 30912724Snikos.nikoleris@arm.com TimeBuffer<RenameStruct> *renameQueue; 31012724Snikos.nikoleris@arm.com 31112724Snikos.nikoleris@arm.com /** Wire to write any information heading to IEW. */ 31212724Snikos.nikoleris@arm.com typename TimeBuffer<RenameStruct>::wire toIEW; 31312724Snikos.nikoleris@arm.com 31412724Snikos.nikoleris@arm.com /** Decode instruction queue interface. */ 31512724Snikos.nikoleris@arm.com TimeBuffer<DecodeStruct> *decodeQueue; 31612724Snikos.nikoleris@arm.com 31712724Snikos.nikoleris@arm.com /** Wire to get decode's output from decode queue. */ 31812724Snikos.nikoleris@arm.com typename TimeBuffer<DecodeStruct>::wire fromDecode; 31912724Snikos.nikoleris@arm.com 32012724Snikos.nikoleris@arm.com /** Queue of all instructions coming from decode this cycle. */ 32112724Snikos.nikoleris@arm.com InstQueue insts[Impl::MaxThreads]; 32212724Snikos.nikoleris@arm.com 32312724Snikos.nikoleris@arm.com /** Skid buffer between rename and decode. */ 32412724Snikos.nikoleris@arm.com InstQueue skidBuffer[Impl::MaxThreads]; 32512724Snikos.nikoleris@arm.com 32612724Snikos.nikoleris@arm.com /** Rename map interface. */ 32712724Snikos.nikoleris@arm.com RenameMap *renameMap[Impl::MaxThreads]; 32812724Snikos.nikoleris@arm.com 32912724Snikos.nikoleris@arm.com /** Free list interface. */ 33012724Snikos.nikoleris@arm.com FreeList *freeList; 33112724Snikos.nikoleris@arm.com 33212724Snikos.nikoleris@arm.com /** Pointer to the list of active threads. */ 33312724Snikos.nikoleris@arm.com std::list<unsigned> *activeThreads; 33412724Snikos.nikoleris@arm.com 33512724Snikos.nikoleris@arm.com /** Pointer to the scoreboard. */ 33612724Snikos.nikoleris@arm.com Scoreboard *scoreboard; 33712724Snikos.nikoleris@arm.com 33812724Snikos.nikoleris@arm.com /** Count of instructions in progress that have been sent off to the IQ 33912724Snikos.nikoleris@arm.com * and ROB, but are not yet included in their occupancy counts. 34012724Snikos.nikoleris@arm.com */ 34112724Snikos.nikoleris@arm.com int instsInProgress[Impl::MaxThreads]; 34212724Snikos.nikoleris@arm.com 34312724Snikos.nikoleris@arm.com /** Variable that tracks if decode has written to the time buffer this 34412724Snikos.nikoleris@arm.com * cycle. Used to tell CPU if there is activity this cycle. 34512724Snikos.nikoleris@arm.com */ 34612724Snikos.nikoleris@arm.com bool wroteToTimeBuffer; 34712724Snikos.nikoleris@arm.com 34812724Snikos.nikoleris@arm.com /** Structures whose free entries impact the amount of instructions that 34912724Snikos.nikoleris@arm.com * can be renamed. 35012724Snikos.nikoleris@arm.com */ 35112724Snikos.nikoleris@arm.com struct FreeEntries { 35212724Snikos.nikoleris@arm.com unsigned iqEntries; 35312724Snikos.nikoleris@arm.com unsigned lsqEntries; 35412724Snikos.nikoleris@arm.com unsigned robEntries; 35512724Snikos.nikoleris@arm.com }; 35612724Snikos.nikoleris@arm.com 35712724Snikos.nikoleris@arm.com /** Per-thread tracking of the number of free entries of back-end 35812724Snikos.nikoleris@arm.com * structures. 35912724Snikos.nikoleris@arm.com */ 36012724Snikos.nikoleris@arm.com FreeEntries freeEntries[Impl::MaxThreads]; 36112724Snikos.nikoleris@arm.com 36212724Snikos.nikoleris@arm.com /** Records if the ROB is empty. In SMT mode the ROB may be dynamically 36312724Snikos.nikoleris@arm.com * partitioned between threads, so the ROB must tell rename when it is 36412724Snikos.nikoleris@arm.com * empty. 36512724Snikos.nikoleris@arm.com */ 36612724Snikos.nikoleris@arm.com bool emptyROB[Impl::MaxThreads]; 36712724Snikos.nikoleris@arm.com 36812724Snikos.nikoleris@arm.com /** Source of possible stalls. */ 36912724Snikos.nikoleris@arm.com struct Stalls { 37012724Snikos.nikoleris@arm.com bool iew; 37112724Snikos.nikoleris@arm.com bool commit; 37212724Snikos.nikoleris@arm.com }; 37312724Snikos.nikoleris@arm.com 37412724Snikos.nikoleris@arm.com /** Tracks which stages are telling decode to stall. */ 37512724Snikos.nikoleris@arm.com Stalls stalls[Impl::MaxThreads]; 37612724Snikos.nikoleris@arm.com 37712724Snikos.nikoleris@arm.com /** The serialize instruction that rename has stalled on. */ 37812724Snikos.nikoleris@arm.com DynInstPtr serializeInst[Impl::MaxThreads]; 37912724Snikos.nikoleris@arm.com 38012724Snikos.nikoleris@arm.com /** Records if rename needs to serialize on the next instruction for any 38112724Snikos.nikoleris@arm.com * thread. 38212724Snikos.nikoleris@arm.com */ 38312724Snikos.nikoleris@arm.com bool serializeOnNextInst[Impl::MaxThreads]; 38412724Snikos.nikoleris@arm.com 38512724Snikos.nikoleris@arm.com /** Delay between iew and rename, in ticks. */ 38612724Snikos.nikoleris@arm.com int iewToRenameDelay; 38712724Snikos.nikoleris@arm.com 38812724Snikos.nikoleris@arm.com /** Delay between decode and rename, in ticks. */ 38912724Snikos.nikoleris@arm.com int decodeToRenameDelay; 39012724Snikos.nikoleris@arm.com 39112724Snikos.nikoleris@arm.com /** Delay between commit and rename, in ticks. */ 39212724Snikos.nikoleris@arm.com unsigned commitToRenameDelay; 39312724Snikos.nikoleris@arm.com 39412724Snikos.nikoleris@arm.com /** Rename width, in instructions. */ 39512724Snikos.nikoleris@arm.com unsigned renameWidth; 39612724Snikos.nikoleris@arm.com 39712724Snikos.nikoleris@arm.com /** Commit width, in instructions. Used so rename knows how many 39812724Snikos.nikoleris@arm.com * instructions might have freed registers in the previous cycle. 39912724Snikos.nikoleris@arm.com */ 40012724Snikos.nikoleris@arm.com unsigned commitWidth; 40112724Snikos.nikoleris@arm.com 40212724Snikos.nikoleris@arm.com /** The index of the instruction in the time buffer to IEW that rename is 40312724Snikos.nikoleris@arm.com * currently using. 40412724Snikos.nikoleris@arm.com */ 40512724Snikos.nikoleris@arm.com unsigned toIEWIndex; 40612724Snikos.nikoleris@arm.com 40712724Snikos.nikoleris@arm.com /** Whether or not rename needs to block this cycle. */ 40812724Snikos.nikoleris@arm.com bool blockThisCycle; 40912724Snikos.nikoleris@arm.com 41012724Snikos.nikoleris@arm.com /** The number of threads active in rename. */ 41112724Snikos.nikoleris@arm.com unsigned numThreads; 41212724Snikos.nikoleris@arm.com 41312724Snikos.nikoleris@arm.com /** The maximum skid buffer size. */ 41412724Snikos.nikoleris@arm.com unsigned skidBufferMax; 41512724Snikos.nikoleris@arm.com 41612724Snikos.nikoleris@arm.com /** Enum to record the source of a structure full stall. Can come from 41712724Snikos.nikoleris@arm.com * either ROB, IQ, LSQ, and it is priortized in that order. 41812724Snikos.nikoleris@arm.com */ 41912724Snikos.nikoleris@arm.com enum FullSource { 42012724Snikos.nikoleris@arm.com ROB, 42112724Snikos.nikoleris@arm.com IQ, 42212724Snikos.nikoleris@arm.com LSQ, 42312724Snikos.nikoleris@arm.com NONE 42412724Snikos.nikoleris@arm.com }; 42512724Snikos.nikoleris@arm.com 42612724Snikos.nikoleris@arm.com /** Function used to increment the stat that corresponds to the source of 42712724Snikos.nikoleris@arm.com * the stall. 42812724Snikos.nikoleris@arm.com */ 42912724Snikos.nikoleris@arm.com inline void incrFullStat(const FullSource &source); 43012724Snikos.nikoleris@arm.com 43112724Snikos.nikoleris@arm.com /** Stat for total number of cycles spent squashing. */ 43212724Snikos.nikoleris@arm.com Stats::Scalar<> renameSquashCycles; 43312724Snikos.nikoleris@arm.com /** Stat for total number of cycles spent idle. */ 43412724Snikos.nikoleris@arm.com Stats::Scalar<> renameIdleCycles; 43512724Snikos.nikoleris@arm.com /** Stat for total number of cycles spent blocking. */ 43612724Snikos.nikoleris@arm.com Stats::Scalar<> renameBlockCycles; 43712724Snikos.nikoleris@arm.com /** Stat for total number of cycles spent stalling for a serializing inst. */ 43812724Snikos.nikoleris@arm.com Stats::Scalar<> renameSerializeStallCycles; 43912724Snikos.nikoleris@arm.com /** Stat for total number of cycles spent running normally. */ 44012724Snikos.nikoleris@arm.com Stats::Scalar<> renameRunCycles; 44112724Snikos.nikoleris@arm.com /** Stat for total number of cycles spent unblocking. */ 44212724Snikos.nikoleris@arm.com Stats::Scalar<> renameUnblockCycles; 44312724Snikos.nikoleris@arm.com /** Stat for total number of renamed instructions. */ 44412724Snikos.nikoleris@arm.com Stats::Scalar<> renameRenamedInsts; 44512724Snikos.nikoleris@arm.com /** Stat for total number of squashed instructions that rename discards. */ 44612724Snikos.nikoleris@arm.com Stats::Scalar<> renameSquashedInsts; 44712724Snikos.nikoleris@arm.com /** Stat for total number of times that the ROB starts a stall in rename. */ 44812724Snikos.nikoleris@arm.com Stats::Scalar<> renameROBFullEvents; 44912724Snikos.nikoleris@arm.com /** Stat for total number of times that the IQ starts a stall in rename. */ 45012724Snikos.nikoleris@arm.com Stats::Scalar<> renameIQFullEvents; 45112724Snikos.nikoleris@arm.com /** Stat for total number of times that the LSQ starts a stall in rename. */ 45212724Snikos.nikoleris@arm.com Stats::Scalar<> renameLSQFullEvents; 45312724Snikos.nikoleris@arm.com /** Stat for total number of times that rename runs out of free registers 45412724Snikos.nikoleris@arm.com * to use to rename. */ 45512724Snikos.nikoleris@arm.com Stats::Scalar<> renameFullRegistersEvents; 45612724Snikos.nikoleris@arm.com /** Stat for total number of renamed destination registers. */ 45712724Snikos.nikoleris@arm.com Stats::Scalar<> renameRenamedOperands; 45812724Snikos.nikoleris@arm.com /** Stat for total number of source register rename lookups. */ 45912724Snikos.nikoleris@arm.com Stats::Scalar<> renameRenameLookups; 46012724Snikos.nikoleris@arm.com /** Stat for total number of committed renaming mappings. */ 46112724Snikos.nikoleris@arm.com Stats::Scalar<> renameCommittedMaps; 46212724Snikos.nikoleris@arm.com /** Stat for total number of mappings that were undone due to a squash. */ 46312724Snikos.nikoleris@arm.com Stats::Scalar<> renameUndoneMaps; 46412724Snikos.nikoleris@arm.com /** Number of serialize instructions handled. */ 46512724Snikos.nikoleris@arm.com Stats::Scalar<> renamedSerializing; 46612724Snikos.nikoleris@arm.com /** Number of instructions marked as temporarily serializing. */ 46712724Snikos.nikoleris@arm.com Stats::Scalar<> renamedTempSerializing; 46812724Snikos.nikoleris@arm.com /** Number of instructions inserted into skid buffers. */ 46912724Snikos.nikoleris@arm.com Stats::Scalar<> renameSkidInsts; 47012724Snikos.nikoleris@arm.com}; 47112724Snikos.nikoleris@arm.com 47212724Snikos.nikoleris@arm.com#endif // __CPU_O3_RENAME_HH__ 47312724Snikos.nikoleris@arm.com