42#ifndef __CPU_PRED_BPRED_UNIT_HH__
43#define __CPU_PRED_BPRED_UNIT_HH__
54#include "params/BranchPredictor.hh"
61namespace branch_prediction
71 typedef BranchPredictorParams
Params;
184 void *bp_history,
bool squashed,
209 bool pred_taken,
void *bp_history,
210 void *indirect_history,
ThreadID _tid,
Defines global host-dependent types: Counter, Tick, and (indirectly) {int,uint}{8,...
virtual std::string name() const
Abstract superclass for simulation objects.
Basically a wrapper class to hold both the branch predictor and the BTB.
std::vector< History > predHist
The per-thread predictor history.
virtual void uncondBranch(ThreadID tid, Addr pc, void *&bp_history)=0
probing::PMUUPtr pmuProbePoint(const char *name)
Helper method to instantiate probe points belonging to this object.
virtual void btbUpdate(ThreadID tid, Addr instPC, void *&bp_history)=0
If a branch is not taken, because the BTB address is invalid or missing, this function sets the appro...
void update(const InstSeqNum &done_sn, ThreadID tid)
Tells the branch predictor to commit any updates until the given sequence number.
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 update(ThreadID tid, Addr instPC, bool taken, void *bp_history, bool squashed, const StaticInstPtr &inst, Addr corrTarget)=0
Updates the BP with taken/not taken information.
probing::PMUUPtr ppMisses
Miss-predicted branches.
bool BTBValid(Addr instPC)
Looks up a given PC in the BTB to see if a matching entry exists.
virtual bool lookup(ThreadID tid, Addr instPC, void *&bp_history)=0
Looks up a given PC in the BP to see if it is taken or not taken.
void drainSanityCheck() const
Perform sanity checks after a drain.
IndirectPredictor * iPred
The indirect target predictor.
std::deque< PredictorHistory > History
probing::PMUUPtr ppBranches
Branches seen by the branch predictor.
void regProbePoints() override
Register probe points for this object.
std::vector< ReturnAddrStack > RAS
The per-thread return address stack.
void BTBUpdate(Addr instPC, const PCStateBase &target)
Updates the BTB with the target of a branch.
const PCStateBase * BTBLookup(Addr inst_pc)
Looks up a given PC in the BTB to get the predicted target.
const unsigned numThreads
Number of the threads for which the branch history is maintained.
const unsigned instShiftAmt
Number of bits to shift instructions by for predictor addresses.
BranchPredictorParams Params
void squash(const InstSeqNum &squashed_sn, ThreadID tid)
Squashes all outstanding updates until a given sequence number.
gem5::branch_prediction::BPredUnit::BPredUnitStats stats
virtual void squash(ThreadID tid, void *bp_history)=0
bool valid(Addr instPC, ThreadID tid)
Checks if a branch is in the BTB.
void update(Addr inst_pc, const PCStateBase &target_pc, ThreadID tid)
Updates the BTB with the target of a branch.
const PCStateBase * lookup(Addr instPC, ThreadID tid)
Looks up an address in the BTB.
This is a simple scalar statistic, like a counter.
std::unique_ptr< PMU > PMUUPtr
Reference material can be found at the JEDEC website: UFS standard http://www.jedec....
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::Scalar BTBUpdates
Stat for number of BTB updates.
statistics::Scalar indirectMispredicted
Stat for the number of indirect target mispredictions.
statistics::Scalar BTBLookups
Stat for number of BTB lookups.
statistics::Scalar condIncorrect
Stat for number of conditional branches predicted incorrectly.
statistics::Scalar indirectLookups
Stat for the number of indirect target lookups.
statistics::Scalar indirectHits
Stat for the number of indirect target hits.
statistics::Scalar RASUsed
Stat for number of times the RAS is used to get a target.
statistics::Scalar condPredicted
Stat for number of conditional branches predicted.
statistics::Formula BTBHitRatio
Stat for the ratio between BTB hits and BTB lookups.
statistics::Scalar indirectMisses
Stat for the number of indirect target misses.
statistics::Scalar RASIncorrect
Stat for number of times the RAS is incorrect.
statistics::Scalar lookups
Stat for number of BP lookups.
statistics::Scalar BTBHits
Stat for number of BTB hits.
InstSeqNum seqNum
The sequence number for the predictor history entry.
bool predTaken
Whether or not it was predicted taken.
Addr target
Target of the branch.
void * bpHistory
Pointer to the history object passed back from the branch predictor.
unsigned RASIndex
The RAS index of the instruction (only valid if a call).
bool wasReturn
Whether or not the instruction was a return.
bool wasIndirect
Wether this instruction was an indirect branch.
ThreadID tid
The thread id.
bool wasCall
Whether or not the instruction was a call.
Addr pc
The PC associated with the sequence number.
bool operator==(const PredictorHistory &entry) const
std::unique_ptr< PCStateBase > RASTarget
The RAS target (only valid if a return).
PredictorHistory(const PredictorHistory &other)
bool usedRAS
Whether or not the RAS was used.
const StaticInstPtr inst
The branch instrction.
PredictorHistory(const InstSeqNum &seq_num, Addr instPC, bool pred_taken, void *bp_history, void *indirect_history, ThreadID _tid, const StaticInstPtr &inst)
Makes a predictor history struct that contains any information needed to update the predictor,...