58#include "debug/TageSCL.hh"
76 return (
rng->random<
int>() & 7) == 0;
99 for (
int i = 2;
i <= numHistLengths;
i++) {
102 (
double) (
i - 1) / (
double) ((numHistLengths - 1))))
216 a =
a & ((1ULL << size) - 1);
239 return ((shifted_pc ^ (shifted_pc >> 2)) &
255 bool taken,
Addr branch_pc,
276 bi->ghist = ((shifted_pc >> 2) ^ ((target >>
instShiftAmt) >> 3));
283 bi->ghist = ((shifted_pc ^ (shifted_pc >> 2))) ^ taken;
284 if ((brtype == 3) & taken) {
285 bi->ghist = (
bi->ghist ^ (shifted_target >> 2));
288 bi->nGhist = (brtype == 2) ? 3 : 2;
297 bool taken,
int brtype,
Addr target)
const
306 int path = shifted_pc ^ (shifted_pc >> 2) ^ (shifted_pc >> 4);
307 if ((brtype == 3) & taken) {
308 path =
path ^ (shifted_target >> 2) ^ (shifted_target >> 4);
312 int maxt = (brtype == 2) ? 3 : 2;
314 for (
int t = 0;
t < maxt;
t++) {
315 int pathbits = (
path & 127);
317 cur_phist = (cur_phist << 1) ^ pathbits;
330 if ((taken == pred_taken) && ((
rng->random<
int>() & 31) != 0)) {
339 if ((
rng->random<
int>() & 127) < 32) {
342 return ((((
bi->hitBank - 1 + 2 *
a) & 0xffe)) ^
343 (
rng->random<
int>() & 1));
379 bi->highConf = (bim == 0) || (bim == 3);
380 bi->lowConf = !
bi->highConf;
381 bi->altConf =
bi->highConf;
391 int8_t ctr =
gtable[
bi->altBank][
bi->altBankIndex].ctr;
392 tage_scl_bi->
altConf = (abs(2*ctr + 1) > 1);
404 bool pred_taken =
tage->tagePredict(tid,
pc, cond_branch,
407 bi->lpBranchInfo, pred_taken,
410 if (
bi->lpBranchInfo->loopPredUsed) {
411 bi->tageBranchInfo->provider =
LOOP;
418 bi->scBranchInfo->lowConf = tage_scl_bi->
lowConf;
419 bi->scBranchInfo->highConf = tage_scl_bi->
highConf;
420 bi->scBranchInfo->altConf = tage_scl_bi->
altConf;
421 bi->scBranchInfo->medConf = tage_scl_bi->
medConf;
424 bool use_tage_ctr =
bi->tageBranchInfo->hitBank > 0;
425 int8_t tage_ctr = use_tage_ctr ?
427 bool bias = (
bi->tageBranchInfo->longestMatchPred !=
428 bi->tageBranchInfo->altTaken);
433 use_tage_ctr, tage_ctr,
434 tage->getTageCtrBits(),
440 if (
bi->scBranchInfo->usedScPred) {
441 bi->tageBranchInfo->provider =
SC;
446 bi->lpBranchInfo->predTaken = pred_taken;
462 if (
tage->isSpeculativeUpdateEnabled()) {
465 tage->squash(tid, taken, target, inst, tage_bi);
466 if (
bi->tageBranchInfo->condBranch) {
471 bi->scBranchInfo, target,
472 tage->getPathHist(tid));
478 int nrand =
rng->random<
int>() & 3;
480 DPRINTF(TageSCL,
"Updating tables for branch:%lx; taken?:%d\n",
482 tage->updateStats(taken,
bi->tageBranchInfo);
489 bool bias = (
bi->tageBranchInfo->longestMatchPred !=
490 bi->tageBranchInfo->altTaken);
492 bi->scBranchInfo, target,
494 bi->tageBranchInfo->hitBank,
495 bi->tageBranchInfo->altBank
500 bi->tageBranchInfo->tagePred,
503 tage->condBranchUpdate(tid,
pc, taken,
bi->tageBranchInfo,
504 nrand, target,
bi->lpBranchInfo->predTaken);
507 tage->updateHistories(tid,
pc,
false, taken, target,
508 inst,
bi->tageBranchInfo);
512 bi->scBranchInfo, target,
513 tage->getPathHist(tid,
false));
518 bp_history =
nullptr;
541 bi->scBranchInfo, target,
542 tage->getPathHist(tid));
static std::stack< std::string > path
bool isDirectCtrl() const
bool isUncondCtrl() const
const unsigned instShiftAmt
Number of bits to shift instructions by for predictor addresses.
LTAGE(const LTAGEParams ¶ms)
LoopPredictor * loopPredictor
The loop predictor object.
void squash(ThreadID tid, void *&bp_history) override
virtual bool calcConf(int index) const
virtual void resetUctr(uint8_t &u)
Algorithm for resetting a single U counter.
const unsigned logRatioBiModalHystEntries
std::vector< bool > btableHysteresis
std::vector< bool > btablePrediction
const unsigned nHistoryTables
std::vector< ThreadHistory > threadHistory
virtual bool getBimodePred(Addr pc, BranchInfo *bi) const
Get a branch prediction from the bimodal predictor.
const unsigned pathHistBits
std::vector< int > logTagTableSizes
const unsigned instShiftAmt
std::vector< bool > noSkip
const bool takenOnlyHistory
Use taken only history.
std::vector< unsigned > tagTableTagWidths
void updateGHist(ThreadID tid, uint64_t bv, uint8_t n)
Internal history update function.
virtual bool optionalAgeInc() const override
virtual bool calcConf(int index) const override
const unsigned shortTagsTageFactor
void extraAltCalc(TAGEBase::BranchInfo *bi) override
Extra steps for calculating altTaken For this base TAGE class it does nothing.
void calculateIndicesAndTags(ThreadID tid, Addr branch_pc, TAGEBase::BranchInfo *bi) override
On a prediction, calculates the TAGE indices and tags for all the different history lengths.
int bindex(Addr pc_in) const override
Computes the index used to access the bimodal table.
int calcDep(TAGEBase::BranchInfo *bi)
bool getBimodePred(Addr branch_pc, TAGEBase::BranchInfo *tage_bi) const override
Get a branch prediction from the bimodal predictor.
const unsigned longTagsTageFactor
const bool truncatePathHist
void updatePathAndGlobalHistory(ThreadID tid, int brtype, bool taken, Addr branch_pc, Addr target, TAGEBase::BranchInfo *bi) override
Does the actual update of path and global history.
const unsigned longTagsSize
int gindex(ThreadID tid, Addr pc, int bank) const override
Computes the index used to access a partially tagged table.
int calcNewPathHist(ThreadID tid, Addr pc, int cur_phist, bool taken, int brtype, Addr target) const override
virtual int gindex_ext(int index, int bank) const =0
const unsigned shortTagsSize
const unsigned firstLongTagTable
int F(int phist, int size, int bank) const override
Utility function to shuffle the path history depending on which tagged table we are accessing.
void calculateParameters() override
Calculates the history lengths and some other paramters in derived classes.
int branchTypeExtra(const StaticInstPtr &inst) override
This function acts as a hook for other TAGE implementations to adjust the branch type.
void adjustAlloc(bool &alloc, bool taken, bool pred_taken) override
Extra calculation to tell whether TAGE allocaitons may happen or not on an update For this base TAGE ...
void buildTageTables() override
Instantiates the TAGE table entries.
unsigned getUseAltIdx(TAGEBase::BranchInfo *bi, Addr branch_pc) override
Calculation of the index for useAltPredForNewlyAllocated On this base TAGE implementation it is alway...
virtual uint16_t gtag(ThreadID tid, Addr pc, int bank) const override=0
Computes the partial tag of a tagged table.
virtual TAGEBase::BranchInfo * makeBranchInfo(Addr pc, bool cond) override
const unsigned logTagTableSize
void handleUReset() override
Handles the U bits reset.
bool predict(ThreadID tid, Addr branch_pc, bool cond_branch, void *&b) override
Get a branch prediction from LTAGE.
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.
TAGE_SC_L(const TAGE_SC_LParams ¶ms)
StatisticalCorrector * statisticalCorrector
void squash(ThreadID tid, void *&bp_history) override
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.
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.
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