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,
262 int tmp = ((shifted_pc ^ (shifted_pc >> 2))) ^ taken;
263 int path = shifted_pc ^ (shifted_pc >> 2) ^ (shifted_pc >> 4);
264 if ((brtype == 3) & taken) {
265 tmp = (tmp ^ (target >> 2));
266 path =
path ^ (target >> 2) ^ (target >> 4);
270 int maxt = (brtype == 2) ? 3 : 2;
272 for (
int t = 0;
t < maxt;
t++) {
273 int pathbit = (
path & 127);
292 if ((taken == pred_taken) && ((
rng->random<
int>() & 31) != 0)) {
301 if ((
rng->random<
int>() & 127) < 32) {
304 return ((((
bi->hitBank - 1 + 2 *
a) & 0xffe)) ^
305 (
rng->random<
int>() & 1));
341 bi->highConf = (bim == 0) || (bim == 3);
342 bi->lowConf = !
bi->highConf;
343 bi->altConf =
bi->highConf;
353 int8_t ctr =
gtable[
bi->altBank][
bi->altBankIndex].ctr;
354 tage_scl_bi->
altConf = (abs(2*ctr + 1) > 1);
366 bool pred_taken =
tage->tagePredict(tid,
pc, cond_branch,
369 bi->lpBranchInfo, pred_taken,
372 if (
bi->lpBranchInfo->loopPredUsed) {
373 bi->tageBranchInfo->provider =
LOOP;
380 bi->scBranchInfo->lowConf = tage_scl_bi->
lowConf;
381 bi->scBranchInfo->highConf = tage_scl_bi->
highConf;
382 bi->scBranchInfo->altConf = tage_scl_bi->
altConf;
383 bi->scBranchInfo->medConf = tage_scl_bi->
medConf;
386 bool use_tage_ctr =
bi->tageBranchInfo->hitBank > 0;
387 int8_t tage_ctr = use_tage_ctr ?
389 bool bias = (
bi->tageBranchInfo->longestMatchPred !=
390 bi->tageBranchInfo->altTaken);
395 use_tage_ctr, tage_ctr,
396 tage->getTageCtrBits(),
402 if (
bi->scBranchInfo->usedScPred) {
403 bi->tageBranchInfo->provider =
SC;
408 bi->lpBranchInfo->predTaken = pred_taken;
424 if (
tage->isSpeculativeUpdateEnabled()) {
427 tage->squash(tid, taken, target, inst, tage_bi);
428 if (
bi->tageBranchInfo->condBranch) {
433 bi->scBranchInfo, target,
434 tage->getPathHist(tid));
440 int nrand =
rng->random<
int>() & 3;
442 DPRINTF(TageSCL,
"Updating tables for branch:%lx; taken?:%d\n",
444 tage->updateStats(taken,
bi->tageBranchInfo);
451 bool bias = (
bi->tageBranchInfo->longestMatchPred !=
452 bi->tageBranchInfo->altTaken);
454 bi->scBranchInfo, target,
456 bi->tageBranchInfo->hitBank,
457 bi->tageBranchInfo->altBank
462 bi->tageBranchInfo->tagePred,
465 tage->condBranchUpdate(tid,
pc, taken,
bi->tageBranchInfo,
466 nrand, target,
bi->lpBranchInfo->predTaken);
469 tage->updateHistories(tid,
pc,
false, taken, target,
470 inst,
bi->tageBranchInfo);
474 bi->scBranchInfo, target,
475 tage->getPathHist(tid,
false));
480 bp_history =
nullptr;
503 bi->scBranchInfo, target,
504 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
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.
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