gem5  v20.0.0.3
dyn_inst_impl.hh
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2010-2011 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  * All rights reserved.
16  *
17  * Redistribution and use in source and binary forms, with or without
18  * modification, are permitted provided that the following conditions are
19  * met: redistributions of source code must retain the above copyright
20  * notice, this list of conditions and the following disclaimer;
21  * redistributions in binary form must reproduce the above copyright
22  * notice, this list of conditions and the following disclaimer in the
23  * documentation and/or other materials provided with the distribution;
24  * neither the name of the copyright holders nor the names of its
25  * contributors may be used to endorse or promote products derived from
26  * this software without specific prior written permission.
27  *
28  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
29  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
30  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
31  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
32  * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
33  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
34  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
35  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
36  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
37  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
38  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
39  */
40 
41 #ifndef __CPU_O3_DYN_INST_IMPL_HH__
42 #define __CPU_O3_DYN_INST_IMPL_HH__
43 
44 #include "base/cp_annotate.hh"
45 #include "cpu/o3/dyn_inst.hh"
46 #include "debug/O3PipeView.hh"
47 
48 template <class Impl>
50  const StaticInstPtr &macroop,
52  InstSeqNum seq_num, O3CPU *cpu)
53  : BaseDynInst<Impl>(staticInst, macroop, pc, predPC, seq_num, cpu)
54 {
55  initVars();
56 }
57 
58 template <class Impl>
60  const StaticInstPtr &_macroop)
61  : BaseDynInst<Impl>(_staticInst, _macroop)
62 {
63  initVars();
64 }
65 
67 {
68 #if TRACING_ON
69  if (DTRACE(O3PipeView)) {
70  Tick fetch = this->fetchTick;
71  // fetchTick can be -1 if the instruction fetched outside the trace window.
72  if (fetch != -1) {
73  Tick val;
74  // Print info needed by the pipeline activity viewer.
75  DPRINTFR(O3PipeView, "O3PipeView:fetch:%llu:0x%08llx:%d:%llu:%s\n",
76  fetch,
77  this->instAddr(),
78  this->microPC(),
79  this->seqNum,
80  this->staticInst->disassemble(this->instAddr()));
81 
82  val = (this->decodeTick == -1) ? 0 : fetch + this->decodeTick;
83  DPRINTFR(O3PipeView, "O3PipeView:decode:%llu\n", val);
84  val = (this->renameTick == -1) ? 0 : fetch + this->renameTick;
85  DPRINTFR(O3PipeView, "O3PipeView:rename:%llu\n", val);
86  val = (this->dispatchTick == -1) ? 0 : fetch + this->dispatchTick;
87  DPRINTFR(O3PipeView, "O3PipeView:dispatch:%llu\n", val);
88  val = (this->issueTick == -1) ? 0 : fetch + this->issueTick;
89  DPRINTFR(O3PipeView, "O3PipeView:issue:%llu\n", val);
90  val = (this->completeTick == -1) ? 0 : fetch + this->completeTick;
91  DPRINTFR(O3PipeView, "O3PipeView:complete:%llu\n", val);
92  val = (this->commitTick == -1) ? 0 : fetch + this->commitTick;
93 
94  Tick valS = (this->storeTick == -1) ? 0 : fetch + this->storeTick;
95  DPRINTFR(O3PipeView, "O3PipeView:retire:%llu:store:%llu\n", val, valS);
96  }
97  }
98 #endif
99 };
100 
101 
102 template <class Impl>
103 void
105 {
106  this->_readySrcRegIdx.reset();
107 
108  _numDestMiscRegs = 0;
109 
110 #if TRACING_ON
111  // Value -1 indicates that particular phase
112  // hasn't happened (yet).
113  fetchTick = -1;
114  decodeTick = -1;
115  renameTick = -1;
116  dispatchTick = -1;
117  issueTick = -1;
118  completeTick = -1;
119  commitTick = -1;
120  storeTick = -1;
121 #endif
122 }
123 
124 template <class Impl>
125 Fault
127 {
128  // @todo: Pretty convoluted way to avoid squashing from happening
129  // when using the TC during an instruction's execution
130  // (specifically for instructions that have side-effects that use
131  // the TC). Fix this.
132  bool no_squash_from_TC = this->thread->noSquashFromTC;
133  this->thread->noSquashFromTC = true;
134 
135  this->fault = this->staticInst->execute(this, this->traceData);
136 
137  this->thread->noSquashFromTC = no_squash_from_TC;
138 
139  return this->fault;
140 }
141 
142 template <class Impl>
143 Fault
145 {
146  // @todo: Pretty convoluted way to avoid squashing from happening
147  // when using the TC during an instruction's execution
148  // (specifically for instructions that have side-effects that use
149  // the TC). Fix this.
150  bool no_squash_from_TC = this->thread->noSquashFromTC;
151  this->thread->noSquashFromTC = true;
152 
153  this->fault = this->staticInst->initiateAcc(this, this->traceData);
154 
155  this->thread->noSquashFromTC = no_squash_from_TC;
156 
157  return this->fault;
158 }
159 
160 template <class Impl>
161 Fault
163 {
164  // @todo: Pretty convoluted way to avoid squashing from happening
165  // when using the TC during an instruction's execution
166  // (specifically for instructions that have side-effects that use
167  // the TC). Fix this.
168  bool no_squash_from_TC = this->thread->noSquashFromTC;
169  this->thread->noSquashFromTC = true;
170 
171  if (this->cpu->checker) {
172  if (this->isStoreConditional()) {
173  this->reqToVerify->setExtraData(pkt->req->getExtraData());
174  }
175  }
176 
177  this->fault = this->staticInst->completeAcc(pkt, this, this->traceData);
178 
179  this->thread->noSquashFromTC = no_squash_from_TC;
180 
181  return this->fault;
182 }
183 
184 template <class Impl>
185 void
187 {
188  this->cpu->trap(fault, this->threadNumber, this->staticInst);
189 }
190 
191 template <class Impl>
192 void
194 {
195  // HACK: check CPU's nextPC before and after syscall. If it
196  // changes, update this instruction's nextPC because the syscall
197  // must have changed the nextPC.
198  TheISA::PCState curPC = this->cpu->pcState(this->threadNumber);
199  this->cpu->syscall(this->threadNumber, fault);
200  TheISA::PCState newPC = this->cpu->pcState(this->threadNumber);
201  if (!(curPC == newPC)) {
202  this->pcState(newPC);
203  }
204 }
205 
206 #endif//__CPU_O3_DYN_INST_IMPL_HH__
virtual const std::string & disassemble(Addr pc, const Loader::SymbolTable *symtab=nullptr) const
Return string representation of disassembled instruction.
Definition: static_inst.cc:121
RequestPtr reqToVerify
InstSeqNum seqNum
The sequence number of the instruction.
virtual Fault completeAcc(Packet *pkt, ExecContext *xc, Trace::InstRecord *traceData) const
Definition: static_inst.hh:284
Fault fault
The kind of fault this instruction has generated.
virtual Fault execute(ExecContext *xc, Trace::InstRecord *traceData) const =0
Trace::InstRecord * traceData
InstRecord that tracks this instructions.
Fault completeAcc(PacketPtr pkt)
Completes the access.
void trap(const Fault &fault)
Traps to handle specified fault.
virtual Fault initiateAcc(ExecContext *xc, Trace::InstRecord *traceData) const
Definition: static_inst.hh:278
Bitfield< 63 > val
Definition: misc.hh:769
RequestPtr req
A pointer to the original request.
Definition: packet.hh:321
void syscall(Fault *fault) override
Emulates a syscall.
uint8_t _numDestMiscRegs
Number of destination misc.
Definition: dyn_inst.hh:118
Bitfield< 4 > pc
#define DTRACE(x)
Definition: trace.hh:223
uint64_t Tick
Tick count type.
Definition: types.hh:61
bool isStoreConditional() const
uint64_t InstSeqNum
Definition: inst_seq.hh:37
BaseO3DynInst(const StaticInstPtr &staticInst, const StaticInstPtr &macroop, TheISA::PCState pc, TheISA::PCState predPC, InstSeqNum seq_num, O3CPU *cpu)
BaseDynInst constructor given a binary instruction.
const StaticInstPtr staticInst
The StaticInst used by this BaseDynInst.
Fault execute()
Executes the instruction.
std::bitset< MaxInstSrcRegs > _readySrcRegIdx
Whether or not the source register is ready.
A Packet is used to encapsulate a transfer between two objects in the memory system (e...
Definition: packet.hh:249
Addr microPC() const
Read the micro PC of this instruction.
ImplCPU * cpu
Pointer to the Impl&#39;s CPU object.
Impl::O3CPU O3CPU
Typedef for the CPU.
Definition: dyn_inst.hh:62
Addr instAddr() const
Read the PC of this instruction.
TheISA::PCState pcState() const
Read the PC state of this instruction.
ThreadID threadNumber
The thread this instruction is from.
GenericISA::DelaySlotPCState< MachInst > PCState
Definition: types.hh:41
std::shared_ptr< FaultBase > Fault
Definition: types.hh:238
ImplState * thread
Pointer to the thread state.
void initVars()
Initializes variables.
#define DPRINTFR(...)
Definition: trace.hh:227
Fault initiateAcc()
Initiates the access.

Generated on Fri Jul 3 2020 15:53:00 for gem5 by doxygen 1.8.13