rename.hh revision 2329
114213Sandreas.sandberg@arm.com/* 211923Sandreas.sandberg@arm.com * Copyright (c) 2004-2006 The Regents of The University of Michigan 311923Sandreas.sandberg@arm.com * All rights reserved. 411923Sandreas.sandberg@arm.com * 511923Sandreas.sandberg@arm.com * Redistribution and use in source and binary forms, with or without 611923Sandreas.sandberg@arm.com * modification, are permitted provided that the following conditions are 711923Sandreas.sandberg@arm.com * met: redistributions of source code must retain the above copyright 811923Sandreas.sandberg@arm.com * notice, this list of conditions and the following disclaimer; 911923Sandreas.sandberg@arm.com * redistributions in binary form must reproduce the above copyright 1011923Sandreas.sandberg@arm.com * notice, this list of conditions and the following disclaimer in the 1111923Sandreas.sandberg@arm.com * documentation and/or other materials provided with the distribution; 1211923Sandreas.sandberg@arm.com * neither the name of the copyright holders nor the names of its 132889Sbinkertn@umich.edu * contributors may be used to endorse or promote products derived from 142889Sbinkertn@umich.edu * this software without specific prior written permission. 152889Sbinkertn@umich.edu * 162889Sbinkertn@umich.edu * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 172889Sbinkertn@umich.edu * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 182889Sbinkertn@umich.edu * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 192889Sbinkertn@umich.edu * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 202889Sbinkertn@umich.edu * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 212889Sbinkertn@umich.edu * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 222889Sbinkertn@umich.edu * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 232889Sbinkertn@umich.edu * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 242889Sbinkertn@umich.edu * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 252889Sbinkertn@umich.edu * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 262889Sbinkertn@umich.edu * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 272889Sbinkertn@umich.edu */ 282889Sbinkertn@umich.edu 292889Sbinkertn@umich.edu#ifndef __CPU_O3_RENAME_HH__ 302889Sbinkertn@umich.edu#define __CPU_O3_RENAME_HH__ 312889Sbinkertn@umich.edu 322889Sbinkertn@umich.edu#include <list> 332889Sbinkertn@umich.edu 342889Sbinkertn@umich.edu#include "base/statistics.hh" 352889Sbinkertn@umich.edu#include "base/timebuf.hh" 362889Sbinkertn@umich.edu 372889Sbinkertn@umich.edu/** 382889Sbinkertn@umich.edu * DefaultRename handles both single threaded and SMT rename. Its 392889Sbinkertn@umich.edu * width is specified by the parameters; each cycle it tries to rename 402889Sbinkertn@umich.edu * that many instructions. It holds onto the rename history of all 4112563Sgabeblack@google.com * instructions with destination registers, storing the 4212563Sgabeblack@google.com * arch. register, the new physical register, and the old physical 434850Snate@binkert.org * register, to allow for undoing of mappings if squashing happens, or 444850Snate@binkert.org * freeing up registers upon commit. Rename handles blocking if the 454850Snate@binkert.org * ROB, IQ, or LSQ is going to be full. Rename also handles barriers, 464850Snate@binkert.org * and does so by stalling on the instruction until the ROB is empty 474850Snate@binkert.org * and there are no instructions in flight to the ROB. 484850Snate@binkert.org */ 492889Sbinkertn@umich.edutemplate<class Impl> 502889Sbinkertn@umich.educlass DefaultRename 518327Sgblack@eecs.umich.edu{ 525470Snate@binkert.org public: 538333Snate@binkert.org // Typedefs from the Impl. 548333Snate@binkert.org typedef typename Impl::CPUPol CPUPol; 552889Sbinkertn@umich.edu typedef typename Impl::DynInstPtr DynInstPtr; 5614213Sandreas.sandberg@arm.com typedef typename Impl::FullCPU FullCPU; 5714213Sandreas.sandberg@arm.com typedef typename Impl::Params Params; 5814213Sandreas.sandberg@arm.com 5914213Sandreas.sandberg@arm.com // Typedefs from the CPUPol 6014213Sandreas.sandberg@arm.com typedef typename CPUPol::DecodeStruct DecodeStruct; 6114213Sandreas.sandberg@arm.com typedef typename CPUPol::RenameStruct RenameStruct; 6214213Sandreas.sandberg@arm.com typedef typename CPUPol::TimeStruct TimeStruct; 6314213Sandreas.sandberg@arm.com typedef typename CPUPol::FreeList FreeList; 6414213Sandreas.sandberg@arm.com typedef typename CPUPol::RenameMap RenameMap; 6514213Sandreas.sandberg@arm.com // These are used only for initialization. 6614213Sandreas.sandberg@arm.com typedef typename CPUPol::IEW IEW; 6714213Sandreas.sandberg@arm.com typedef typename CPUPol::Commit Commit; 688234Snate@binkert.org 6913714Sandreas.sandberg@arm.com // Typedefs from the ISA. 7013714Sandreas.sandberg@arm.com typedef TheISA::RegIndex RegIndex; 712889Sbinkertn@umich.edu 728234Snate@binkert.org // A list is used to queue the instructions. Barrier insts must 738234Snate@binkert.org // be added to the front of the list, which is the only reason for 748234Snate@binkert.org // using a list instead of a queue. (Most other stages use a 758234Snate@binkert.org // queue) 762889Sbinkertn@umich.edu typedef std::list<DynInstPtr> InstQueue; 7711923Sandreas.sandberg@arm.com 7811923Sandreas.sandberg@arm.com public: 798234Snate@binkert.org /** Overall rename status. Used to determine if the CPU can 808234Snate@binkert.org * deschedule itself due to a lack of activity. 818234Snate@binkert.org */ 828234Snate@binkert.org enum RenameStatus { 838234Snate@binkert.org Active, 848234Snate@binkert.org Inactive 858234Snate@binkert.org }; 862889Sbinkertn@umich.edu 878234Snate@binkert.org /** Individual thread status. */ 888234Snate@binkert.org enum ThreadStatus { 898234Snate@binkert.org Running, 908234Snate@binkert.org Idle, 918234Snate@binkert.org StartSquash, 928234Snate@binkert.org Squashing, 938234Snate@binkert.org Blocked, 948234Snate@binkert.org Unblocking, 958234Snate@binkert.org SerializeStall 968234Snate@binkert.org }; 978234Snate@binkert.org 9811923Sandreas.sandberg@arm.com private: 9911923Sandreas.sandberg@arm.com /** Rename status. */ 10011923Sandreas.sandberg@arm.com RenameStatus _status; 10111923Sandreas.sandberg@arm.com 10212012Sgabeblack@google.com /** Per-thread status. */ 10312012Sgabeblack@google.com ThreadStatus renameStatus[Impl::MaxThreads]; 10412012Sgabeblack@google.com 1058234Snate@binkert.org public: 1068234Snate@binkert.org /** DefaultRename constructor. */ 1078234Snate@binkert.org DefaultRename(Params *params); 1088234Snate@binkert.org 1098234Snate@binkert.org /** Returns the name of rename. */ 1108234Snate@binkert.org std::string name() const; 1118234Snate@binkert.org 1128234Snate@binkert.org /** Registers statistics. */ 1138234Snate@binkert.org void regStats(); 1148234Snate@binkert.org 1152889Sbinkertn@umich.edu /** Sets CPU pointer. */ 1168234Snate@binkert.org void setCPU(FullCPU *cpu_ptr); 1178234Snate@binkert.org 1188234Snate@binkert.org /** Sets the main backwards communication time buffer pointer. */ 1198234Snate@binkert.org void setTimeBuffer(TimeBuffer<TimeStruct> *tb_ptr); 12014213Sandreas.sandberg@arm.com 12114213Sandreas.sandberg@arm.com /** Sets pointer to time buffer used to communicate to the next stage. */ 12214213Sandreas.sandberg@arm.com void setRenameQueue(TimeBuffer<RenameStruct> *rq_ptr); 1235773Snate@binkert.org 1248234Snate@binkert.org /** Sets pointer to time buffer coming from decode. */ 1258234Snate@binkert.org void setDecodeQueue(TimeBuffer<DecodeStruct> *dq_ptr); 1268234Snate@binkert.org 1278234Snate@binkert.org /** Sets pointer to IEW stage. Used only for initialization. */ 1288664SAli.Saidi@ARM.com void setIEWStage(IEW *iew_stage) 1298664SAli.Saidi@ARM.com { iew_ptr = iew_stage; } 1308998Suri.wiener@arm.com 1318998Suri.wiener@arm.com /** Sets pointer to commit stage. Used only for initialization. */ 13211431Ssascha.bischoff@arm.com void setCommitStage(Commit *commit_stage) 13311418Ssascha.bischoff@arm.com { commit_ptr = commit_stage; } 13411418Ssascha.bischoff@arm.com 1352889Sbinkertn@umich.edu private: 1368234Snate@binkert.org /** Pointer to IEW stage. Used only for initialization. */ 1378234Snate@binkert.org IEW *iew_ptr; 13811299Ssteve.reinhardt@amd.com 13911299Ssteve.reinhardt@amd.com /** Pointer to commit stage. Used only for initialization. */ 14011299Ssteve.reinhardt@amd.com Commit *commit_ptr; 1418234Snate@binkert.org 1429960Sandreas.hansson@arm.com public: 1438234Snate@binkert.org /** Initializes variables for the stage. */ 1449960Sandreas.hansson@arm.com void initStage(); 14511299Ssteve.reinhardt@amd.com 14611304Ssteve.reinhardt@amd.com /** Sets pointer to list of active threads. */ 14711338SMichael.Lebeane@amd.com void setActiveThreads(std::list<unsigned> *at_ptr); 14811338SMichael.Lebeane@amd.com 1499960Sandreas.hansson@arm.com /** Sets pointer to rename maps (per-thread structures). */ 1509960Sandreas.hansson@arm.com void setRenameMap(RenameMap rm_ptr[Impl::MaxThreads]); 1519960Sandreas.hansson@arm.com 1529960Sandreas.hansson@arm.com /** Sets pointer to the free list. */ 1538234Snate@binkert.org void setFreeList(FreeList *fl_ptr); 1548234Snate@binkert.org 1552889Sbinkertn@umich.edu /** Sets pointer to the scoreboard. */ 1568234Snate@binkert.org void setScoreboard(Scoreboard *_scoreboard); 1578234Snate@binkert.org 1588234Snate@binkert.org void switchOut(); 1598234Snate@binkert.org 1606171Snate@binkert.org void doSwitchOut(); 1618234Snate@binkert.org 1628234Snate@binkert.org void takeOverFrom(); 1638234Snate@binkert.org 1648234Snate@binkert.org /** Squashes all instructions in a thread. */ 1658234Snate@binkert.org void squash(unsigned tid); 16613671Sandreas.sandberg@arm.com 1678234Snate@binkert.org /** Ticks rename, which processes all input signals and attempts to rename 1688234Snate@binkert.org * as many instructions as possible. 1698234Snate@binkert.org */ 1706171Snate@binkert.org void tick(); 1718219Snate@binkert.org 1728327Sgblack@eecs.umich.edu /** Debugging function used to dump history buffer of renamings. */ 1739512Sandreas@sandberg.pp.se void dumpHistory(); 1749512Sandreas@sandberg.pp.se 1759512Sandreas@sandberg.pp.se private: 1769512Sandreas@sandberg.pp.se /** Determines what to do based on rename's current status. 1779512Sandreas@sandberg.pp.se * @param status_change rename() sets this variable if there was a status 1789512Sandreas@sandberg.pp.se * change (ie switching from blocking to unblocking). 1798219Snate@binkert.org * @param tid Thread id to rename instructions from. 1808219Snate@binkert.org */ 1819512Sandreas@sandberg.pp.se void rename(bool &status_change, unsigned tid); 1829512Sandreas@sandberg.pp.se 1839512Sandreas@sandberg.pp.se /** Renames instructions for the given thread. Also handles serializing 1849512Sandreas@sandberg.pp.se * instructions. 1859512Sandreas@sandberg.pp.se */ 1869512Sandreas@sandberg.pp.se void renameInsts(unsigned tid); 1879512Sandreas@sandberg.pp.se 1889512Sandreas@sandberg.pp.se /** Inserts unused instructions from a given thread into the skid buffer, 1899512Sandreas@sandberg.pp.se * to be renamed once rename unblocks. 1909512Sandreas@sandberg.pp.se */ 1919512Sandreas@sandberg.pp.se void skidInsert(unsigned tid); 19211635SCurtis.Dunham@arm.com 1939512Sandreas@sandberg.pp.se /** Separates instructions from decode into individual lists of instructions 1949512Sandreas@sandberg.pp.se * sorted by thread. 1959512Sandreas@sandberg.pp.se */ 1969512Sandreas@sandberg.pp.se void sortInsts(); 1979512Sandreas@sandberg.pp.se 1989512Sandreas@sandberg.pp.se /** Returns if all of the skid buffers are empty. */ 1999512Sandreas@sandberg.pp.se bool skidsEmpty(); 2009512Sandreas@sandberg.pp.se 2019512Sandreas@sandberg.pp.se /** Updates overall rename status based on all of the threads' statuses. */ 2029512Sandreas@sandberg.pp.se void updateStatus(); 2038219Snate@binkert.org 2049512Sandreas@sandberg.pp.se /** Switches rename to blocking, and signals back that rename has become 2059512Sandreas@sandberg.pp.se * blocked. 2069512Sandreas@sandberg.pp.se * @return Returns true if there is a status change. 2078219Snate@binkert.org */ 2088219Snate@binkert.org bool block(unsigned tid); 20913671Sandreas.sandberg@arm.com 21013671Sandreas.sandberg@arm.com /** Switches rename to unblocking if the skid buffer is empty, and signals 21113868Sciro.santilli@arm.com * back that rename has unblocked. 21213674Sandreas.sandberg@arm.com * @return Returns true if there is a status change. 21313671Sandreas.sandberg@arm.com */ 21413671Sandreas.sandberg@arm.com bool unblock(unsigned tid); 21513671Sandreas.sandberg@arm.com 21613671Sandreas.sandberg@arm.com /** Executes actual squash, removing squashed instructions. */ 21713671Sandreas.sandberg@arm.com void doSquash(unsigned tid); 2188234Snate@binkert.org 2198245Snate@binkert.org /** Removes a committed instruction's rename history. */ 2208245Snate@binkert.org void removeFromHistory(InstSeqNum inst_seq_num, unsigned tid); 22113714Sandreas.sandberg@arm.com 22213714Sandreas.sandberg@arm.com /** Renames the source registers of an instruction. */ 22313714Sandreas.sandberg@arm.com inline void renameSrcRegs(DynInstPtr &inst, unsigned tid); 22413714Sandreas.sandberg@arm.com 22513714Sandreas.sandberg@arm.com /** Renames the destination registers of an instruction. */ 22613714Sandreas.sandberg@arm.com inline void renameDestRegs(DynInstPtr &inst, unsigned tid); 22713714Sandreas.sandberg@arm.com 2285799Snate@binkert.org /** Calculates the number of free ROB entries for a specific thread. */ 22913714Sandreas.sandberg@arm.com inline int calcFreeROBEntries(unsigned tid); 2308234Snate@binkert.org 2318234Snate@binkert.org /** Calculates the number of free IQ entries for a specific thread. */ 2328234Snate@binkert.org inline int calcFreeIQEntries(unsigned tid); 2338234Snate@binkert.org 2348234Snate@binkert.org /** Calculates the number of free LSQ entries for a specific thread. */ 2358234Snate@binkert.org inline int calcFreeLSQEntries(unsigned tid); 23613663Sandreas.sandberg@arm.com 2378234Snate@binkert.org /** Returns the number of valid instructions coming from decode. */ 2388245Snate@binkert.org unsigned validInsts(); 2398245Snate@binkert.org 2409983Sstever@gmail.com /** Reads signals telling rename to block/unblock. */ 2419983Sstever@gmail.com void readStallSignals(unsigned tid); 2429983Sstever@gmail.com 2439983Sstever@gmail.com /** Checks if any stages are telling rename to block. */ 2445524Sstever@gmail.com bool checkStall(unsigned tid); 2455524Sstever@gmail.com 2465524Sstever@gmail.com void readFreeEntries(unsigned tid); 2475524Sstever@gmail.com 2485524Sstever@gmail.com bool checkSignalsAndUpdate(unsigned tid); 2495524Sstever@gmail.com 2505524Sstever@gmail.com /** Either serializes on the next instruction available in the InstQueue, 2515524Sstever@gmail.com * or records that it must serialize on the next instruction to enter 2525524Sstever@gmail.com * rename. 25312563Sgabeblack@google.com * @param inst_list The list of younger, unprocessed instructions for the 2545524Sstever@gmail.com * thread that has the serializeAfter instruction. 2555524Sstever@gmail.com * @param tid The thread id. 25612563Sgabeblack@google.com */ 2575524Sstever@gmail.com void serializeAfter(InstQueue &inst_list, unsigned tid); 25812563Sgabeblack@google.com 2595524Sstever@gmail.com /** Holds the information for each destination register rename. It holds 2605524Sstever@gmail.com * the instruction's sequence number, the arch register, the old physical 2615524Sstever@gmail.com * register for that arch. register, and the new physical register. 2625524Sstever@gmail.com */ 2635524Sstever@gmail.com struct RenameHistory { 2645524Sstever@gmail.com RenameHistory(InstSeqNum _instSeqNum, RegIndex _archReg, 2655524Sstever@gmail.com PhysRegIndex _newPhysReg, PhysRegIndex _prevPhysReg) 2665524Sstever@gmail.com : instSeqNum(_instSeqNum), archReg(_archReg), 2675524Sstever@gmail.com newPhysReg(_newPhysReg), prevPhysReg(_prevPhysReg) 2685524Sstever@gmail.com { 2695524Sstever@gmail.com } 2705524Sstever@gmail.com 2712889Sbinkertn@umich.edu /** The sequence number of the instruction that renamed. */ 2724850Snate@binkert.org InstSeqNum instSeqNum; 2734850Snate@binkert.org /** The architectural register index that was renamed. */ 2744850Snate@binkert.org RegIndex archReg; 27512563Sgabeblack@google.com /** The new physical register that the arch. register is renamed to. */ 27612563Sgabeblack@google.com PhysRegIndex newPhysReg; 27712563Sgabeblack@google.com /** The old physical register that the arch. register was renamed to. */ 27812563Sgabeblack@google.com PhysRegIndex prevPhysReg; 27913709Sandreas.sandberg@arm.com }; 2804850Snate@binkert.org 2814850Snate@binkert.org /** A per-thread list of all destination register renames, used to either 2825801Snate@binkert.org * undo rename mappings or free old physical registers. 28312563Sgabeblack@google.com */ 28412563Sgabeblack@google.com std::list<RenameHistory> historyBuffer[Impl::MaxThreads]; 2854850Snate@binkert.org 2862889Sbinkertn@umich.edu /** Pointer to CPU. */ 2872889Sbinkertn@umich.edu FullCPU *cpu; 28812563Sgabeblack@google.com 28912563Sgabeblack@google.com /** Pointer to main time buffer used for backwards communication. */ 2902889Sbinkertn@umich.edu TimeBuffer<TimeStruct> *timeBuffer; 2912889Sbinkertn@umich.edu 2922889Sbinkertn@umich.edu /** Wire to get IEW's output from backwards time buffer. */ 29312563Sgabeblack@google.com typename TimeBuffer<TimeStruct>::wire fromIEW; 29412563Sgabeblack@google.com 29512563Sgabeblack@google.com /** Wire to get commit's output from backwards time buffer. */ 29612563Sgabeblack@google.com typename TimeBuffer<TimeStruct>::wire fromCommit; 2972889Sbinkertn@umich.edu 2988232Snate@binkert.org /** Wire to write infromation heading to previous stages. */ 2994053Sbinkertn@umich.edu typename TimeBuffer<TimeStruct>::wire toDecode; 30013671Sandreas.sandberg@arm.com 3018232Snate@binkert.org /** Rename instruction queue. */ 3024053Sbinkertn@umich.edu TimeBuffer<RenameStruct> *renameQueue; 3035473Snate@binkert.org 30413714Sandreas.sandberg@arm.com /** Wire to write any information heading to IEW. */ 3055473Snate@binkert.org typename TimeBuffer<RenameStruct>::wire toIEW; 30612563Sgabeblack@google.com 30713709Sandreas.sandberg@arm.com /** Decode instruction queue interface. */ 3085473Snate@binkert.org TimeBuffer<DecodeStruct> *decodeQueue; 3095473Snate@binkert.org 3105473Snate@binkert.org /** Wire to get decode's output from decode queue. */ 31112563Sgabeblack@google.com typename TimeBuffer<DecodeStruct>::wire fromDecode; 31213709Sandreas.sandberg@arm.com 3135473Snate@binkert.org /** Queue of all instructions coming from decode this cycle. */ 3145473Snate@binkert.org InstQueue insts[Impl::MaxThreads]; 3155473Snate@binkert.org 3165473Snate@binkert.org /** Skid buffer between rename and decode. */ 31712563Sgabeblack@google.com InstQueue skidBuffer[Impl::MaxThreads]; 3185473Snate@binkert.org 31912563Sgabeblack@google.com /** Rename map interface. */ 32012563Sgabeblack@google.com RenameMap *renameMap[Impl::MaxThreads]; 32112563Sgabeblack@google.com 32212563Sgabeblack@google.com /** Free list interface. */ 3235473Snate@binkert.org FreeList *freeList; 3242889Sbinkertn@umich.edu 3252889Sbinkertn@umich.edu /** Pointer to the list of active threads. */ 3262889Sbinkertn@umich.edu std::list<unsigned> *activeThreads; 3275470Snate@binkert.org 3285470Snate@binkert.org /** Pointer to the scoreboard. */ 3295470Snate@binkert.org Scoreboard *scoreboard; 3305470Snate@binkert.org 3315470Snate@binkert.org /** Count of instructions in progress that have been sent off to the IQ 33210134Sstan.czerniawski@arm.com * and ROB, but are not yet included in their occupancy counts. 33312563Sgabeblack@google.com */ 33412563Sgabeblack@google.com int instsInProgress[Impl::MaxThreads]; 33512563Sgabeblack@google.com 3365801Snate@binkert.org /** Variable that tracks if decode has written to the time buffer this 33712563Sgabeblack@google.com * cycle. Used to tell CPU if there is activity this cycle. 3385456Ssaidi@eecs.umich.edu */ 33912563Sgabeblack@google.com bool wroteToTimeBuffer; 34012563Sgabeblack@google.com 34112563Sgabeblack@google.com /** Structures whose free entries impact the amount of instructions that 34212563Sgabeblack@google.com * can be renamed. 3435528Sstever@gmail.com */ 34410758Ssteve.reinhardt@amd.com struct FreeEntries { 34510758Ssteve.reinhardt@amd.com unsigned iqEntries; 34612563Sgabeblack@google.com unsigned lsqEntries; 34712563Sgabeblack@google.com unsigned robEntries; 3482889Sbinkertn@umich.edu }; 3492889Sbinkertn@umich.edu 3502889Sbinkertn@umich.edu /** Per-thread tracking of the number of free entries of back-end 3512922Sktlim@umich.edu * structures. 35212563Sgabeblack@google.com */ 3534053Sbinkertn@umich.edu FreeEntries freeEntries[Impl::MaxThreads]; 3545470Snate@binkert.org 3552889Sbinkertn@umich.edu /** Records if the ROB is empty. In SMT mode the ROB may be dynamically 3562889Sbinkertn@umich.edu * partitioned between threads, so the ROB must tell rename when it is 3575801Snate@binkert.org * empty. 3582889Sbinkertn@umich.edu */ 3592889Sbinkertn@umich.edu bool emptyROB[Impl::MaxThreads]; 3602889Sbinkertn@umich.edu 3612889Sbinkertn@umich.edu /** Source of possible stalls. */ 3622889Sbinkertn@umich.edu struct Stalls { 36311878Sandreas.sandberg@arm.com bool iew; 3642889Sbinkertn@umich.edu bool commit; 36511923Sandreas.sandberg@arm.com }; 36611923Sandreas.sandberg@arm.com 36711923Sandreas.sandberg@arm.com /** Tracks which stages are telling decode to stall. */ 36811923Sandreas.sandberg@arm.com Stalls stalls[Impl::MaxThreads]; 36911923Sandreas.sandberg@arm.com 37011923Sandreas.sandberg@arm.com /** The serialize instruction that rename has stalled on. */ 37111923Sandreas.sandberg@arm.com DynInstPtr serializeInst[Impl::MaxThreads]; 37211923Sandreas.sandberg@arm.com 37311923Sandreas.sandberg@arm.com /** Records if rename needs to serialize on the next instruction for any 37411923Sandreas.sandberg@arm.com * thread. 37511923Sandreas.sandberg@arm.com */ 37611923Sandreas.sandberg@arm.com bool serializeOnNextInst[Impl::MaxThreads]; 37711923Sandreas.sandberg@arm.com 37812012Sgabeblack@google.com /** Delay between iew and rename, in ticks. */ 37912012Sgabeblack@google.com int iewToRenameDelay; 38012012Sgabeblack@google.com 3812889Sbinkertn@umich.edu /** Delay between decode and rename, in ticks. */ 3825801Snate@binkert.org int decodeToRenameDelay; 3833645Sbinkertn@umich.edu 3849960Sandreas.hansson@arm.com /** Delay between commit and rename, in ticks. */ 3852889Sbinkertn@umich.edu unsigned commitToRenameDelay; 3868232Snate@binkert.org 38713671Sandreas.sandberg@arm.com /** Rename width, in instructions. */ 3884053Sbinkertn@umich.edu unsigned renameWidth; 3895586Snate@binkert.org 3905586Snate@binkert.org /** Commit width, in instructions. Used so rename knows how many 3918232Snate@binkert.org * instructions might have freed registers in the previous cycle. 3925586Snate@binkert.org */ 3935586Snate@binkert.org unsigned commitWidth; 3945586Snate@binkert.org 3955586Snate@binkert.org /** The index of the instruction in the time buffer to IEW that rename is 3968232Snate@binkert.org * currently using. 3978232Snate@binkert.org */ 39812563Sgabeblack@google.com unsigned toIEWIndex; 3995586Snate@binkert.org 4004053Sbinkertn@umich.edu /** Whether or not rename needs to block this cycle. */ 4015586Snate@binkert.org bool blockThisCycle; 4028232Snate@binkert.org 4035586Snate@binkert.org /** The number of threads active in rename. */ 4048232Snate@binkert.org unsigned numThreads; 4054053Sbinkertn@umich.edu 4069960Sandreas.hansson@arm.com /** The maximum skid buffer size. */ 40713671Sandreas.sandberg@arm.com unsigned skidBufferMax; 4089960Sandreas.hansson@arm.com 4099960Sandreas.hansson@arm.com /** Enum to record the source of a structure full stall. Can come from 4104074Sbinkertn@umich.edu * either ROB, IQ, LSQ, and it is priortized in that order. 4115799Snate@binkert.org */ 4124042Sbinkertn@umich.edu enum FullSource { 41311338SMichael.Lebeane@amd.com ROB, 41413671Sandreas.sandberg@arm.com IQ, 41511338SMichael.Lebeane@amd.com LSQ, 41611338SMichael.Lebeane@amd.com NONE 41711338SMichael.Lebeane@amd.com }; 4189960Sandreas.hansson@arm.com 4194042Sbinkertn@umich.edu /** Function used to increment the stat that corresponds to the source of 4209960Sandreas.hansson@arm.com * the stall. 42113671Sandreas.sandberg@arm.com */ 4225799Snate@binkert.org inline void incrFullStat(const FullSource &source); 4232889Sbinkertn@umich.edu 4242889Sbinkertn@umich.edu /** Stat for total number of cycles spent squashing. */ 4252889Sbinkertn@umich.edu Stats::Scalar<> renameSquashCycles; 4262891Sbinkertn@umich.edu /** Stat for total number of cycles spent idle. */ 4275604Snate@binkert.org Stats::Scalar<> renameIdleCycles; 42813670Sandreas.sandberg@arm.com /** Stat for total number of cycles spent blocking. */ 4295604Snate@binkert.org Stats::Scalar<> renameBlockCycles; 4305604Snate@binkert.org /** Stat for total number of cycles spent stalling for a serializing inst. */ 4313887Sbinkertn@umich.edu Stats::Scalar<> renameSerializeStallCycles; 4322899Sbinkertn@umich.edu /** Stat for total number of cycles spent running normally. */ 4332899Sbinkertn@umich.edu Stats::Scalar<> renameRunCycles; 4342899Sbinkertn@umich.edu /** Stat for total number of cycles spent unblocking. */ 4352899Sbinkertn@umich.edu Stats::Scalar<> renameUnblockCycles; 4365604Snate@binkert.org /** Stat for total number of renamed instructions. */ 4375604Snate@binkert.org Stats::Scalar<> renameRenamedInsts; 4385604Snate@binkert.org /** Stat for total number of squashed instructions that rename discards. */ 4395604Snate@binkert.org Stats::Scalar<> renameSquashedInsts; 4405604Snate@binkert.org /** Stat for total number of times that the ROB starts a stall in rename. */ 4415604Snate@binkert.org Stats::Scalar<> renameROBFullEvents; 4425604Snate@binkert.org /** Stat for total number of times that the IQ starts a stall in rename. */ 44312563Sgabeblack@google.com Stats::Scalar<> renameIQFullEvents; 44412563Sgabeblack@google.com /** Stat for total number of times that the LSQ starts a stall in rename. */ 4455604Snate@binkert.org Stats::Scalar<> renameLSQFullEvents; 4465604Snate@binkert.org /** Stat for total number of times that rename runs out of free registers 44712563Sgabeblack@google.com * to use to rename. */ 4485604Snate@binkert.org Stats::Scalar<> renameFullRegistersEvents; 4495604Snate@binkert.org /** Stat for total number of renamed destination registers. */ 4505604Snate@binkert.org Stats::Scalar<> renameRenamedOperands; 4515604Snate@binkert.org /** Stat for total number of source register rename lookups. */ 4522899Sbinkertn@umich.edu Stats::Scalar<> renameRenameLookups; 45313671Sandreas.sandberg@arm.com /** Stat for total number of committed renaming mappings. */ 4542889Sbinkertn@umich.edu Stats::Scalar<> renameCommittedMaps; 4552889Sbinkertn@umich.edu /** Stat for total number of mappings that were undone due to a squash. */ 4562889Sbinkertn@umich.edu Stats::Scalar<> renameUndoneMaps; 4578219Snate@binkert.org Stats::Scalar<> renamedSerializing; 4582889Sbinkertn@umich.edu Stats::Scalar<> renamedTempSerializing; 4592889Sbinkertn@umich.edu Stats::Scalar<> renameSkidInsts; 4602889Sbinkertn@umich.edu}; 4612889Sbinkertn@umich.edu 4628234Snate@binkert.org#endif // __CPU_O3_RENAME_HH__ 4638234Snate@binkert.org