gem5  [DEVELOP-FOR-23.0]
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
pipe_data.cc
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2013-2014 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  * Redistribution and use in source and binary forms, with or without
15  * modification, are permitted provided that the following conditions are
16  * met: redistributions of source code must retain the above copyright
17  * notice, this list of conditions and the following disclaimer;
18  * redistributions in binary form must reproduce the above copyright
19  * notice, this list of conditions and the following disclaimer in the
20  * documentation and/or other materials provided with the distribution;
21  * neither the name of the copyright holders nor the names of its
22  * contributors may be used to endorse or promote products derived from
23  * this software without specific prior written permission.
24  *
25  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
26  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
27  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
28  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
29  * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
30  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
31  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
32  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
33  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
34  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
35  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
36  */
37 
38 #include "cpu/minor/pipe_data.hh"
39 
40 namespace gem5
41 {
42 
43 namespace minor
44 {
45 
46 std::ostream &
47 operator <<(std::ostream &os, BranchData::Reason reason)
48 {
49  switch (reason)
50  {
52  os << "NoBranch";
53  break;
55  os << "UnpredictedBranch";
56  break;
58  os << "BranchPrediction";
59  break;
61  os << "CorrectlyPredictedBranch";
62  break;
64  os << "BadlyPredictedBranch";
65  break;
67  os << "BadlyPredictedBranchTarget";
68  break;
70  os << "Interrupt";
71  break;
73  os << "SuspendThread";
74  break;
76  os << "HaltFetch";
77  break;
78  }
79 
80  return os;
81 }
82 
83 bool
85 {
86  bool ret = false;
87 
88  switch (reason)
89  {
90  /* No change of stream (see the enum comment in pipe_data.hh) */
91  case NoBranch:
93  ret = false;
94  break;
95 
96  /* Change of stream (Fetch1 should act on) */
97  case UnpredictedBranch:
98  case BranchPrediction:
101  case SuspendThread:
102  case Interrupt:
103  case HaltFetch:
104  ret = true;
105  break;
106  }
107 
108  return ret;
109 }
110 
111 bool
113 {
114  bool ret = false;
115 
116  switch (reason)
117  {
118  /* No change of stream (see the enum comment in pipe_data.hh) */
119  case NoBranch:
121  case SuspendThread:
122  case Interrupt:
123  case HaltFetch:
124  ret = false;
125  break;
126 
127  /* Change of stream (Fetch1 should act on) */
128  case UnpredictedBranch:
129  case BranchPrediction:
132  ret = true;
133  break;
134  }
135 
136  return ret;
137 }
138 
139 void
140 BranchData::reportData(std::ostream &os) const
141 {
142  if (isBubble()) {
143  os << '-';
144  } else {
145  os << reason
146  << ';' << newStreamSeqNum << '.' << newPredictionSeqNum
147  << ";0x" << std::hex << target->instAddr() << std::dec
148  << ';';
149  inst->reportData(os);
150  }
151 }
152 
153 std::ostream &
154 operator <<(std::ostream &os, const BranchData &branch)
155 {
156  os << branch.reason << " target: 0x"
157  << std::hex << branch.target->instAddr() << std::dec
158  << ' ' << *branch.inst
159  << ' ' << branch.newStreamSeqNum << "(stream)."
160  << branch.newPredictionSeqNum << "(pred)";
161 
162  return os;
163 }
164 
165 void
167 {
168  fault = fault_;
169  if (isFault())
170  bubbleFlag = false;
171 }
172 
173 void
174 ForwardLineData::allocateLine(unsigned int width_)
175 {
176  lineWidth = width_;
177  bubbleFlag = false;
178 
179  assert(!isFault());
180  assert(!line);
181 
182  line = new uint8_t[width_];
183 }
184 
185 void
187 {
188  this->packet = packet;
189  lineWidth = packet->req->getSize();
190  bubbleFlag = false;
191 
192  assert(!isFault());
193  assert(!line);
194 
195  line = packet->getPtr<uint8_t>();
196 }
197 
198 void
200 {
201  /* Only free lines in non-faulting, non-bubble lines */
202  if (!isFault() && !isBubble()) {
203  assert(line);
204  /* If packet is not NULL then the line must belong to the packet so
205  * we don't need to separately deallocate the line */
206  if (packet) {
207  delete packet;
208  } else {
209  delete [] line;
210  }
211  line = NULL;
212  bubbleFlag = true;
213  }
214 }
215 
216 void
217 ForwardLineData::reportData(std::ostream &os) const
218 {
219  if (isBubble())
220  os << '-';
221  else if (fault != NoFault)
222  os << "F;" << id;
223  else
224  os << id;
225 }
226 
228  numInsts(width), threadId(tid)
229 {
230  bubbleFill();
231 }
232 
234 {
235  *this = src;
236 }
237 
240 {
241  numInsts = src.numInsts;
242 
243  for (unsigned int i = 0; i < src.numInsts; i++)
244  insts[i] = src.insts[i];
245 
246  return *this;
247 }
248 
249 bool
251 {
252  return numInsts == 0 || insts[0]->isBubble();
253 }
254 
255 void
257 {
258  for (unsigned int i = 0; i < numInsts; i++)
260 }
261 
262 void
264 {
265  assert(width < MAX_FORWARD_INSTS);
266  numInsts = width;
267 
268  bubbleFill();
269 }
270 
271 void
272 ForwardInstData::reportData(std::ostream &os) const
273 {
274  if (isBubble()) {
275  os << '-';
276  } else {
277  unsigned int i = 0;
278 
279  os << '(';
280  while (i != numInsts) {
281  insts[i]->reportData(os);
282  i++;
283  if (i != numInsts)
284  os << ',';
285  }
286  os << ')';
287  }
288 }
289 
290 } // namespace minor
291 } // namespace gem5
gem5::minor::ForwardInstData::ForwardInstData
ForwardInstData(unsigned int width=0, ThreadID tid=InvalidThreadID)
Definition: pipe_data.cc:227
pipe_data.hh
gem5::NoFault
constexpr decltype(nullptr) NoFault
Definition: types.hh:253
gem5::minor::BranchData::target
std::unique_ptr< PCStateBase > target
Starting PC of that stream.
Definition: pipe_data.hh:122
gem5::minor::ForwardInstData::reportData
void reportData(std::ostream &os) const
ReportIF interface.
Definition: pipe_data.cc:272
gem5::minor::ForwardInstData::bubbleFill
void bubbleFill()
Fill with bubbles from 0 to width() - 1.
Definition: pipe_data.cc:256
gem5::minor::ForwardLineData::id
InstId id
Thread, stream, prediction ...
Definition: pipe_data.hh:214
gem5::minor::ForwardInstData::isBubble
bool isBubble() const
BubbleIF interface.
Definition: pipe_data.cc:250
gem5::minor::BranchData::Reason
Reason
Definition: pipe_data.hh:68
gem5::minor::ForwardInstData::insts
MinorDynInstPtr insts[MAX_FORWARD_INSTS]
Array of carried insts, ref counted.
Definition: pipe_data.hh:287
gem5::minor::ForwardLineData::isBubble
bool isBubble() const
Definition: pipe_data.hh:271
gem5::Packet::req
RequestPtr req
A pointer to the original request.
Definition: packet.hh:377
gem5::minor::BranchData::reason
Reason reason
Explanation for this branch.
Definition: pipe_data.hh:112
gem5::minor::ForwardInstData::numInsts
unsigned int numInsts
The number of insts slots that can be expected to be valid insts.
Definition: pipe_data.hh:290
gem5::minor::ForwardLineData::allocateLine
void allocateLine(unsigned int width_)
In-place initialise a ForwardLineData, freeing and overridding the line.
Definition: pipe_data.cc:174
minor
gem5::minor::ForwardLineData::lineWidth
unsigned int lineWidth
Explicit line width, don't rely on data.size.
Definition: pipe_data.hh:206
gem5::minor::BranchData::isBranch
bool isBranch() const
As static isBranch but on this branch data.
Definition: pipe_data.hh:169
gem5::minor::BranchData::NoBranch
@ NoBranch
Definition: pipe_data.hh:73
gem5::minor::ForwardInstData
Forward flowing data between Fetch2,Decode,Execute carrying a packet of instructions of a width appro...
Definition: pipe_data.hh:283
gem5::ArmISA::i
Bitfield< 7 > i
Definition: misc_types.hh:67
gem5::minor::ForwardLineData::setFault
void setFault(Fault fault_)
Set fault and possible clear the bubble flag.
Definition: pipe_data.cc:166
gem5::minor::ForwardLineData::reportData
void reportData(std::ostream &os) const
ReportIF interface.
Definition: pipe_data.cc:217
gem5::minor::BranchData::Interrupt
@ Interrupt
Definition: pipe_data.hh:96
gem5::Fault
std::shared_ptr< FaultBase > Fault
Definition: types.hh:248
gem5::ArmISA::width
Bitfield< 4 > width
Definition: misc_types.hh:72
gem5::minor::BranchData::CorrectlyPredictedBranch
@ CorrectlyPredictedBranch
Definition: pipe_data.hh:76
gem5::Packet
A Packet is used to encapsulate a transfer between two objects in the memory system (e....
Definition: packet.hh:294
gem5::minor::BranchData::BadlyPredictedBranchTarget
@ BadlyPredictedBranchTarget
Definition: pipe_data.hh:85
gem5::minor::ForwardLineData::line
uint8_t * line
Line data.
Definition: pipe_data.hh:218
gem5::minor::MinorDynInst::bubble
static MinorDynInstPtr bubble()
There is a single bubble inst.
Definition: dyn_inst.hh:250
gem5::minor::ForwardInstData::width
unsigned int width() const
Number of instructions carried by this object.
Definition: pipe_data.hh:303
gem5::minor::ForwardInstData::operator=
ForwardInstData & operator=(const ForwardInstData &src)
Copy the inst array only as far as numInsts.
Definition: pipe_data.cc:239
gem5::minor::MAX_FORWARD_INSTS
const unsigned int MAX_FORWARD_INSTS
Maximum number of instructions that can be carried by the pipeline.
Definition: pipe_data.hh:278
gem5::minor::BranchData
Forward data betwen Execute and Fetch1 carrying change-of-address/stream information.
Definition: pipe_data.hh:65
gem5::minor::BranchData::inst
MinorDynInstPtr inst
Instruction which caused this branch.
Definition: pipe_data.hh:125
gem5::minor::BranchData::isBubble
bool isBubble() const
Definition: pipe_data.hh:163
gem5::minor::ForwardLineData::isFault
bool isFault() const
This is a fault, not a line.
Definition: pipe_data.hh:250
gem5::minor::ForwardLineData::packet
Packet * packet
Packet from which the line is taken.
Definition: pipe_data.hh:221
gem5::minor::ForwardLineData::adoptPacketData
void adoptPacketData(Packet *packet)
Use the data from a packet as line instead of allocating new space.
Definition: pipe_data.cc:186
gem5::minor::BranchData::isStreamChange
bool isStreamChange() const
As static isStreamChange but on this branch data.
Definition: pipe_data.hh:166
gem5::minor::ForwardInstData::resize
void resize(unsigned int width)
Resize a bubble/empty ForwardInstData and fill with bubbles.
Definition: pipe_data.cc:263
gem5::X86ISA::os
Bitfield< 17 > os
Definition: misc.hh:810
gem5::minor::operator<<
std::ostream & operator<<(std::ostream &os, const InstId &id)
Print this id in the usual slash-separated format expected by MinorTrace.
Definition: dyn_inst.cc:63
gem5::minor::BranchData::HaltFetch
@ HaltFetch
Definition: pipe_data.hh:98
gem5::minor::BranchData::BranchPrediction
@ BranchPrediction
Definition: pipe_data.hh:83
gem5::minor::BranchData::BadlyPredictedBranch
@ BadlyPredictedBranch
Definition: pipe_data.hh:89
gem5::minor::ForwardLineData::fault
Fault fault
This line has a fault.
Definition: pipe_data.hh:211
gem5::minor::BranchData::reportData
void reportData(std::ostream &os) const
ReportIF interface.
Definition: pipe_data.cc:140
gem5::minor::BranchData::SuspendThread
@ SuspendThread
Definition: pipe_data.hh:94
gem5
Reference material can be found at the JEDEC website: UFS standard http://www.jedec....
Definition: gpu_translation_state.hh:37
gem5::minor::BranchData::UnpredictedBranch
@ UnpredictedBranch
Definition: pipe_data.hh:81
gem5::minor::BranchData::newPredictionSeqNum
InstSeqNum newPredictionSeqNum
Definition: pipe_data.hh:119
gem5::minor::BranchData::newStreamSeqNum
InstSeqNum newStreamSeqNum
Sequence number of new stream/prediction to be adopted.
Definition: pipe_data.hh:118
gem5::minor::ForwardLineData::bubbleFlag
bool bubbleFlag
This line is a bubble.
Definition: pipe_data.hh:192
gem5::ThreadID
int16_t ThreadID
Thread index/ID type.
Definition: types.hh:235
gem5::minor::ForwardLineData::freeLine
void freeLine()
Free this ForwardLineData line.
Definition: pipe_data.cc:199
gem5::Packet::getPtr
T * getPtr()
get a pointer to the data ptr.
Definition: packet.hh:1225

Generated on Sun Jul 30 2023 01:56:52 for gem5 by doxygen 1.8.17