gem5  v21.2.1.1
bpred_unit.cc
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2011-2012, 2014 ARM Limited
3  * Copyright (c) 2010 The University of Edinburgh
4  * Copyright (c) 2012 Mark D. Hill and David A. Wood
5  * All rights reserved
6  *
7  * The license below extends only to copyright in the software and shall
8  * not be construed as granting a license to any other intellectual
9  * property including but not limited to intellectual property relating
10  * to a hardware implementation of the functionality of the software
11  * licensed hereunder. You may use the software subject to the license
12  * terms below provided that you ensure that this notice is replicated
13  * unmodified and in its entirety in all distributions of the software,
14  * modified or unmodified, in source code or in binary form.
15  *
16  * Copyright (c) 2004-2005 The Regents of The University of Michigan
17  * All rights reserved.
18  *
19  * Redistribution and use in source and binary forms, with or without
20  * modification, are permitted provided that the following conditions are
21  * met: redistributions of source code must retain the above copyright
22  * notice, this list of conditions and the following disclaimer;
23  * redistributions in binary form must reproduce the above copyright
24  * notice, this list of conditions and the following disclaimer in the
25  * documentation and/or other materials provided with the distribution;
26  * neither the name of the copyright holders nor the names of its
27  * contributors may be used to endorse or promote products derived from
28  * this software without specific prior written permission.
29  *
30  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
31  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
32  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
33  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
34  * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
35  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
36  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
37  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
38  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
39  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
40  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
41  */
42 
43 #include "cpu/pred/bpred_unit.hh"
44 
45 #include <algorithm>
46 
47 #include "arch/generic/pcstate.hh"
48 #include "base/compiler.hh"
49 #include "base/trace.hh"
50 #include "config/the_isa.hh"
51 #include "debug/Branch.hh"
52 
53 namespace gem5
54 {
55 
56 namespace branch_prediction
57 {
58 
60  : SimObject(params),
61  numThreads(params.numThreads),
62  predHist(numThreads),
63  BTB(params.BTBEntries,
64  params.BTBTagSize,
65  params.instShiftAmt,
66  params.numThreads),
67  RAS(numThreads),
68  iPred(params.indirectBranchPred),
69  stats(this),
70  instShiftAmt(params.instShiftAmt)
71 {
72  for (auto& r : RAS)
73  r.init(params.RASSize);
74 }
75 
77  : statistics::Group(parent),
78  ADD_STAT(lookups, statistics::units::Count::get(),
79  "Number of BP lookups"),
80  ADD_STAT(condPredicted, statistics::units::Count::get(),
81  "Number of conditional branches predicted"),
82  ADD_STAT(condIncorrect, statistics::units::Count::get(),
83  "Number of conditional branches incorrect"),
84  ADD_STAT(BTBLookups, statistics::units::Count::get(),
85  "Number of BTB lookups"),
86  ADD_STAT(BTBHits, statistics::units::Count::get(), "Number of BTB hits"),
87  ADD_STAT(BTBHitRatio, statistics::units::Ratio::get(), "BTB Hit Ratio",
88  BTBHits / BTBLookups),
89  ADD_STAT(RASUsed, statistics::units::Count::get(),
90  "Number of times the RAS was used to get a target."),
91  ADD_STAT(RASIncorrect, statistics::units::Count::get(),
92  "Number of incorrect RAS predictions."),
93  ADD_STAT(indirectLookups, statistics::units::Count::get(),
94  "Number of indirect predictor lookups."),
95  ADD_STAT(indirectHits, statistics::units::Count::get(),
96  "Number of indirect target hits."),
97  ADD_STAT(indirectMisses, statistics::units::Count::get(),
98  "Number of indirect misses."),
99  ADD_STAT(indirectMispredicted, statistics::units::Count::get(),
100  "Number of mispredicted indirect branches.")
101 {
103 }
104 
107 {
108  probing::PMUUPtr ptr;
109  ptr.reset(new probing::PMU(getProbeManager(), name));
110 
111  return ptr;
112 }
113 
114 void
116 {
117  ppBranches = pmuProbePoint("Branches");
118  ppMisses = pmuProbePoint("Misses");
119 }
120 
121 void
123 {
124  // We shouldn't have any outstanding requests when we resume from
125  // a drained system.
126  for ([[maybe_unused]] const auto& ph : predHist)
127  assert(ph.empty());
128 }
129 
130 bool
131 BPredUnit::predict(const StaticInstPtr &inst, const InstSeqNum &seqNum,
132  PCStateBase &pc, ThreadID tid)
133 {
134  // See if branch predictor predicts taken.
135  // If so, get its target addr either from the BTB or the RAS.
136  // Save off record of branch stuff so the RAS can be fixed
137  // up once it's done.
138 
139  bool pred_taken = false;
140  std::unique_ptr<PCStateBase> target(pc.clone());
141 
142  ++stats.lookups;
143  ppBranches->notify(1);
144 
145  void *bp_history = NULL;
146  void *indirect_history = NULL;
147 
148  if (inst->isUncondCtrl()) {
149  DPRINTF(Branch, "[tid:%i] [sn:%llu] Unconditional control\n",
150  tid,seqNum);
151  pred_taken = true;
152  // Tell the BP there was an unconditional branch.
153  uncondBranch(tid, pc.instAddr(), bp_history);
154  } else {
156  pred_taken = lookup(tid, pc.instAddr(), bp_history);
157 
158  DPRINTF(Branch, "[tid:%i] [sn:%llu] "
159  "Branch predictor predicted %i for PC %s\n",
160  tid, seqNum, pred_taken, pc);
161  }
162 
163  const bool orig_pred_taken = pred_taken;
164  if (iPred) {
165  iPred->genIndirectInfo(tid, indirect_history);
166  }
167 
168  DPRINTF(Branch,
169  "[tid:%i] [sn:%llu] Creating prediction history for PC %s\n",
170  tid, seqNum, pc);
171 
172  PredictorHistory predict_record(seqNum, pc.instAddr(), pred_taken,
173  bp_history, indirect_history, tid, inst);
174 
175  // Now lookup in the BTB or RAS.
176  if (pred_taken) {
177  if (inst->isReturn()) {
178  ++stats.RASUsed;
179  predict_record.wasReturn = true;
180  // If it's a function return call, then look up the address
181  // in the RAS.
182  const PCStateBase *ras_top = RAS[tid].top();
183  if (ras_top)
184  set(target, inst->buildRetPC(pc, *ras_top));
185 
186  // Record the top entry of the RAS, and its index.
187  predict_record.usedRAS = true;
188  predict_record.RASIndex = RAS[tid].topIdx();
189  set(predict_record.RASTarget, ras_top);
190 
191  RAS[tid].pop();
192 
193  DPRINTF(Branch, "[tid:%i] [sn:%llu] Instruction %s is a return, "
194  "RAS predicted target: %s, RAS index: %i\n",
195  tid, seqNum, pc, *target, predict_record.RASIndex);
196  } else {
197 
198  if (inst->isCall()) {
199  RAS[tid].push(pc);
200  predict_record.pushedRAS = true;
201 
202  // Record that it was a call so that the top RAS entry can
203  // be popped off if the speculation is incorrect.
204  predict_record.wasCall = true;
205 
206  DPRINTF(Branch,
207  "[tid:%i] [sn:%llu] Instruction %s was a call, adding "
208  "%s to the RAS index: %i\n",
209  tid, seqNum, pc, pc, RAS[tid].topIdx());
210  }
211 
212  if (inst->isDirectCtrl() || !iPred) {
213  ++stats.BTBLookups;
214  // Check BTB on direct branches
215  if (BTB.valid(pc.instAddr(), tid)) {
216  ++stats.BTBHits;
217  // If it's not a return, use the BTB to get target addr.
218  set(target, BTB.lookup(pc.instAddr(), tid));
219  DPRINTF(Branch,
220  "[tid:%i] [sn:%llu] Instruction %s predicted "
221  "target is %s\n",
222  tid, seqNum, pc, *target);
223  } else {
224  DPRINTF(Branch, "[tid:%i] [sn:%llu] BTB doesn't have a "
225  "valid entry\n", tid, seqNum);
226  pred_taken = false;
227  predict_record.predTaken = pred_taken;
228  // The Direction of the branch predictor is altered
229  // because the BTB did not have an entry
230  // The predictor needs to be updated accordingly
231  if (!inst->isCall() && !inst->isReturn()) {
232  btbUpdate(tid, pc.instAddr(), bp_history);
233  DPRINTF(Branch,
234  "[tid:%i] [sn:%llu] btbUpdate "
235  "called for %s\n",
236  tid, seqNum, pc);
237  } else if (inst->isCall() && !inst->isUncondCtrl()) {
238  RAS[tid].pop();
239  predict_record.pushedRAS = false;
240  }
241  inst->advancePC(*target);
242  }
243  } else {
244  predict_record.wasIndirect = true;
246  //Consult indirect predictor on indirect control
247  if (iPred->lookup(pc.instAddr(), *target, tid)) {
248  // Indirect predictor hit
250  DPRINTF(Branch,
251  "[tid:%i] [sn:%llu] Instruction %s predicted "
252  "indirect target is %s\n",
253  tid, seqNum, pc, *target);
254  } else {
256  pred_taken = false;
257  predict_record.predTaken = pred_taken;
258  DPRINTF(Branch,
259  "[tid:%i] [sn:%llu] Instruction %s no indirect "
260  "target\n",
261  tid, seqNum, pc);
262  if (!inst->isCall() && !inst->isReturn()) {
263 
264  } else if (inst->isCall() && !inst->isUncondCtrl()) {
265  RAS[tid].pop();
266  predict_record.pushedRAS = false;
267  }
268  inst->advancePC(*target);
269  }
270  iPred->recordIndirect(pc.instAddr(), target->instAddr(),
271  seqNum, tid);
272  }
273  }
274  } else {
275  if (inst->isReturn()) {
276  predict_record.wasReturn = true;
277  }
278  inst->advancePC(*target);
279  }
280  predict_record.target = target->instAddr();
281 
282  set(pc, *target);
283 
284  if (iPred) {
285  // Update the indirect predictor with the direction prediction
286  // Note that this happens after indirect lookup, so it does not use
287  // the new information
288  // Note also that we use orig_pred_taken instead of pred_taken in
289  // as this is the actual outcome of the direction prediction
290  iPred->updateDirectionInfo(tid, orig_pred_taken);
291  }
292 
293  predHist[tid].push_front(predict_record);
294 
295  DPRINTF(Branch,
296  "[tid:%i] [sn:%llu] History entry added. "
297  "predHist.size(): %i\n",
298  tid, seqNum, predHist[tid].size());
299 
300  return pred_taken;
301 }
302 
303 void
305 {
306  DPRINTF(Branch, "[tid:%i] Committing branches until "
307  "sn:%llu]\n", tid, done_sn);
308 
309  while (!predHist[tid].empty() &&
310  predHist[tid].back().seqNum <= done_sn) {
311  // Update the branch predictor with the correct results.
312  update(tid, predHist[tid].back().pc,
313  predHist[tid].back().predTaken,
314  predHist[tid].back().bpHistory, false,
315  predHist[tid].back().inst,
316  predHist[tid].back().target);
317 
318  if (iPred) {
319  iPred->commit(done_sn, tid, predHist[tid].back().indirectHistory);
320  }
321 
322  predHist[tid].pop_back();
323  }
324 }
325 
326 void
327 BPredUnit::squash(const InstSeqNum &squashed_sn, ThreadID tid)
328 {
329  History &pred_hist = predHist[tid];
330 
331  if (iPred) {
332  iPred->squash(squashed_sn, tid);
333  }
334 
335  while (!pred_hist.empty() &&
336  pred_hist.front().seqNum > squashed_sn) {
337  if (pred_hist.front().usedRAS) {
338  DPRINTF(Branch, "[tid:%i] [squash sn:%llu]"
339  " Restoring top of RAS to: %i,"
340  " target: %s\n", tid, squashed_sn,
341  pred_hist.front().RASIndex, *pred_hist.front().RASTarget);
342 
343  RAS[tid].restore(pred_hist.front().RASIndex,
344  pred_hist.front().RASTarget.get());
345  } else if (pred_hist.front().wasCall && pred_hist.front().pushedRAS) {
346  // Was a call but predicated false. Pop RAS here
347  DPRINTF(Branch, "[tid:%i] [squash sn:%llu] Squashing"
348  " Call [sn:%llu] PC: %s Popping RAS\n", tid, squashed_sn,
349  pred_hist.front().seqNum, pred_hist.front().pc);
350  RAS[tid].pop();
351  }
352 
353  // This call should delete the bpHistory.
354  squash(tid, pred_hist.front().bpHistory);
355  if (iPred) {
356  iPred->deleteIndirectInfo(tid, pred_hist.front().indirectHistory);
357  }
358 
359  DPRINTF(Branch, "[tid:%i] [squash sn:%llu] "
360  "Removing history for [sn:%llu] "
361  "PC %#x\n", tid, squashed_sn, pred_hist.front().seqNum,
362  pred_hist.front().pc);
363 
364  pred_hist.pop_front();
365 
366  DPRINTF(Branch, "[tid:%i] [squash sn:%llu] predHist.size(): %i\n",
367  tid, squashed_sn, predHist[tid].size());
368  }
369 }
370 
371 void
372 BPredUnit::squash(const InstSeqNum &squashed_sn,
373  const PCStateBase &corr_target,
374  bool actually_taken, ThreadID tid)
375 {
376  // Now that we know that a branch was mispredicted, we need to undo
377  // all the branches that have been seen up until this branch and
378  // fix up everything.
379  // NOTE: This should be call conceivably in 2 scenarios:
380  // (1) After an branch is executed, it updates its status in the ROB
381  // The commit stage then checks the ROB update and sends a signal to
382  // the fetch stage to squash history after the mispredict
383  // (2) In the decode stage, you can find out early if a unconditional
384  // PC-relative, branch was predicted incorrectly. If so, a signal
385  // to the fetch stage is sent to squash history after the mispredict
386 
387  History &pred_hist = predHist[tid];
388 
390  ppMisses->notify(1);
391 
392  DPRINTF(Branch, "[tid:%i] Squashing from sequence number %i, "
393  "setting target to %s\n", tid, squashed_sn, corr_target);
394 
395  // Squash All Branches AFTER this mispredicted branch
396  squash(squashed_sn, tid);
397 
398  // If there's a squash due to a syscall, there may not be an entry
399  // corresponding to the squash. In that case, don't bother trying to
400  // fix up the entry.
401  if (!pred_hist.empty()) {
402 
403  auto hist_it = pred_hist.begin();
404  //HistoryIt hist_it = find(pred_hist.begin(), pred_hist.end(),
405  // squashed_sn);
406 
407  //assert(hist_it != pred_hist.end());
408  if (pred_hist.front().seqNum != squashed_sn) {
409  DPRINTF(Branch, "Front sn %i != Squash sn %i\n",
410  pred_hist.front().seqNum, squashed_sn);
411 
412  assert(pred_hist.front().seqNum == squashed_sn);
413  }
414 
415 
416  if ((*hist_it).usedRAS) {
418  DPRINTF(Branch,
419  "[tid:%i] [squash sn:%llu] Incorrect RAS [sn:%llu]\n",
420  tid, squashed_sn, hist_it->seqNum);
421  }
422 
423  // There are separate functions for in-order and out-of-order
424  // branch prediction, but not for update. Therefore, this
425  // call should take into account that the mispredicted branch may
426  // be on the wrong path (i.e., OoO execution), and that the counter
427  // counter table(s) should not be updated. Thus, this call should
428  // restore the state of the underlying predictor, for instance the
429  // local/global histories. The counter tables will be updated when
430  // the branch actually commits.
431 
432  // Remember the correct direction for the update at commit.
433  pred_hist.front().predTaken = actually_taken;
434  pred_hist.front().target = corr_target.instAddr();
435 
436  update(tid, (*hist_it).pc, actually_taken,
437  pred_hist.front().bpHistory, true, pred_hist.front().inst,
438  corr_target.instAddr());
439 
440  if (iPred) {
442  pred_hist.front().indirectHistory, actually_taken);
443  }
444 
445  if (actually_taken) {
446  if (hist_it->wasReturn && !hist_it->usedRAS) {
447  DPRINTF(Branch, "[tid:%i] [squash sn:%llu] "
448  "Incorrectly predicted "
449  "return [sn:%llu] PC: %#x\n", tid, squashed_sn,
450  hist_it->seqNum,
451  hist_it->pc);
452  RAS[tid].pop();
453  hist_it->usedRAS = true;
454  }
455  if (hist_it->wasIndirect) {
457  if (iPred) {
459  hist_it->seqNum, pred_hist.front().indirectHistory,
460  corr_target, tid);
461  }
462  } else {
463  DPRINTF(Branch,"[tid:%i] [squash sn:%llu] "
464  "BTB Update called for [sn:%llu] "
465  "PC %#x\n", tid, squashed_sn,
466  hist_it->seqNum, hist_it->pc);
467 
468  BTB.update(hist_it->pc, corr_target, tid);
469  }
470  } else {
471  //Actually not Taken
472  if (hist_it->usedRAS) {
473  DPRINTF(Branch,
474  "[tid:%i] [squash sn:%llu] Incorrectly predicted "
475  "return [sn:%llu] PC: %#x Restoring RAS\n", tid,
476  squashed_sn,
477  hist_it->seqNum, hist_it->pc);
478  DPRINTF(Branch,
479  "[tid:%i] [squash sn:%llu] Restoring top of RAS "
480  "to: %i, target: %s\n", tid, squashed_sn,
481  hist_it->RASIndex, *hist_it->RASTarget);
482  RAS[tid].restore(hist_it->RASIndex, hist_it->RASTarget.get());
483  hist_it->usedRAS = false;
484  } else if (hist_it->wasCall && hist_it->pushedRAS) {
485  //Was a Call but predicated false. Pop RAS here
486  DPRINTF(Branch,
487  "[tid:%i] [squash sn:%llu] "
488  "Incorrectly predicted "
489  "Call [sn:%llu] PC: %s Popping RAS\n",
490  tid, squashed_sn,
491  hist_it->seqNum, hist_it->pc);
492  RAS[tid].pop();
493  hist_it->pushedRAS = false;
494  }
495  }
496  } else {
497  DPRINTF(Branch, "[tid:%i] [sn:%llu] pred_hist empty, can't "
498  "update\n", tid, squashed_sn);
499  }
500 }
501 
502 void
504 {
505  int i = 0;
506  for (const auto& ph : predHist) {
507  if (!ph.empty()) {
508  auto pred_hist_it = ph.begin();
509 
510  cprintf("predHist[%i].size(): %i\n", i++, ph.size());
511 
512  while (pred_hist_it != ph.end()) {
513  cprintf("sn:%llu], PC:%#x, tid:%i, predTaken:%i, "
514  "bpHistory:%#x\n",
515  pred_hist_it->seqNum, pred_hist_it->pc,
516  pred_hist_it->tid, pred_hist_it->predTaken,
517  pred_hist_it->bpHistory);
518  pred_hist_it++;
519  }
520 
521  cprintf("\n");
522  }
523  }
524 }
525 
526 } // namespace branch_prediction
527 } // namespace gem5
gem5::branch_prediction::BPredUnit::update
void update(const InstSeqNum &done_sn, ThreadID tid)
Tells the branch predictor to commit any updates until the given sequence number.
Definition: bpred_unit.cc:304
gem5::PCStateBase::instAddr
Addr instAddr() const
Returns the memory address of the instruction this PC points to.
Definition: pcstate.hh:107
gem5::branch_prediction::BPredUnit::predict
bool predict(const StaticInstPtr &inst, const InstSeqNum &seqNum, PCStateBase &pc, ThreadID tid)
Predicts whether or not the instruction is a taken branch, and the target of the branch if it is take...
Definition: bpred_unit.cc:131
gem5::branch_prediction::BPredUnit::pmuProbePoint
probing::PMUUPtr pmuProbePoint(const char *name)
Helper method to instantiate probe points belonging to this object.
Definition: bpred_unit.cc:106
gem5::branch_prediction::BPredUnit::BPredUnit
BPredUnit(const Params &p)
Definition: bpred_unit.cc:59
gem5::cprintf
void cprintf(const char *format, const Args &...args)
Definition: cprintf.hh:155
gem5::branch_prediction::BPredUnit::PredictorHistory::RASIndex
unsigned RASIndex
The RAS index of the instruction (only valid if a call).
Definition: bpred_unit.hh:251
gem5::branch_prediction::DefaultBTB::lookup
const PCStateBase * lookup(Addr instPC, ThreadID tid)
Looks up an address in the BTB.
Definition: btb.cc:116
gem5::branch_prediction::BPredUnit::PredictorHistory::target
Addr target
Target of the branch.
Definition: bpred_unit.hh:277
gem5::StaticInst::buildRetPC
virtual std::unique_ptr< PCStateBase > buildRetPC(const PCStateBase &cur_pc, const PCStateBase &call_pc) const
Definition: static_inst.hh:326
gem5::branch_prediction::IndirectPredictor::genIndirectInfo
virtual void genIndirectInfo(ThreadID tid, void *&indirect_history)=0
gem5::branch_prediction::IndirectPredictor::recordTarget
virtual void recordTarget(InstSeqNum seq_num, void *indirect_history, const PCStateBase &target, ThreadID tid)=0
gem5::branch_prediction::IndirectPredictor::lookup
virtual bool lookup(Addr br_addr, PCStateBase &br_target, ThreadID tid)=0
gem5::branch_prediction::BPredUnit::PredictorHistory::wasIndirect
bool wasIndirect
Wether this instruction was an indirect branch.
Definition: bpred_unit.hh:272
gem5::branch_prediction::BPredUnit::PredictorHistory::wasCall
bool wasCall
Whether or not the instruction was a call.
Definition: bpred_unit.hh:266
gem5::branch_prediction::BPredUnit::Params
BranchPredictorParams Params
Definition: bpred_unit.hh:71
gem5::branch_prediction::BPredUnit::stats
gem5::branch_prediction::BPredUnit::BPredUnitStats stats
gem5::branch_prediction::IndirectPredictor::recordIndirect
virtual void recordIndirect(Addr br_addr, Addr tgt_addr, InstSeqNum seq_num, ThreadID tid)=0
gem5::ArmISA::i
Bitfield< 7 > i
Definition: misc_types.hh:67
gem5::branch_prediction::IndirectPredictor::deleteIndirectInfo
virtual void deleteIndirectInfo(ThreadID tid, void *indirect_history)=0
gem5::branch_prediction::BPredUnit::BPredUnitStats::BTBHits
statistics::Scalar BTBHits
Stat for number of BTB hits.
Definition: bpred_unit.hh:318
gem5::branch_prediction::BPredUnit::BPredUnitStats::indirectMispredicted
statistics::Scalar indirectMispredicted
Stat for the number of indirect target mispredictions.
Definition: bpred_unit.hh:333
gem5::StaticInst::advancePC
virtual void advancePC(PCStateBase &pc_state) const =0
gem5::RefCountingPtr< StaticInst >
gem5::branch_prediction::BPredUnit::PredictorHistory::wasReturn
bool wasReturn
Whether or not the instruction was a return.
Definition: bpred_unit.hh:269
gem5::branch_prediction::BPredUnit::predHist
std::vector< History > predHist
The per-thread predictor history.
Definition: bpred_unit.hh:294
gem5::branch_prediction::BPredUnit::BPredUnitStats::condIncorrect
statistics::Scalar condIncorrect
Stat for number of conditional branches predicted incorrectly.
Definition: bpred_unit.hh:314
gem5::StaticInst::isReturn
bool isReturn() const
Definition: static_inst.hh:183
gem5::branch_prediction::BPredUnit::BPredUnitStats::BTBLookups
statistics::Scalar BTBLookups
Stat for number of BTB lookups.
Definition: bpred_unit.hh:316
gem5::branch_prediction::BPredUnit::PredictorHistory
Definition: bpred_unit.hh:201
gem5::Named::name
virtual std::string name() const
Definition: named.hh:47
gem5::SimObject::params
const Params & params() const
Definition: sim_object.hh:176
gem5::probing::PMUUPtr
std::unique_ptr< PMU > PMUUPtr
Definition: pmu.hh:61
DPRINTF
#define DPRINTF(x,...)
Definition: trace.hh:186
ADD_STAT
#define ADD_STAT(n,...)
Convenience macro to add a stat to a statistics group.
Definition: group.hh:75
gem5::branch_prediction::BPredUnit::BPredUnitStats::indirectMisses
statistics::Scalar indirectMisses
Stat for the number of indirect target misses.
Definition: bpred_unit.hh:331
gem5::branch_prediction::BPredUnit::BTB
DefaultBTB BTB
The BTB.
Definition: bpred_unit.hh:297
gem5::branch_prediction::BPredUnit::drainSanityCheck
void drainSanityCheck() const
Perform sanity checks after a drain.
Definition: bpred_unit.cc:122
gem5::branch_prediction::IndirectPredictor::updateDirectionInfo
virtual void updateDirectionInfo(ThreadID tid, bool actually_taken)=0
gem5::branch_prediction::BPredUnit::ppBranches
probing::PMUUPtr ppBranches
Branches seen by the branch predictor.
Definition: bpred_unit.hh:360
gem5::branch_prediction::BPredUnit::BPredUnitStats::indirectHits
statistics::Scalar indirectHits
Stat for the number of indirect target hits.
Definition: bpred_unit.hh:329
compiler.hh
gem5::branch_prediction::BPredUnit::BPredUnitStats::BPredUnitStats
BPredUnitStats(statistics::Group *parent)
Definition: bpred_unit.cc:76
gem5::StaticInst::isDirectCtrl
bool isDirectCtrl() const
Definition: static_inst.hh:184
gem5::SimObject
Abstract superclass for simulation objects.
Definition: sim_object.hh:146
gem5::branch_prediction::BPredUnit::squash
void squash(const InstSeqNum &squashed_sn, ThreadID tid)
Squashes all outstanding updates until a given sequence number.
Definition: bpred_unit.cc:327
gem5::statistics::DataWrap::precision
Derived & precision(int _precision)
Set the precision and marks this stat to print at the end of simulation.
Definition: statistics.hh:346
gem5::branch_prediction::BPredUnit::BPredUnitStats::RASIncorrect
statistics::Scalar RASIncorrect
Stat for number of times the RAS is incorrect.
Definition: bpred_unit.hh:324
gem5::branch_prediction::BPredUnit::PredictorHistory::pushedRAS
bool pushedRAS
Definition: bpred_unit.hh:263
gem5::branch_prediction::BPredUnit::PredictorHistory::predTaken
bool predTaken
Whether or not it was predicted taken.
Definition: bpred_unit.hh:257
gem5::branch_prediction::BPredUnit::BPredUnitStats::condPredicted
statistics::Scalar condPredicted
Stat for number of conditional branches predicted.
Definition: bpred_unit.hh:312
gem5::branch_prediction::BPredUnit::PredictorHistory::RASTarget
std::unique_ptr< PCStateBase > RASTarget
The RAS target (only valid if a return).
Definition: bpred_unit.hh:248
gem5::ProbePointArg
ProbePointArg generates a point for the class of Arg.
Definition: thermal_domain.hh:54
gem5::branch_prediction::BPredUnit::BPredUnitStats::lookups
statistics::Scalar lookups
Stat for number of BP lookups.
Definition: bpred_unit.hh:310
pcstate.hh
gem5::SimObject::getProbeManager
ProbeManager * getProbeManager()
Get the probe manager for this object.
Definition: sim_object.cc:120
gem5::branch_prediction::BPredUnit::regProbePoints
void regProbePoints() override
Register probe points for this object.
Definition: bpred_unit.cc:115
gem5::branch_prediction::BPredUnit::RAS
std::vector< ReturnAddrStack > RAS
The per-thread return address stack.
Definition: bpred_unit.hh:300
gem5::branch_prediction::BPredUnit::lookup
virtual bool lookup(ThreadID tid, Addr instPC, void *&bp_history)=0
Looks up a given PC in the BP to see if it is taken or not taken.
bpred_unit.hh
gem5::SparcISA::Branch
Base class for branch operations.
Definition: branch.hh:48
gem5::branch_prediction::BPredUnit::PredictorHistory::usedRAS
bool usedRAS
Whether or not the RAS was used.
Definition: bpred_unit.hh:260
gem5::branch_prediction::BPredUnit::uncondBranch
virtual void uncondBranch(ThreadID tid, Addr pc, void *&bp_history)=0
gem5::branch_prediction::IndirectPredictor::commit
virtual void commit(InstSeqNum seq_num, ThreadID tid, void *indirect_history)=0
std::deque
STL deque class.
Definition: stl.hh:44
gem5::MipsISA::pc
Bitfield< 4 > pc
Definition: pra_constants.hh:243
gem5::statistics::Group
Statistics container.
Definition: group.hh:93
gem5::StaticInst::isCall
bool isCall() const
Definition: static_inst.hh:182
gem5::branch_prediction::BPredUnit::BPredUnitStats::indirectLookups
statistics::Scalar indirectLookups
Stat for the number of indirect target lookups.
Definition: bpred_unit.hh:327
gem5::InstSeqNum
uint64_t InstSeqNum
Definition: inst_seq.hh:40
gem5::branch_prediction::BPredUnit::iPred
IndirectPredictor * iPred
The indirect target predictor.
Definition: bpred_unit.hh:303
gem5::MipsISA::r
r
Definition: pra_constants.hh:98
gem5::branch_prediction::IndirectPredictor::squash
virtual void squash(InstSeqNum seq_num, ThreadID tid)=0
gem5::branch_prediction::BPredUnit::ppMisses
probing::PMUUPtr ppMisses
Miss-predicted branches.
Definition: bpred_unit.hh:363
trace.hh
gem5::StaticInst::isUncondCtrl
bool isUncondCtrl() const
Definition: static_inst.hh:187
gem5::PCStateBase
Definition: pcstate.hh:57
gem5::branch_prediction::IndirectPredictor::changeDirectionPrediction
virtual void changeDirectionPrediction(ThreadID tid, void *indirect_history, bool actually_taken)=0
gem5::branch_prediction::BPredUnit::BPredUnitStats::BTBHitRatio
statistics::Formula BTBHitRatio
Stat for the ratio between BTB hits and BTB lookups.
Definition: bpred_unit.hh:320
gem5
Reference material can be found at the JEDEC website: UFS standard http://www.jedec....
Definition: tlb.cc:60
gem5::branch_prediction::DefaultBTB::valid
bool valid(Addr instPC, ThreadID tid)
Checks if a branch is in the BTB.
Definition: btb.cc:95
gem5::branch_prediction::BPredUnit::dump
void dump()
Definition: bpred_unit.cc:503
gem5::branch_prediction::DefaultBTB::update
void update(Addr inst_pc, const PCStateBase &target_pc, ThreadID tid)
Updates the BTB with the target of a branch.
Definition: btb.cc:134
gem5::ThreadID
int16_t ThreadID
Thread index/ID type.
Definition: types.hh:242
gem5::branch_prediction::BPredUnit::BPredUnitStats::RASUsed
statistics::Scalar RASUsed
Stat for number of times the RAS is used to get a target.
Definition: bpred_unit.hh:322
gem5::branch_prediction::BPredUnit::btbUpdate
virtual void btbUpdate(ThreadID tid, Addr instPC, void *&bp_history)=0
If a branch is not taken, because the BTB address is invalid or missing, this function sets the appro...

Generated on Wed May 4 2022 12:13:54 for gem5 by doxygen 1.8.17