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

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