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);
401 bp_history = (
void *)(
bi);
413 bool pred_taken =
tage->tagePredict(tid,
pc, cond_branch,
416 bi->lpBranchInfo, pred_taken,
419 if (
bi->lpBranchInfo->loopPredUsed) {
420 bi->tageBranchInfo->provider =
LOOP;
427 bi->scBranchInfo->lowConf = tage_scl_bi->
lowConf;
428 bi->scBranchInfo->highConf = tage_scl_bi->
highConf;
429 bi->scBranchInfo->altConf = tage_scl_bi->
altConf;
430 bi->scBranchInfo->medConf = tage_scl_bi->
medConf;
433 bool use_tage_ctr =
bi->tageBranchInfo->hitBank > 0;
434 int8_t tage_ctr = use_tage_ctr ?
436 bool bias = (
bi->tageBranchInfo->longestMatchPred !=
437 bi->tageBranchInfo->altTaken);
442 use_tage_ctr, tage_ctr,
443 tage->getTageCtrBits(),
449 if (
bi->scBranchInfo->usedScPred) {
450 bi->tageBranchInfo->provider =
SC;
455 bi->lpBranchInfo->predTaken = pred_taken;
471 if (
tage->isSpeculativeUpdateEnabled()) {
474 tage->squash(tid, taken, target, inst, tage_bi);
475 if (
bi->tageBranchInfo->condBranch) {
480 bi->scBranchInfo, target,
481 tage->getPathHist(tid));
487 int nrand =
rng->random<
int>() & 3;
489 DPRINTF(TageSCL,
"Updating tables for branch:%lx; taken?:%d\n",
491 tage->updateStats(taken,
bi->tageBranchInfo);
498 bool bias = (
bi->tageBranchInfo->longestMatchPred !=
499 bi->tageBranchInfo->altTaken);
501 bi->scBranchInfo, target,
503 bi->tageBranchInfo->hitBank,
504 bi->tageBranchInfo->altBank
509 bi->tageBranchInfo->tagePred,
512 tage->condBranchUpdate(tid,
pc, taken,
bi->tageBranchInfo,
513 nrand, target,
bi->lpBranchInfo->predTaken);
516 tage->updateHistories(tid,
pc,
false, taken, target,
517 inst,
bi->tageBranchInfo);
521 bi->scBranchInfo, target,
522 tage->getPathHist(tid,
false));
527 bp_history =
nullptr;
550 bi->scBranchInfo, target,
551 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)
void branchPlaceholder(ThreadID tid, Addr pc, bool uncond, void *&bp_history) override
Special function for the decoupled front-end.
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