42#ifndef __CPU_PRED_BPRED_UNIT_HH__
43#define __CPU_PRED_BPRED_UNIT_HH__
55#include "enums/TargetProvider.hh"
56#include "params/BranchPredictor.hh"
63namespace branch_prediction
72 typedef BranchPredictorParams
Params;
129 bool actually_taken,
ThreadID tid,
bool from_commit=
true);
162 bool taken,
Addr target,
void * &bp_history) = 0;
187 void * &bp_history,
bool squashed,
Defines global host-dependent types: Counter, Tick, and (indirectly) {int,uint}{8,...
virtual std::string name() const
Addr instAddr() const
Returns the memory address of the instruction this PC points to.
Abstract superclass for simulation objects.
Basically a wrapper class to hold both the branch predictor and the BTB.
const StaticInstPtr BTBGetInst(ThreadID tid, Addr instPC)
Looks up a given PC in the BTB to get current static instruction information.
std::vector< History > predHist
The per-thread predictor history.
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...
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
bool BTBValid(ThreadID tid, Addr instPC)
Looks up a given PC in the BTB to see if a matching entry exists.
void drainSanityCheck() const
Perform sanity checks after a drain.
void BTBUpdate(ThreadID tid, Addr instPC, const PCStateBase &target)
Updates the BTB with the target of a branch.
IndirectPredictor * iPred
The indirect target predictor.
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.
virtual void updateHistories(ThreadID tid, Addr pc, bool uncond, bool taken, Addr target, void *&bp_history)=0
Ones done with the prediction this function updates the path and global history.
BranchPredictorParams Params
void squashHistory(ThreadID tid, PredictorHistory *&bpu_history)
Squashes a particular branch instance.
const PCStateBase * BTBLookup(ThreadID tid, PCStateBase &instPC)
Looks up a given PC in the BTB to get the predicted target.
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
virtual const PCStateBase * lookup(ThreadID tid, Addr instPC, BranchType type=BranchType::NoBranch)=0
Looks up an address in the BTB to get the target of the branch.
virtual bool valid(ThreadID tid, Addr instPC)=0
Checks if a branch address is in the BTB.
virtual const StaticInstPtr getInst(ThreadID tid, Addr instPC)=0
Looks up an address in the BTB and return the instruction information if existant.
virtual void update(ThreadID tid, Addr inst_pc, const PCStateBase &target_pc, BranchType type=BranchType::NoBranch, StaticInstPtr inst=nullptr)=0
Updates the BTB with the target of a branch.
Return address stack class, implements a simple RAS.
This is a simple scalar statistic, like a counter.
A 2-Dimensional vecto of scalar stats.
BranchType getBranchType(StaticInstPtr inst)
enums::BranchType BranchType
std::unique_ptr< PMU > PMUUPtr
Copyright (c) 2024 - Pranith Kumar Copyright (c) 2020 Inria 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.
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::Scalar NotTakenMispredicted
statistics::Scalar TakenMispredicted
statistics::Vector2d targetProvider
Target prediction per branch type.
statistics::Scalar condPredictedTaken
statistics::Scalar condPredicted
Additional scalar stats for conditional branches.
statistics::Vector2d mispredicted
statistics::Vector2d earlyResteers
BPredUnitStats(BPredUnit *bp)
statistics::Formula BTBHitRatio
statistics::Scalar predTakenBTBMiss
statistics::Scalar indirectMisses
statistics::Vector2d targetWrong
statistics::Scalar BTBHits
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.