42#ifndef __CPU_PRED_BPRED_UNIT_HH__
43#define __CPU_PRED_BPRED_UNIT_HH__
55#include "enums/TargetProvider.hh"
56#include "params/BranchPredictor.hh"
72 typedef BranchPredictorParams
Params;
130 bool actually_taken,
ThreadID tid,
bool from_commit=
true);
166 bool taken,
Addr target,
192 void * &bp_history,
bool squashed,
211 bool uncond,
void * &bp_history);
221 return btb->valid(tid,
pc);
235 return btb->lookup(tid,
pc.instAddr());
251 return btb->getInst(tid,
pc);
264 return btb->update(tid,
pc, target);
Defines global host-dependent types: Counter, Tick, and (indirectly) {int,uint}{8,...
std::vector< History > predHist
The per-thread predictor history.
const StaticInstPtr BTBGetInst(ThreadID tid, Addr pc)
Looks up a given PC in the BTB to get current static instruction information.
probing::PMUUPtr pmuProbePoint(const char *name)
Helper method to instantiate probe points belonging to this object.
void update(const InstSeqNum &done_sn, ThreadID tid)
Tells the branch predictor to commit any updates until the given sequence number.
BPredUnit(const Params &p)
Branch Predictor Unit (BPU) interface functions.
bool predict(const StaticInstPtr &inst, const InstSeqNum &seqNum, PCStateBase &pc, ThreadID tid)
Predicts whether or not the instruction is a taken branch, and the target of the branch if it is take...
virtual void branchPlaceholder(ThreadID tid, Addr pc, bool uncond, void *&bp_history)
Special function for the decoupled front-end.
void BTBUpdate(ThreadID tid, Addr pc, const PCStateBase &target)
Updates the BTB with the target of a branch.
virtual void updateHistories(ThreadID tid, Addr pc, bool uncond, bool taken, Addr target, const StaticInstPtr &inst, void *&bp_history)=0
Ones done with the prediction this function updates the path and global history.
probing::PMUUPtr ppMisses
Miss-predicted branches.
const bool requiresBTBHit
Requires the BTB to hit for returns and indirect branches.
virtual void squash(ThreadID tid, void *&bp_history)=0
void drainSanityCheck() const
Perform sanity checks after a drain.
IndirectPredictor * iPred
The indirect target predictor.
const PCStateBase * BTBLookup(ThreadID tid, PCStateBase &pc)
Looks up a given PC in the BTB to get the predicted target.
void commitBranch(ThreadID tid, PredictorHistory *&bpu_history)
Commit a particular branch.
probing::PMUUPtr ppBranches
Branches seen by the branch predictor.
virtual void update(ThreadID tid, Addr pc, bool taken, void *&bp_history, bool squashed, const StaticInstPtr &inst, Addr target)=0
Updates the BP with taken/not taken information.
void regProbePoints() override
Register probe points for this object.
enums::TargetProvider TargetProvider
const unsigned numThreads
Number of the threads for which the branch history is maintained.
virtual bool lookup(ThreadID tid, Addr pc, void *&bp_history)=0
Looks up a given conditional branch PC of in the BP to see if it is taken or not taken.
const unsigned instShiftAmt
Number of bits to shift instructions by for predictor addresses.
BranchPredictorParams Params
void squashHistory(ThreadID tid, PredictorHistory *&bpu_history)
Squashes a particular branch instance.
ReturnAddrStack * ras
The return address stack.
void squash(const InstSeqNum &squashed_sn, ThreadID tid)
Squashes all outstanding updates until a given sequence number.
gem5::branch_prediction::BPredUnit::BPredUnitStats stats
BranchTargetBuffer * btb
The BTB.
std::deque< PredictorHistory * > History
bool BTBValid(ThreadID tid, Addr pc)
Looks up a given PC in the BTB to see if a matching entry exists.
Return address stack class, implements a simple RAS.
This is a simple scalar statistic, like a counter.
A 2-Dimensional vecto of scalar stats.
SimObject(const Params &p)
BranchType getBranchType(StaticInstPtr inst)
enums::BranchType BranchType
std::unique_ptr< PMU > PMUUPtr
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
Declaration of Statistics objects.
statistics::Vector2d corrected
statistics::Scalar BTBUpdates
statistics::Scalar indirectMispredicted
statistics::Scalar BTBLookups
BTB stats.
statistics::Scalar condIncorrect
statistics::Vector2d squashes
statistics::Vector2d committed
statistics::Scalar BTBMispredicted
statistics::Scalar indirectLookups
Indirect stats.
statistics::Vector2d lookups
Stats per branch type.
statistics::Scalar indirectHits
statistics::Vector2d targetProvider
Target prediction per branch type.
statistics::Scalar condPredictedTaken
statistics::Scalar condPredicted
Additional scalar stats for conditional branches.
statistics::Vector2d mispredictDueToBTBMiss
statistics::Vector2d mispredicted
statistics::Vector2d earlyResteers
BPredUnitStats(BPredUnit *bp)
statistics::Formula BTBHitRatio
statistics::Scalar predTakenBTBMiss
statistics::Scalar indirectMisses
statistics::Vector2d targetWrong
statistics::Scalar BTBHits
statistics::Vector2d mispredictDueToPredictor
Branch Predictor Unit (BPU) history object PredictorHistory This class holds all information needed t...
bool predTaken
Whether or not it was predicted taken.
const InstSeqNum seqNum
The sequence number for the predictor history entry.
bool condPred
The prediction of the conditional predictor.
void * bpHistory
Pointer to the history objects passed back from the branch predictor subcomponents.
const Addr pc
The PC associated with the sequence number.
const bool call
Whether or not the instruction was a call.
PredictorHistory & operator=(const PredictorHistory &)=delete
const ThreadID tid
The thread id.
bool operator==(const PredictorHistory &entry) const
PredictorHistory(const PredictorHistory &)=delete
const StaticInstPtr inst
The branch instrction.
bool actuallyTaken
To record the actual outcome of the branch.
bool mispredict
The branch was corrected hence was mispredicted.
PredictorHistory(ThreadID _tid, InstSeqNum sn, Addr _pc, const StaticInstPtr &inst)
Makes a predictor history struct that contains any information needed to update the predictor,...
const bool uncond
Was unconditional control.
const BranchType type
The type of the branch.
bool btbHit
Was BTB hit at prediction time.
std::unique_ptr< PCStateBase > target
The predicted target.
TargetProvider targetProvider
Which component provided the target.
const std::string & name()