rename.hh revision 2292
111507SCurtis.Dunham@arm.com/*
211507SCurtis.Dunham@arm.com * Copyright (c) 2004-2005 The Regents of The University of Michigan
311960Sgabeblack@google.com * All rights reserved.
411960Sgabeblack@google.com *
511960Sgabeblack@google.com * Redistribution and use in source and binary forms, with or without
611960Sgabeblack@google.com * modification, are permitted provided that the following conditions are
711960Sgabeblack@google.com * met: redistributions of source code must retain the above copyright
811960Sgabeblack@google.com * notice, this list of conditions and the following disclaimer;
911960Sgabeblack@google.com * redistributions in binary form must reproduce the above copyright
1011960Sgabeblack@google.com * notice, this list of conditions and the following disclaimer in the
1111960Sgabeblack@google.com * documentation and/or other materials provided with the distribution;
1211960Sgabeblack@google.com * neither the name of the copyright holders nor the names of its
1311960Sgabeblack@google.com * contributors may be used to endorse or promote products derived from
1411960Sgabeblack@google.com * this software without specific prior written permission.
1511960Sgabeblack@google.com *
1611960Sgabeblack@google.com * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
1711960Sgabeblack@google.com * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
1811960Sgabeblack@google.com * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
1911960Sgabeblack@google.com * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
2011960Sgabeblack@google.com * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
2111960Sgabeblack@google.com * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
2211960Sgabeblack@google.com * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
2311960Sgabeblack@google.com * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
2411960Sgabeblack@google.com * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
2511960Sgabeblack@google.com * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
2611960Sgabeblack@google.com * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
2711960Sgabeblack@google.com */
2811960Sgabeblack@google.com
2911960Sgabeblack@google.com#ifndef __CPU_O3_RENAME_HH__
3011960Sgabeblack@google.com#define __CPU_O3_RENAME_HH__
3111960Sgabeblack@google.com
3211960Sgabeblack@google.com#include <list>
3311960Sgabeblack@google.com
3411960Sgabeblack@google.com#include "base/statistics.hh"
3511960Sgabeblack@google.com#include "base/timebuf.hh"
3611960Sgabeblack@google.com
3711960Sgabeblack@google.com/**
3811960Sgabeblack@google.com * DefaultRename handles both single threaded and SMT rename. Its width is
3911960Sgabeblack@google.com * specified by the parameters; each cycle it tries to rename that many
4011960Sgabeblack@google.com * instructions. It holds onto the rename history of all instructions with
4111960Sgabeblack@google.com * destination registers, storing the arch. register, the new physical
4211960Sgabeblack@google.com * register, and the old physical register, to allow for undoing of mappings
4311960Sgabeblack@google.com * if squashing happens, or freeing up registers upon commit. Rename handles
4411960Sgabeblack@google.com * blocking if the ROB, IQ, or LSQ is going to be full. Rename also handles
4511960Sgabeblack@google.com * barriers, and does so by stalling on the instruction until the ROB is
4611960Sgabeblack@google.com * empty and there are no instructions in flight to the ROB.
4711960Sgabeblack@google.com */
4811960Sgabeblack@google.comtemplate<class Impl>
4911960Sgabeblack@google.comclass DefaultRename
5011960Sgabeblack@google.com{
5111960Sgabeblack@google.com  public:
5211960Sgabeblack@google.com    // Typedefs from the Impl.
5311960Sgabeblack@google.com    typedef typename Impl::CPUPol CPUPol;
5411960Sgabeblack@google.com    typedef typename Impl::DynInstPtr DynInstPtr;
5511960Sgabeblack@google.com    typedef typename Impl::FullCPU FullCPU;
5611960Sgabeblack@google.com    typedef typename Impl::Params Params;
5711960Sgabeblack@google.com
5811960Sgabeblack@google.com    // Typedefs from the CPUPol
5911960Sgabeblack@google.com    typedef typename CPUPol::DecodeStruct DecodeStruct;
6011960Sgabeblack@google.com    typedef typename CPUPol::RenameStruct RenameStruct;
6111960Sgabeblack@google.com    typedef typename CPUPol::TimeStruct TimeStruct;
6211960Sgabeblack@google.com    typedef typename CPUPol::FreeList FreeList;
6311960Sgabeblack@google.com    typedef typename CPUPol::RenameMap RenameMap;
6411960Sgabeblack@google.com    // These are used only for initialization.
6511960Sgabeblack@google.com    typedef typename CPUPol::IEW IEW;
6611960Sgabeblack@google.com    typedef typename CPUPol::Commit Commit;
6711960Sgabeblack@google.com
6811960Sgabeblack@google.com    // Typedefs from the ISA.
6911960Sgabeblack@google.com    typedef TheISA::RegIndex RegIndex;
7011960Sgabeblack@google.com
7111960Sgabeblack@google.com    // A deque is used to queue the instructions.  Barrier insts must be
7211960Sgabeblack@google.com    // added to the front of the deque, which is the only reason for using
7311960Sgabeblack@google.com    // a deque instead of a queue. (Most other stages use a queue)
7411960Sgabeblack@google.com    typedef std::list<DynInstPtr> InstQueue;
7511960Sgabeblack@google.com
7611960Sgabeblack@google.com  public:
7711960Sgabeblack@google.com    /** Overall rename status. Used to determine if the CPU can deschedule
7811960Sgabeblack@google.com     * itself due to a lack of activity.
7911960Sgabeblack@google.com     */
8011960Sgabeblack@google.com    enum RenameStatus {
8111960Sgabeblack@google.com        Active,
8211960Sgabeblack@google.com        Inactive
8311960Sgabeblack@google.com    };
8411960Sgabeblack@google.com
8511960Sgabeblack@google.com    /** Individual thread status. */
8611960Sgabeblack@google.com    enum ThreadStatus {
8711960Sgabeblack@google.com        Running,
8811960Sgabeblack@google.com        Idle,
8911960Sgabeblack@google.com        StartSquash,
9011960Sgabeblack@google.com        Squashing,
9111960Sgabeblack@google.com        Blocked,
9211960Sgabeblack@google.com        Unblocking,
9311960Sgabeblack@google.com        BarrierStall
9411960Sgabeblack@google.com    };
9511960Sgabeblack@google.com
9611960Sgabeblack@google.com  private:
9711960Sgabeblack@google.com    /** Rename status. */
9811960Sgabeblack@google.com    RenameStatus _status;
9911960Sgabeblack@google.com
10011960Sgabeblack@google.com    /** Per-thread status. */
10111960Sgabeblack@google.com    ThreadStatus renameStatus[Impl::MaxThreads];
10211960Sgabeblack@google.com
10311960Sgabeblack@google.com  public:
10411960Sgabeblack@google.com    /** DefaultRename constructor. */
10511960Sgabeblack@google.com    DefaultRename(Params *params);
10611960Sgabeblack@google.com
10711960Sgabeblack@google.com    /** Returns the name of rename. */
10811960Sgabeblack@google.com    std::string name() const;
10911960Sgabeblack@google.com
11011960Sgabeblack@google.com    /** Registers statistics. */
11111960Sgabeblack@google.com    void regStats();
11211960Sgabeblack@google.com
11311960Sgabeblack@google.com    /** Sets CPU pointer. */
11411960Sgabeblack@google.com    void setCPU(FullCPU *cpu_ptr);
11511960Sgabeblack@google.com
11611960Sgabeblack@google.com    /** Sets the main backwards communication time buffer pointer. */
11711960Sgabeblack@google.com    void setTimeBuffer(TimeBuffer<TimeStruct> *tb_ptr);
11811960Sgabeblack@google.com
11911960Sgabeblack@google.com    /** Sets pointer to time buffer used to communicate to the next stage. */
12011960Sgabeblack@google.com    void setRenameQueue(TimeBuffer<RenameStruct> *rq_ptr);
12111960Sgabeblack@google.com
12211960Sgabeblack@google.com    /** Sets pointer to time buffer coming from decode. */
12311960Sgabeblack@google.com    void setDecodeQueue(TimeBuffer<DecodeStruct> *dq_ptr);
12411960Sgabeblack@google.com
12511960Sgabeblack@google.com    /** Sets pointer to IEW stage. Used only for initialization. */
12611960Sgabeblack@google.com    void setIEWStage(IEW *iew_stage)
12711960Sgabeblack@google.com    { iew_ptr = iew_stage; }
12811960Sgabeblack@google.com
12911960Sgabeblack@google.com    /** Sets pointer to commit stage. Used only for initialization. */
13011960Sgabeblack@google.com    void setCommitStage(Commit *commit_stage)
13111960Sgabeblack@google.com    { commit_ptr = commit_stage; }
13211960Sgabeblack@google.com
13311960Sgabeblack@google.com  private:
13411960Sgabeblack@google.com    /** Pointer to IEW stage. Used only for initialization. */
13511960Sgabeblack@google.com    IEW *iew_ptr;
13611960Sgabeblack@google.com
13711960Sgabeblack@google.com    /** Pointer to commit stage. Used only for initialization. */
13811960Sgabeblack@google.com    Commit *commit_ptr;
13911960Sgabeblack@google.com
14011960Sgabeblack@google.com  public:
14111960Sgabeblack@google.com    /** Initializes variables for the stage. */
14211960Sgabeblack@google.com    void initStage();
14311960Sgabeblack@google.com
14411960Sgabeblack@google.com    /** Sets pointer to list of active threads. */
14511960Sgabeblack@google.com    void setActiveThreads(std::list<unsigned> *at_ptr);
14611960Sgabeblack@google.com
14711960Sgabeblack@google.com    /** Sets pointer to rename maps (per-thread structures). */
14811960Sgabeblack@google.com    void setRenameMap(RenameMap rm_ptr[Impl::MaxThreads]);
14911960Sgabeblack@google.com
15011960Sgabeblack@google.com    /** Sets pointer to the free list. */
15111960Sgabeblack@google.com    void setFreeList(FreeList *fl_ptr);
15211960Sgabeblack@google.com
15311960Sgabeblack@google.com    /** Sets pointer to the scoreboard. */
15411960Sgabeblack@google.com    void setScoreboard(Scoreboard *_scoreboard);
15511960Sgabeblack@google.com
15611960Sgabeblack@google.com    /** Squashes all instructions in a thread. */
15711960Sgabeblack@google.com    void squash(unsigned tid);
15811960Sgabeblack@google.com
15911960Sgabeblack@google.com    /** Ticks rename, which processes all input signals and attempts to rename
16011960Sgabeblack@google.com     * as many instructions as possible.
16111960Sgabeblack@google.com     */
16211960Sgabeblack@google.com    void tick();
16311960Sgabeblack@google.com
16411960Sgabeblack@google.com    /** Debugging function used to dump history buffer of renamings. */
16511960Sgabeblack@google.com    void dumpHistory();
16611960Sgabeblack@google.com
16711960Sgabeblack@google.com  private:
16811960Sgabeblack@google.com    /** Determines what to do based on rename's current status.
16911960Sgabeblack@google.com     * @param status_change rename() sets this variable if there was a status
17011960Sgabeblack@google.com     * change (ie switching from blocking to unblocking).
17111960Sgabeblack@google.com     * @param tid Thread id to rename instructions from.
17211960Sgabeblack@google.com     */
17311960Sgabeblack@google.com    void rename(bool &status_change, unsigned tid);
17411960Sgabeblack@google.com
17511960Sgabeblack@google.com    /** Renames instructions for the given thread. Also handles serializing
17611960Sgabeblack@google.com     * instructions.
17711960Sgabeblack@google.com     */
17811960Sgabeblack@google.com    void renameInsts(unsigned tid);
17911960Sgabeblack@google.com
18011960Sgabeblack@google.com    /** Inserts unused instructions from a given thread into the skid buffer,
18111960Sgabeblack@google.com     * to be renamed once rename unblocks.
18211960Sgabeblack@google.com     */
18311960Sgabeblack@google.com    void skidInsert(unsigned tid);
18411960Sgabeblack@google.com
18511960Sgabeblack@google.com    /** Separates instructions from decode into individual lists of instructions
18611960Sgabeblack@google.com     * sorted by thread.
18711960Sgabeblack@google.com     */
18811960Sgabeblack@google.com    void sortInsts();
18911960Sgabeblack@google.com
19011960Sgabeblack@google.com    /** Returns if all of the skid buffers are empty. */
19111960Sgabeblack@google.com    bool skidsEmpty();
19211960Sgabeblack@google.com
19311960Sgabeblack@google.com    /** Updates overall rename status based on all of the threads' statuses. */
19411960Sgabeblack@google.com    void updateStatus();
19511960Sgabeblack@google.com
19611960Sgabeblack@google.com    /** Switches rename to blocking, and signals back that rename has become
19711960Sgabeblack@google.com     * blocked.
19811960Sgabeblack@google.com     * @return Returns true if there is a status change.
19911960Sgabeblack@google.com     */
20011960Sgabeblack@google.com    bool block(unsigned tid);
20111960Sgabeblack@google.com
20211960Sgabeblack@google.com    /** Switches rename to unblocking if the skid buffer is empty, and signals
20311960Sgabeblack@google.com     * back that rename has unblocked.
20411960Sgabeblack@google.com     * @return Returns true if there is a status change.
20511960Sgabeblack@google.com     */
20611960Sgabeblack@google.com    bool unblock(unsigned tid);
20711960Sgabeblack@google.com
20811960Sgabeblack@google.com    /** Executes actual squash, removing squashed instructions. */
20911960Sgabeblack@google.com    void doSquash(unsigned tid);
21011960Sgabeblack@google.com
21111960Sgabeblack@google.com    /** Removes a committed instruction's rename history. */
21211960Sgabeblack@google.com    void removeFromHistory(InstSeqNum inst_seq_num, unsigned tid);
21311960Sgabeblack@google.com
21411960Sgabeblack@google.com    /** Renames the source registers of an instruction. */
21511960Sgabeblack@google.com    inline void renameSrcRegs(DynInstPtr &inst, unsigned tid);
21611960Sgabeblack@google.com
21711960Sgabeblack@google.com    /** Renames the destination registers of an instruction. */
21811960Sgabeblack@google.com    inline void renameDestRegs(DynInstPtr &inst, unsigned tid);
21911960Sgabeblack@google.com
22011960Sgabeblack@google.com    /** Calculates the number of free ROB entries for a specific thread. */
22111960Sgabeblack@google.com    inline int calcFreeROBEntries(unsigned tid);
22211960Sgabeblack@google.com
22311960Sgabeblack@google.com    /** Calculates the number of free IQ entries for a specific thread. */
22411960Sgabeblack@google.com    inline int calcFreeIQEntries(unsigned tid);
22511960Sgabeblack@google.com
22611960Sgabeblack@google.com    /** Calculates the number of free LSQ entries for a specific thread. */
22711960Sgabeblack@google.com    inline int calcFreeLSQEntries(unsigned tid);
22811960Sgabeblack@google.com
22911960Sgabeblack@google.com    /** Returns the number of valid instructions coming from decode. */
23011960Sgabeblack@google.com    unsigned validInsts();
23111960Sgabeblack@google.com
23211960Sgabeblack@google.com    /** Reads signals telling rename to block/unblock. */
23311960Sgabeblack@google.com    void readStallSignals(unsigned tid);
23411960Sgabeblack@google.com
23511960Sgabeblack@google.com    /** Checks if any stages are telling rename to block. */
23611960Sgabeblack@google.com    bool checkStall(unsigned tid);
23711960Sgabeblack@google.com
23811960Sgabeblack@google.com    void readFreeEntries(unsigned tid);
23911960Sgabeblack@google.com
24011960Sgabeblack@google.com    bool checkSignalsAndUpdate(unsigned tid);
24111960Sgabeblack@google.com
24211960Sgabeblack@google.com    /** Either serializes on the next instruction available in the InstQueue,
24311960Sgabeblack@google.com     * or records that it must serialize on the next instruction to enter
24411960Sgabeblack@google.com     * rename.
24511960Sgabeblack@google.com     * @param inst_list The list of younger, unprocessed instructions for the
24611960Sgabeblack@google.com     * thread that has the serializeAfter instruction.
24711960Sgabeblack@google.com     * @param tid The thread id.
24811960Sgabeblack@google.com     */
24911960Sgabeblack@google.com    void serializeAfter(InstQueue &inst_list, unsigned tid);
25011960Sgabeblack@google.com
25111960Sgabeblack@google.com    /** Holds the information for each destination register rename. It holds
25211960Sgabeblack@google.com     * the instruction's sequence number, the arch register, the old physical
25311960Sgabeblack@google.com     * register for that arch. register, and the new physical register.
25411960Sgabeblack@google.com     */
25511960Sgabeblack@google.com    struct RenameHistory {
25611960Sgabeblack@google.com        RenameHistory(InstSeqNum _instSeqNum, RegIndex _archReg,
25711960Sgabeblack@google.com                      PhysRegIndex _newPhysReg, PhysRegIndex _prevPhysReg)
25811960Sgabeblack@google.com            : instSeqNum(_instSeqNum), archReg(_archReg),
25911960Sgabeblack@google.com              newPhysReg(_newPhysReg), prevPhysReg(_prevPhysReg)
26011960Sgabeblack@google.com        {
26111960Sgabeblack@google.com        }
26211960Sgabeblack@google.com
26311960Sgabeblack@google.com        /** The sequence number of the instruction that renamed. */
26411960Sgabeblack@google.com        InstSeqNum instSeqNum;
26511960Sgabeblack@google.com        /** The architectural register index that was renamed. */
26611960Sgabeblack@google.com        RegIndex archReg;
26711960Sgabeblack@google.com        /** The new physical register that the arch. register is renamed to. */
26811960Sgabeblack@google.com        PhysRegIndex newPhysReg;
26911960Sgabeblack@google.com        /** The old physical register that the arch. register was renamed to. */
27011960Sgabeblack@google.com        PhysRegIndex prevPhysReg;
27111960Sgabeblack@google.com    };
27211960Sgabeblack@google.com
27311960Sgabeblack@google.com    /** A per-thread list of all destination register renames, used to either
27411960Sgabeblack@google.com     * undo rename mappings or free old physical registers.
27511960Sgabeblack@google.com     */
27611960Sgabeblack@google.com    std::list<RenameHistory> historyBuffer[Impl::MaxThreads];
27711960Sgabeblack@google.com
27811960Sgabeblack@google.com    /** Pointer to CPU. */
27911960Sgabeblack@google.com    FullCPU *cpu;
28011960Sgabeblack@google.com
28111960Sgabeblack@google.com    /** Pointer to main time buffer used for backwards communication. */
28211960Sgabeblack@google.com    TimeBuffer<TimeStruct> *timeBuffer;
28311960Sgabeblack@google.com
28411960Sgabeblack@google.com    /** Wire to get IEW's output from backwards time buffer. */
28511960Sgabeblack@google.com    typename TimeBuffer<TimeStruct>::wire fromIEW;
28611960Sgabeblack@google.com
28711960Sgabeblack@google.com    /** Wire to get commit's output from backwards time buffer. */
28811960Sgabeblack@google.com    typename TimeBuffer<TimeStruct>::wire fromCommit;
28911960Sgabeblack@google.com
29011960Sgabeblack@google.com    /** Wire to write infromation heading to previous stages. */
29111960Sgabeblack@google.com    typename TimeBuffer<TimeStruct>::wire toDecode;
29211960Sgabeblack@google.com
29311960Sgabeblack@google.com    /** Rename instruction queue. */
29411960Sgabeblack@google.com    TimeBuffer<RenameStruct> *renameQueue;
29511960Sgabeblack@google.com
29611960Sgabeblack@google.com    /** Wire to write any information heading to IEW. */
29711960Sgabeblack@google.com    typename TimeBuffer<RenameStruct>::wire toIEW;
29811960Sgabeblack@google.com
29911960Sgabeblack@google.com    /** Decode instruction queue interface. */
30011960Sgabeblack@google.com    TimeBuffer<DecodeStruct> *decodeQueue;
30111960Sgabeblack@google.com
30211960Sgabeblack@google.com    /** Wire to get decode's output from decode queue. */
30311960Sgabeblack@google.com    typename TimeBuffer<DecodeStruct>::wire fromDecode;
30411960Sgabeblack@google.com
30511960Sgabeblack@google.com    /** Queue of all instructions coming from decode this cycle. */
30611960Sgabeblack@google.com    InstQueue insts[Impl::MaxThreads];
30711960Sgabeblack@google.com
30811960Sgabeblack@google.com    /** Skid buffer between rename and decode. */
30911960Sgabeblack@google.com    InstQueue skidBuffer[Impl::MaxThreads];
31011960Sgabeblack@google.com
31111960Sgabeblack@google.com    /** Rename map interface. */
31211960Sgabeblack@google.com    RenameMap *renameMap[Impl::MaxThreads];
31311960Sgabeblack@google.com
31411960Sgabeblack@google.com    /** Free list interface. */
31511960Sgabeblack@google.com    FreeList *freeList;
31611960Sgabeblack@google.com
31711960Sgabeblack@google.com    /** Pointer to the list of active threads. */
31811960Sgabeblack@google.com    std::list<unsigned> *activeThreads;
31911960Sgabeblack@google.com
32011960Sgabeblack@google.com    /** Pointer to the scoreboard. */
32111960Sgabeblack@google.com    Scoreboard *scoreboard;
32211960Sgabeblack@google.com
32311960Sgabeblack@google.com    /** Count of instructions in progress that have been sent off to the IQ
32411960Sgabeblack@google.com     * and ROB, but are not yet included in their occupancy counts.
32511960Sgabeblack@google.com     */
32611960Sgabeblack@google.com    int instsInProgress[Impl::MaxThreads];
32711960Sgabeblack@google.com
32811960Sgabeblack@google.com    /** Variable that tracks if decode has written to the time buffer this
32911960Sgabeblack@google.com     * cycle. Used to tell CPU if there is activity this cycle.
33011960Sgabeblack@google.com     */
33111960Sgabeblack@google.com    bool wroteToTimeBuffer;
33211960Sgabeblack@google.com
33311960Sgabeblack@google.com    /** Structures whose free entries impact the amount of instructions that
33411960Sgabeblack@google.com     * can be renamed.
33511960Sgabeblack@google.com     */
33611960Sgabeblack@google.com    struct FreeEntries {
33711960Sgabeblack@google.com        unsigned iqEntries;
33811960Sgabeblack@google.com        unsigned lsqEntries;
33911960Sgabeblack@google.com        unsigned robEntries;
34011960Sgabeblack@google.com    };
34111960Sgabeblack@google.com
34211960Sgabeblack@google.com    /** Per-thread tracking of the number of free entries of back-end
34311960Sgabeblack@google.com     * structures.
34411960Sgabeblack@google.com     */
34511960Sgabeblack@google.com    FreeEntries freeEntries[Impl::MaxThreads];
34611960Sgabeblack@google.com
34711960Sgabeblack@google.com    /** Records if the ROB is empty. In SMT mode the ROB may be dynamically
34811960Sgabeblack@google.com     * partitioned between threads, so the ROB must tell rename when it is
34911960Sgabeblack@google.com     * empty.
35011960Sgabeblack@google.com     */
35111960Sgabeblack@google.com    bool emptyROB[Impl::MaxThreads];
35211960Sgabeblack@google.com
35311960Sgabeblack@google.com    /** Source of possible stalls. */
35411960Sgabeblack@google.com    struct Stalls {
35511960Sgabeblack@google.com        bool iew;
35611960Sgabeblack@google.com        bool commit;
35711960Sgabeblack@google.com    };
35811960Sgabeblack@google.com
35911960Sgabeblack@google.com    /** Tracks which stages are telling decode to stall. */
36011960Sgabeblack@google.com    Stalls stalls[Impl::MaxThreads];
36111960Sgabeblack@google.com
36211960Sgabeblack@google.com    /** The barrier instruction that rename has stalled on. */
36311960Sgabeblack@google.com    DynInstPtr barrierInst[Impl::MaxThreads];
36411960Sgabeblack@google.com
36511960Sgabeblack@google.com    /** Records if rename needs to serialize on the next instruction for any
36611960Sgabeblack@google.com     * thread.
36711960Sgabeblack@google.com     */
36811960Sgabeblack@google.com    bool serializeOnNextInst[Impl::MaxThreads];
36911960Sgabeblack@google.com
37011960Sgabeblack@google.com    /** Delay between iew and rename, in ticks. */
37111960Sgabeblack@google.com    int iewToRenameDelay;
37211960Sgabeblack@google.com
37311960Sgabeblack@google.com    /** Delay between decode and rename, in ticks. */
37411960Sgabeblack@google.com    int decodeToRenameDelay;
37511960Sgabeblack@google.com
37611960Sgabeblack@google.com    /** Delay between commit and rename, in ticks. */
37711960Sgabeblack@google.com    unsigned commitToRenameDelay;
37811960Sgabeblack@google.com
37911960Sgabeblack@google.com    /** Rename width, in instructions. */
38011960Sgabeblack@google.com    unsigned renameWidth;
38111960Sgabeblack@google.com
38211960Sgabeblack@google.com    /** Commit width, in instructions.  Used so rename knows how many
38311960Sgabeblack@google.com     *  instructions might have freed registers in the previous cycle.
38411960Sgabeblack@google.com     */
38511960Sgabeblack@google.com    unsigned commitWidth;
38611960Sgabeblack@google.com
38711960Sgabeblack@google.com    /** The index of the instruction in the time buffer to IEW that rename is
38811960Sgabeblack@google.com     * currently using.
38911960Sgabeblack@google.com     */
39011960Sgabeblack@google.com    unsigned toIEWIndex;
39111960Sgabeblack@google.com
39211960Sgabeblack@google.com    /** Whether or not rename needs to block this cycle. */
39311960Sgabeblack@google.com    bool blockThisCycle;
39411960Sgabeblack@google.com
39511960Sgabeblack@google.com    /** The number of threads active in rename. */
39611960Sgabeblack@google.com    unsigned numThreads;
39711960Sgabeblack@google.com
39811960Sgabeblack@google.com    /** The maximum skid buffer size. */
39911960Sgabeblack@google.com    unsigned skidBufferMax;
40011960Sgabeblack@google.com
40111960Sgabeblack@google.com    /** Enum to record the source of a structure full stall.  Can come from
40211960Sgabeblack@google.com     * either ROB, IQ, LSQ, and it is priortized in that order.
40311960Sgabeblack@google.com     */
40411960Sgabeblack@google.com    enum FullSource {
40511960Sgabeblack@google.com        ROB,
40611960Sgabeblack@google.com        IQ,
40711960Sgabeblack@google.com        LSQ,
40811960Sgabeblack@google.com        NONE
40911960Sgabeblack@google.com    };
41011960Sgabeblack@google.com
41111960Sgabeblack@google.com    /** Function used to increment the stat that corresponds to the source of
41211960Sgabeblack@google.com     * the stall.
41311960Sgabeblack@google.com     */
41411960Sgabeblack@google.com    inline void incrFullStat(const FullSource &source);
41511960Sgabeblack@google.com
41611960Sgabeblack@google.com    /** Stat for total number of cycles spent squashing. */
41711960Sgabeblack@google.com    Stats::Scalar<> renameSquashCycles;
41811960Sgabeblack@google.com    /** Stat for total number of cycles spent idle. */
41911960Sgabeblack@google.com    Stats::Scalar<> renameIdleCycles;
42011960Sgabeblack@google.com    /** Stat for total number of cycles spent blocking. */
42111960Sgabeblack@google.com    Stats::Scalar<> renameBlockCycles;
42211960Sgabeblack@google.com    /** Stat for total number of cycles spent stalling for a barrier. */
42311960Sgabeblack@google.com    Stats::Scalar<> renameBarrierCycles;
42411960Sgabeblack@google.com    /** Stat for total number of cycles spent running normally. */
42511960Sgabeblack@google.com    Stats::Scalar<> renameRunCycles;
42611960Sgabeblack@google.com    /** Stat for total number of cycles spent unblocking. */
42711960Sgabeblack@google.com    Stats::Scalar<> renameUnblockCycles;
42811960Sgabeblack@google.com    /** Stat for total number of renamed instructions. */
42911960Sgabeblack@google.com    Stats::Scalar<> renameRenamedInsts;
43011960Sgabeblack@google.com    /** Stat for total number of squashed instructions that rename discards. */
43111960Sgabeblack@google.com    Stats::Scalar<> renameSquashedInsts;
43211960Sgabeblack@google.com    /** Stat for total number of times that the ROB starts a stall in rename. */
43311960Sgabeblack@google.com    Stats::Scalar<> renameROBFullEvents;
43411960Sgabeblack@google.com    /** Stat for total number of times that the IQ starts a stall in rename. */
43511960Sgabeblack@google.com    Stats::Scalar<> renameIQFullEvents;
43611960Sgabeblack@google.com    /** Stat for total number of times that the LSQ starts a stall in rename. */
43711960Sgabeblack@google.com    Stats::Scalar<> renameLSQFullEvents;
43811960Sgabeblack@google.com    /** Stat for total number of times that rename runs out of free registers
43911960Sgabeblack@google.com     * to use to rename. */
44011960Sgabeblack@google.com    Stats::Scalar<> renameFullRegistersEvents;
44111960Sgabeblack@google.com    /** Stat for total number of renamed destination registers. */
44211960Sgabeblack@google.com    Stats::Scalar<> renameRenamedOperands;
44311960Sgabeblack@google.com    /** Stat for total number of source register rename lookups. */
44411960Sgabeblack@google.com    Stats::Scalar<> renameRenameLookups;
44511960Sgabeblack@google.com    /** Stat for total number of committed renaming mappings. */
44611960Sgabeblack@google.com    Stats::Scalar<> renameCommittedMaps;
44711960Sgabeblack@google.com    /** Stat for total number of mappings that were undone due to a squash. */
44811960Sgabeblack@google.com    Stats::Scalar<> renameUndoneMaps;
44911960Sgabeblack@google.com};
45011960Sgabeblack@google.com
45111960Sgabeblack@google.com#endif // __CPU_O3_RENAME_HH__
45211960Sgabeblack@google.com