params->numThreads),
RAS(numThreads),
iPred(params->indirectBranchPred),
+ stats(this),
instShiftAmt(params->instShiftAmt)
{
for (auto& r : RAS)
r.init(params->RASSize);
}
-void
-BPredUnit::regStats()
+BPredUnit::BPredUnitStats::BPredUnitStats(Stats::Group *parent)
+ : Stats::Group(parent),
+ ADD_STAT(lookups, "Number of BP lookups"),
+ ADD_STAT(condPredicted, "Number of conditional branches predicted"),
+ ADD_STAT(condIncorrect, "Number of conditional branches incorrect"),
+ ADD_STAT(BTBLookups, "Number of BTB lookups"),
+ ADD_STAT(BTBHits, "Number of BTB hits"),
+ ADD_STAT(BTBHitPct, "BTB Hit Percentage",
+ (BTBHits / BTBLookups) * 100),
+ ADD_STAT(RASUsed, "Number of times the RAS was used to get a target."),
+ ADD_STAT(RASIncorrect, "Number of incorrect RAS predictions."),
+ ADD_STAT(indirectLookups, "Number of indirect predictor lookups."),
+ ADD_STAT(indirectHits, "Number of indirect target hits."),
+ ADD_STAT(indirectMisses, "Number of indirect misses."),
+ ADD_STAT(indirectMispredicted, "Number of mispredicted indirect"
+ " branches.")
{
- SimObject::regStats();
-
- lookups
- .name(name() + ".lookups")
- .desc("Number of BP lookups")
- ;
-
- condPredicted
- .name(name() + ".condPredicted")
- .desc("Number of conditional branches predicted")
- ;
-
- condIncorrect
- .name(name() + ".condIncorrect")
- .desc("Number of conditional branches incorrect")
- ;
-
- BTBLookups
- .name(name() + ".BTBLookups")
- .desc("Number of BTB lookups")
- ;
-
- BTBHits
- .name(name() + ".BTBHits")
- .desc("Number of BTB hits")
- ;
-
- BTBCorrect
- .name(name() + ".BTBCorrect")
- .desc("Number of correct BTB predictions (this stat may not "
- "work properly.")
- ;
-
- BTBHitPct
- .name(name() + ".BTBHitPct")
- .desc("BTB Hit Percentage")
- .precision(6);
- BTBHitPct = (BTBHits / BTBLookups) * 100;
-
- usedRAS
- .name(name() + ".usedRAS")
- .desc("Number of times the RAS was used to get a target.")
- ;
-
- RASIncorrect
- .name(name() + ".RASInCorrect")
- .desc("Number of incorrect RAS predictions.")
- ;
-
- indirectLookups
- .name(name() + ".indirectLookups")
- .desc("Number of indirect predictor lookups.")
- ;
-
- indirectHits
- .name(name() + ".indirectHits")
- .desc("Number of indirect target hits.")
- ;
-
- indirectMisses
- .name(name() + ".indirectMisses")
- .desc("Number of indirect misses.")
- ;
-
- indirectMispredicted
- .name(name() + "indirectMispredicted")
- .desc("Number of mispredicted indirect branches.")
- ;
-
+ BTBHitPct.precision(6);
}
ProbePoints::PMUUPtr
bool pred_taken = false;
TheISA::PCState target = pc;
- ++lookups;
+ ++stats.lookups;
ppBranches->notify(1);
void *bp_history = NULL;
// Tell the BP there was an unconditional branch.
uncondBranch(tid, pc.instAddr(), bp_history);
} else {
- ++condPredicted;
+ ++stats.condPredicted;
pred_taken = lookup(tid, pc.instAddr(), bp_history);
DPRINTF(Branch, "[tid:%i] [sn:%llu] "
// Now lookup in the BTB or RAS.
if (pred_taken) {
if (inst->isReturn()) {
- ++usedRAS;
+ ++stats.RASUsed;
predict_record.wasReturn = true;
// If it's a function return call, then look up the address
// in the RAS.
}
if (inst->isDirectCtrl() || !iPred) {
- ++BTBLookups;
+ ++stats.BTBLookups;
// Check BTB on direct branches
if (BTB.valid(pc.instAddr(), tid)) {
- ++BTBHits;
+ ++stats.BTBHits;
// If it's not a return, use the BTB to get target addr.
target = BTB.lookup(pc.instAddr(), tid);
DPRINTF(Branch,
}
} else {
predict_record.wasIndirect = true;
- ++indirectLookups;
+ ++stats.indirectLookups;
//Consult indirect predictor on indirect control
if (iPred->lookup(pc.instAddr(), target, tid)) {
// Indirect predictor hit
- ++indirectHits;
+ ++stats.indirectHits;
DPRINTF(Branch,
"[tid:%i] [sn:%llu] "
"Instruction %s predicted "
"indirect target is %s\n",
tid, seqNum, pc, target);
} else {
- ++indirectMisses;
+ ++stats.indirectMisses;
pred_taken = false;
predict_record.predTaken = pred_taken;
DPRINTF(Branch,
History &pred_hist = predHist[tid];
- ++condIncorrect;
+ ++stats.condIncorrect;
ppMisses->notify(1);
DPRINTF(Branch, "[tid:%i] Squashing from sequence number %i, "
if ((*hist_it).usedRAS) {
- ++RASIncorrect;
+ ++stats.RASIncorrect;
DPRINTF(Branch,
"[tid:%i] [squash sn:%llu] Incorrect RAS [sn:%llu]\n",
tid, squashed_sn, hist_it->seqNum);
hist_it->usedRAS = true;
}
if (hist_it->wasIndirect) {
- ++indirectMispredicted;
+ ++stats.indirectMispredicted;
if (iPred) {
iPred->recordTarget(
hist_it->seqNum, pred_hist.front().indirectHistory,
*/
BPredUnit(const Params *p);
- /**
- * Registers statistics.
- */
- void regStats() override;
-
void regProbePoints() override;
/** Perform sanity checks after a drain. */
/** The indirect target predictor. */
IndirectPredictor * iPred;
- /** Stat for number of BP lookups. */
- Stats::Scalar lookups;
- /** Stat for number of conditional branches predicted. */
- Stats::Scalar condPredicted;
- /** Stat for number of conditional branches predicted incorrectly. */
- Stats::Scalar condIncorrect;
- /** Stat for number of BTB lookups. */
- Stats::Scalar BTBLookups;
- /** Stat for number of BTB hits. */
- Stats::Scalar BTBHits;
- /** Stat for number of times the BTB is correct. */
- Stats::Scalar BTBCorrect;
- /** Stat for percent times an entry in BTB found. */
- Stats::Formula BTBHitPct;
- /** Stat for number of times the RAS is used to get a target. */
- Stats::Scalar usedRAS;
- /** Stat for number of times the RAS is incorrect. */
- Stats::Scalar RASIncorrect;
-
- /** Stat for the number of indirect target lookups.*/
- Stats::Scalar indirectLookups;
- /** Stat for the number of indirect target hits.*/
- Stats::Scalar indirectHits;
- /** Stat for the number of indirect target misses.*/
- Stats::Scalar indirectMisses;
- /** Stat for the number of indirect target mispredictions.*/
- Stats::Scalar indirectMispredicted;
+ struct BPredUnitStats : public Stats::Group {
+ BPredUnitStats(Stats::Group *parent);
+
+ /** Stat for number of BP lookups. */
+ Stats::Scalar lookups;
+ /** Stat for number of conditional branches predicted. */
+ Stats::Scalar condPredicted;
+ /** Stat for number of conditional branches predicted incorrectly. */
+ Stats::Scalar condIncorrect;
+ /** Stat for number of BTB lookups. */
+ Stats::Scalar BTBLookups;
+ /** Stat for number of BTB hits. */
+ Stats::Scalar BTBHits;
+ /** Stat for percent times an entry in BTB found. */
+ Stats::Formula BTBHitPct;
+ /** Stat for number of times the RAS is used to get a target. */
+ Stats::Scalar RASUsed;
+ /** Stat for number of times the RAS is incorrect. */
+ Stats::Scalar RASIncorrect;
+
+ /** Stat for the number of indirect target lookups.*/
+ Stats::Scalar indirectLookups;
+ /** Stat for the number of indirect target hits.*/
+ Stats::Scalar indirectHits;
+ /** Stat for the number of indirect target misses.*/
+ Stats::Scalar indirectMisses;
+ /** Stat for the number of indirect target mispredictions.*/
+ Stats::Scalar indirectMispredicted;
+ } stats;
protected:
/** Number of bits to shift instructions by for predictor addresses. */