74 fatal(
"Invalid local predictor size!\n");
78 fatal(
"Invalid global predictor size!\n");
84 fatal(
"Invalid local history table size!\n");
98 fatal(
"Invalid choice predictor size!\n");
110 fatal(
"Global predictor too large for global history bits!\n");
113 fatal(
"Choice predictor too large for global history bits!\n");
118 inform(
"More global history bits than required by predictors\n");
155 bool local_prediction;
156 unsigned local_history_idx;
157 unsigned local_predictor_idx;
159 bool global_prediction;
160 bool choice_prediction;
184 bp_history = (
void *)history;
190 if (choice_prediction) {
191 return global_prediction;
193 return local_prediction;
202 assert(uncond || bp_history);
212 bp_history =
static_cast<void *
>(history);
220 auto history =
static_cast<BPHistory *
>(bp_history);
228 void * &bp_history,
bool squashed,
252 if (old_local_pred_valid) {
268 old_local_pred_valid)
273 unsigned choice_predictor_idx =
287 unsigned global_predictor_idx =
291 if (old_local_pred_valid) {
296 if (old_local_pred_valid) {
303 bp_history =
nullptr;
321 bp_history =
nullptr;
326TournamentBP::BPHistory::newCount = 0;
BPredUnit(const Params &p)
Branch Predictor Unit (BPU) interface functions.
const unsigned numThreads
Number of the threads for which the branch history is maintained.
const unsigned instShiftAmt
Number of bits to shift instructions by for predictor addresses.
unsigned globalHistoryMask
Mask to apply to globalHistory to access global history table.
std::vector< SatCounter8 > choiceCtrs
Array of counters that make up the choice predictor.
unsigned globalHistoryBits
Number of bits for the global history.
void updateGlobalHist(ThreadID tid, bool taken)
Updates global history with the given direction.
TournamentBP(const TournamentBPParams ¶ms)
Default branch predictor constructor.
bool lookup(ThreadID tid, Addr pc, void *&bp_history) override
Looks up a given conditional branch PC of in the BP to see if it is taken or not taken.
unsigned globalPredictorSize
Number of entries in the global predictor.
std::vector< SatCounter8 > localCtrs
Local counters.
unsigned localPredictorMask
Mask to truncate values stored in the local history table.
void squash(ThreadID tid, void *&bp_history) override
unsigned historyRegisterMask
Mask to control how much history is stored.
void update(ThreadID tid, Addr pc, bool taken, void *&bp_history, bool squashed, const StaticInstPtr &inst, Addr target) override
Updates the BP with taken/not taken information.
static const int invalidPredictorIndex
Flag for invalid predictor index.
unsigned localHistoryBits
Number of bits for each entry of the local history table.
std::vector< unsigned > localHistoryTable
Array of local history table entries.
unsigned localCtrBits
Number of bits of the local predictor's counters.
unsigned localThreshold
Thresholds for the counter value; above the threshold is taken, equal to or below the threshold is no...
unsigned choiceHistoryMask
Mask to apply to globalHistory to access choice history table.
void updateLocalHist(unsigned local_history_idx, bool taken)
Updates local histories.
std::vector< SatCounter8 > globalCtrs
Array of counters that make up the global predictor.
void updateHistories(ThreadID tid, Addr pc, bool uncond, bool taken, Addr target, const StaticInstPtr &inst, void *&bp_history) override
Ones done with the prediction this function updates the path and global history.
unsigned localPredictorSize
Number of counters in the local predictor.
unsigned calcLocHistIdx(Addr &branch_addr)
Returns the local history index, given a branch address.
std::vector< unsigned > globalHistory
Global history register.
unsigned globalCtrBits
Number of bits of the global predictor's counters.
unsigned choiceCtrBits
Number of bits in the choice predictor's counters.
unsigned localHistoryTableSize
Number of entries in the local history table.
unsigned choicePredictorSize
Number of entries in the choice predictor.
static constexpr int ceilLog2(const T &n)
static constexpr bool isPowerOf2(const T &n)
#define fatal(...)
This implements a cprintf based fatal() function.
GenericSatCounter< uint8_t > SatCounter8
const Params & params() const
Copyright (c) 2024 Arm Limited All rights reserved.
int16_t ThreadID
Thread index/ID type.
uint64_t Addr
Address type This will probably be moved somewhere else in the near future.
RefCountingPtr< StaticInst > StaticInstPtr
The branch history information that is created upon predicting a branch.