/*
- * Copyright (c) 2011 ARM Limited
+ * Copyright (c) 2011, 2014 ARM Limited
* All rights reserved
*
* The license below extends only to copyright in the software and shall
*/
void update(Addr branch_addr, bool taken, void *bp_history, bool squashed);
+ void retireSquashed(void *bp_history)
+ { assert(bp_history == NULL); }
+
void squash(void *bp_history)
{ assert(bp_history == NULL); }
*/
virtual void update(Addr instPC, bool taken, void *bp_history,
bool squashed) = 0;
+ /**
+ * Deletes the associated history with a branch, performs no predictor
+ * updates. Used for branches that mispredict and update tables but
+ * are still speculative and later retire.
+ * @param bp_history History to delete associated with this predictor
+ */
+ virtual void retireSquashed(void *bp_history) = 0;
/**
* Updates the BTB with the target of a branch.
ThreadID _tid)
: seqNum(seq_num), pc(instPC), bpHistory(bp_history), RASTarget(0),
RASIndex(0), tid(_tid), predTaken(pred_taken), usedRAS(0), pushedRAS(0),
- wasCall(0), wasReturn(0)
+ wasCall(0), wasReturn(0), wasSquashed(0)
{}
bool operator==(const PredictorHistory &entry) const {
/** Whether or not the RAS was used. */
bool usedRAS;
- /* Wether or not the RAS was pushed */
+ /* Whether or not the RAS was pushed */
bool pushedRAS;
/** Whether or not the instruction was a call. */
/** Whether or not the instruction was a return. */
bool wasReturn;
+
+ /** Whether this instruction has already mispredicted/updated bp */
+ bool wasSquashed;
};
typedef std::deque<PredictorHistory> History;
while (!predHist[tid].empty() &&
predHist[tid].back().seqNum <= done_sn) {
// Update the branch predictor with the correct results.
- update(predHist[tid].back().pc, predHist[tid].back().predTaken,
- predHist[tid].back().bpHistory, false);
+ if (!predHist[tid].back().wasSquashed) {
+ update(predHist[tid].back().pc, predHist[tid].back().predTaken,
+ predHist[tid].back().bpHistory, false);
+ } else {
+ retireSquashed(predHist[tid].back().bpHistory);
+ }
predHist[tid].pop_back();
}
update((*hist_it).pc, actually_taken,
pred_hist.front().bpHistory, true);
+ hist_it->wasSquashed = true;
+
if (actually_taken) {
if (hist_it->wasReturn && !hist_it->usedRAS) {
DPRINTF(Branch, "[tid: %i] Incorrectly predicted"
" return [sn:%i] PC: %s\n", tid, hist_it->seqNum,
hist_it->pc);
RAS[tid].pop();
+ hist_it->usedRAS = true;
}
DPRINTF(Branch,"[tid: %i] BTB Update called for [sn:%i]"
" to: %i, target: %s.\n", tid,
hist_it->RASIndex, hist_it->RASTarget);
RAS[tid].restore(hist_it->RASIndex, hist_it->RASTarget);
-
+ hist_it->usedRAS = false;
} else if (hist_it->wasCall && hist_it->pushedRAS) {
//Was a Call but predicated false. Pop RAS here
DPRINTF(Branch, "[tid: %i] Incorrectly predicted"
" Call [sn:%i] PC: %s Popping RAS\n", tid,
hist_it->seqNum, hist_it->pc);
RAS[tid].pop();
+ hist_it->pushedRAS = false;
}
}
- DPRINTF(Branch, "[tid:%i]: Removing history for [sn:%i]"
- " PC %s Actually Taken: %i\n", tid, hist_it->seqNum,
- hist_it->pc, actually_taken);
-
- pred_hist.erase(hist_it);
-
- DPRINTF(Branch, "[tid:%i]: predHist.size(): %i\n", tid,
- predHist[tid].size());
} else {
DPRINTF(Branch, "[tid:%i]: [sn:%i] pred_hist empty, can't "
"update.\n", tid, squashed_sn);
/*
- * Copyright (c) 2011 ARM Limited
+ * Copyright (c) 2011, 2014 ARM Limited
* All rights reserved
*
* The license below extends only to copyright in the software and shall
}
}
+ } else {
+ // We're done with this history, now delete it.
+ delete history;
}
- // We're done with this history, now delete it.
- delete history;
-
}
assert(local_history_idx < localHistoryTableSize);
}
+void
+TournamentBP::retireSquashed(void *bp_history)
+{
+ BPHistory *history = static_cast<BPHistory *>(bp_history);
+ delete history;
+}
+
void
TournamentBP::squash(void *bp_history)
{
/*
- * Copyright (c) 2011 ARM Limited
+ * Copyright (c) 2011, 2014 ARM Limited
* All rights reserved
*
* The license below extends only to copyright in the software and shall
*/
void update(Addr branch_addr, bool taken, void *bp_history, bool squashed);
+ void retireSquashed(void *bp_history);
+
/**
* Restores the global branch history on a squash.
* @param bp_history Pointer to the BPHistory object that has the