gem5  v20.0.0.2
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 
42 #ifndef __CPU_O3_LSQ_UNIT_HH__
43 #define __CPU_O3_LSQ_UNIT_HH__
44 
45 #include <algorithm>
46 #include <cstring>
47 #include <map>
48 #include <queue>
49 
51 #include "arch/generic/vec_reg.hh"
52 #include "arch/isa_traits.hh"
53 #include "arch/locked_mem.hh"
54 #include "config/the_isa.hh"
55 #include "cpu/inst_seq.hh"
56 #include "cpu/timebuf.hh"
57 #include "debug/LSQUnit.hh"
58 #include "mem/packet.hh"
59 #include "mem/port.hh"
60 
61 struct DerivO3CPUParams;
62 #include "base/circular_queue.hh"
63 
76 template <class Impl>
77 class LSQUnit
78 {
79  public:
80  static constexpr auto MaxDataBytes = MaxVecRegLenInBytes;
81 
82  typedef typename Impl::O3CPU O3CPU;
83  typedef typename Impl::DynInstPtr DynInstPtr;
84  typedef typename Impl::CPUPol::IEW IEW;
85  typedef typename Impl::CPUPol::LSQ LSQ;
86  typedef typename Impl::CPUPol::IssueStruct IssueStruct;
87 
89  using LSQRequest = typename Impl::CPUPol::LSQ::LSQRequest;
90  private:
91  class LSQEntry
92  {
93  private:
95  DynInstPtr inst;
99  uint32_t _size;
101  bool _valid;
102  public:
105  : inst(nullptr), req(nullptr), _size(0), _valid(false)
106  {
107  }
108 
110  {
111  inst = nullptr;
112  if (req != nullptr) {
113  req->freeLSQEntry();
114  req = nullptr;
115  }
116  }
117 
118  void
120  {
121  inst = nullptr;
122  if (req != nullptr) {
123  req->freeLSQEntry();
124  }
125  req = nullptr;
126  _valid = false;
127  _size = 0;
128  }
129 
130  void
131  set(const DynInstPtr& inst)
132  {
133  assert(!_valid);
134  this->inst = inst;
135  _valid = true;
136  _size = 0;
137  }
138  LSQRequest* request() { return req; }
139  void setRequest(LSQRequest* r) { req = r; }
140  bool hasRequest() { return req != nullptr; }
143  bool valid() const { return _valid; }
144  uint32_t& size() { return _size; }
145  const uint32_t& size() const { return _size; }
146  const DynInstPtr& instruction() const { return inst; }
148  };
149 
150  class SQEntry : public LSQEntry
151  {
152  private:
154  char _data[MaxDataBytes];
156  bool _canWB;
166  public:
167  static constexpr size_t DataSize = sizeof(_data);
170  : _canWB(false), _committed(false), _completed(false),
171  _isAllZeros(false)
172  {
173  std::memset(_data, 0, DataSize);
174  }
175 
177  {
178  }
179 
180  void
181  set(const DynInstPtr& inst)
182  {
184  }
185 
186  void
188  {
189  LSQEntry::clear();
190  _canWB = _completed = _committed = _isAllZeros = false;
191  }
194  bool& canWB() { return _canWB; }
195  const bool& canWB() const { return _canWB; }
196  bool& completed() { return _completed; }
197  const bool& completed() const { return _completed; }
198  bool& committed() { return _committed; }
199  const bool& committed() const { return _committed; }
200  bool& isAllZeros() { return _isAllZeros; }
201  const bool& isAllZeros() const { return _isAllZeros; }
202  char* data() { return _data; }
203  const char* data() const { return _data; }
205  };
206  using LQEntry = LSQEntry;
207 
209  enum class AddrRangeCoverage
210  {
211  PartialAddrRangeCoverage, /* Two ranges partly overlap */
212  FullAddrRangeCoverage, /* One range fully covers another */
213  NoAddrRangeCoverage /* Two ranges are disjoint */
214  };
215 
216  public:
219 
220  public:
222  LSQUnit(uint32_t lqEntries, uint32_t sqEntries);
223 
228  LSQUnit(const LSQUnit &l) { panic("LSQUnit is not copy-able"); }
229 
231  void init(O3CPU *cpu_ptr, IEW *iew_ptr, DerivO3CPUParams *params,
232  LSQ *lsq_ptr, unsigned id);
233 
235  std::string name() const;
236 
238  void regStats();
239 
241  void setDcachePort(MasterPort *dcache_port);
242 
244  void drainSanityCheck() const;
245 
247  void takeOverFrom();
248 
250  void insert(const DynInstPtr &inst);
252  void insertLoad(const DynInstPtr &load_inst);
254  void insertStore(const DynInstPtr &store_inst);
255 
262  Fault checkViolations(typename LoadQueue::iterator& loadIt,
263  const DynInstPtr& inst);
264 
269  void checkSnoop(PacketPtr pkt);
270 
272  Fault executeLoad(const DynInstPtr &inst);
273 
274  Fault executeLoad(int lq_idx) { panic("Not implemented"); return NoFault; }
276  Fault executeStore(const DynInstPtr &inst);
277 
279  void commitLoad();
281  void commitLoads(InstSeqNum &youngest_inst);
282 
284  void commitStores(InstSeqNum &youngest_inst);
285 
287  void writebackStores();
288 
291  void completeDataAccess(PacketPtr pkt);
292 
294  void squash(const InstSeqNum &squashed_num);
295 
299  bool violation() { return memDepViolator; }
300 
302  DynInstPtr getMemDepViolator();
303 
305  unsigned numFreeLoadEntries();
306 
308  unsigned numFreeStoreEntries();
309 
311  int numLoads() { return loads; }
312 
314  int numStores() { return stores; }
315 
317  bool isFull() { return lqFull() || sqFull(); }
318 
320  bool isEmpty() const { return lqEmpty() && sqEmpty(); }
321 
323  bool lqFull() { return loadQueue.full(); }
324 
326  bool sqFull() { return storeQueue.full(); }
327 
329  bool lqEmpty() const { return loads == 0; }
330 
332  bool sqEmpty() const { return stores == 0; }
333 
335  unsigned getCount() { return loads + stores; }
336 
338  bool hasStoresToWB() { return storesToWB; }
339 
341  int numStoresToWB() { return storesToWB; }
342 
344  bool
346  {
347  return storeWBIt.dereferenceable() &&
348  storeWBIt->valid() &&
349  storeWBIt->canWB() &&
350  !storeWBIt->completed() &&
352  }
353 
355  void recvRetry();
356 
357  unsigned int cacheLineSize();
358  private:
360  void resetState();
361 
363  void writeback(const DynInstPtr &inst, PacketPtr pkt);
364 
366  void writebackBlockedStore();
367 
369  void completeStore(typename StoreQueue::iterator store_idx);
370 
372  void storePostSend();
373 
374  public:
379  bool trySendPacket(bool isLoad, PacketPtr data_pkt);
380 
381 
383  void dumpInsts() const;
384 
386  void schedule(Event& ev, Tick when) { cpu->schedule(ev, when); }
387 
388  BaseTLB* dTLB() { return cpu->dtb; }
389 
390  private:
392  O3CPU *cpu;
393 
395  IEW *iewStage;
396 
398  LSQ *lsq;
399 
402 
405  {
406  using LSQSenderState::alive;
407  public:
408  LQSenderState(typename LoadQueue::iterator idx_)
409  : LSQSenderState(idx_->request(), true), idx(idx_) { }
410 
412  typename LoadQueue::iterator idx;
413  //virtual LSQRequest* request() { return idx->request(); }
414  virtual void
416  {
417  //if (alive())
418  // idx->request()->senderState(nullptr);
419  }
420  };
421 
424  {
425  using LSQSenderState::alive;
426  public:
428  : LSQSenderState(idx_->request(), false), idx(idx_) { }
431  //virtual LSQRequest* request() { return idx->request(); }
432  virtual void
434  {
435  //if (alive())
436  // idx->request()->senderState(nullptr);
437  }
438  };
439 
441  class WritebackEvent : public Event
442  {
443  public:
445  WritebackEvent(const DynInstPtr &_inst, PacketPtr pkt,
446  LSQUnit *lsq_ptr);
447 
449  void process();
450 
452  const char *description() const;
453 
454  private:
456  DynInstPtr inst;
457 
460 
463  };
464 
465  public:
472  bool recvTimingResp(PacketPtr pkt);
473 
474  private:
477  public:
480 
483 
484  private:
488  unsigned depCheckShift;
489 
492 
494  int loads;
496  int stores;
499 
504 
507 
510 
512  bool stalled;
519 
522 
525 
528 
530  DynInstPtr memDepViolator;
531 
535 
538 
540  bool needsTSO;
541 
542  // Will also need how many read/write ports the Dcache has. Or keep track
543  // of that in stage that is one level up, and only call executeLoad/Store
544  // the appropriate number of times.
547 
550 
553 
557 
560 
563 
566 
569 
572 
575 
576  public:
578  Fault read(LSQRequest *req, int load_idx);
579 
581  Fault write(LSQRequest *req, uint8_t *data, int store_idx);
582 
584  int getLoadHead() { return loadQueue.head(); }
585 
587  InstSeqNum
589  {
590  return loadQueue.front().valid()
591  ? loadQueue.front().instruction()->seqNum
592  : 0;
593  }
594 
596  int getStoreHead() { return storeQueue.head(); }
598  InstSeqNum
600  {
601  return storeQueue.front().valid()
602  ? storeQueue.front().instruction()->seqNum
603  : 0;
604  }
605 
607  bool isStalled() { return stalled; }
608  public:
613 };
614 
615 template <class Impl>
616 Fault
618 {
619  LQEntry& load_req = loadQueue[load_idx];
620  const DynInstPtr& load_inst = load_req.instruction();
621 
622  load_req.setRequest(req);
623  assert(load_inst);
624 
625  assert(!load_inst->isExecuted());
626 
627  // Make sure this isn't a strictly ordered load
628  // A bit of a hackish way to get strictly ordered accesses to work
629  // only if they're at the head of the LSQ and are ready to commit
630  // (at the head of the ROB too).
631 
632  if (req->mainRequest()->isStrictlyOrdered() &&
633  (load_idx != loadQueue.head() || !load_inst->isAtCommit())) {
634  // Tell IQ/mem dep unit that this instruction will need to be
635  // rescheduled eventually
636  iewStage->rescheduleMemInst(load_inst);
637  load_inst->clearIssued();
638  load_inst->effAddrValid(false);
640  DPRINTF(LSQUnit, "Strictly ordered load [sn:%lli] PC %s\n",
641  load_inst->seqNum, load_inst->pcState());
642 
643  // Must delete request now that it wasn't handed off to
644  // memory. This is quite ugly. @todo: Figure out the proper
645  // place to really handle request deletes.
646  load_req.setRequest(nullptr);
647  req->discard();
648  return std::make_shared<GenericISA::M5PanicFault>(
649  "Strictly ordered load [sn:%llx] PC %s\n",
650  load_inst->seqNum, load_inst->pcState());
651  }
652 
653  DPRINTF(LSQUnit, "Read called, load idx: %i, store idx: %i, "
654  "storeHead: %i addr: %#x%s\n",
655  load_idx - 1, load_inst->sqIt._idx, storeQueue.head() - 1,
656  req->mainRequest()->getPaddr(), req->isSplit() ? " split" : "");
657 
658  if (req->mainRequest()->isLLSC()) {
659  // Disable recording the result temporarily. Writing to misc
660  // regs normally updates the result, but this is not the
661  // desired behavior when handling store conditionals.
662  load_inst->recordResult(false);
663  TheISA::handleLockedRead(load_inst.get(), req->mainRequest());
664  load_inst->recordResult(true);
665  }
666 
667  if (req->mainRequest()->isLocalAccess()) {
668  assert(!load_inst->memData);
669  load_inst->memData = new uint8_t[MaxDataBytes];
670 
671  ThreadContext *thread = cpu->tcBase(lsqID);
672  PacketPtr main_pkt = new Packet(req->mainRequest(), MemCmd::ReadReq);
673 
674  main_pkt->dataStatic(load_inst->memData);
675 
676  Cycles delay = req->mainRequest()->localAccessor(thread, main_pkt);
677 
678  WritebackEvent *wb = new WritebackEvent(load_inst, main_pkt, this);
679  cpu->schedule(wb, cpu->clockEdge(delay));
680  return NoFault;
681  }
682 
683  // Check the SQ for any previous stores that might lead to forwarding
684  auto store_it = load_inst->sqIt;
685  assert (store_it >= storeWBIt);
686  // End once we've reached the top of the LSQ
687  while (store_it != storeWBIt) {
688  // Move the index to one younger
689  store_it--;
690  assert(store_it->valid());
691  assert(store_it->instruction()->seqNum < load_inst->seqNum);
692  int store_size = store_it->size();
693 
694  // Cache maintenance instructions go down via the store
695  // path but they carry no data and they shouldn't be
696  // considered for forwarding
697  if (store_size != 0 && !store_it->instruction()->strictlyOrdered() &&
698  !(store_it->request()->mainRequest() &&
699  store_it->request()->mainRequest()->isCacheMaintenance())) {
700  assert(store_it->instruction()->effAddrValid());
701 
702  // Check if the store data is within the lower and upper bounds of
703  // addresses that the request needs.
704  auto req_s = req->mainRequest()->getVaddr();
705  auto req_e = req_s + req->mainRequest()->getSize();
706  auto st_s = store_it->instruction()->effAddr;
707  auto st_e = st_s + store_size;
708 
709  bool store_has_lower_limit = req_s >= st_s;
710  bool store_has_upper_limit = req_e <= st_e;
711  bool lower_load_has_store_part = req_s < st_e;
712  bool upper_load_has_store_part = req_e > st_s;
713 
715 
716  // If the store entry is not atomic (atomic does not have valid
717  // data), the store has all of the data needed, and
718  // the load is not LLSC, then
719  // we can forward data from the store to the load
720  if (!store_it->instruction()->isAtomic() &&
721  store_has_lower_limit && store_has_upper_limit &&
722  !req->mainRequest()->isLLSC()) {
723 
724  const auto& store_req = store_it->request()->mainRequest();
725  coverage = store_req->isMasked() ?
728  } else if (
729  // This is the partial store-load forwarding case where a store
730  // has only part of the load's data and the load isn't LLSC
731  (!req->mainRequest()->isLLSC() &&
732  ((store_has_lower_limit && lower_load_has_store_part) ||
733  (store_has_upper_limit && upper_load_has_store_part) ||
734  (lower_load_has_store_part && upper_load_has_store_part))) ||
735  // The load is LLSC, and the store has all or part of the
736  // load's data
737  (req->mainRequest()->isLLSC() &&
738  ((store_has_lower_limit || upper_load_has_store_part) &&
739  (store_has_upper_limit || lower_load_has_store_part))) ||
740  // The store entry is atomic and has all or part of the load's
741  // data
742  (store_it->instruction()->isAtomic() &&
743  ((store_has_lower_limit || upper_load_has_store_part) &&
744  (store_has_upper_limit || lower_load_has_store_part)))) {
745 
747  }
748 
750  // Get shift amount for offset into the store's data.
751  int shift_amt = req->mainRequest()->getVaddr() -
752  store_it->instruction()->effAddr;
753 
754  // Allocate memory if this is the first time a load is issued.
755  if (!load_inst->memData) {
756  load_inst->memData =
757  new uint8_t[req->mainRequest()->getSize()];
758  }
759  if (store_it->isAllZeros())
760  memset(load_inst->memData, 0,
761  req->mainRequest()->getSize());
762  else
763  memcpy(load_inst->memData,
764  store_it->data() + shift_amt,
765  req->mainRequest()->getSize());
766 
767  DPRINTF(LSQUnit, "Forwarding from store idx %i to load to "
768  "addr %#x\n", store_it._idx,
769  req->mainRequest()->getVaddr());
770 
771  PacketPtr data_pkt = new Packet(req->mainRequest(),
773  data_pkt->dataStatic(load_inst->memData);
774 
775  if (req->isAnyOutstandingRequest()) {
776  assert(req->_numOutstandingPackets > 0);
777  // There are memory requests packets in flight already.
778  // This may happen if the store was not complete the
779  // first time this load got executed. Signal the senderSate
780  // that response packets should be discarded.
781  req->discardSenderState();
782  }
783 
784  WritebackEvent *wb = new WritebackEvent(load_inst, data_pkt,
785  this);
786 
787  // We'll say this has a 1 cycle load-store forwarding latency
788  // for now.
789  // @todo: Need to make this a parameter.
790  cpu->schedule(wb, curTick());
791 
792  // Don't need to do anything special for split loads.
793  ++lsqForwLoads;
794 
795  return NoFault;
796  } else if (coverage == AddrRangeCoverage::PartialAddrRangeCoverage) {
797  // If it's already been written back, then don't worry about
798  // stalling on it.
799  if (store_it->completed()) {
800  panic("Should not check one of these");
801  continue;
802  }
803 
804  // Must stall load and force it to retry, so long as it's the
805  // oldest load that needs to do so.
806  if (!stalled ||
807  (stalled &&
808  load_inst->seqNum <
809  loadQueue[stallingLoadIdx].instruction()->seqNum)) {
810  stalled = true;
811  stallingStoreIsn = store_it->instruction()->seqNum;
812  stallingLoadIdx = load_idx;
813  }
814 
815  // Tell IQ/mem dep unit that this instruction will need to be
816  // rescheduled eventually
817  iewStage->rescheduleMemInst(load_inst);
818  load_inst->clearIssued();
819  load_inst->effAddrValid(false);
821 
822  // Do not generate a writeback event as this instruction is not
823  // complete.
824  DPRINTF(LSQUnit, "Load-store forwarding mis-match. "
825  "Store idx %i to load addr %#x\n",
826  store_it._idx, req->mainRequest()->getVaddr());
827 
828  // Must discard the request.
829  req->discard();
830  load_req.setRequest(nullptr);
831  return NoFault;
832  }
833  }
834  }
835 
836  // If there's no forwarding case, then go access memory
837  DPRINTF(LSQUnit, "Doing memory access for inst [sn:%lli] PC %s\n",
838  load_inst->seqNum, load_inst->pcState());
839 
840  // Allocate memory if this is the first time a load is issued.
841  if (!load_inst->memData) {
842  load_inst->memData = new uint8_t[req->mainRequest()->getSize()];
843  }
844 
845  // For now, load throughput is constrained by the number of
846  // load FUs only, and loads do not consume a cache port (only
847  // stores do).
848  // @todo We should account for cache port contention
849  // and arbitrate between loads and stores.
850 
851  // if we the cache is not blocked, do cache access
852  if (req->senderState() == nullptr) {
853  LQSenderState *state = new LQSenderState(
854  loadQueue.getIterator(load_idx));
855  state->isLoad = true;
856  state->inst = load_inst;
857  state->isSplit = req->isSplit();
858  req->senderState(state);
859  }
860  req->buildPackets();
861  req->sendPacketToCache();
862  if (!req->isSent())
863  iewStage->blockMemInst(load_inst);
864 
865  return NoFault;
866 }
867 
868 template <class Impl>
869 Fault
870 LSQUnit<Impl>::write(LSQRequest *req, uint8_t *data, int store_idx)
871 {
872  assert(storeQueue[store_idx].valid());
873 
874  DPRINTF(LSQUnit, "Doing write to store idx %i, addr %#x | storeHead:%i "
875  "[sn:%llu]\n",
876  store_idx - 1, req->request()->getPaddr(), storeQueue.head() - 1,
877  storeQueue[store_idx].instruction()->seqNum);
878 
879  storeQueue[store_idx].setRequest(req);
880  unsigned size = req->_size;
881  storeQueue[store_idx].size() = size;
882  bool store_no_data =
883  req->mainRequest()->getFlags() & Request::STORE_NO_DATA;
884  storeQueue[store_idx].isAllZeros() = store_no_data;
885  assert(size <= SQEntry::DataSize || store_no_data);
886 
887  // copy data into the storeQueue only if the store request has valid data
888  if (!(req->request()->getFlags() & Request::CACHE_BLOCK_ZERO) &&
889  !req->request()->isCacheMaintenance() &&
890  !req->request()->isAtomic())
891  memcpy(storeQueue[store_idx].data(), data, size);
892 
893  // This function only writes the data to the store queue, so no fault
894  // can happen here.
895  return NoFault;
896 }
897 
898 #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:71
#define panic(...)
This implements a cprintf based panic() function.
Definition: logging.hh:163
#define DPRINTF(x,...)
Definition: trace.hh:222
int getStoreHead()
Returns the index of the head store instruction.
Definition: lsq_unit.hh:596
MasterPort * dcachePort
Pointer to the dcache port.
Definition: lsq_unit.hh:401
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:320
Impl::DynInstPtr DynInstPtr
Definition: lsq_unit.hh:83
CircularQueue< SQEntry >::iterator SQIterator
Definition: lsq_unit.hh:610
int getLoadHead()
Returns the index of the head load instruction.
Definition: lsq_unit.hh:584
decltype(nullptr) constexpr NoFault
Definition: types.hh:243
Cycles is a wrapper class for representing cycle counts, i.e.
Definition: types.hh:81
Stats::Scalar invAddrSwpfs
Total number of software prefetches ignored due to invalid addresses.
Definition: lsq_unit.hh:565
bool hasStoresToWB()
Returns if there are any stores to writeback.
Definition: lsq_unit.hh:338
LSQEntry()
Constructs an empty store queue entry.
Definition: lsq_unit.hh:104
Iterator to the circular queue.
static constexpr size_t DataSize
Definition: lsq_unit.hh:167
LSQUnit(const LSQUnit &l)
We cannot copy LSQUnit because it has stats for which copy contructor is deleted explicitly.
Definition: lsq_unit.hh:228
char * data()
Definition: lsq_unit.hh:202
const bool & completed() const
Definition: lsq_unit.hh:197
DynInstPtr memDepViolator
The oldest load that caused a memory ordering violation.
Definition: lsq_unit.hh:530
bool valid() const
Member accessors.
Definition: lsq_unit.hh:143
void schedule(Event &ev, Tick when)
Schedule event for the cpu.
Definition: lsq_unit.hh:386
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:314
Stats::Scalar lsqForwLoads
Total number of loads forwaded from LSQ stores.
Definition: lsq_unit.hh:546
bool isStoreBlocked
Whehter or not a store is blocked due to the memory system.
Definition: lsq_unit.hh:524
uint32_t head() const
LSQRequest * pendingRequest
The packet that is pending free cache ports.
Definition: lsq_unit.hh:537
bool violation()
Returns if there is a memory ordering violation.
Definition: lsq_unit.hh:299
DynInstPtr getMemDepViolator()
Returns the memory ordering violator.
Writeback event, specifically for when stores forward data to loads.
Definition: lsq_unit.hh:441
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:198
TimeBuffer< IssueStruct >::wire fromIssue
Wire to read information from the issue stage time queue.
Definition: lsq_unit.hh:509
bool isStalled()
Returns whether or not the LSQ unit is stalled.
Definition: lsq_unit.hh:607
Stats::Scalar lsqRescheduledLoads
Number of loads that were rescheduled.
Definition: lsq_unit.hh:571
void resetState()
Reset the LSQ state.
const DynInstPtr & instruction() const
Definition: lsq_unit.hh:146
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:503
Derived class to hold any sender state the LSQ needs.
Definition: lsq.hh:73
void regStats()
Registers statistics.
typename Impl::CPUPol::LSQ::LSQRequest LSQRequest
Definition: lsq_unit.hh:89
typename LSQ::LSQSenderState LSQSenderState
Definition: lsq_unit.hh:88
bool isFull()
Returns if either the LQ or SQ is full.
Definition: lsq_unit.hh:317
void insertLoad(const DynInstPtr &load_inst)
Inserts a load instruction.
void handleLockedRead(XC *xc, const RequestPtr &req)
Definition: locked_mem.hh:64
int numLoads()
Returns the number of loads in the LQ.
Definition: lsq_unit.hh:311
LSQRequest * req
The request.
Definition: lsq_unit.hh:97
void storePostSend()
Handles completing the send of a store to memory.
bool & completed()
Definition: lsq_unit.hh:196
Stats::Scalar invAddrLoads
Total number of loads ignored due to invalid addresses.
Definition: lsq_unit.hh:549
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:158
Stats::Scalar lsqIgnoredResponses
Total number of responses from the memory system that are ignored due to the instruction already bein...
Definition: lsq_unit.hh:556
Stats::Scalar lsqSquashedLoads
Total number of squashed loads.
Definition: lsq_unit.hh:552
void recvRetry()
Handles doing the retry.
This is a simple scalar statistic, like a counter.
Definition: statistics.hh:2505
DynInstPtr inst
Instruction whose results are being written back.
Definition: lsq_unit.hh:456
BaseTLB * dTLB()
Definition: lsq_unit.hh:388
bool _isAllZeros
Does this request write all zeros and thus doesn&#39;t have any data attached to it.
Definition: lsq_unit.hh:165
void dataStatic(T *p)
Set the data pointer to the following value that should not be freed.
Definition: packet.hh:1034
SQSenderState(typename StoreQueue::iterator idx_)
Definition: lsq_unit.hh:427
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:332
ThreadID lsqID
The LSQUnit thread id.
Definition: lsq_unit.hh:476
Fault executeStore(const DynInstPtr &inst)
Executes a store instruction.
This is a write that is targeted and zeroing an entire cache block.
Definition: request.hh:131
void dumpInsts() const
Debugging function to dump instructions in the LSQ.
Definition: tlb.hh:50
InstSeqNum getStoreHeadSeqNum()
Returns the sequence number of the head store instruction.
Definition: lsq_unit.hh:599
Fault read(LSQRequest *req, int load_idx)
Executes the load at the given index.
Definition: lsq_unit.hh:617
bool storeInFlight
Whether or not a store is in flight.
Definition: lsq_unit.hh:527
bool & canWB()
Member accessors.
Definition: lsq_unit.hh:194
Tick curTick()
The current simulated tick.
Definition: core.hh:44
void setRequest(LSQRequest *r)
Definition: lsq_unit.hh:139
bool willWB()
Returns if the LSQ unit will writeback on this cycle.
Definition: lsq_unit.hh:345
CircularQueue< LQEntry > LQueue
Definition: lsq_unit.hh:611
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:395
Fault write(LSQRequest *req, uint8_t *data, int store_idx)
Executes the store at the given index.
Definition: lsq_unit.hh:870
LSQRequest * request()
Definition: lsq_unit.hh:138
bool lqFull()
Returns if the LQ is full.
Definition: lsq_unit.hh:323
CircularQueue< SQEntry > SQueue
Definition: lsq_unit.hh:612
uint64_t Tick
Tick count type.
Definition: types.hh:61
AddrRangeCoverage
Coverage of one address range with another.
Definition: lsq_unit.hh:209
Fault executeLoad(const DynInstPtr &inst)
Executes a load instruction.
bool stalled
Whether or not the LSQ is stalled.
Definition: lsq_unit.hh:512
void commitLoads(InstSeqNum &youngest_inst)
Commits loads older than a specific sequence number.
SQEntry()
Constructs an empty store queue entry.
Definition: lsq_unit.hh:169
uint32_t & size()
Definition: lsq_unit.hh:144
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:430
void commitLoad()
Commits the head load.
int stallingLoadIdx
The index of the above store.
Definition: lsq_unit.hh:518
void completeDataAccess(PacketPtr pkt)
Completes the data access that has been returned from the memory system.
const bool & canWB() const
Definition: lsq_unit.hh:195
InstSeqNum getLoadHeadSeqNum()
Returns the sequence number of the head load instruction.
Definition: lsq_unit.hh:588
uint64_t InstSeqNum
Definition: inst_seq.hh:37
static const FlagsType STORE_NO_DATA
Definition: request.hh:196
Port Object Declaration.
bool _completed
Whether or not the store is completed.
Definition: lsq_unit.hh:160
Fault executeLoad(int lq_idx)
Definition: lsq_unit.hh:274
void setDcachePort(MasterPort *dcache_port)
Sets the pointer to the dcache port.
CircularQueue< LQEntry >::iterator LQIterator
Definition: lsq_unit.hh:609
const bool & committed() const
Definition: lsq_unit.hh:199
uint64_t Addr
Address type This will probably be moved somewhere else in the near future.
Definition: types.hh:140
LSQUnit< Impl > * lsqPtr
The pointer to the LSQ unit that issued the store.
Definition: lsq_unit.hh:462
A Packet is used to encapsulate a transfer between two objects in the memory system (e...
Definition: packet.hh:249
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:534
PacketPtr retryPkt
The packet that needs to be retried.
Definition: lsq_unit.hh:521
InstSeqNum stallingStoreIsn
The store that causes the stall due to partial store to load forwarding.
Definition: lsq_unit.hh:516
LQSenderState(typename LoadQueue::iterator idx_)
Definition: lsq_unit.hh:408
constexpr unsigned MaxVecRegLenInBytes
Definition: vec_reg.hh:153
Particularisation of the LSQSenderState to the SQ.
Definition: lsq_unit.hh:423
Stats::Scalar lsqSquashedStores
Total number of squashed stores.
Definition: lsq_unit.hh:562
bool sqFull()
Returns if the SQ is full.
Definition: lsq_unit.hh:326
const uint32_t & size() const
Definition: lsq_unit.hh:145
const char * data() const
Definition: lsq_unit.hh:203
void writebackBlockedStore()
Try to finish a previously blocked write back attempt.
LSQ * lsq
Pointer to the LSQ.
Definition: lsq_unit.hh:398
int16_t ThreadID
Thread index/ID type.
Definition: types.hh:225
const bool & isAllZeros() const
Definition: lsq_unit.hh:201
int stores
The number of store instructions in the SQ.
Definition: lsq_unit.hh:496
void set(const DynInstPtr &inst)
Definition: lsq_unit.hh:131
std::string name() const
Returns the name of the LSQ unit.
bool checkLoads
Should loads be checked for dependency issues.
Definition: lsq_unit.hh:491
Declaration of the Packet class.
PacketPtr pkt
The packet that would have been sent to memory.
Definition: lsq_unit.hh:459
unsigned numFreeStoreEntries()
Returns the number of free SQ entries.
unsigned getCount()
Returns the number of instructions in the LSQ.
Definition: lsq_unit.hh:335
static constexpr auto MaxDataBytes
Definition: lsq_unit.hh:80
virtual void complete()
Definition: lsq_unit.hh:415
Definition: eventq.hh:246
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:329
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:498
Particularisation of the LSQSenderState to the LQ.
Definition: lsq_unit.hh:404
void writebackStores()
Writes back stores.
bool needsTSO
Flag for memory model.
Definition: lsq_unit.hh:540
int loads
The number of load instructions in the LQ.
Definition: lsq_unit.hh:494
LSQUnit(uint32_t lqEntries, uint32_t sqEntries)
Constructs an LSQ unit.
O3CPU * cpu
Pointer to the CPU.
Definition: lsq_unit.hh:392
Stats::Scalar lsqBlockedLoads
Ready loads blocked due to partial store-forwarding.
Definition: lsq_unit.hh:568
bool _canWB
Whether or not the store can writeback.
Definition: lsq_unit.hh:156
uint32_t _size
The size of the operation.
Definition: lsq_unit.hh:99
Stats::Scalar lsqCacheBlocked
Number of times the LSQ is blocked due to the cache.
Definition: lsq_unit.hh:574
LoadQueue loadQueue
The load queue.
Definition: lsq_unit.hh:482
unsigned depCheckShift
The number of places to shift addresses in the LSQ before checking for dependency violations...
Definition: lsq_unit.hh:488
CircularQueue< SQEntry > storeQueue
The store queue.
Definition: lsq_unit.hh:479
DynInstPtr inst
The instruction.
Definition: lsq_unit.hh:95
void insert(const DynInstPtr &inst)
Inserts an instruction.
Class that implements the actual LQ and SQ for each specific thread.
Definition: lsq_unit.hh:77
Impl::CPUPol::IssueStruct IssueStruct
Definition: lsq_unit.hh:86
virtual void complete()
Definition: lsq_unit.hh:433
Impl::CPUPol::LSQ LSQ
Definition: lsq_unit.hh:85
bool _valid
Valid entry.
Definition: lsq_unit.hh:101
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:412
Impl::O3CPU O3CPU
Definition: lsq_unit.hh:82
const char data[]
std::shared_ptr< FaultBase > Fault
Definition: types.hh:238
Bitfield< 5 > l
Impl::CPUPol::IEW IEW
Definition: lsq_unit.hh:84
bool & isAllZeros()
Definition: lsq_unit.hh:200
Stats::Scalar lsqMemOrderViolation
Tota number of memory ordering violations.
Definition: lsq_unit.hh:559
int numStoresToWB()
Returns the number of stores to writeback.
Definition: lsq_unit.hh:341
ProbePointArg< PacketInfo > Packet
Packet probe point.
Definition: mem.hh:103
reference front()
Addr cacheBlockMask
Address Mask for a cache block (e.g.
Definition: lsq_unit.hh:506

Generated on Mon Jun 8 2020 15:45:08 for gem5 by doxygen 1.8.13