inst_queue.hh revision 8229
12810SN/A/* 29614Srene.dejong@arm.com * Copyright (c) 2011 ARM Limited 38856Sandreas.hansson@arm.com * All rights reserved. 48856Sandreas.hansson@arm.com * 58856Sandreas.hansson@arm.com * The license below extends only to copyright in the software and shall 68856Sandreas.hansson@arm.com * not be construed as granting a license to any other intellectual 78856Sandreas.hansson@arm.com * property including but not limited to intellectual property relating 88856Sandreas.hansson@arm.com * to a hardware implementation of the functionality of the software 98856Sandreas.hansson@arm.com * licensed hereunder. You may use the software subject to the license 108856Sandreas.hansson@arm.com * terms below provided that you ensure that this notice is replicated 118856Sandreas.hansson@arm.com * unmodified and in its entirety in all distributions of the software, 128856Sandreas.hansson@arm.com * modified or unmodified, in source code or in binary form. 138856Sandreas.hansson@arm.com * 142810SN/A * Copyright (c) 2004-2006 The Regents of The University of Michigan 152810SN/A * All rights reserved. 162810SN/A * 172810SN/A * Redistribution and use in source and binary forms, with or without 182810SN/A * modification, are permitted provided that the following conditions are 192810SN/A * met: redistributions of source code must retain the above copyright 202810SN/A * notice, this list of conditions and the following disclaimer; 212810SN/A * redistributions in binary form must reproduce the above copyright 222810SN/A * notice, this list of conditions and the following disclaimer in the 232810SN/A * documentation and/or other materials provided with the distribution; 242810SN/A * neither the name of the copyright holders nor the names of its 252810SN/A * contributors may be used to endorse or promote products derived from 262810SN/A * this software without specific prior written permission. 272810SN/A * 282810SN/A * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 292810SN/A * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 302810SN/A * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 312810SN/A * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 322810SN/A * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 332810SN/A * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 342810SN/A * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 352810SN/A * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 362810SN/A * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 372810SN/A * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 382810SN/A * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 392810SN/A * 402810SN/A * Authors: Kevin Lim 412810SN/A */ 422810SN/A 432810SN/A#ifndef __CPU_O3_INST_QUEUE_HH__ 442810SN/A#define __CPU_O3_INST_QUEUE_HH__ 452810SN/A 462810SN/A#include <list> 472810SN/A#include <map> 4811486Snikos.nikoleris@arm.com#include <queue> 4911486Snikos.nikoleris@arm.com#include <vector> 508232Snate@binkert.org 519152Satgutier@umich.edu#include "base/statistics.hh" 5211486Snikos.nikoleris@arm.com#include "base/types.hh" 5311486Snikos.nikoleris@arm.com#include "cpu/o3/dep_graph.hh" 549795Sandreas.hansson@arm.com#include "cpu/inst_seq.hh" 559795Sandreas.hansson@arm.com#include "cpu/op_class.hh" 5610263Satgutier@umich.edu#include "cpu/timebuf.hh" 578786Sgblack@eecs.umich.edu#include "sim/eventq.hh" 582810SN/A 592810SN/Aclass DerivO3CPUParams; 602810SN/Aclass FUPool; 618856Sandreas.hansson@arm.comclass MemInterface; 628856Sandreas.hansson@arm.com 638856Sandreas.hansson@arm.com/** 648922Swilliam.wang@arm.com * A standard instruction queue class. It holds ready instructions, in 658914Sandreas.hansson@arm.com * order, in seperate priority queues to facilitate the scheduling of 668856Sandreas.hansson@arm.com * instructions. The IQ uses a separate linked list to track dependencies. 678856Sandreas.hansson@arm.com * Similar to the rename map and the free list, it expects that 684475SN/A * floating point registers have their indices start after the integer 6911053Sandreas.hansson@arm.com * registers (ie with 96 int and 96 fp registers, regs 0-95 are integer 705034SN/A * and 96-191 are fp). This remains true even for both logical and 7110360Sandreas.hansson@arm.com * physical register indices. The IQ depends on the memory dependence unit to 7211377Sandreas.hansson@arm.com * track when memory operations are ready in terms of ordering; register 7311377Sandreas.hansson@arm.com * dependencies are tracked normally. Right now the IQ also handles the 7411053Sandreas.hansson@arm.com * execution timing; this is mainly to allow back-to-back scheduling without 7510693SMarco.Balboni@ARM.com * requiring IEW to be able to peek into the IQ. At the end of the execution 7610693SMarco.Balboni@ARM.com * latency, the instruction is put into the queue to execute, where it will 7710693SMarco.Balboni@ARM.com * have the execute() function called on it. 789263Smrinmoy.ghosh@arm.com * @todo: Make IQ able to handle multiple FU pools. 795034SN/A */ 8011331Sandreas.hansson@arm.comtemplate <class Impl> 8110884Sandreas.hansson@arm.comclass InstructionQueue 824626SN/A{ 8310360Sandreas.hansson@arm.com public: 8411484Snikos.nikoleris@arm.com //Typedefs from the Impl. 855034SN/A typedef typename Impl::O3CPU O3CPU; 868883SAli.Saidi@ARM.com typedef typename Impl::DynInstPtr DynInstPtr; 878833Sdam.sunwoo@arm.com 884458SN/A typedef typename Impl::CPUPol::IEW IEW; 8911377Sandreas.hansson@arm.com typedef typename Impl::CPUPol::MemDepUnit MemDepUnit; 9011377Sandreas.hansson@arm.com typedef typename Impl::CPUPol::IssueStruct IssueStruct; 9111377Sandreas.hansson@arm.com typedef typename Impl::CPUPol::TimeStruct TimeStruct; 9211377Sandreas.hansson@arm.com 9311377Sandreas.hansson@arm.com // Typedef of iterator through the list of instructions. 9411377Sandreas.hansson@arm.com typedef typename std::list<DynInstPtr>::iterator ListIt; 9511331Sandreas.hansson@arm.com 9611331Sandreas.hansson@arm.com friend class Impl::O3CPU; 972810SN/A 982810SN/A /** FU completion event class. */ 993013SN/A class FUCompletion : public Event { 1008856Sandreas.hansson@arm.com private: 1012810SN/A /** Executing instruction. */ 1023013SN/A DynInstPtr inst; 10310714Sandreas.hansson@arm.com 1042810SN/A /** Index of the FU used for executing. */ 1059614Srene.dejong@arm.com int fuIdx; 1069614Srene.dejong@arm.com 1079614Srene.dejong@arm.com /** Pointer back to the instruction queue. */ 10810345SCurtis.Dunham@arm.com InstructionQueue<Impl> *iqPtr; 10910714Sandreas.hansson@arm.com 11010345SCurtis.Dunham@arm.com /** Should the FU be added to the list to be freed upon 1119614Srene.dejong@arm.com * completing this event. 1122810SN/A */ 1132810SN/A bool freeFU; 1142810SN/A 1158856Sandreas.hansson@arm.com public: 1162810SN/A /** Construct a FU completion event. */ 1173013SN/A FUCompletion(DynInstPtr &_inst, int fu_idx, 11810714Sandreas.hansson@arm.com InstructionQueue<Impl> *iq_ptr); 1193013SN/A 1208856Sandreas.hansson@arm.com virtual void process(); 12110714Sandreas.hansson@arm.com virtual const char *description() const; 1228922Swilliam.wang@arm.com void setFreeFU() { freeFU = true; } 1232897SN/A }; 1242810SN/A 1252810SN/A /** Constructs an IQ. */ 12610344Sandreas.hansson@arm.com InstructionQueue(O3CPU *cpu_ptr, IEW *iew_ptr, DerivO3CPUParams *params); 12710344Sandreas.hansson@arm.com 12810344Sandreas.hansson@arm.com /** Destructs the IQ. */ 12910714Sandreas.hansson@arm.com ~InstructionQueue(); 13010344Sandreas.hansson@arm.com 13110344Sandreas.hansson@arm.com /** Returns the name of the IQ. */ 13210344Sandreas.hansson@arm.com std::string name() const; 13310713Sandreas.hansson@arm.com 13410344Sandreas.hansson@arm.com /** Registers statistics. */ 1352844SN/A void regStats(); 1362810SN/A 1372858SN/A /** Resets all instruction queue state. */ 1382858SN/A void resetState(); 1398856Sandreas.hansson@arm.com 1408922Swilliam.wang@arm.com /** Sets active threads list. */ 1418711Sandreas.hansson@arm.com void setActiveThreads(std::list<ThreadID> *at_ptr); 14211331Sandreas.hansson@arm.com 1432858SN/A /** Sets the timer buffer between issue and execute. */ 1442858SN/A void setIssueToExecuteQueue(TimeBuffer<IssueStruct> *i2eQueue); 1459294Sandreas.hansson@arm.com 1469294Sandreas.hansson@arm.com /** Sets the global time buffer. */ 1478922Swilliam.wang@arm.com void setTimeBuffer(TimeBuffer<TimeStruct> *tb_ptr); 1488922Swilliam.wang@arm.com 1498922Swilliam.wang@arm.com /** Switches out the instruction queue. */ 1508922Swilliam.wang@arm.com void switchOut(); 1518922Swilliam.wang@arm.com 1528922Swilliam.wang@arm.com /** Takes over execution from another CPU's thread. */ 1538922Swilliam.wang@arm.com void takeOverFrom(); 1548922Swilliam.wang@arm.com 1559294Sandreas.hansson@arm.com /** Returns if the IQ is switched out. */ 1569294Sandreas.hansson@arm.com bool isSwitchedOut() { return switchedOut; } 1578922Swilliam.wang@arm.com 1588922Swilliam.wang@arm.com /** Number of entries needed for given amount of threads. */ 1598922Swilliam.wang@arm.com int entryAmount(ThreadID num_threads); 1608922Swilliam.wang@arm.com 1618922Swilliam.wang@arm.com /** Resets max entries for all threads. */ 1628922Swilliam.wang@arm.com void resetEntries(); 1638922Swilliam.wang@arm.com 1644628SN/A /** Returns total number of free entries. */ 16510821Sandreas.hansson@arm.com unsigned numFreeEntries(); 16610821Sandreas.hansson@arm.com 16710821Sandreas.hansson@arm.com /** Returns number of free entries for a thread. */ 16810821Sandreas.hansson@arm.com unsigned numFreeEntries(ThreadID tid); 16910821Sandreas.hansson@arm.com 17010821Sandreas.hansson@arm.com /** Returns whether or not the IQ is full. */ 17110821Sandreas.hansson@arm.com bool isFull(); 17210821Sandreas.hansson@arm.com 17310821Sandreas.hansson@arm.com /** Returns whether or not the IQ is full for a specific thread. */ 17410821Sandreas.hansson@arm.com bool isFull(ThreadID tid); 17510821Sandreas.hansson@arm.com 1762858SN/A /** Returns if there are any ready instructions in the IQ. */ 1772810SN/A bool hasReadyInsts(); 1782810SN/A 1792810SN/A /** Inserts a new instruction into the IQ. */ 1802810SN/A void insert(DynInstPtr &new_inst); 1812810SN/A 1824022SN/A /** Inserts a new, non-speculative instruction into the IQ. */ 1834022SN/A void insertNonSpec(DynInstPtr &new_inst); 1844022SN/A 1852810SN/A /** Inserts a memory or write barrier into the IQ to make sure 1862810SN/A * loads and stores are ordered properly. 1878833Sdam.sunwoo@arm.com */ 1882810SN/A void insertBarrier(DynInstPtr &barr_inst); 1892810SN/A 1902810SN/A /** Returns the oldest scheduled instruction, and removes it from 1912810SN/A * the list of instructions waiting to execute. 1928833Sdam.sunwoo@arm.com */ 1938833Sdam.sunwoo@arm.com DynInstPtr getInstToExecute(); 1948833Sdam.sunwoo@arm.com 1952810SN/A /** Returns a memory instruction that was referred due to a delayed DTB 1962810SN/A * translation if it is now ready to execute. 1974871SN/A */ 1984871SN/A DynInstPtr getDeferredMemInstToExecute(); 1994871SN/A 2004871SN/A /** 20111455Sandreas.hansson@arm.com * Records the instruction as the producer of a register without 20210885Sandreas.hansson@arm.com * adding it to the rest of the IQ. 2034871SN/A */ 2044871SN/A void recordProducer(DynInstPtr &inst) 2054871SN/A { addToProducers(inst); } 2064871SN/A 2074871SN/A /** Process FU completion event. */ 2082810SN/A void processFUCompletion(DynInstPtr &inst, int fu_idx); 2092810SN/A 2102810SN/A /** 2118833Sdam.sunwoo@arm.com * Schedules ready instructions, adding the ready ones (oldest first) to 2122810SN/A * the queue to execute. 2134871SN/A */ 2148833Sdam.sunwoo@arm.com void scheduleReadyInsts(); 2158833Sdam.sunwoo@arm.com 2168833Sdam.sunwoo@arm.com /** Schedules a single specific non-speculative instruction. */ 2172810SN/A void scheduleNonSpec(const InstSeqNum &inst); 2182810SN/A 2192810SN/A /** 2202810SN/A * Commits all instructions up to and including the given sequence number, 2218833Sdam.sunwoo@arm.com * for a specific thread. 2222810SN/A */ 2234871SN/A void commit(const InstSeqNum &inst, ThreadID tid = 0); 2248833Sdam.sunwoo@arm.com 2258833Sdam.sunwoo@arm.com /** Wakes all dependents of a completed instruction. */ 2268833Sdam.sunwoo@arm.com int wakeDependents(DynInstPtr &completed_inst); 2272810SN/A 2282810SN/A /** Adds a ready memory instruction to the ready list. */ 2294022SN/A void addReadyMemInst(DynInstPtr &ready_inst); 2304022SN/A 2314022SN/A /** 2322810SN/A * Reschedules a memory instruction. It will be ready to issue once 2332810SN/A * replayMemInst() is called. 2348833Sdam.sunwoo@arm.com */ 2352810SN/A void rescheduleMemInst(DynInstPtr &resched_inst); 2362810SN/A 2372810SN/A /** Replays a memory instruction. It must be rescheduled first. */ 2382810SN/A void replayMemInst(DynInstPtr &replay_inst); 2398833Sdam.sunwoo@arm.com 2408833Sdam.sunwoo@arm.com /** Completes a memory operation. */ 2418833Sdam.sunwoo@arm.com void completeMemInst(DynInstPtr &completed_inst); 2422810SN/A 2432810SN/A /** 2442810SN/A * Defers a memory instruction when its DTB translation incurs a hw 2452810SN/A * page table walk. 2462810SN/A */ 2478833Sdam.sunwoo@arm.com void deferMemInst(DynInstPtr &deferred_inst); 2482810SN/A 2494871SN/A /** Indicates an ordering violation between a store and a load. */ 2508833Sdam.sunwoo@arm.com void violation(DynInstPtr &store, DynInstPtr &faulting_load); 2518833Sdam.sunwoo@arm.com 2528833Sdam.sunwoo@arm.com /** 2532810SN/A * Squashes instructions for a thread. Squashing information is obtained 2542810SN/A * from the time buffer. 2552810SN/A */ 2562810SN/A void squash(ThreadID tid); 2578833Sdam.sunwoo@arm.com 2582810SN/A /** Returns the number of used entries for a thread. */ 2594871SN/A unsigned getCount(ThreadID tid) { return count[tid]; }; 2608833Sdam.sunwoo@arm.com 2618833Sdam.sunwoo@arm.com /** Debug function to print all instructions. */ 2628833Sdam.sunwoo@arm.com void printInsts(); 2632810SN/A 2642810SN/A private: 2654022SN/A /** Does the actual squashing. */ 2664022SN/A void doSquash(ThreadID tid); 2674022SN/A 2682810SN/A ///////////////////////// 2692810SN/A // Various pointers 2708833Sdam.sunwoo@arm.com ///////////////////////// 2712810SN/A 2722810SN/A /** Pointer to the CPU. */ 2732810SN/A O3CPU *cpu; 2742810SN/A 2758833Sdam.sunwoo@arm.com /** Cache interface. */ 2768833Sdam.sunwoo@arm.com MemInterface *dcacheInterface; 2778833Sdam.sunwoo@arm.com 2782810SN/A /** Pointer to IEW stage. */ 2792810SN/A IEW *iewStage; 2802810SN/A 2812810SN/A /** The memory dependence unit, which tracks/predicts memory dependences 2822810SN/A * between instructions. 2838833Sdam.sunwoo@arm.com */ 2842810SN/A MemDepUnit memDepUnit[Impl::MaxThreads]; 2854871SN/A 2868833Sdam.sunwoo@arm.com /** The queue to the execute stage. Issued instructions will be written 2878833Sdam.sunwoo@arm.com * into it. 2888833Sdam.sunwoo@arm.com */ 2892810SN/A TimeBuffer<IssueStruct> *issueToExecuteQueue; 2902810SN/A 2912810SN/A /** The backwards time buffer. */ 2922810SN/A TimeBuffer<TimeStruct> *timeBuffer; 2938833Sdam.sunwoo@arm.com 2942810SN/A /** Wire to read information from timebuffer. */ 2954871SN/A typename TimeBuffer<TimeStruct>::wire fromCommit; 2968833Sdam.sunwoo@arm.com 2978833Sdam.sunwoo@arm.com /** Function unit pool. */ 2988833Sdam.sunwoo@arm.com FUPool *fuPool; 2992810SN/A 3002810SN/A ////////////////////////////////////// 3014022SN/A // Instruction lists, ready queues, and ordering 3024022SN/A ////////////////////////////////////// 3034022SN/A 3042810SN/A /** List of all the instructions in the IQ (some of which may be issued). */ 3052810SN/A std::list<DynInstPtr> instList[Impl::MaxThreads]; 3062810SN/A 3072810SN/A /** List of instructions that are ready to be executed. */ 3082810SN/A std::list<DynInstPtr> instsToExecute; 3092810SN/A 3108833Sdam.sunwoo@arm.com /** List of instructions waiting for their DTB translation to 3112810SN/A * complete (hw page table walk in progress). 3128833Sdam.sunwoo@arm.com */ 3138833Sdam.sunwoo@arm.com std::list<DynInstPtr> deferredMemInsts; 3148833Sdam.sunwoo@arm.com 3152810SN/A /** 3162810SN/A * Struct for comparing entries to be added to the priority queue. 3172810SN/A * This gives reverse ordering to the instructions in terms of 3182810SN/A * sequence numbers: the instructions with smaller sequence 3192810SN/A * numbers (and hence are older) will be at the top of the 3208833Sdam.sunwoo@arm.com * priority queue. 3212810SN/A */ 3222810SN/A struct pqCompare { 3238833Sdam.sunwoo@arm.com bool operator() (const DynInstPtr &lhs, const DynInstPtr &rhs) const 3248833Sdam.sunwoo@arm.com { 3258833Sdam.sunwoo@arm.com return lhs->seqNum > rhs->seqNum; 3262810SN/A } 3272810SN/A }; 3282810SN/A 3292810SN/A typedef std::priority_queue<DynInstPtr, std::vector<DynInstPtr>, pqCompare> 3308833Sdam.sunwoo@arm.com ReadyInstQueue; 3312810SN/A 3322810SN/A /** List of ready instructions, per op class. They are separated by op 3338833Sdam.sunwoo@arm.com * class to allow for easy mapping to FUs. 3348833Sdam.sunwoo@arm.com */ 3358833Sdam.sunwoo@arm.com ReadyInstQueue readyInsts[Num_OpClasses]; 3362810SN/A 3372810SN/A /** List of non-speculative instructions that will be scheduled 3384022SN/A * once the IQ gets a signal from commit. While it's redundant to 3394022SN/A * have the key be a part of the value (the sequence number is stored 3404022SN/A * inside of DynInst), when these instructions are woken up only 3412810SN/A * the sequence number will be available. Thus it is most efficient to be 3422810SN/A * able to search by the sequence number alone. 3432810SN/A */ 3442810SN/A std::map<InstSeqNum, DynInstPtr> nonSpecInsts; 3452810SN/A 3462810SN/A typedef typename std::map<InstSeqNum, DynInstPtr>::iterator NonSpecMapIt; 3478833Sdam.sunwoo@arm.com 3482810SN/A /** Entry for the list age ordering by op class. */ 3498833Sdam.sunwoo@arm.com struct ListOrderEntry { 3508833Sdam.sunwoo@arm.com OpClass queueType; 3518833Sdam.sunwoo@arm.com InstSeqNum oldestInst; 3522810SN/A }; 3532810SN/A 3542810SN/A /** List that contains the age order of the oldest instruction of each 3552810SN/A * ready queue. Used to select the oldest instruction available 3562810SN/A * among op classes. 3578833Sdam.sunwoo@arm.com * @todo: Might be better to just move these entries around instead 3582810SN/A * of creating new ones every time the position changes due to an 3592810SN/A * instruction issuing. Not sure std::list supports this. 3608833Sdam.sunwoo@arm.com */ 3618833Sdam.sunwoo@arm.com std::list<ListOrderEntry> listOrder; 3628833Sdam.sunwoo@arm.com 3632810SN/A typedef typename std::list<ListOrderEntry>::iterator ListOrderIt; 3642810SN/A 3652810SN/A /** Tracks if each ready queue is on the age order list. */ 3662810SN/A bool queueOnList[Num_OpClasses]; 3678833Sdam.sunwoo@arm.com 3682810SN/A /** Iterators of each ready queue. Points to their spot in the age order 3692810SN/A * list. 3708833Sdam.sunwoo@arm.com */ 3718833Sdam.sunwoo@arm.com ListOrderIt readyIt[Num_OpClasses]; 3728833Sdam.sunwoo@arm.com 3732810SN/A /** Add an op class to the age order list. */ 3742810SN/A void addToOrderList(OpClass op_class); 3754022SN/A 3764022SN/A /** 3774022SN/A * Called when the oldest instruction has been removed from a ready queue; 3782810SN/A * this places that ready queue into the proper spot in the age order list. 3792810SN/A */ 3802810SN/A void moveToYoungerInst(ListOrderIt age_order_it); 3812810SN/A 3822810SN/A DependencyGraph<DynInstPtr> dependGraph; 3832810SN/A 3842810SN/A ////////////////////////////////////// 3852810SN/A // Various parameters 3868833Sdam.sunwoo@arm.com ////////////////////////////////////// 3878833Sdam.sunwoo@arm.com 3888833Sdam.sunwoo@arm.com /** IQ Resource Sharing Policy */ 3898833Sdam.sunwoo@arm.com enum IQPolicy { 3902810SN/A Dynamic, 3912810SN/A Partitioned, 3922810SN/A Threshold 3932810SN/A }; 3942810SN/A 3958833Sdam.sunwoo@arm.com /** IQ sharing policy for SMT. */ 3962810SN/A IQPolicy iqPolicy; 3972810SN/A 3988833Sdam.sunwoo@arm.com /** Number of Total Threads*/ 3998833Sdam.sunwoo@arm.com ThreadID numThreads; 4008833Sdam.sunwoo@arm.com 4012810SN/A /** Pointer to list of active threads. */ 4022810SN/A std::list<ThreadID> *activeThreads; 4032810SN/A 4042810SN/A /** Per Thread IQ count */ 4058833Sdam.sunwoo@arm.com unsigned count[Impl::MaxThreads]; 4062810SN/A 4072810SN/A /** Max IQ Entries Per Thread */ 4088833Sdam.sunwoo@arm.com unsigned maxEntries[Impl::MaxThreads]; 4098833Sdam.sunwoo@arm.com 4108833Sdam.sunwoo@arm.com /** Number of free IQ entries left. */ 4112810SN/A unsigned freeEntries; 4122810SN/A 4132810SN/A /** The number of entries in the instruction queue. */ 4142810SN/A unsigned numEntries; 4152810SN/A 4162810SN/A /** The total number of instructions that can be issued in one cycle. */ 4172810SN/A unsigned totalWidth; 4182810SN/A 4192810SN/A /** The number of physical registers in the CPU. */ 4202810SN/A unsigned numPhysRegs; 4212810SN/A 4222810SN/A /** The number of physical integer registers in the CPU. */ 4232810SN/A unsigned numPhysIntRegs; 4242810SN/A 4252810SN/A /** The number of floating point registers in the CPU. */ 4262810SN/A unsigned numPhysFloatRegs; 4272810SN/A 4282810SN/A /** Delay between commit stage and the IQ. 4292810SN/A * @todo: Make there be a distinction between the delays within IEW. 4302810SN/A */ 4312810SN/A unsigned commitToIEWDelay; 4322810SN/A 4332810SN/A /** Is the IQ switched out. */ 4342810SN/A bool switchedOut; 4352810SN/A 4362810SN/A /** The sequence number of the squashed instruction. */ 4372810SN/A InstSeqNum squashedSeqNum[Impl::MaxThreads]; 43811436SRekai.GonzalezAlberquilla@arm.com 43911436SRekai.GonzalezAlberquilla@arm.com /** A cache of the recently woken registers. It is 1 if the register 44011436SRekai.GonzalezAlberquilla@arm.com * has been woken up recently, and 0 if the register has been added 44111436SRekai.GonzalezAlberquilla@arm.com * to the dependency graph and has not yet received its value. It 44211436SRekai.GonzalezAlberquilla@arm.com * is basically a secondary scoreboard, and should pretty much mirror 44311436SRekai.GonzalezAlberquilla@arm.com * the scoreboard that exists in the rename map. 4444626SN/A */ 4458833Sdam.sunwoo@arm.com std::vector<bool> regScoreboard; 4464626SN/A 4474626SN/A /** Adds an instruction to the dependency graph, as a consumer. */ 4488833Sdam.sunwoo@arm.com bool addToDependents(DynInstPtr &new_inst); 4494626SN/A 4508833Sdam.sunwoo@arm.com /** Adds an instruction to the dependency graph, as a producer. */ 4518833Sdam.sunwoo@arm.com void addToProducers(DynInstPtr &new_inst); 4528833Sdam.sunwoo@arm.com 4534626SN/A /** Moves an instruction to the ready queue if it is ready. */ 4544626SN/A void addIfReady(DynInstPtr &inst); 4554626SN/A 4564626SN/A /** Debugging function to count how many entries are in the IQ. It does 4574626SN/A * a linear walk through the instructions, so do not call this function 4584626SN/A * during normal execution. 4594626SN/A */ 4604626SN/A int countInsts(); 4618833Sdam.sunwoo@arm.com 4624626SN/A /** Debugging function to dump all the list sizes, as well as print 4634626SN/A * out the list of nonspeculative instructions. Should not be used 4644626SN/A * in any other capacity, but it has no harmful sideaffects. 4654626SN/A */ 4668833Sdam.sunwoo@arm.com void dumpLists(); 4678833Sdam.sunwoo@arm.com 4688833Sdam.sunwoo@arm.com /** Debugging function to dump out all instructions that are in the 4694626SN/A * IQ. 4704626SN/A */ 4714626SN/A void dumpInsts(); 4724626SN/A 4734626SN/A /** Stat for number of instructions added. */ 4748833Sdam.sunwoo@arm.com Stats::Scalar iqInstsAdded; 4754626SN/A /** Stat for number of non-speculative instructions added. */ 4764871SN/A Stats::Scalar iqNonSpecInstsAdded; 4778833Sdam.sunwoo@arm.com 4788833Sdam.sunwoo@arm.com Stats::Scalar iqInstsIssued; 4798833Sdam.sunwoo@arm.com /** Stat for number of integer instructions issued. */ 4804626SN/A Stats::Scalar iqIntInstsIssued; 4814626SN/A /** Stat for number of floating point instructions issued. */ 4824626SN/A Stats::Scalar iqFloatInstsIssued; 4834626SN/A /** Stat for number of branch instructions issued. */ 4848833Sdam.sunwoo@arm.com Stats::Scalar iqBranchInstsIssued; 4854626SN/A /** Stat for number of memory instructions issued. */ 4864871SN/A Stats::Scalar iqMemInstsIssued; 4878833Sdam.sunwoo@arm.com /** Stat for number of miscellaneous instructions issued. */ 4888833Sdam.sunwoo@arm.com Stats::Scalar iqMiscInstsIssued; 4898833Sdam.sunwoo@arm.com /** Stat for number of squashed instructions that were ready to issue. */ 4904626SN/A Stats::Scalar iqSquashedInstsIssued; 4914626SN/A /** Stat for number of squashed instructions examined when squashing. */ 4924626SN/A Stats::Scalar iqSquashedInstsExamined; 4934626SN/A /** Stat for number of squashed instruction operands examined when 4944626SN/A * squashing. 4954626SN/A */ 4964626SN/A Stats::Scalar iqSquashedOperandsExamined; 4978833Sdam.sunwoo@arm.com /** Stat for number of non-speculative instructions removed due to a squash. 4984626SN/A */ 4994626SN/A Stats::Scalar iqSquashedNonSpecRemoved; 5004626SN/A // Also include number of instructions rescheduled and replayed. 5014626SN/A 5028833Sdam.sunwoo@arm.com /** Distribution of number of instructions in the queue. 5038833Sdam.sunwoo@arm.com * @todo: Need to create struct to track the entry time for each 5048833Sdam.sunwoo@arm.com * instruction. */ 5054626SN/A// Stats::VectorDistribution queueResDist; 5064626SN/A /** Distribution of the number of instructions issued. */ 5074626SN/A Stats::Distribution numIssuedDist; 5084626SN/A /** Distribution of the cycles it takes to issue an instruction. 5094626SN/A * @todo: Need to create struct to track the ready time for each 5108833Sdam.sunwoo@arm.com * instruction. */ 5114626SN/A// Stats::VectorDistribution issueDelayDist; 5124871SN/A 5138833Sdam.sunwoo@arm.com /** Number of times an instruction could not be issued because a 5148833Sdam.sunwoo@arm.com * FU was busy. 5158833Sdam.sunwoo@arm.com */ 5164626SN/A Stats::Vector statFuBusy; 5174626SN/A// Stats::Vector dist_unissued; 5184626SN/A /** Stat for total number issued for each instruction type. */ 5194626SN/A Stats::Vector2d statIssuedInstType; 5208833Sdam.sunwoo@arm.com 5214626SN/A /** Number of instructions issued per cycle. */ 5224871SN/A Stats::Formula issueRate; 5238833Sdam.sunwoo@arm.com 5248833Sdam.sunwoo@arm.com /** Number of times the FU was busy. */ 5258833Sdam.sunwoo@arm.com Stats::Vector fuBusy; 5264626SN/A /** Number of times the FU was busy per instruction issued. */ 5274626SN/A Stats::Formula fuBusyRate; 5284626SN/A public: 5294626SN/A Stats::Scalar intInstQueueReads; 5304626SN/A Stats::Scalar intInstQueueWrites; 5314626SN/A Stats::Scalar intInstQueueWakeupAccesses; 5324626SN/A Stats::Scalar fpInstQueueReads; 5338833Sdam.sunwoo@arm.com Stats::Scalar fpInstQueueWrites; 5344626SN/A Stats::Scalar fpInstQueueWakeupQccesses; 5354626SN/A 5364626SN/A Stats::Scalar intAluAccesses; 5374626SN/A Stats::Scalar fpAluAccesses; 5388833Sdam.sunwoo@arm.com}; 5398833Sdam.sunwoo@arm.com 5408833Sdam.sunwoo@arm.com#endif //__CPU_O3_INST_QUEUE_HH__ 5414626SN/A