gem5
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
base_dyn_inst.hh
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2011,2013 ARM Limited
3  * Copyright (c) 2013 Advanced Micro Devices, Inc.
4  * All rights reserved.
5  *
6  * The license below extends only to copyright in the software and shall
7  * not be construed as granting a license to any other intellectual
8  * property including but not limited to intellectual property relating
9  * to a hardware implementation of the functionality of the software
10  * licensed hereunder. You may use the software subject to the license
11  * terms below provided that you ensure that this notice is replicated
12  * unmodified and in its entirety in all distributions of the software,
13  * modified or unmodified, in source code or in binary form.
14  *
15  * Copyright (c) 2004-2006 The Regents of The University of Michigan
16  * Copyright (c) 2009 The University of Edinburgh
17  * All rights reserved.
18  *
19  * Redistribution and use in source and binary forms, with or without
20  * modification, are permitted provided that the following conditions are
21  * met: redistributions of source code must retain the above copyright
22  * notice, this list of conditions and the following disclaimer;
23  * redistributions in binary form must reproduce the above copyright
24  * notice, this list of conditions and the following disclaimer in the
25  * documentation and/or other materials provided with the distribution;
26  * neither the name of the copyright holders nor the names of its
27  * contributors may be used to endorse or promote products derived from
28  * this software without specific prior written permission.
29  *
30  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
31  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
32  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
33  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
34  * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
35  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
36  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
37  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
38  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
39  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
40  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
41  *
42  * Authors: Kevin Lim
43  * Timothy M. Jones
44  */
45 
46 #ifndef __CPU_BASE_DYN_INST_HH__
47 #define __CPU_BASE_DYN_INST_HH__
48 
49 #include <array>
50 #include <bitset>
51 #include <list>
52 #include <string>
53 #include <queue>
54 
55 #include "arch/generic/tlb.hh"
56 #include "arch/utility.hh"
57 #include "base/trace.hh"
58 #include "config/the_isa.hh"
59 #include "cpu/checker/cpu.hh"
60 #include "cpu/o3/comm.hh"
61 #include "cpu/exec_context.hh"
62 #include "cpu/exetrace.hh"
63 #include "cpu/inst_seq.hh"
64 #include "cpu/op_class.hh"
65 #include "cpu/static_inst.hh"
66 #include "cpu/translation.hh"
67 #include "mem/packet.hh"
68 #include "mem/request.hh"
69 #include "sim/byteswap.hh"
70 #include "sim/system.hh"
71 
77 template <class Impl>
78 class BaseDynInst : public ExecContext, public RefCounted
79 {
80  public:
81  // Typedef for the CPU.
82  typedef typename Impl::CPUType ImplCPU;
83  typedef typename ImplCPU::ImplState ImplState;
84 
85  // Logical register index type.
87 
88  // The DynInstPtr type.
89  typedef typename Impl::DynInstPtr DynInstPtr;
91 
92  // The list of instructions iterator type.
94 
95  enum {
97  MaxInstDestRegs = TheISA::MaxInstDestRegs
98  };
99 
100  union Result {
101  uint64_t integer;
102  double dbl;
103  void set(uint64_t i) { integer = i; }
104  void set(double d) { dbl = d; }
105  void get(uint64_t& i) { i = integer; }
106  void get(double& d) { d = dbl; }
107  };
108 
109  protected:
110  enum Status {
134  };
135 
136  enum Flags {
153  };
154 
155  public:
158 
161 
164 
165  BaseCPU *getCpuPtr() { return cpu; }
166 
169 
172 
175 
176  protected:
180  std::queue<Result> instResult;
181 
184 
185  /* An amalgamation of a lot of boolean values into one */
186  std::bitset<MaxFlags> instFlags;
187 
189  std::bitset<NumStatus> status;
190 
194  std::bitset<MaxInstSrcRegs> _readySrcRegIdx;
195 
196  public:
199 
202 
204 
206 
209 
211  uint8_t readyRegs;
212 
213  public:
215 
217 
220 
225 
227  unsigned memReqFlags;
228 
230  short asid;
231 
233  uint8_t effSize;
234 
236  uint8_t *memData;
237 
239  int16_t lqIdx;
240 
242  int16_t sqIdx;
243 
244 
246 
253 
255  // Need a copy of main request pointer to verify on writes.
257 
258  private:
263 
264  protected:
268  std::array<TheISA::RegIndex, TheISA::MaxInstDestRegs> _flatDestRegIdx;
269 
273  std::array<PhysRegIndex, TheISA::MaxInstDestRegs> _destRegIdx;
274 
278  std::array<PhysRegIndex, TheISA::MaxInstSrcRegs> _srcRegIdx;
279 
283  std::array<PhysRegIndex, TheISA::MaxInstDestRegs> _prevDestRegIdx;
284 
285 
286  public:
288  void recordResult(bool f) { instFlags[RecordResult] = f; }
289 
291  bool effAddrValid() const { return instFlags[EffAddrValid]; }
292 
294  bool memOpDone() const { return instFlags[MemOpDone]; }
295  void memOpDone(bool f) { instFlags[MemOpDone] = f; }
296 
297 
299  //
300  // INSTRUCTION EXECUTION
301  //
303 
304  void demapPage(Addr vaddr, uint64_t asn)
305  {
306  cpu->demapPage(vaddr, asn);
307  }
308  void demapInstPage(Addr vaddr, uint64_t asn)
309  {
310  cpu->demapPage(vaddr, asn);
311  }
312  void demapDataPage(Addr vaddr, uint64_t asn)
313  {
314  cpu->demapPage(vaddr, asn);
315  }
316 
317  Fault initiateMemRead(Addr addr, unsigned size, Request::Flags flags);
318 
319  Fault writeMem(uint8_t *data, unsigned size, Addr addr,
320  Request::Flags flags, uint64_t *res);
321 
323  void splitRequest(RequestPtr req, RequestPtr &sreqLow,
324  RequestPtr &sreqHigh);
325 
327  void initiateTranslation(RequestPtr req, RequestPtr sreqLow,
328  RequestPtr sreqHigh, uint64_t *res,
330 
333 
337 
341 
349 
354  bool hitExternalSnoop() const { return instFlags[HitExternalSnoop]; }
356 
361  bool isTranslationDelayed() const
362  {
363  return (translationStarted() && !translationCompleted());
364  }
365 
366  public:
367 #ifdef DEBUG
368  void dumpSNList();
369 #endif
370 
375  {
376  return _destRegIdx[idx];
377  }
378 
381  {
382  assert(TheISA::MaxInstSrcRegs > idx);
383  return _srcRegIdx[idx];
384  }
385 
390  {
391  return _flatDestRegIdx[idx];
392  }
393 
398  {
399  return _prevDestRegIdx[idx];
400  }
401 
405  void renameDestReg(int idx,
406  PhysRegIndex renamed_dest,
407  PhysRegIndex previous_rename)
408  {
409  _destRegIdx[idx] = renamed_dest;
410  _prevDestRegIdx[idx] = previous_rename;
411  }
412 
417  void renameSrcReg(int idx, PhysRegIndex renamed_src)
418  {
419  _srcRegIdx[idx] = renamed_src;
420  }
421 
425  void flattenDestReg(int idx, TheISA::RegIndex flattened_dest)
426  {
427  _flatDestRegIdx[idx] = flattened_dest;
428  }
438  InstSeqNum seq_num, ImplCPU *cpu);
439 
444 
446  ~BaseDynInst();
447 
448  private:
450  void initVars();
451 
452  public:
454  void dump();
455 
457  void dump(std::string &outstring);
458 
460  int cpuId() const { return cpu->cpuId(); }
461 
463  uint32_t socketId() const { return cpu->socketId(); }
464 
466  MasterID masterId() const { return cpu->dataMasterId(); }
467 
469  ContextID contextId() const { return thread->contextId(); }
470 
472  Fault getFault() const { return fault; }
473 
479  bool doneTargCalc() { return false; }
480 
482  void setPredTarg(const TheISA::PCState &_predPC)
483  {
484  predPC = _predPC;
485  }
486 
487  const TheISA::PCState &readPredTarg() { return predPC; }
488 
490  Addr predInstAddr() { return predPC.instAddr(); }
491 
493  Addr predNextInstAddr() { return predPC.nextInstAddr(); }
494 
496  Addr predMicroPC() { return predPC.microPC(); }
497 
500  {
501  return instFlags[PredTaken];
502  }
503 
504  void setPredTaken(bool predicted_taken)
505  {
506  instFlags[PredTaken] = predicted_taken;
507  }
508 
511  {
512  TheISA::PCState tempPC = pc;
513  TheISA::advancePC(tempPC, staticInst);
514  return !(tempPC == predPC);
515  }
516 
517  //
518  // Instruction types. Forward checks to StaticInst object.
519  //
520  bool isNop() const { return staticInst->isNop(); }
521  bool isMemRef() const { return staticInst->isMemRef(); }
522  bool isLoad() const { return staticInst->isLoad(); }
523  bool isStore() const { return staticInst->isStore(); }
524  bool isStoreConditional() const
525  { return staticInst->isStoreConditional(); }
526  bool isInstPrefetch() const { return staticInst->isInstPrefetch(); }
527  bool isDataPrefetch() const { return staticInst->isDataPrefetch(); }
528  bool isInteger() const { return staticInst->isInteger(); }
529  bool isFloating() const { return staticInst->isFloating(); }
530  bool isControl() const { return staticInst->isControl(); }
531  bool isCall() const { return staticInst->isCall(); }
532  bool isReturn() const { return staticInst->isReturn(); }
533  bool isDirectCtrl() const { return staticInst->isDirectCtrl(); }
534  bool isIndirectCtrl() const { return staticInst->isIndirectCtrl(); }
535  bool isCondCtrl() const { return staticInst->isCondCtrl(); }
536  bool isUncondCtrl() const { return staticInst->isUncondCtrl(); }
537  bool isCondDelaySlot() const { return staticInst->isCondDelaySlot(); }
538  bool isThreadSync() const { return staticInst->isThreadSync(); }
539  bool isSerializing() const { return staticInst->isSerializing(); }
540  bool isSerializeBefore() const
542  bool isSerializeAfter() const
544  bool isSquashAfter() const { return staticInst->isSquashAfter(); }
545  bool isMemBarrier() const { return staticInst->isMemBarrier(); }
546  bool isWriteBarrier() const { return staticInst->isWriteBarrier(); }
547  bool isNonSpeculative() const { return staticInst->isNonSpeculative(); }
548  bool isQuiesce() const { return staticInst->isQuiesce(); }
549  bool isIprAccess() const { return staticInst->isIprAccess(); }
550  bool isUnverifiable() const { return staticInst->isUnverifiable(); }
551  bool isSyscall() const { return staticInst->isSyscall(); }
552  bool isMacroop() const { return staticInst->isMacroop(); }
553  bool isMicroop() const { return staticInst->isMicroop(); }
554  bool isDelayedCommit() const { return staticInst->isDelayedCommit(); }
555  bool isLastMicroop() const { return staticInst->isLastMicroop(); }
556  bool isFirstMicroop() const { return staticInst->isFirstMicroop(); }
557  bool isMicroBranch() const { return staticInst->isMicroBranch(); }
558 
561 
564 
567 
570 
573 
576 
579 
586 
588  OpClass opClass() const { return staticInst->opClass(); }
589 
592  { return staticInst->branchTarget(pc); }
593 
595  int8_t numSrcRegs() const { return staticInst->numSrcRegs(); }
596 
598  int8_t numDestRegs() const { return staticInst->numDestRegs(); }
599 
600  // the following are used to track physical register usage
601  // for machines with separate int & FP reg files
602  int8_t numFPDestRegs() const { return staticInst->numFPDestRegs(); }
603  int8_t numIntDestRegs() const { return staticInst->numIntDestRegs(); }
604  int8_t numCCDestRegs() const { return staticInst->numCCDestRegs(); }
605 
607  RegIndex destRegIdx(int i) const { return staticInst->destRegIdx(i); }
608 
610  RegIndex srcRegIdx(int i) const { return staticInst->srcRegIdx(i); }
611 
613  template <class T>
614  void popResult(T& t)
615  {
616  if (!instResult.empty()) {
617  instResult.front().get(t);
618  instResult.pop();
619  }
620  }
621 
623  template <class T>
624  void readResult(T& t)
625  {
626  instResult.back().get(t);
627  }
628 
630  template <class T>
631  void setResult(T t)
632  {
633  if (instFlags[RecordResult]) {
634  Result instRes;
635  instRes.set(t);
636  instResult.push(instRes);
637  }
638  }
639 
641  void setIntRegOperand(const StaticInst *si, int idx, IntReg val)
642  {
643  setResult<uint64_t>(val);
644  }
645 
647  void setCCRegOperand(const StaticInst *si, int idx, CCReg val)
648  {
649  setResult<uint64_t>(val);
650  }
651 
653  void setFloatRegOperand(const StaticInst *si, int idx, FloatReg val)
654  {
655  setResult<double>(val);
656  }
657 
660  {
661  setResult<uint64_t>(val);
662  }
663 
665  void markSrcRegReady();
666 
668  void markSrcRegReady(RegIndex src_idx);
669 
671  bool isReadySrcRegIdx(int idx) const
672  {
673  return this->_readySrcRegIdx[idx];
674  }
675 
677  void setCompleted() { status.set(Completed); }
678 
680  bool isCompleted() const { return status[Completed]; }
681 
684 
686  bool isResultReady() const { return status[ResultReady]; }
687 
689  void setCanIssue() { status.set(CanIssue); }
690 
692  bool readyToIssue() const { return status[CanIssue]; }
693 
695  void clearCanIssue() { status.reset(CanIssue); }
696 
698  void setIssued() { status.set(Issued); }
699 
701  bool isIssued() const { return status[Issued]; }
702 
704  void clearIssued() { status.reset(Issued); }
705 
707  void setExecuted() { status.set(Executed); }
708 
710  bool isExecuted() const { return status[Executed]; }
711 
713  void setCanCommit() { status.set(CanCommit); }
714 
716  void clearCanCommit() { status.reset(CanCommit); }
717 
719  bool readyToCommit() const { return status[CanCommit]; }
720 
721  void setAtCommit() { status.set(AtCommit); }
722 
723  bool isAtCommit() { return status[AtCommit]; }
724 
726  void setCommitted() { status.set(Committed); }
727 
729  bool isCommitted() const { return status[Committed]; }
730 
732  void setSquashed() { status.set(Squashed); }
733 
735  bool isSquashed() const { return status[Squashed]; }
736 
737  //Instruction Queue Entry
738  //-----------------------
740  void setInIQ() { status.set(IqEntry); }
741 
743  void clearInIQ() { status.reset(IqEntry); }
744 
746  bool isInIQ() const { return status[IqEntry]; }
747 
750 
752  bool isSquashedInIQ() const { return status[SquashedInIQ]; }
753 
754 
755  //Load / Store Queue Functions
756  //-----------------------
758  void setInLSQ() { status.set(LsqEntry); }
759 
761  void removeInLSQ() { status.reset(LsqEntry); }
762 
764  bool isInLSQ() const { return status[LsqEntry]; }
765 
768 
770  bool isSquashedInLSQ() const { return status[SquashedInLSQ]; }
771 
772 
773  //Reorder Buffer Functions
774  //-----------------------
776  void setInROB() { status.set(RobEntry); }
777 
779  void clearInROB() { status.reset(RobEntry); }
780 
782  bool isInROB() const { return status[RobEntry]; }
783 
786 
788  bool isSquashedInROB() const { return status[SquashedInROB]; }
789 
791  TheISA::PCState pcState() const { return pc; }
792 
794  void pcState(const TheISA::PCState &val) { pc = val; }
795 
797  Addr instAddr() const { return pc.instAddr(); }
798 
800  Addr nextInstAddr() const { return pc.nextInstAddr(); }
801 
803  Addr microPC() const { return pc.microPC(); }
804 
806  {
807  return instFlags[Predicate];
808  }
809 
810  void setPredicate(bool val)
811  {
813 
814  if (traceData) {
815  traceData->setPredicate(val);
816  }
817  }
818 
820  void setASID(short addr_space_id) { asid = addr_space_id; }
821 
823  void setTid(ThreadID tid) { threadNumber = tid; }
824 
826  void setThreadState(ImplState *state) { thread = state; }
827 
829  ThreadContext *tcBase() { return thread->getTC(); }
830 
831  public:
834 
836  Addr getEA() const { return instEffAddr; }
837 
839  bool doneEACalc() { return instFlags[EACalcDone]; }
840 
842  bool eaSrcsReady();
843 
845  bool strictlyOrdered() const { return instFlags[IsStrictlyOrdered]; }
846 
848  bool hasRequest() { return instFlags[ReqMade]; }
849 
852 
854  void setInstListIt(ListIt _instListIt) { instListIt = _instListIt; }
855 
856  public:
858  unsigned int readStCondFailures() const
859  { return thread->storeCondFailures; }
860 
862  void setStCondFailures(unsigned int sc_failures)
863  { thread->storeCondFailures = sc_failures; }
864 
865  public:
866  // monitor/mwait funtions
867  void armMonitor(Addr address) { cpu->armMonitor(threadNumber, address); }
868  bool mwait(PacketPtr pkt) { return cpu->mwait(threadNumber, pkt); }
870  { return cpu->mwaitAtomic(threadNumber, tc, cpu->dtb); }
871  AddressMonitor *getAddrMonitor()
872  { return cpu->getCpuAddrMonitor(threadNumber); }
873 };
874 
875 template<class Impl>
876 Fault
878  Request::Flags flags)
879 {
880  instFlags[ReqMade] = true;
881  Request *req = NULL;
882  Request *sreqLow = NULL;
883  Request *sreqHigh = NULL;
884 
885  if (instFlags[ReqMade] && translationStarted()) {
886  req = savedReq;
887  sreqLow = savedSreqLow;
888  sreqHigh = savedSreqHigh;
889  } else {
890  req = new Request(asid, addr, size, flags, masterId(), this->pc.instAddr(),
891  thread->contextId());
892 
893  req->taskId(cpu->taskId());
894 
895  // Only split the request if the ISA supports unaligned accesses.
897  splitRequest(req, sreqLow, sreqHigh);
898  }
899  initiateTranslation(req, sreqLow, sreqHigh, NULL, BaseTLB::Read);
900  }
901 
902  if (translationCompleted()) {
903  if (fault == NoFault) {
904  effAddr = req->getVaddr();
905  effSize = size;
906  instFlags[EffAddrValid] = true;
907 
908  if (cpu->checker) {
909  if (reqToVerify != NULL) {
910  delete reqToVerify;
911  }
912  reqToVerify = new Request(*req);
913  }
914  fault = cpu->read(req, sreqLow, sreqHigh, lqIdx);
915  } else {
916  // Commit will have to clean up whatever happened. Set this
917  // instruction as executed.
918  this->setExecuted();
919  }
920  }
921 
922  if (traceData)
923  traceData->setMem(addr, size, flags);
924 
925  return fault;
926 }
927 
928 template<class Impl>
929 Fault
931  Request::Flags flags, uint64_t *res)
932 {
933  if (traceData)
934  traceData->setMem(addr, size, flags);
935 
936  instFlags[ReqMade] = true;
937  Request *req = NULL;
938  Request *sreqLow = NULL;
939  Request *sreqHigh = NULL;
940 
941  if (instFlags[ReqMade] && translationStarted()) {
942  req = savedReq;
943  sreqLow = savedSreqLow;
944  sreqHigh = savedSreqHigh;
945  } else {
946  req = new Request(asid, addr, size, flags, masterId(), this->pc.instAddr(),
947  thread->contextId());
948 
949  req->taskId(cpu->taskId());
950 
951  // Only split the request if the ISA supports unaligned accesses.
953  splitRequest(req, sreqLow, sreqHigh);
954  }
955  initiateTranslation(req, sreqLow, sreqHigh, res, BaseTLB::Write);
956  }
957 
958  if (fault == NoFault && translationCompleted()) {
959  effAddr = req->getVaddr();
960  effSize = size;
961  instFlags[EffAddrValid] = true;
962 
963  if (cpu->checker) {
964  if (reqToVerify != NULL) {
965  delete reqToVerify;
966  }
967  reqToVerify = new Request(*req);
968  }
969  fault = cpu->write(req, sreqLow, sreqHigh, data, sqIdx);
970  }
971 
972  return fault;
973 }
974 
975 template<class Impl>
976 inline void
978  RequestPtr &sreqHigh)
979 {
980  // Check to see if the request crosses the next level block boundary.
981  unsigned block_size = cpu->cacheLineSize();
982  Addr addr = req->getVaddr();
983  Addr split_addr = roundDown(addr + req->getSize() - 1, block_size);
984  assert(split_addr <= addr || split_addr - addr < block_size);
985 
986  // Spans two blocks.
987  if (split_addr > addr) {
988  req->splitOnVaddr(split_addr, sreqLow, sreqHigh);
989  }
990 }
991 
992 template<class Impl>
993 inline void
995  RequestPtr sreqHigh, uint64_t *res,
997 {
998  translationStarted(true);
999 
1000  if (!TheISA::HasUnalignedMemAcc || sreqLow == NULL) {
1001  WholeTranslationState *state =
1002  new WholeTranslationState(req, NULL, res, mode);
1003 
1004  // One translation if the request isn't split.
1006  new DataTranslation<BaseDynInstPtr>(this, state);
1007 
1008  cpu->dtb->translateTiming(req, thread->getTC(), trans, mode);
1009 
1010  if (!translationCompleted()) {
1011  // The translation isn't yet complete, so we can't possibly have a
1012  // fault. Overwrite any existing fault we might have from a previous
1013  // execution of this instruction (e.g. an uncachable load that
1014  // couldn't execute because it wasn't at the head of the ROB).
1015  fault = NoFault;
1016 
1017  // Save memory requests.
1018  savedReq = state->mainReq;
1019  savedSreqLow = state->sreqLow;
1020  savedSreqHigh = state->sreqHigh;
1021  }
1022  } else {
1023  WholeTranslationState *state =
1024  new WholeTranslationState(req, sreqLow, sreqHigh, NULL, res, mode);
1025 
1026  // Two translations when the request is split.
1027  DataTranslation<BaseDynInstPtr> *stransLow =
1028  new DataTranslation<BaseDynInstPtr>(this, state, 0);
1029  DataTranslation<BaseDynInstPtr> *stransHigh =
1030  new DataTranslation<BaseDynInstPtr>(this, state, 1);
1031 
1032  cpu->dtb->translateTiming(sreqLow, thread->getTC(), stransLow, mode);
1033  cpu->dtb->translateTiming(sreqHigh, thread->getTC(), stransHigh, mode);
1034 
1035  if (!translationCompleted()) {
1036  // The translation isn't yet complete, so we can't possibly have a
1037  // fault. Overwrite any existing fault we might have from a previous
1038  // execution of this instruction (e.g. an uncachable load that
1039  // couldn't execute because it wasn't at the head of the ROB).
1040  fault = NoFault;
1041 
1042  // Save memory requests.
1043  savedReq = state->mainReq;
1044  savedSreqLow = state->sreqLow;
1045  savedSreqHigh = state->sreqHigh;
1046  }
1047  }
1048 }
1049 
1050 template<class Impl>
1051 inline void
1053 {
1054  fault = state->getFault();
1055 
1056  instFlags[IsStrictlyOrdered] = state->isStrictlyOrdered();
1057 
1058  if (fault == NoFault) {
1059  // save Paddr for a single req
1060  physEffAddrLow = state->getPaddr();
1061 
1062  // case for the request that has been split
1063  if (state->isSplit) {
1064  physEffAddrLow = state->sreqLow->getPaddr();
1065  physEffAddrHigh = state->sreqHigh->getPaddr();
1066  }
1067 
1068  memReqFlags = state->getFlags();
1069 
1070  if (state->mainReq->isCondSwap()) {
1071  assert(state->res);
1072  state->mainReq->setExtraData(*state->res);
1073  }
1074 
1075  } else {
1076  state->deleteReqs();
1077  }
1078  delete state;
1079 
1080  translationCompleted(true);
1081 }
1082 
1083 #endif // __CPU_BASE_DYN_INST_HH__
Fault getFault() const
Returns the fault type.
uint8_t effSize
The size of the request.
bool isIssued() const
Returns whether or not this instruction has issued.
const TheISA::PCState & readPredTarg()
Instruction has reached commit.
bool isCommitted() const
Returns whether or not this instruction is committed.
bool isSerializing() const
bool isTranslationDelayed() const
Returns true if the DTB address translation is being delayed due to a hw page table walk...
Is a blocking instruction.
PhysRegIndex renamedDestRegIdx(int idx) const
Returns the physical register index of the i'th destination register.
void setSquashed()
Sets this instruction as squashed.
This class represents part of a data address translation.
Definition: translation.hh:218
bool isNop() const
bool isFirstMicroop() const
Definition: static_inst.hh:172
unsigned getFlags()
Get the flags associated with this request.
Definition: translation.hh:190
bool isWriteBarrier() const
OpClass opClass() const
Returns the opclass of this instruction.
bool memOpDone() const
Whether or not the memory operation is done.
decltype(nullptr) constexpr NoFault
Definition: types.hh:189
bool mwait(PacketPtr pkt)
~BaseDynInst()
BaseDynInst destructor.
bool isMicroBranch() const
Definition: static_inst.hh:174
void demapDataPage(Addr vaddr, uint64_t asn)
void clearCanIssue()
Clears this instruction being able to issue.
bool readyToIssue() const
Returns whether or not this instruction is ready to issue.
void setExecuted()
Sets this instruction as executed.
Whether or not the effective address calculation is completed.
Addr instEffAddr
Instruction effective address.
Bitfield< 7 > i
Definition: miscregs.hh:1378
std::bitset< NumStatus > status
The status of this BaseDynInst.
bool isMicroop() const
RequestPtr reqToVerify
InstSeqNum seqNum
The sequence number of the instruction.
Serialization has been handled.
bool isDataPrefetch() const
Definition: static_inst.hh:137
Instruction has its result.
unsigned memReqFlags
The memory request flags (from translation).
Instruction is in the LSQ.
bool isSyscall() const
Definition: static_inst.hh:167
TheISA::PCState branchTarget() const
Returns the branch target address.
bool isSquashAfter() const
Definition: static_inst.hh:160
uint8_t readyRegs
How many source registers are ready.
void setExtraData(uint64_t extraData)
Accessor function for store conditional return value.
Definition: request.hh:680
bool isDelayedCommit() const
Definition: static_inst.hh:170
int16_t lqIdx
Load queue index.
void setAtCommit()
Needs to serialize instructions behind it.
bool isInstPrefetch() const
int8_t numCCDestRegs() const
Number of coprocesor destination regs.
Definition: static_inst.hh:121
bool isMemBarrier() const
Definition: static_inst.hh:161
void readResult(T &t)
Read the most recent result stored by this instruction.
Declaration of a request, the overall memory request consisting of the parts of the request that are ...
void clearSerializeAfter()
Clears the serializeAfter part of this instruction.
void deleteReqs()
Delete all requests that make up this translation.
Definition: translation.hh:197
OpClass opClass() const
Operation class. Used to select appropriate function unit in issue.
Definition: static_inst.hh:183
bool isSquashed() const
Returns whether or not this instruction is squashed.
ip6_addr_t addr
Definition: inet.hh:335
Fault fault
The kind of fault this instruction has generated.
void setCommitted()
Sets this instruction as committed.
uint8_t * memData
Pointer to the data for the memory access.
void finishTranslation(WholeTranslationState *state)
Finish a DTB address translation.
bool isMacroop() const
Definition: static_inst.hh:168
unsigned int readStCondFailures() const
Returns the number of consecutive store conditional failures.
const bool HasUnalignedMemAcc
Definition: isa_traits.hh:119
bool isIprAccess() const
Definition: static_inst.hh:165
RegIndex destRegIdx(int i) const
Return logical index (architectural reg num) of i'th destination reg.
Definition: static_inst.hh:188
bool isCompleted() const
Returns whether or not this instruction is completed.
bool isMicroop() const
Definition: static_inst.hh:169
std::array< PhysRegIndex, TheISA::MaxInstDestRegs > _destRegIdx
Physical register index of the destination registers of this instruction.
bool isCall() const
Definition: static_inst.hh:146
RequestPtr savedSreqHigh
bool possibleLoadViolation() const
True if this address was found to match a previous load and they issued out of order.
void setCCRegOperand(const StaticInst *si, int idx, CCReg val)
Records a CC register being set to a value.
Is a thread synchronization instruction.
bool isCondDelaySlot() const
bool hitExternalSnoop() const
True if the address hit a external snoop while sitting in the LSQ.
void setInIQ()
Sets this instruction as a entry the IQ.
bool isSquashedInLSQ() const
Returns whether or not this instruction is squashed in the LSQ.
bool isMemBarrier() const
short asid
data address space ID, for loads & stores.
void hitExternalSnoop(bool f)
bool isResultReady() const
Returns whether or not the result is ready.
Trace::InstRecord * traceData
InstRecord that tracks this instructions.
bool isQuiesce() const
Definition: static_inst.hh:164
void markSrcRegReady()
Records that one of the source registers is ready.
Impl::CPUType ImplCPU
bool isQuiesce() const
TheISA::IntReg IntReg
Definition: exec_context.hh:74
void mwaitAtomic(ThreadContext *tc)
This class captures the state of an address translation.
Definition: translation.hh:61
bool readPredTaken()
Returns whether the instruction was predicted taken or not.
bool isNonSpeculative() const
Definition: static_inst.hh:163
std::list< DynInstPtr >::iterator ListIt
bool isUncondCtrl() const
Definition: static_inst.hh:151
bool isNonSpeculative() const
std::array< PhysRegIndex, TheISA::MaxInstDestRegs > _prevDestRegIdx
Physical register index of the previous producers of the architected destinations.
TheISA::RegIndex flattenedDestRegIdx(int idx) const
Returns the flattened register index of the i'th destination register.
uint32_t socketId() const
Read this CPU's Socket ID.
BaseCPU * getCpuPtr()
bool isInteger() const
bool isTempSerializeAfter()
Checks if this serializeAfter is only temporarily set.
Bitfield< 4, 0 > mode
Definition: miscregs.hh:1385
std::array< TheISA::RegIndex, TheISA::MaxInstDestRegs > _flatDestRegIdx
Flattened register index of the destination registers of this instruction.
void clearSerializeBefore()
Clears the serializeBefore part of this instruction.
void setThreadState(ImplState *state)
Sets the pointer to the thread state.
void clearIssued()
Clears this instruction as being issued.
bool effAddrValid() const
Is the effective virtual address valid.
const int MaxInstSrcRegs
Definition: registers.hh:56
void set(uint64_t i)
void setStCondFailures(unsigned int sc_failures)
Sets the number of consecutive store conditional failures.
If you want a reference counting pointer to a mutable object, create it like this: ...
Definition: refcnt.hh:106
ThreadContext is the external interface to all thread state for anything outside of the CPU...
PhysRegIndex renamedSrcRegIdx(int idx) const
Returns the physical register index of the i'th source register.
void setIntRegOperand(const StaticInst *si, int idx, IntReg val)
Records an integer register being set to a value.
Addr physEffAddrLow
The effective physical address.
TheISA::CCReg CCReg
Definition: exec_context.hh:80
bool isSerializing() const
Definition: static_inst.hh:155
bool isAtCommit()
bool hasRequest()
Has this instruction generated a memory request.
bool isCondSwap() const
Definition: request.hh:775
std::queue< Result > instResult
The result of the instruction; assumes an instruction can have many destination registers.
Bitfield< 63 > val
Definition: misc.hh:770
bool isMemRef() const
Definition: static_inst.hh:132
int8_t numSrcRegs() const
Returns the number of source registers.
void splitRequest(RequestPtr req, RequestPtr &sreqLow, RequestPtr &sreqHigh)
Splits a request in two if it crosses a dcache block.
bool eaSrcsReady()
Returns whether or not the eff.
const char data[]
Definition: circlebuf.cc:43
Instruction is squashed in the ROB.
Bitfield< 15, 0 > si
Definition: types.hh:55
void armMonitor(Addr address)
Bitfield< 6 > f
Definition: miscregs.hh:1379
void setPredTarg(const TheISA::PCState &_predPC)
Set the predicted target of this current instruction.
bool translationStarted() const
True if the DTB address translation has started.
void flattenDestReg(int idx, TheISA::RegIndex flattened_dest)
Flattens a destination architectural register index into a logical index.
bool isDirectCtrl() const
Addr nextInstAddr() const
Read the PC of the next instruction.
Fault getFault() const
Determine whether this translation produced a fault.
Definition: translation.hh:136
bool isStore() const
Definition: static_inst.hh:134
void setTid(ThreadID tid)
Sets the thread id.
TheISA::FloatReg FloatReg
Definition: exec_context.hh:76
ListIt instListIt
Iterator pointing to this BaseDynInst in the list of all insts.
bool isReturn() const
bool isDelayedCommit() const
bool isSerializeAfter() const
Definition: static_inst.hh:159
bool isControl() const
RegIndex destRegIdx(int i) const
Returns the logical register index of the i'th destination register.
RegIndex srcRegIdx(int i) const
Returns the logical register index of the i'th source register.
The ExecContext is an abstract base class the provides the interface used by the ISA to manipulate th...
Definition: exec_context.hh:72
Instruction is in the IQ.
uint8_t RegIndex
Definition: registers.hh:46
bool isInROB() const
Returns whether or not this instruction is in the ROB.
void setSerializeBefore()
Temporarily sets this instruction as a serialize before instruction.
TheISA::FloatRegBits FloatRegBits
Definition: exec_context.hh:77
bool isInteger() const
Definition: static_inst.hh:141
bool isThreadSync() const
Addr predMicroPC()
Returns the predicted micro PC after the branch.
Definition: flags.hh:35
bool isInIQ() const
Returns whether or not this instruction has issued.
bool isCondCtrl() const
bool doneTargCalc()
Checks whether or not this instruction has had its branch target calculated yet.
bool isIndirectCtrl() const
Definition: static_inst.hh:149
bool isStoreConditional() const
void pcState(const TheISA::PCState &val)
Set the PC state of this instruction.
bool isLastMicroop() const
void demapInstPage(Addr vaddr, uint64_t asn)
Bitfield< 9 > d
Definition: miscregs.hh:1375
ImplCPU::ImplState ImplState
Addr getEA() const
Returns the effective address.
Addr getPaddr() const
Definition: request.hh:519
std::bitset< MaxFlags > instFlags
bool isCondDelaySlot() const
Definition: static_inst.hh:152
AddressMonitor * getAddrMonitor()
bool isFirstMicroop() const
void splitOnVaddr(Addr split_addr, RequestPtr &req1, RequestPtr &req2)
Generate two requests as if this request had been split into two pieces.
Definition: request.hh:497
ContextID contextId() const
Read this context's system-wide ID.
void setPredicate(bool val)
Definition: insttracer.hh:182
Instruction is squashed in the LSQ.
void setASID(short addr_space_id)
Sets the ASID.
bool mispredicted()
Returns whether the instruction mispredicted.
uint64_t InstSeqNum
Definition: inst_seq.hh:40
void setInstListIt(ListIt _instListIt)
Sets iterator for this instruction in the list of all insts.
T roundDown(const T &val, const U &align)
Definition: intmath.hh:213
void setPredicate(bool val)
Derive from RefCounted if you want to enable reference counting of this class.
Definition: refcnt.hh:45
void clearInROB()
Sets this instruction as a entry the ROB.
STL list class.
Definition: stl.hh:54
Instruction has issued.
bool isControl() const
Definition: static_inst.hh:145
const StaticInstPtr staticInst
The StaticInst used by this BaseDynInst.
bool isUnverifiable() const
Addr predNextInstAddr()
Returns the predicted PC two instructions after the branch.
void setInLSQ()
Sets this instruction as a entry the LSQ.
Fault initiateMemRead(Addr addr, unsigned size, Request::Flags flags)
bool isThreadSync() const
Definition: static_inst.hh:154
bool isReadySrcRegIdx(int idx) const
Returns if a source register is ready.
bool isInLSQ() const
Returns whether or not this instruction is in the LSQ.
TheISA::RegIndex RegIndex
void renameDestReg(int idx, PhysRegIndex renamed_dest, PhysRegIndex previous_rename)
Renames a destination register to a physical register.
uint64_t Addr
Address type This will probably be moved somewhere else in the near future.
Definition: types.hh:142
TheISA::PCState pc
PC state for this instruction.
uint16_t MasterID
Definition: request.hh:85
int8_t numDestRegs() const
Returns the number of destination registers.
std::bitset< MaxInstSrcRegs > _readySrcRegIdx
Whether or not the source register is ready.
int8_t numFPDestRegs() const
Number of floating-point destination regs.
Definition: static_inst.hh:116
void renameSrcReg(int idx, PhysRegIndex renamed_src)
Renames a source logical register to the physical register which has/will produce that logical regist...
void advancePC(PCState &pc, const StaticInstPtr &inst)
Definition: utility.hh:108
void demapPage(Addr vaddr, uint64_t asn)
Invalidate a page in the DTLB and ITLB.
A Packet is used to encapsulate a transfer between two objects in the memory system (e...
Definition: packet.hh:245
bool isSerializeBefore() const
Definition: static_inst.hh:158
RegIndex srcRegIdx(int i) const
Return logical index (architectural reg num) of i'th source reg.
Definition: static_inst.hh:192
Instruction can issue and execute.
ThreadContext * tcBase()
Returns the thread context.
int8_t numSrcRegs() const
Number of source registers.
Definition: static_inst.hh:112
bool isSquashedInIQ() const
Returns whether or not this instruction is squashed in the IQ.
void popResult(T &t)
Pops a result off the instResult queue.
bool isSquashAfter() const
void setResult(T t)
Pushes a result onto the instResult queue.
ListIt & getInstListIt()
Returns iterator to this instruction in the list of all insts.
int16_t sqIdx
Store queue index.
void clearInIQ()
Sets this instruction as a entry the IQ.
Addr predInstAddr()
Returns the predicted PC immediately after the branch.
RequestPtr savedSreqLow
bool isDirectCtrl() const
Definition: static_inst.hh:148
Mode
Definition: tlb.hh:61
bool isStore() const
void clearCanCommit()
Clears this instruction as being ready to commit.
void setCanCommit()
Sets this instruction as ready to commit.
void memOpDone(bool f)
int16_t ThreadID
Thread index/ID type.
Definition: types.hh:171
PhysRegIndex prevDestRegIdx(int idx) const
Returns the physical register index of the previous physical register that remapped to the same logic...
bool isFloating() const
void setCompleted()
Sets this instruction as completed.
bool readyToCommit() const
Returns whether or not this instruction is ready to commit.
int size()
Definition: pagetable.hh:146
void initiateTranslation(RequestPtr req, RequestPtr sreqLow, RequestPtr sreqHigh, uint64_t *res, BaseTLB::Mode mode)
Initiate a DTB address translation.
bool isLoad() const
void setSquashedInLSQ()
Sets this instruction as squashed in the LSQ.
bool translationCompleted() const
True if the DTB address translation has completed.
bool isMemRef() const
BaseDynInst(const StaticInstPtr &staticInst, const StaticInstPtr &macroop, TheISA::PCState pc, TheISA::PCState predPC, InstSeqNum seq_num, ImplCPU *cpu)
BaseDynInst constructor given a binary instruction.
Declaration of the Packet class.
ImplCPU * cpu
Pointer to the Impl's CPU object.
void setPredTaken(bool predicted_taken)
bool isUnverifiable() const
Definition: static_inst.hh:166
Fault writeMem(uint8_t *data, unsigned size, Addr addr, Request::Flags flags, uint64_t *res)
bool isLoad() const
Definition: static_inst.hh:133
int cpuId() const
Read this CPU's ID.
GenericISA::SimplePCState< MachInst > PCState
Definition: types.hh:43
void setResultReady()
Marks the result as ready.
Addr instAddr() const
Read the PC of this instruction.
void setSquashedInROB()
Sets this instruction as squashed in the ROB.
void setFloatRegOperandBits(const StaticInst *si, int idx, FloatRegBits val)
Records an fp register being set to an integer value.
Addr getVaddr() const
Definition: request.hh:616
Addr physEffAddrHigh
The effective physical address of the second request for a split request.
bool isMacroop() const
void setSerializeAfter()
Temporarily sets this instruction as a serialize after instruction.
bool strictlyOrdered() const
Is this instruction's memory access strictly ordered?
std::array< PhysRegIndex, TheISA::MaxInstSrcRegs > _srcRegIdx
Physical register index of the source registers of this instruction.
TheISA::PCState pcState() const
Read the PC state of this instruction.
short int PhysRegIndex
Definition: comm.hh:57
bool isSerializeBefore() const
Instruction is squashed.
Is a recover instruction.
bool isSyscall() const
int8_t numIntDestRegs() const
Base, ISA-independent static instruction class.
Definition: static_inst.hh:68
Addr effAddr
The effective virtual address (lds & stores only).
bool isMicroBranch() const
void translationCompleted(bool f)
Instruction is squashed in the IQ.
int8_t numIntDestRegs() const
Number of integer destination regs.
Definition: static_inst.hh:118
bool isSerializeAfter() const
void setEA(Addr ea)
Sets the effective address.
bool isSquashedInROB() const
Returns whether or not this instruction is squashed in the ROB.
const StaticInstPtr macroop
The Macroop if one exists.
IntReg pc
Definition: remote_gdb.hh:91
void initVars()
Function to initialize variables in the constructors.
bool isTempSerializeBefore()
Checks if this serializeBefore is only temporarily set.
bool isCondCtrl() const
Definition: static_inst.hh:150
void possibleLoadViolation(bool f)
TheISA::PCState predPC
Predicted PC state after this instruction.
bool isIndirectCtrl() const
Instruction can commit.
void set(double d)
RequestPtr savedReq
Saved memory requests (needed when the DTB address translation is delayed due to a hw page table walk...
Bitfield< 5 > t
Definition: miscregs.hh:1382
Impl::DynInstPtr DynInstPtr
bool isIprAccess() const
bool isSerializeHandled()
Checks if the serialization part of this instruction has been handled.
bool isReturn() const
Definition: static_inst.hh:147
bool isStrictlyOrdered() const
Check if this request is strictly ordered device access.
Definition: translation.hh:161
ThreadID threadNumber
The thread this instruction is from.
void translationStarted(bool f)
unsigned getSize() const
Definition: request.hh:552
bool readPredicate()
bool isExecuted() const
Returns whether or not this instruction has executed.
bool isUncondCtrl() const
void dump()
Dumps out contents of this BaseDynInst.
bool isDataPrefetch() const
void setFloatRegOperand(const StaticInst *si, int idx, FloatReg val)
Records an fp register being set to a value.
int8_t numCCDestRegs() const
Instruction has committed.
void setSquashedInIQ()
Sets this instruction as squashed in the IQ.
Instruction has executed.
bool isLastMicroop() const
Definition: static_inst.hh:171
void setIssued()
Sets this instruction as issued from the IQ.
bool isInstPrefetch() const
Definition: static_inst.hh:136
std::shared_ptr< FaultBase > Fault
Definition: types.hh:184
void setCanIssue()
Sets this instruction as ready to issue.
Addr microPC() const
Read the micro PC of this instruction.
ImplState * thread
Pointer to the thread state.
void removeInLSQ()
Sets this instruction as a entry the LSQ.
Needs to serialize on instructions ahead of it.
int ContextID
Globally unique thread context ID.
Definition: types.hh:175
uint32_t taskId() const
Definition: request.hh:630
Bitfield< 3 > ea
Definition: miscregs.hh:1518
MasterID masterId() const
Read this CPU's data requestor ID.
Instruction has completed.
bool isFloating() const
Definition: static_inst.hh:142
void setInROB()
Sets this instruction as a entry the ROB.
virtual TheISA::PCState branchTarget(const TheISA::PCState &pc) const
Return the target address for a PC-relative branch.
Definition: static_inst.cc:73
int8_t numDestRegs() const
Number of destination registers.
Definition: static_inst.hh:114
Instruction is in the ROB.
Addr getPaddr() const
Get the physical address of this request.
Definition: translation.hh:179
RefCountingPtr< BaseDynInst< Impl > > BaseDynInstPtr
bool isWriteBarrier() const
Definition: static_inst.hh:162
bool isCall() const
int8_t numFPDestRegs() const
bool isNop() const
Definition: static_inst.hh:130
void recordResult(bool f)
Records changes to result?
bool doneEACalc()
Returns whether or not the eff.
void setSerializeHandled()
Sets the serialization part of this instruction as handled.
bool isStoreConditional() const
Definition: static_inst.hh:135

Generated on Fri Jun 9 2017 13:03:41 for gem5 by doxygen 1.8.6