gem5  v19.0.0.0
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
lsq_unit.hh
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2012-2014,2017-2018,2020 ARM Limited
3  * All rights reserved
4  *
5  * The license below extends only to copyright in the software and shall
6  * not be construed as granting a license to any other intellectual
7  * property including but not limited to intellectual property relating
8  * to a hardware implementation of the functionality of the software
9  * licensed hereunder. You may use the software subject to the license
10  * terms below provided that you ensure that this notice is replicated
11  * unmodified and in its entirety in all distributions of the software,
12  * modified or unmodified, in source code or in binary form.
13  *
14  * Copyright (c) 2004-2006 The Regents of The University of Michigan
15  * Copyright (c) 2013 Advanced Micro Devices, Inc.
16  * All rights reserved.
17  *
18  * Redistribution and use in source and binary forms, with or without
19  * modification, are permitted provided that the following conditions are
20  * met: redistributions of source code must retain the above copyright
21  * notice, this list of conditions and the following disclaimer;
22  * redistributions in binary form must reproduce the above copyright
23  * notice, this list of conditions and the following disclaimer in the
24  * documentation and/or other materials provided with the distribution;
25  * neither the name of the copyright holders nor the names of its
26  * contributors may be used to endorse or promote products derived from
27  * this software without specific prior written permission.
28  *
29  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
30  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
31  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
32  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
33  * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
34  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
35  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
36  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
37  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
38  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
39  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
40  *
41  * Authors: Kevin Lim
42  * Korey Sewell
43  */
44 
45 #ifndef __CPU_O3_LSQ_UNIT_HH__
46 #define __CPU_O3_LSQ_UNIT_HH__
47 
48 #include <algorithm>
49 #include <cstring>
50 #include <map>
51 #include <queue>
52 
54 #include "arch/generic/vec_reg.hh"
55 #include "arch/isa_traits.hh"
56 #include "arch/locked_mem.hh"
57 #include "arch/mmapped_ipr.hh"
58 #include "config/the_isa.hh"
59 #include "cpu/inst_seq.hh"
60 #include "cpu/timebuf.hh"
61 #include "debug/LSQUnit.hh"
62 #include "mem/packet.hh"
63 #include "mem/port.hh"
64 
65 struct DerivO3CPUParams;
66 #include "base/circular_queue.hh"
67 
80 template <class Impl>
81 class LSQUnit
82 {
83  public:
84  static constexpr auto MaxDataBytes = MaxVecRegLenInBytes;
85 
86  typedef typename Impl::O3CPU O3CPU;
87  typedef typename Impl::DynInstPtr DynInstPtr;
88  typedef typename Impl::CPUPol::IEW IEW;
89  typedef typename Impl::CPUPol::LSQ LSQ;
90  typedef typename Impl::CPUPol::IssueStruct IssueStruct;
91 
93  using LSQRequest = typename Impl::CPUPol::LSQ::LSQRequest;
94  private:
95  class LSQEntry
96  {
97  private:
99  DynInstPtr inst;
103  uint32_t _size;
105  bool _valid;
106  public:
109  : inst(nullptr), req(nullptr), _size(0), _valid(false)
110  {
111  }
112 
114  {
115  inst = nullptr;
116  if (req != nullptr) {
117  req->freeLSQEntry();
118  req = nullptr;
119  }
120  }
121 
122  void
124  {
125  inst = nullptr;
126  if (req != nullptr) {
127  req->freeLSQEntry();
128  }
129  req = nullptr;
130  _valid = false;
131  _size = 0;
132  }
133 
134  void
135  set(const DynInstPtr& inst)
136  {
137  assert(!_valid);
138  this->inst = inst;
139  _valid = true;
140  _size = 0;
141  }
142  LSQRequest* request() { return req; }
143  void setRequest(LSQRequest* r) { req = r; }
144  bool hasRequest() { return req != nullptr; }
147  bool valid() const { return _valid; }
148  uint32_t& size() { return _size; }
149  const uint32_t& size() const { return _size; }
150  const DynInstPtr& instruction() const { return inst; }
152  };
153 
154  class SQEntry : public LSQEntry
155  {
156  private:
158  char _data[MaxDataBytes];
160  bool _canWB;
170  public:
171  static constexpr size_t DataSize = sizeof(_data);
174  : _canWB(false), _committed(false), _completed(false),
175  _isAllZeros(false)
176  {
177  std::memset(_data, 0, DataSize);
178  }
179 
181  {
182  }
183 
184  void
185  set(const DynInstPtr& inst)
186  {
188  }
189 
190  void
192  {
193  LSQEntry::clear();
194  _canWB = _completed = _committed = _isAllZeros = false;
195  }
198  bool& canWB() { return _canWB; }
199  const bool& canWB() const { return _canWB; }
200  bool& completed() { return _completed; }
201  const bool& completed() const { return _completed; }
202  bool& committed() { return _committed; }
203  const bool& committed() const { return _committed; }
204  bool& isAllZeros() { return _isAllZeros; }
205  const bool& isAllZeros() const { return _isAllZeros; }
206  char* data() { return _data; }
207  const char* data() const { return _data; }
209  };
210  using LQEntry = LSQEntry;
211 
213  enum class AddrRangeCoverage
214  {
215  PartialAddrRangeCoverage, /* Two ranges partly overlap */
216  FullAddrRangeCoverage, /* One range fully covers another */
217  NoAddrRangeCoverage /* Two ranges are disjoint */
218  };
219 
220  public:
223 
224  public:
226  LSQUnit(uint32_t lqEntries, uint32_t sqEntries);
227 
232  LSQUnit(const LSQUnit &l) { panic("LSQUnit is not copy-able"); }
233 
235  void init(O3CPU *cpu_ptr, IEW *iew_ptr, DerivO3CPUParams *params,
236  LSQ *lsq_ptr, unsigned id);
237 
239  std::string name() const;
240 
242  void regStats();
243 
245  void setDcachePort(MasterPort *dcache_port);
246 
248  void drainSanityCheck() const;
249 
251  void takeOverFrom();
252 
254  void insert(const DynInstPtr &inst);
256  void insertLoad(const DynInstPtr &load_inst);
258  void insertStore(const DynInstPtr &store_inst);
259 
266  Fault checkViolations(typename LoadQueue::iterator& loadIt,
267  const DynInstPtr& inst);
268 
273  void checkSnoop(PacketPtr pkt);
274 
276  Fault executeLoad(const DynInstPtr &inst);
277 
278  Fault executeLoad(int lq_idx) { panic("Not implemented"); return NoFault; }
280  Fault executeStore(const DynInstPtr &inst);
281 
283  void commitLoad();
285  void commitLoads(InstSeqNum &youngest_inst);
286 
288  void commitStores(InstSeqNum &youngest_inst);
289 
291  void writebackStores();
292 
295  void completeDataAccess(PacketPtr pkt);
296 
298  void squash(const InstSeqNum &squashed_num);
299 
303  bool violation() { return memDepViolator; }
304 
306  DynInstPtr getMemDepViolator();
307 
309  unsigned numFreeLoadEntries();
310 
312  unsigned numFreeStoreEntries();
313 
315  int numLoads() { return loads; }
316 
318  int numStores() { return stores; }
319 
321  bool isFull() { return lqFull() || sqFull(); }
322 
324  bool isEmpty() const { return lqEmpty() && sqEmpty(); }
325 
327  bool lqFull() { return loadQueue.full(); }
328 
330  bool sqFull() { return storeQueue.full(); }
331 
333  bool lqEmpty() const { return loads == 0; }
334 
336  bool sqEmpty() const { return stores == 0; }
337 
339  unsigned getCount() { return loads + stores; }
340 
342  bool hasStoresToWB() { return storesToWB; }
343 
345  int numStoresToWB() { return storesToWB; }
346 
348  bool
350  {
351  return storeWBIt.dereferenceable() &&
352  storeWBIt->valid() &&
353  storeWBIt->canWB() &&
354  !storeWBIt->completed() &&
356  }
357 
359  void recvRetry();
360 
361  unsigned int cacheLineSize();
362  private:
364  void resetState();
365 
367  void writeback(const DynInstPtr &inst, PacketPtr pkt);
368 
370  void writebackBlockedStore();
371 
373  void completeStore(typename StoreQueue::iterator store_idx);
374 
376  void storePostSend();
377 
378  public:
383  bool trySendPacket(bool isLoad, PacketPtr data_pkt);
384 
385 
387  void dumpInsts() const;
388 
390  void schedule(Event& ev, Tick when) { cpu->schedule(ev, when); }
391 
392  BaseTLB* dTLB() { return cpu->dtb; }
393 
394  private:
396  O3CPU *cpu;
397 
399  IEW *iewStage;
400 
402  LSQ *lsq;
403 
406 
409  {
410  using LSQSenderState::alive;
411  public:
412  LQSenderState(typename LoadQueue::iterator idx_)
413  : LSQSenderState(idx_->request(), true), idx(idx_) { }
414 
416  typename LoadQueue::iterator idx;
417  //virtual LSQRequest* request() { return idx->request(); }
418  virtual void
420  {
421  //if (alive())
422  // idx->request()->senderState(nullptr);
423  }
424  };
425 
428  {
429  using LSQSenderState::alive;
430  public:
432  : LSQSenderState(idx_->request(), false), idx(idx_) { }
435  //virtual LSQRequest* request() { return idx->request(); }
436  virtual void
438  {
439  //if (alive())
440  // idx->request()->senderState(nullptr);
441  }
442  };
443 
445  class WritebackEvent : public Event
446  {
447  public:
449  WritebackEvent(const DynInstPtr &_inst, PacketPtr pkt,
450  LSQUnit *lsq_ptr);
451 
453  void process();
454 
456  const char *description() const;
457 
458  private:
460  DynInstPtr inst;
461 
464 
467  };
468 
469  public:
476  bool recvTimingResp(PacketPtr pkt);
477 
478  private:
481  public:
484 
487 
488  private:
492  unsigned depCheckShift;
493 
496 
498  int loads;
500  int stores;
503 
508 
511 
514 
516  bool stalled;
523 
526 
529 
532 
534  DynInstPtr memDepViolator;
535 
539 
542 
544  bool needsTSO;
545 
546  // Will also need how many read/write ports the Dcache has. Or keep track
547  // of that in stage that is one level up, and only call executeLoad/Store
548  // the appropriate number of times.
551 
554 
557 
561 
564 
567 
570 
573 
576 
579 
580  public:
582  Fault read(LSQRequest *req, int load_idx);
583 
585  Fault write(LSQRequest *req, uint8_t *data, int store_idx);
586 
588  int getLoadHead() { return loadQueue.head(); }
589 
591  InstSeqNum
593  {
594  return loadQueue.front().valid()
595  ? loadQueue.front().instruction()->seqNum
596  : 0;
597  }
598 
600  int getStoreHead() { return storeQueue.head(); }
602  InstSeqNum
604  {
605  return storeQueue.front().valid()
606  ? storeQueue.front().instruction()->seqNum
607  : 0;
608  }
609 
611  bool isStalled() { return stalled; }
612  public:
617 };
618 
619 template <class Impl>
620 Fault
622 {
623  LQEntry& load_req = loadQueue[load_idx];
624  const DynInstPtr& load_inst = load_req.instruction();
625 
626  load_req.setRequest(req);
627  assert(load_inst);
628 
629  assert(!load_inst->isExecuted());
630 
631  // Make sure this isn't a strictly ordered load
632  // A bit of a hackish way to get strictly ordered accesses to work
633  // only if they're at the head of the LSQ and are ready to commit
634  // (at the head of the ROB too).
635 
636  if (req->mainRequest()->isStrictlyOrdered() &&
637  (load_idx != loadQueue.head() || !load_inst->isAtCommit())) {
638  // Tell IQ/mem dep unit that this instruction will need to be
639  // rescheduled eventually
640  iewStage->rescheduleMemInst(load_inst);
641  load_inst->clearIssued();
642  load_inst->effAddrValid(false);
644  DPRINTF(LSQUnit, "Strictly ordered load [sn:%lli] PC %s\n",
645  load_inst->seqNum, load_inst->pcState());
646 
647  // Must delete request now that it wasn't handed off to
648  // memory. This is quite ugly. @todo: Figure out the proper
649  // place to really handle request deletes.
650  load_req.setRequest(nullptr);
651  req->discard();
652  return std::make_shared<GenericISA::M5PanicFault>(
653  "Strictly ordered load [sn:%llx] PC %s\n",
654  load_inst->seqNum, load_inst->pcState());
655  }
656 
657  DPRINTF(LSQUnit, "Read called, load idx: %i, store idx: %i, "
658  "storeHead: %i addr: %#x%s\n",
659  load_idx - 1, load_inst->sqIt._idx, storeQueue.head() - 1,
660  req->mainRequest()->getPaddr(), req->isSplit() ? " split" : "");
661 
662  if (req->mainRequest()->isLLSC()) {
663  // Disable recording the result temporarily. Writing to misc
664  // regs normally updates the result, but this is not the
665  // desired behavior when handling store conditionals.
666  load_inst->recordResult(false);
667  TheISA::handleLockedRead(load_inst.get(), req->mainRequest());
668  load_inst->recordResult(true);
669  }
670 
671  if (req->mainRequest()->isMmappedIpr()) {
672  assert(!load_inst->memData);
673  load_inst->memData = new uint8_t[MaxDataBytes];
674 
675  ThreadContext *thread = cpu->tcBase(lsqID);
676  PacketPtr main_pkt = new Packet(req->mainRequest(), MemCmd::ReadReq);
677 
678  main_pkt->dataStatic(load_inst->memData);
679 
680  Cycles delay = req->handleIprRead(thread, main_pkt);
681 
682  WritebackEvent *wb = new WritebackEvent(load_inst, main_pkt, this);
683  cpu->schedule(wb, cpu->clockEdge(delay));
684  return NoFault;
685  }
686 
687  // Check the SQ for any previous stores that might lead to forwarding
688  auto store_it = load_inst->sqIt;
689  assert (store_it >= storeWBIt);
690  // End once we've reached the top of the LSQ
691  while (store_it != storeWBIt) {
692  // Move the index to one younger
693  store_it--;
694  assert(store_it->valid());
695  assert(store_it->instruction()->seqNum < load_inst->seqNum);
696  int store_size = store_it->size();
697 
698  // Cache maintenance instructions go down via the store
699  // path but they carry no data and they shouldn't be
700  // considered for forwarding
701  if (store_size != 0 && !store_it->instruction()->strictlyOrdered() &&
702  !(store_it->request()->mainRequest() &&
703  store_it->request()->mainRequest()->isCacheMaintenance())) {
704  assert(store_it->instruction()->effAddrValid());
705 
706  // Check if the store data is within the lower and upper bounds of
707  // addresses that the request needs.
708  auto req_s = req->mainRequest()->getVaddr();
709  auto req_e = req_s + req->mainRequest()->getSize();
710  auto st_s = store_it->instruction()->effAddr;
711  auto st_e = st_s + store_size;
712 
713  bool store_has_lower_limit = req_s >= st_s;
714  bool store_has_upper_limit = req_e <= st_e;
715  bool lower_load_has_store_part = req_s < st_e;
716  bool upper_load_has_store_part = req_e > st_s;
717 
719 
720  // If the store entry is not atomic (atomic does not have valid
721  // data), the store has all of the data needed, and
722  // the load is not LLSC, then
723  // we can forward data from the store to the load
724  if (!store_it->instruction()->isAtomic() &&
725  store_has_lower_limit && store_has_upper_limit &&
726  !req->mainRequest()->isLLSC()) {
727 
728  const auto& store_req = store_it->request()->mainRequest();
729  coverage = store_req->isMasked() ?
732  } else if (
733  // This is the partial store-load forwarding case where a store
734  // has only part of the load's data and the load isn't LLSC
735  (!req->mainRequest()->isLLSC() &&
736  ((store_has_lower_limit && lower_load_has_store_part) ||
737  (store_has_upper_limit && upper_load_has_store_part) ||
738  (lower_load_has_store_part && upper_load_has_store_part))) ||
739  // The load is LLSC, and the store has all or part of the
740  // load's data
741  (req->mainRequest()->isLLSC() &&
742  ((store_has_lower_limit || upper_load_has_store_part) &&
743  (store_has_upper_limit || lower_load_has_store_part))) ||
744  // The store entry is atomic and has all or part of the load's
745  // data
746  (store_it->instruction()->isAtomic() &&
747  ((store_has_lower_limit || upper_load_has_store_part) &&
748  (store_has_upper_limit || lower_load_has_store_part)))) {
749 
751  }
752 
754  // Get shift amount for offset into the store's data.
755  int shift_amt = req->mainRequest()->getVaddr() -
756  store_it->instruction()->effAddr;
757 
758  // Allocate memory if this is the first time a load is issued.
759  if (!load_inst->memData) {
760  load_inst->memData =
761  new uint8_t[req->mainRequest()->getSize()];
762  }
763  if (store_it->isAllZeros())
764  memset(load_inst->memData, 0,
765  req->mainRequest()->getSize());
766  else
767  memcpy(load_inst->memData,
768  store_it->data() + shift_amt,
769  req->mainRequest()->getSize());
770 
771  DPRINTF(LSQUnit, "Forwarding from store idx %i to load to "
772  "addr %#x\n", store_it._idx,
773  req->mainRequest()->getVaddr());
774 
775  PacketPtr data_pkt = new Packet(req->mainRequest(),
777  data_pkt->dataStatic(load_inst->memData);
778 
779  if (req->isAnyOutstandingRequest()) {
780  assert(req->_numOutstandingPackets > 0);
781  // There are memory requests packets in flight already.
782  // This may happen if the store was not complete the
783  // first time this load got executed. Signal the senderSate
784  // that response packets should be discarded.
785  req->discardSenderState();
786  }
787 
788  WritebackEvent *wb = new WritebackEvent(load_inst, data_pkt,
789  this);
790 
791  // We'll say this has a 1 cycle load-store forwarding latency
792  // for now.
793  // @todo: Need to make this a parameter.
794  cpu->schedule(wb, curTick());
795 
796  // Don't need to do anything special for split loads.
797  ++lsqForwLoads;
798 
799  return NoFault;
800  } else if (coverage == AddrRangeCoverage::PartialAddrRangeCoverage) {
801  // If it's already been written back, then don't worry about
802  // stalling on it.
803  if (store_it->completed()) {
804  panic("Should not check one of these");
805  continue;
806  }
807 
808  // Must stall load and force it to retry, so long as it's the
809  // oldest load that needs to do so.
810  if (!stalled ||
811  (stalled &&
812  load_inst->seqNum <
813  loadQueue[stallingLoadIdx].instruction()->seqNum)) {
814  stalled = true;
815  stallingStoreIsn = store_it->instruction()->seqNum;
816  stallingLoadIdx = load_idx;
817  }
818 
819  // Tell IQ/mem dep unit that this instruction will need to be
820  // rescheduled eventually
821  iewStage->rescheduleMemInst(load_inst);
822  load_inst->clearIssued();
823  load_inst->effAddrValid(false);
825 
826  // Do not generate a writeback event as this instruction is not
827  // complete.
828  DPRINTF(LSQUnit, "Load-store forwarding mis-match. "
829  "Store idx %i to load addr %#x\n",
830  store_it._idx, req->mainRequest()->getVaddr());
831 
832  // Must discard the request.
833  req->discard();
834  load_req.setRequest(nullptr);
835  return NoFault;
836  }
837  }
838  }
839 
840  // If there's no forwarding case, then go access memory
841  DPRINTF(LSQUnit, "Doing memory access for inst [sn:%lli] PC %s\n",
842  load_inst->seqNum, load_inst->pcState());
843 
844  // Allocate memory if this is the first time a load is issued.
845  if (!load_inst->memData) {
846  load_inst->memData = new uint8_t[req->mainRequest()->getSize()];
847  }
848 
849  // For now, load throughput is constrained by the number of
850  // load FUs only, and loads do not consume a cache port (only
851  // stores do).
852  // @todo We should account for cache port contention
853  // and arbitrate between loads and stores.
854 
855  // if we the cache is not blocked, do cache access
856  if (req->senderState() == nullptr) {
857  LQSenderState *state = new LQSenderState(
858  loadQueue.getIterator(load_idx));
859  state->isLoad = true;
860  state->inst = load_inst;
861  state->isSplit = req->isSplit();
862  req->senderState(state);
863  }
864  req->buildPackets();
865  req->sendPacketToCache();
866  if (!req->isSent())
867  iewStage->blockMemInst(load_inst);
868 
869  return NoFault;
870 }
871 
872 template <class Impl>
873 Fault
874 LSQUnit<Impl>::write(LSQRequest *req, uint8_t *data, int store_idx)
875 {
876  assert(storeQueue[store_idx].valid());
877 
878  DPRINTF(LSQUnit, "Doing write to store idx %i, addr %#x | storeHead:%i "
879  "[sn:%llu]\n",
880  store_idx - 1, req->request()->getPaddr(), storeQueue.head() - 1,
881  storeQueue[store_idx].instruction()->seqNum);
882 
883  storeQueue[store_idx].setRequest(req);
884  unsigned size = req->_size;
885  storeQueue[store_idx].size() = size;
886  bool store_no_data =
887  req->mainRequest()->getFlags() & Request::STORE_NO_DATA;
888  storeQueue[store_idx].isAllZeros() = store_no_data;
889  assert(size <= SQEntry::DataSize || store_no_data);
890 
891  // copy data into the storeQueue only if the store request has valid data
892  if (!(req->request()->getFlags() & Request::CACHE_BLOCK_ZERO) &&
893  !req->request()->isCacheMaintenance() &&
894  !req->request()->isAtomic())
895  memcpy(storeQueue[store_idx].data(), data, size);
896 
897  // This function only writes the data to the store queue, so no fault
898  // can happen here.
899  return NoFault;
900 }
901 
902 #endif // __CPU_O3_LSQ_UNIT_HH__
A MasterPort is a specialisation of a BaseMasterPort, which implements the default protocol for the t...
Definition: port.hh:75
#define panic(...)
This implements a cprintf based panic() function.
Definition: logging.hh:167
#define DPRINTF(x,...)
Definition: trace.hh:229
int getStoreHead()
Returns the index of the head store instruction.
Definition: lsq_unit.hh:600
MasterPort * dcachePort
Pointer to the dcache port.
Definition: lsq_unit.hh:405
unsigned numFreeLoadEntries()
Returns the number of free LQ entries.
void squash(const InstSeqNum &squashed_num)
Squashes all instructions younger than a specific sequence number.
bool isEmpty() const
Returns if both the LQ and SQ are empty.
Definition: lsq_unit.hh:324
Impl::DynInstPtr DynInstPtr
Definition: lsq_unit.hh:87
CircularQueue< SQEntry >::iterator SQIterator
Definition: lsq_unit.hh:614
int getLoadHead()
Returns the index of the head load instruction.
Definition: lsq_unit.hh:588
decltype(nullptr) constexpr NoFault
Definition: types.hh:245
Cycles is a wrapper class for representing cycle counts, i.e.
Definition: types.hh:83
Stats::Scalar invAddrSwpfs
Total number of software prefetches ignored due to invalid addresses.
Definition: lsq_unit.hh:569
bool hasStoresToWB()
Returns if there are any stores to writeback.
Definition: lsq_unit.hh:342
LSQEntry()
Constructs an empty store queue entry.
Definition: lsq_unit.hh:108
Iterator to the circular queue.
static constexpr size_t DataSize
Definition: lsq_unit.hh:171
LSQUnit(const LSQUnit &l)
We cannot copy LSQUnit because it has stats for which copy contructor is deleted explicitly.
Definition: lsq_unit.hh:232
char * data()
Definition: lsq_unit.hh:206
const bool & completed() const
Definition: lsq_unit.hh:201
DynInstPtr memDepViolator
The oldest load that caused a memory ordering violation.
Definition: lsq_unit.hh:534
bool valid() const
Member accessors.
Definition: lsq_unit.hh:147
void schedule(Event &ev, Tick when)
Schedule event for the cpu.
Definition: lsq_unit.hh:390
void completeStore(typename StoreQueue::iterator store_idx)
Completes the store at the specified index.
int numStores()
Returns the number of stores in the SQ.
Definition: lsq_unit.hh:318
Stats::Scalar lsqForwLoads
Total number of loads forwaded from LSQ stores.
Definition: lsq_unit.hh:550
bool isStoreBlocked
Whehter or not a store is blocked due to the memory system.
Definition: lsq_unit.hh:528
uint32_t head() const
LSQRequest * pendingRequest
The packet that is pending free cache ports.
Definition: lsq_unit.hh:541
bool violation()
Returns if there is a memory ordering violation.
Definition: lsq_unit.hh:303
DynInstPtr getMemDepViolator()
Returns the memory ordering violator.
Writeback event, specifically for when stores forward data to loads.
Definition: lsq_unit.hh:445
void insertStore(const DynInstPtr &store_inst)
Inserts a store instruction.
bool trySendPacket(bool isLoad, PacketPtr data_pkt)
Attempts to send a packet to the cache.
bool full() const
Is the queue full? A queue is full if the head is the 0^{th} element and the tail is the (size-1)^{th...
bool & committed()
Definition: lsq_unit.hh:202
TimeBuffer< IssueStruct >::wire fromIssue
Wire to read information from the issue stage time queue.
Definition: lsq_unit.hh:513
bool isStalled()
Returns whether or not the LSQ unit is stalled.
Definition: lsq_unit.hh:611
Stats::Scalar lsqRescheduledLoads
Number of loads that were rescheduled.
Definition: lsq_unit.hh:575
void resetState()
Reset the LSQ state.
const DynInstPtr & instruction() const
Definition: lsq_unit.hh:150
iterator getIterator(size_t idx)
Return an iterator to an index in the vector.
StoreQueue::iterator storeWBIt
The index of the first instruction that may be ready to be written back, and has not yet been written...
Definition: lsq_unit.hh:507
Derived class to hold any sender state the LSQ needs.
Definition: lsq.hh:75
void regStats()
Registers statistics.
typename Impl::CPUPol::LSQ::LSQRequest LSQRequest
Definition: lsq_unit.hh:93
typename LSQ::LSQSenderState LSQSenderState
Definition: lsq_unit.hh:92
bool isFull()
Returns if either the LQ or SQ is full.
Definition: lsq_unit.hh:321
void insertLoad(const DynInstPtr &load_inst)
Inserts a load instruction.
void handleLockedRead(XC *xc, const RequestPtr &req)
Definition: locked_mem.hh:66
int numLoads()
Returns the number of loads in the LQ.
Definition: lsq_unit.hh:315
LSQRequest * req
The request.
Definition: lsq_unit.hh:101
void storePostSend()
Handles completing the send of a store to memory.
bool & completed()
Definition: lsq_unit.hh:200
Stats::Scalar invAddrLoads
Total number of loads ignored due to invalid addresses.
Definition: lsq_unit.hh:553
ThreadContext is the external interface to all thread state for anything outside of the CPU...
bool _committed
Whether or not the store is committed.
Definition: lsq_unit.hh:162
Stats::Scalar lsqIgnoredResponses
Total number of responses from the memory system that are ignored due to the instruction already bein...
Definition: lsq_unit.hh:560
Stats::Scalar lsqSquashedLoads
Total number of squashed loads.
Definition: lsq_unit.hh:556
void recvRetry()
Handles doing the retry.
This is a simple scalar statistic, like a counter.
Definition: statistics.hh:2508
DynInstPtr inst
Instruction whose results are being written back.
Definition: lsq_unit.hh:460
BaseTLB * dTLB()
Definition: lsq_unit.hh:392
bool _isAllZeros
Does this request write all zeros and thus doesn&#39;t have any data attached to it.
Definition: lsq_unit.hh:169
void dataStatic(T *p)
Set the data pointer to the following value that should not be freed.
Definition: packet.hh:1040
SQSenderState(typename StoreQueue::iterator idx_)
Definition: lsq_unit.hh:431
void drainSanityCheck() const
Perform sanity checks after a drain.
void takeOverFrom()
Takes over from another CPU&#39;s thread.
void commitStores(InstSeqNum &youngest_inst)
Commits stores older than a specific sequence number.
void writeback(const DynInstPtr &inst, PacketPtr pkt)
Writes back the instruction, sending it to IEW.
bool sqEmpty() const
Returns if the SQ is empty.
Definition: lsq_unit.hh:336
ThreadID lsqID
The LSQUnit thread id.
Definition: lsq_unit.hh:480
Fault executeStore(const DynInstPtr &inst)
Executes a store instruction.
void dumpInsts() const
Debugging function to dump instructions in the LSQ.
Definition: tlb.hh:52
InstSeqNum getStoreHeadSeqNum()
Returns the sequence number of the head store instruction.
Definition: lsq_unit.hh:603
Fault read(LSQRequest *req, int load_idx)
Executes the load at the given index.
Definition: lsq_unit.hh:621
bool storeInFlight
Whether or not a store is in flight.
Definition: lsq_unit.hh:531
bool & canWB()
Member accessors.
Definition: lsq_unit.hh:198
Tick curTick()
The current simulated tick.
Definition: core.hh:47
void setRequest(LSQRequest *r)
Definition: lsq_unit.hh:143
bool willWB()
Returns if the LSQ unit will writeback on this cycle.
Definition: lsq_unit.hh:349
CircularQueue< LQEntry > LQueue
Definition: lsq_unit.hh:615
void checkSnoop(PacketPtr pkt)
Check if an incoming invalidate hits in the lsq on a load that might have issued out of order wrt ano...
IEW * iewStage
Pointer to the IEW stage.
Definition: lsq_unit.hh:399
Fault write(LSQRequest *req, uint8_t *data, int store_idx)
Executes the store at the given index.
Definition: lsq_unit.hh:874
LSQRequest * request()
Definition: lsq_unit.hh:142
bool lqFull()
Returns if the LQ is full.
Definition: lsq_unit.hh:327
CircularQueue< SQEntry > SQueue
Definition: lsq_unit.hh:616
uint64_t Tick
Tick count type.
Definition: types.hh:63
AddrRangeCoverage
Coverage of one address range with another.
Definition: lsq_unit.hh:213
Fault executeLoad(const DynInstPtr &inst)
Executes a load instruction.
bool stalled
Whether or not the LSQ is stalled.
Definition: lsq_unit.hh:516
void commitLoads(InstSeqNum &youngest_inst)
Commits loads older than a specific sequence number.
SQEntry()
Constructs an empty store queue entry.
Definition: lsq_unit.hh:173
uint32_t & size()
Definition: lsq_unit.hh:148
bool recvTimingResp(PacketPtr pkt)
Handles writing back and completing the load or store that has returned from memory.
StoreQueue::iterator idx
The SQ index of the instruction.
Definition: lsq_unit.hh:434
void commitLoad()
Commits the head load.
int stallingLoadIdx
The index of the above store.
Definition: lsq_unit.hh:522
void completeDataAccess(PacketPtr pkt)
Completes the data access that has been returned from the memory system.
const bool & canWB() const
Definition: lsq_unit.hh:199
InstSeqNum getLoadHeadSeqNum()
Returns the sequence number of the head load instruction.
Definition: lsq_unit.hh:592
uint64_t InstSeqNum
Definition: inst_seq.hh:40
static const FlagsType STORE_NO_DATA
Definition: request.hh:200
Port Object Declaration.
bool _completed
Whether or not the store is completed.
Definition: lsq_unit.hh:164
Fault executeLoad(int lq_idx)
Definition: lsq_unit.hh:278
void setDcachePort(MasterPort *dcache_port)
Sets the pointer to the dcache port.
CircularQueue< LQEntry >::iterator LQIterator
Definition: lsq_unit.hh:613
const bool & committed() const
Definition: lsq_unit.hh:203
uint64_t Addr
Address type This will probably be moved somewhere else in the near future.
Definition: types.hh:142
LSQUnit< Impl > * lsqPtr
The pointer to the LSQ unit that issued the store.
Definition: lsq_unit.hh:466
A Packet is used to encapsulate a transfer between two objects in the memory system (e...
Definition: packet.hh:255
bool hasPendingRequest
Whether or not there is a packet that couldn&#39;t be sent because of a lack of cache ports...
Definition: lsq_unit.hh:538
PacketPtr retryPkt
The packet that needs to be retried.
Definition: lsq_unit.hh:525
InstSeqNum stallingStoreIsn
The store that causes the stall due to partial store to load forwarding.
Definition: lsq_unit.hh:520
LQSenderState(typename LoadQueue::iterator idx_)
Definition: lsq_unit.hh:412
constexpr unsigned MaxVecRegLenInBytes
Definition: vec_reg.hh:157
Particularisation of the LSQSenderState to the SQ.
Definition: lsq_unit.hh:427
Stats::Scalar lsqSquashedStores
Total number of squashed stores.
Definition: lsq_unit.hh:566
bool sqFull()
Returns if the SQ is full.
Definition: lsq_unit.hh:330
const uint32_t & size() const
Definition: lsq_unit.hh:149
const char * data() const
Definition: lsq_unit.hh:207
void writebackBlockedStore()
Try to finish a previously blocked write back attempt.
LSQ * lsq
Pointer to the LSQ.
Definition: lsq_unit.hh:402
int16_t ThreadID
Thread index/ID type.
Definition: types.hh:227
const bool & isAllZeros() const
Definition: lsq_unit.hh:205
int stores
The number of store instructions in the SQ.
Definition: lsq_unit.hh:500
void set(const DynInstPtr &inst)
Definition: lsq_unit.hh:135
std::string name() const
Returns the name of the LSQ unit.
bool checkLoads
Should loads be checked for dependency issues.
Definition: lsq_unit.hh:495
Declaration of the Packet class.
This is a write that is targeted and zeroing an entire cache block.
Definition: request.hh:135
PacketPtr pkt
The packet that would have been sent to memory.
Definition: lsq_unit.hh:463
unsigned numFreeStoreEntries()
Returns the number of free SQ entries.
unsigned getCount()
Returns the number of instructions in the LSQ.
Definition: lsq_unit.hh:339
static constexpr auto MaxDataBytes
Definition: lsq_unit.hh:84
virtual void complete()
Definition: lsq_unit.hh:419
Definition: eventq.hh:189
unsigned int cacheLineSize()
bool dereferenceable() const
Test dereferenceability.
Vector Registers layout specification.
bool lqEmpty() const
Returns if the LQ is empty.
Definition: lsq_unit.hh:333
void init(O3CPU *cpu_ptr, IEW *iew_ptr, DerivO3CPUParams *params, LSQ *lsq_ptr, unsigned id)
Initializes the LSQ unit with the specified number of entries.
int storesToWB
The number of store instructions in the SQ waiting to writeback.
Definition: lsq_unit.hh:502
Particularisation of the LSQSenderState to the LQ.
Definition: lsq_unit.hh:408
void writebackStores()
Writes back stores.
bool needsTSO
Flag for memory model.
Definition: lsq_unit.hh:544
int loads
The number of load instructions in the LQ.
Definition: lsq_unit.hh:498
LSQUnit(uint32_t lqEntries, uint32_t sqEntries)
Constructs an LSQ unit.
O3CPU * cpu
Pointer to the CPU.
Definition: lsq_unit.hh:396
Stats::Scalar lsqBlockedLoads
Ready loads blocked due to partial store-forwarding.
Definition: lsq_unit.hh:572
bool _canWB
Whether or not the store can writeback.
Definition: lsq_unit.hh:160
uint32_t _size
The size of the operation.
Definition: lsq_unit.hh:103
Stats::Scalar lsqCacheBlocked
Number of times the LSQ is blocked due to the cache.
Definition: lsq_unit.hh:578
LoadQueue loadQueue
The load queue.
Definition: lsq_unit.hh:486
unsigned depCheckShift
The number of places to shift addresses in the LSQ before checking for dependency violations...
Definition: lsq_unit.hh:492
CircularQueue< SQEntry > storeQueue
The store queue.
Definition: lsq_unit.hh:483
DynInstPtr inst
The instruction.
Definition: lsq_unit.hh:99
void insert(const DynInstPtr &inst)
Inserts an instruction.
Class that implements the actual LQ and SQ for each specific thread.
Definition: lsq_unit.hh:81
Impl::CPUPol::IssueStruct IssueStruct
Definition: lsq_unit.hh:90
virtual void complete()
Definition: lsq_unit.hh:437
Impl::CPUPol::LSQ LSQ
Definition: lsq_unit.hh:89
bool _valid
Valid entry.
Definition: lsq_unit.hh:105
Fault checkViolations(typename LoadQueue::iterator &loadIt, const DynInstPtr &inst)
Check for ordering violations in the LSQ.
LoadQueue::iterator idx
The LQ index of the instruction.
Definition: lsq_unit.hh:416
Impl::O3CPU O3CPU
Definition: lsq_unit.hh:86
const char data[]
std::shared_ptr< FaultBase > Fault
Definition: types.hh:240
Bitfield< 5 > l
Impl::CPUPol::IEW IEW
Definition: lsq_unit.hh:88
bool & isAllZeros()
Definition: lsq_unit.hh:204
Stats::Scalar lsqMemOrderViolation
Tota number of memory ordering violations.
Definition: lsq_unit.hh:563
int numStoresToWB()
Returns the number of stores to writeback.
Definition: lsq_unit.hh:345
ProbePointArg< PacketInfo > Packet
Packet probe point.
Definition: mem.hh:104
reference front()
Addr cacheBlockMask
Address Mask for a cache block (e.g.
Definition: lsq_unit.hh:510

Generated on Fri Feb 28 2020 16:26:59 for gem5 by doxygen 1.8.13