gem5  v20.1.0.0
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 Minor
41 {
42 
43 std::ostream &
44 operator <<(std::ostream &os, BranchData::Reason reason)
45 {
46  switch (reason)
47  {
49  os << "NoBranch";
50  break;
52  os << "UnpredictedBranch";
53  break;
55  os << "BranchPrediction";
56  break;
58  os << "CorrectlyPredictedBranch";
59  break;
61  os << "BadlyPredictedBranch";
62  break;
64  os << "BadlyPredictedBranchTarget";
65  break;
67  os << "Interrupt";
68  break;
70  os << "SuspendThread";
71  break;
73  os << "HaltFetch";
74  break;
75  }
76 
77  return os;
78 }
79 
80 bool
82 {
83  bool ret = false;
84 
85  switch (reason)
86  {
87  /* No change of stream (see the enum comment in pipe_data.hh) */
88  case NoBranch:
90  ret = false;
91  break;
92 
93  /* Change of stream (Fetch1 should act on) */
94  case UnpredictedBranch:
95  case BranchPrediction:
98  case SuspendThread:
99  case Interrupt:
100  case HaltFetch:
101  ret = true;
102  break;
103  }
104 
105  return ret;
106 }
107 
108 bool
110 {
111  bool ret = false;
112 
113  switch (reason)
114  {
115  /* No change of stream (see the enum comment in pipe_data.hh) */
116  case NoBranch:
118  case SuspendThread:
119  case Interrupt:
120  case HaltFetch:
121  ret = false;
122  break;
123 
124  /* Change of stream (Fetch1 should act on) */
125  case UnpredictedBranch:
126  case BranchPrediction:
129  ret = true;
130  break;
131  }
132 
133  return ret;
134 }
135 
136 void
137 BranchData::reportData(std::ostream &os) const
138 {
139  if (isBubble()) {
140  os << '-';
141  } else {
142  os << reason
143  << ';' << newStreamSeqNum << '.' << newPredictionSeqNum
144  << ";0x" << std::hex << target.instAddr() << std::dec
145  << ';';
146  inst->reportData(os);
147  }
148 }
149 
150 std::ostream &
151 operator <<(std::ostream &os, const BranchData &branch)
152 {
153  os << branch.reason << " target: 0x"
154  << std::hex << branch.target.instAddr() << std::dec
155  << ' ' << *branch.inst
156  << ' ' << branch.newStreamSeqNum << "(stream)."
157  << branch.newPredictionSeqNum << "(pred)";
158 
159  return os;
160 }
161 
162 void
164 {
165  fault = fault_;
166  if (isFault())
167  bubbleFlag = false;
168 }
169 
170 void
171 ForwardLineData::allocateLine(unsigned int width_)
172 {
173  lineWidth = width_;
174  bubbleFlag = false;
175 
176  assert(!isFault());
177  assert(!line);
178 
179  line = new uint8_t[width_];
180 }
181 
182 void
184 {
185  this->packet = packet;
186  lineWidth = packet->req->getSize();
187  bubbleFlag = false;
188 
189  assert(!isFault());
190  assert(!line);
191 
192  line = packet->getPtr<uint8_t>();
193 }
194 
195 void
197 {
198  /* Only free lines in non-faulting, non-bubble lines */
199  if (!isFault() && !isBubble()) {
200  assert(line);
201  /* If packet is not NULL then the line must belong to the packet so
202  * we don't need to separately deallocate the line */
203  if (packet) {
204  delete packet;
205  } else {
206  delete [] line;
207  }
208  line = NULL;
209  bubbleFlag = true;
210  }
211 }
212 
213 void
214 ForwardLineData::reportData(std::ostream &os) const
215 {
216  if (isBubble())
217  os << '-';
218  else if (fault != NoFault)
219  os << "F;" << id;
220  else
221  os << id;
222 }
223 
225  numInsts(width), threadId(tid)
226 {
227  bubbleFill();
228 }
229 
231 {
232  *this = src;
233 }
234 
237 {
238  numInsts = src.numInsts;
239 
240  for (unsigned int i = 0; i < src.numInsts; i++)
241  insts[i] = src.insts[i];
242 
243  return *this;
244 }
245 
246 bool
248 {
249  return numInsts == 0 || insts[0]->isBubble();
250 }
251 
252 void
254 {
255  for (unsigned int i = 0; i < numInsts; i++)
257 }
258 
259 void
261 {
262  assert(width < MAX_FORWARD_INSTS);
263  numInsts = width;
264 
265  bubbleFill();
266 }
267 
268 void
269 ForwardInstData::reportData(std::ostream &os) const
270 {
271  if (isBubble()) {
272  os << '-';
273  } else {
274  unsigned int i = 0;
275 
276  os << '(';
277  while (i != numInsts) {
278  insts[i]->reportData(os);
279  i++;
280  if (i != numInsts)
281  os << ',';
282  }
283  os << ')';
284  }
285 }
286 
287 }
pipe_data.hh
Minor::BranchData::target
TheISA::PCState target
Starting PC of that stream.
Definition: pipe_data.hh:119
X86ISA::os
Bitfield< 17 > os
Definition: misc.hh:803
Minor::BranchData::inst
MinorDynInstPtr inst
Instruction which caused this branch.
Definition: pipe_data.hh:122
Minor::ForwardInstData
Forward flowing data between Fetch2,Decode,Execute carrying a packet of instructions of a width appro...
Definition: pipe_data.hh:253
Minor::BranchData::BranchPrediction
@ BranchPrediction
Definition: pipe_data.hh:80
Minor::ForwardInstData::bubbleFill
void bubbleFill()
Fill with bubbles from 0 to width() - 1.
Definition: pipe_data.cc:253
Minor::BranchData::isStreamChange
bool isStreamChange() const
As static isStreamChange but on this branch data.
Definition: pipe_data.hh:151
ArmISA::i
Bitfield< 7 > i
Definition: miscregs_types.hh:63
ThreadID
int16_t ThreadID
Thread index/ID type.
Definition: types.hh:227
Minor::ForwardLineData::adoptPacketData
void adoptPacketData(Packet *packet)
Use the data from a packet as line instead of allocating new space.
Definition: pipe_data.cc:183
ArmISA::width
Bitfield< 4 > width
Definition: miscregs_types.hh:68
Minor::BranchData::newStreamSeqNum
InstSeqNum newStreamSeqNum
Sequence number of new stream/prediction to be adopted.
Definition: pipe_data.hh:115
Minor::ForwardInstData::ForwardInstData
ForwardInstData(unsigned int width=0, ThreadID tid=InvalidThreadID)
Definition: pipe_data.cc:224
Minor::BranchData::HaltFetch
@ HaltFetch
Definition: pipe_data.hh:95
Minor::BranchData::reportData
void reportData(std::ostream &os) const
ReportIF interface.
Definition: pipe_data.cc:137
Packet::req
RequestPtr req
A pointer to the original request.
Definition: packet.hh:340
Minor::ForwardLineData::freeLine
void freeLine()
Free this ForwardLineData line.
Definition: pipe_data.cc:196
Minor::BranchData::reason
Reason reason
Explanation for this branch.
Definition: pipe_data.hh:109
Minor::ForwardLineData::id
InstId id
Thread, stream, prediction ...
Definition: pipe_data.hh:195
Minor::BranchData::UnpredictedBranch
@ UnpredictedBranch
Definition: pipe_data.hh:78
Minor::BranchData::BadlyPredictedBranchTarget
@ BadlyPredictedBranchTarget
Definition: pipe_data.hh:82
Minor
Definition: activity.cc:44
Minor::BranchData::CorrectlyPredictedBranch
@ CorrectlyPredictedBranch
Definition: pipe_data.hh:73
Minor::ForwardLineData::lineWidth
unsigned int lineWidth
Explicit line width, don't rely on data.size.
Definition: pipe_data.hh:187
Minor::ForwardInstData::reportData
void reportData(std::ostream &os) const
ReportIF interface.
Definition: pipe_data.cc:269
Minor::ForwardLineData::packet
Packet * packet
Packet from which the line is taken.
Definition: pipe_data.hh:202
Minor::BranchData::isBubble
bool isBubble() const
Definition: pipe_data.hh:148
Minor::ForwardLineData::fault
Fault fault
This line has a fault.
Definition: pipe_data.hh:192
Minor::BranchData::NoBranch
@ NoBranch
Definition: pipe_data.hh:70
Minor::BranchData::isBranch
bool isBranch() const
As static isBranch but on this branch data.
Definition: pipe_data.hh:154
Minor::BranchData::Interrupt
@ Interrupt
Definition: pipe_data.hh:93
Minor::MinorDynInst::bubble
static MinorDynInstPtr bubble()
There is a single bubble inst.
Definition: dyn_inst.hh:248
Minor::ForwardLineData::reportData
void reportData(std::ostream &os) const
ReportIF interface.
Definition: pipe_data.cc:214
Minor::ForwardLineData::setFault
void setFault(Fault fault_)
Set fault and possible clear the bubble flag.
Definition: pipe_data.cc:163
Fault
std::shared_ptr< FaultBase > Fault
Definition: types.hh:240
Minor::ForwardInstData::width
unsigned int width() const
Number of instructions carried by this object.
Definition: pipe_data.hh:273
Minor::ForwardInstData::isBubble
bool isBubble() const
BubbleIF interface.
Definition: pipe_data.cc:247
Minor::ForwardInstData::insts
MinorDynInstPtr insts[MAX_FORWARD_INSTS]
Array of carried insts, ref counted.
Definition: pipe_data.hh:257
Minor::ForwardInstData::numInsts
unsigned int numInsts
The number of insts slots that can be expected to be valid insts.
Definition: pipe_data.hh:260
Minor::ForwardLineData::allocateLine
void allocateLine(unsigned int width_)
In-place initialise a ForwardLineData, freeing and overridding the line.
Definition: pipe_data.cc:171
NoFault
constexpr decltype(nullptr) NoFault
Definition: types.hh:245
Minor::ForwardLineData::isFault
bool isFault() const
This is a fault, not a line.
Definition: pipe_data.hh:220
Minor::BranchData::newPredictionSeqNum
InstSeqNum newPredictionSeqNum
Definition: pipe_data.hh:116
Minor::ForwardLineData::bubbleFlag
bool bubbleFlag
This line is a bubble.
Definition: pipe_data.hh:176
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:248
Minor::ForwardLineData::isBubble
bool isBubble() const
Definition: pipe_data.hh:241
Minor::BranchData
Forward data betwen Execute and Fetch1 carrying change-of-address/stream information.
Definition: pipe_data.hh:62
Minor::BranchData::BadlyPredictedBranch
@ BadlyPredictedBranch
Definition: pipe_data.hh:86
Minor::BranchData::Reason
Reason
Definition: pipe_data.hh:65
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:61
Packet
A Packet is used to encapsulate a transfer between two objects in the memory system (e....
Definition: packet.hh:257
Minor::ForwardInstData::operator=
ForwardInstData & operator=(const ForwardInstData &src)
Copy the inst array only as far as numInsts.
Definition: pipe_data.cc:236
Packet::getPtr
T * getPtr()
get a pointer to the data ptr.
Definition: packet.hh:1157
Minor::ForwardInstData::resize
void resize(unsigned int width)
Resize a bubble/empty ForwardInstData and fill with bubbles.
Definition: pipe_data.cc:260
Minor::ForwardLineData::line
uint8_t * line
Line data.
Definition: pipe_data.hh:199
Minor::BranchData::SuspendThread
@ SuspendThread
Definition: pipe_data.hh:91

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