summaryrefslogtreecommitdiff
path: root/src/cpu/pred/bpred_unit.cc
diff options
context:
space:
mode:
authorMitch Hayenga <mitch.hayenga@arm.com>2016-04-05 12:20:19 -0500
committerMitch Hayenga <mitch.hayenga@arm.com>2016-04-05 12:20:19 -0500
commitd99deff8ea296fd28b48da08aba577a1e7dfc01b (patch)
treebb8645f94f33b45b040776e5e0dd0a0d8edb306f /src/cpu/pred/bpred_unit.cc
parent0fd4bb7f12d8a633f3ff0abe61d4f3a78bca6f84 (diff)
downloadgem5-d99deff8ea296fd28b48da08aba577a1e7dfc01b.tar.xz
cpu: Implement per-thread GHRs
Branch predictors that use GHRs should index them on a per-thread basis. This makes that so. This is a re-spin of fb51231 after the revert (bd1c6789).
Diffstat (limited to 'src/cpu/pred/bpred_unit.cc')
-rw-r--r--src/cpu/pred/bpred_unit.cc27
1 files changed, 14 insertions, 13 deletions
diff --git a/src/cpu/pred/bpred_unit.cc b/src/cpu/pred/bpred_unit.cc
index d12e9f9f7..91e43f50e 100644
--- a/src/cpu/pred/bpred_unit.cc
+++ b/src/cpu/pred/bpred_unit.cc
@@ -195,10 +195,10 @@ BPredUnit::predict(const StaticInstPtr &inst, const InstSeqNum &seqNum,
DPRINTF(Branch, "[tid:%i]: Unconditional control.\n", tid);
pred_taken = true;
// Tell the BP there was an unconditional branch.
- uncondBranch(pc.instAddr(), bp_history);
+ uncondBranch(tid, pc.instAddr(), bp_history);
} else {
++condPredicted;
- pred_taken = lookup(pc.instAddr(), bp_history);
+ pred_taken = lookup(tid, pc.instAddr(), bp_history);
DPRINTF(Branch, "[tid:%i]: [sn:%i] Branch predictor"
" predicted %i for PC %s\n", tid, seqNum, pred_taken, pc);
@@ -265,7 +265,7 @@ BPredUnit::predict(const StaticInstPtr &inst, const InstSeqNum &seqNum,
// because the BTB did not have an entry
// The predictor needs to be updated accordingly
if (!inst->isCall() && !inst->isReturn()) {
- btbUpdate(pc.instAddr(), bp_history);
+ btbUpdate(tid, pc.instAddr(), bp_history);
DPRINTF(Branch, "[tid:%i]:[sn:%i] btbUpdate"
" called for %s\n", tid, seqNum, pc);
} else if (inst->isCall() && !inst->isUncondCtrl()) {
@@ -278,8 +278,8 @@ BPredUnit::predict(const StaticInstPtr &inst, const InstSeqNum &seqNum,
predict_record.wasIndirect = true;
++indirectLookups;
//Consult indirect predictor on indirect control
- if (iPred.lookup(pc.instAddr(), getGHR(bp_history), target,
- tid)) {
+ if (iPred.lookup(pc.instAddr(), getGHR(tid, bp_history),
+ target, tid)) {
// Indirect predictor hit
++indirectHits;
DPRINTF(Branch, "[tid:%i]: Instruction %s predicted "
@@ -346,7 +346,7 @@ BPredUnit::predictInOrder(const StaticInstPtr &inst, const InstSeqNum &seqNum,
DPRINTF(Branch, "[tid:%i] Unconditional control.\n", tid);
pred_taken = true;
// Tell the BP there was an unconditional branch.
- uncondBranch(instPC.instAddr(), bp_history);
+ uncondBranch(tid, instPC.instAddr(), bp_history);
if (inst->isReturn() && RAS[tid].empty()) {
DPRINTF(Branch, "[tid:%i] RAS is empty, predicting "
@@ -356,7 +356,7 @@ BPredUnit::predictInOrder(const StaticInstPtr &inst, const InstSeqNum &seqNum,
} else {
++condPredicted;
- pred_taken = lookup(predPC.instAddr(), bp_history);
+ pred_taken = lookup(tid, predPC.instAddr(), bp_history);
}
PredictorHistory predict_record(seqNum, predPC.instAddr(), pred_taken,
@@ -451,10 +451,11 @@ BPredUnit::update(const InstSeqNum &done_sn, ThreadID tid)
predHist[tid].back().seqNum <= done_sn) {
// Update the branch predictor with the correct results.
if (!predHist[tid].back().wasSquashed) {
- update(predHist[tid].back().pc, predHist[tid].back().predTaken,
- predHist[tid].back().bpHistory, false);
+ update(tid, predHist[tid].back().pc,
+ predHist[tid].back().predTaken,
+ predHist[tid].back().bpHistory, false);
} else {
- retireSquashed(predHist[tid].back().bpHistory);
+ retireSquashed(tid, predHist[tid].back().bpHistory);
}
predHist[tid].pop_back();
@@ -485,7 +486,7 @@ BPredUnit::squash(const InstSeqNum &squashed_sn, ThreadID tid)
}
// This call should delete the bpHistory.
- squash(pred_hist.front().bpHistory);
+ squash(tid, pred_hist.front().bpHistory);
DPRINTF(Branch, "[tid:%i]: Removing history for [sn:%i] "
"PC %s.\n", tid, pred_hist.front().seqNum,
@@ -550,9 +551,9 @@ BPredUnit::squash(const InstSeqNum &squashed_sn,
}
// Have to get GHR here because the update deletes bpHistory
- unsigned ghr = getGHR(hist_it->bpHistory);
+ unsigned ghr = getGHR(tid, hist_it->bpHistory);
- update((*hist_it).pc, actually_taken,
+ update(tid, (*hist_it).pc, actually_taken,
pred_hist.front().bpHistory, true);
hist_it->wasSquashed = true;