gem5  v20.1.0.0
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 "cpu/o3/dyn_inst.hh"
45 #include "debug/O3PipeView.hh"
46 
47 template <class Impl>
49  const StaticInstPtr &macroop,
51  InstSeqNum seq_num, O3CPU *cpu)
52  : BaseDynInst<Impl>(staticInst, macroop, pc, predPC, seq_num, cpu)
53 {
54  initVars();
55 }
56 
57 template <class Impl>
59  const StaticInstPtr &_macroop)
60  : BaseDynInst<Impl>(_staticInst, _macroop)
61 {
62  initVars();
63 }
64 
66 {
67 #if TRACING_ON
68  if (DTRACE(O3PipeView)) {
69  Tick fetch = this->fetchTick;
70  // fetchTick can be -1 if the instruction fetched outside the trace window.
71  if (fetch != -1) {
72  Tick val;
73  // Print info needed by the pipeline activity viewer.
74  DPRINTFR(O3PipeView, "O3PipeView:fetch:%llu:0x%08llx:%d:%llu:%s\n",
75  fetch,
76  this->instAddr(),
77  this->microPC(),
78  this->seqNum,
79  this->staticInst->disassemble(this->instAddr()));
80 
81  val = (this->decodeTick == -1) ? 0 : fetch + this->decodeTick;
82  DPRINTFR(O3PipeView, "O3PipeView:decode:%llu\n", val);
83  val = (this->renameTick == -1) ? 0 : fetch + this->renameTick;
84  DPRINTFR(O3PipeView, "O3PipeView:rename:%llu\n", val);
85  val = (this->dispatchTick == -1) ? 0 : fetch + this->dispatchTick;
86  DPRINTFR(O3PipeView, "O3PipeView:dispatch:%llu\n", val);
87  val = (this->issueTick == -1) ? 0 : fetch + this->issueTick;
88  DPRINTFR(O3PipeView, "O3PipeView:issue:%llu\n", val);
89  val = (this->completeTick == -1) ? 0 : fetch + this->completeTick;
90  DPRINTFR(O3PipeView, "O3PipeView:complete:%llu\n", val);
91  val = (this->commitTick == -1) ? 0 : fetch + this->commitTick;
92 
93  Tick valS = (this->storeTick == -1) ? 0 : fetch + this->storeTick;
94  DPRINTFR(O3PipeView, "O3PipeView:retire:%llu:store:%llu\n", val, valS);
95  }
96  }
97 #endif
98 };
99 
100 
101 template <class Impl>
102 void
104 {
105  this->_readySrcRegIdx.reset();
106 
107  _numDestMiscRegs = 0;
108 
109 #if TRACING_ON
110  // Value -1 indicates that particular phase
111  // hasn't happened (yet).
112  fetchTick = -1;
113  decodeTick = -1;
114  renameTick = -1;
115  dispatchTick = -1;
116  issueTick = -1;
117  completeTick = -1;
118  commitTick = -1;
119  storeTick = -1;
120 #endif
121 }
122 
123 template <class Impl>
124 Fault
126 {
127  // @todo: Pretty convoluted way to avoid squashing from happening
128  // when using the TC during an instruction's execution
129  // (specifically for instructions that have side-effects that use
130  // the TC). Fix this.
131  bool no_squash_from_TC = this->thread->noSquashFromTC;
132  this->thread->noSquashFromTC = true;
133 
134  this->fault = this->staticInst->execute(this, this->traceData);
135 
136  this->thread->noSquashFromTC = no_squash_from_TC;
137 
138  return this->fault;
139 }
140 
141 template <class Impl>
142 Fault
144 {
145  // @todo: Pretty convoluted way to avoid squashing from happening
146  // when using the TC during an instruction's execution
147  // (specifically for instructions that have side-effects that use
148  // the TC). Fix this.
149  bool no_squash_from_TC = this->thread->noSquashFromTC;
150  this->thread->noSquashFromTC = true;
151 
152  this->fault = this->staticInst->initiateAcc(this, this->traceData);
153 
154  this->thread->noSquashFromTC = no_squash_from_TC;
155 
156  return this->fault;
157 }
158 
159 template <class Impl>
160 Fault
162 {
163  // @todo: Pretty convoluted way to avoid squashing from happening
164  // when using the TC during an instruction's execution
165  // (specifically for instructions that have side-effects that use
166  // the TC). Fix this.
167  bool no_squash_from_TC = this->thread->noSquashFromTC;
168  this->thread->noSquashFromTC = true;
169 
170  if (this->cpu->checker) {
171  if (this->isStoreConditional()) {
172  this->reqToVerify->setExtraData(pkt->req->getExtraData());
173  }
174  }
175 
176  this->fault = this->staticInst->completeAcc(pkt, this, this->traceData);
177 
178  this->thread->noSquashFromTC = no_squash_from_TC;
179 
180  return this->fault;
181 }
182 
183 template <class Impl>
184 void
186 {
187  this->cpu->trap(fault, this->threadNumber, this->staticInst);
188 }
189 
190 template <class Impl>
191 void
193 {
194  // HACK: check CPU's nextPC before and after syscall. If it
195  // changes, update this instruction's nextPC because the syscall
196  // must have changed the nextPC.
197  TheISA::PCState curPC = this->cpu->pcState(this->threadNumber);
198  this->cpu->syscall(this->threadNumber);
199  TheISA::PCState newPC = this->cpu->pcState(this->threadNumber);
200  if (!(curPC == newPC)) {
201  this->pcState(newPC);
202  }
203 }
204 
205 #endif//__CPU_O3_DYN_INST_IMPL_HH__
BaseO3DynInst::O3CPU
Impl::O3CPU O3CPU
Typedef for the CPU.
Definition: dyn_inst.hh:61
BaseO3DynInst::initVars
void initVars()
Initializes variables.
Definition: dyn_inst_impl.hh:103
Tick
uint64_t Tick
Tick count type.
Definition: types.hh:63
Packet::req
RequestPtr req
A pointer to the original request.
Definition: packet.hh:340
DTRACE
#define DTRACE(x)
Definition: debug.hh:146
BaseO3DynInst::BaseO3DynInst
BaseO3DynInst(const StaticInstPtr &staticInst, const StaticInstPtr &macroop, TheISA::PCState pc, TheISA::PCState predPC, InstSeqNum seq_num, O3CPU *cpu)
BaseDynInst constructor given a binary instruction.
Definition: dyn_inst_impl.hh:48
dyn_inst.hh
BaseO3DynInst::execute
Fault execute()
Executes the instruction.
Definition: dyn_inst_impl.hh:125
Fault
std::shared_ptr< FaultBase > Fault
Definition: types.hh:240
MipsISA::pc
Bitfield< 4 > pc
Definition: pra_constants.hh:240
BaseO3DynInst::~BaseO3DynInst
~BaseO3DynInst()
Definition: dyn_inst_impl.hh:65
DPRINTFR
#define DPRINTFR(...)
Definition: trace.hh:236
BaseDynInst
Definition: base_dyn_inst.hh:76
X86ISA::val
Bitfield< 63 > val
Definition: misc.hh:769
InstSeqNum
uint64_t InstSeqNum
Definition: inst_seq.hh:37
BaseO3DynInst::initiateAcc
Fault initiateAcc()
Initiates the access.
Definition: dyn_inst_impl.hh:143
BaseO3DynInst::completeAcc
Fault completeAcc(PacketPtr pkt)
Completes the access.
Definition: dyn_inst_impl.hh:161
MipsISA::PCState
GenericISA::DelaySlotPCState< MachInst > PCState
Definition: types.hh:41
Packet
A Packet is used to encapsulate a transfer between two objects in the memory system (e....
Definition: packet.hh:257
BaseO3DynInst::syscall
void syscall() override
Emulates a syscall.
Definition: dyn_inst_impl.hh:192
RefCountingPtr< StaticInst >
BaseO3DynInst::trap
void trap(const Fault &fault)
Traps to handle specified fault.
Definition: dyn_inst_impl.hh:185

Generated on Wed Sep 30 2020 14:02:09 for gem5 by doxygen 1.8.17