bpred_unit.hh revision 1684
16019Shines@cs.fsu.edu 214028Sgiacomo.gabrielli@arm.com#ifndef __BPRED_UNIT_HH__ 37091Sgblack@eecs.umich.edu#define __BPRED_UNIT_HH__ 47091Sgblack@eecs.umich.edu 57091Sgblack@eecs.umich.edu// For Addr type. 67091Sgblack@eecs.umich.edu#include "arch/alpha/isa_traits.hh" 77091Sgblack@eecs.umich.edu#include "base/statistics.hh" 87091Sgblack@eecs.umich.edu#include "cpu/inst_seq.hh" 97091Sgblack@eecs.umich.edu 107091Sgblack@eecs.umich.edu#include "cpu/beta_cpu/2bit_local_pred.hh" 117091Sgblack@eecs.umich.edu#include "cpu/beta_cpu/tournament_pred.hh" 127091Sgblack@eecs.umich.edu#include "cpu/beta_cpu/btb.hh" 137091Sgblack@eecs.umich.edu#include "cpu/beta_cpu/ras.hh" 146019Shines@cs.fsu.edu 156019Shines@cs.fsu.edu#include <list> 166019Shines@cs.fsu.edu 176019Shines@cs.fsu.edu/** 186019Shines@cs.fsu.edu * Basically a wrapper class to hold both the branch predictor 196019Shines@cs.fsu.edu * and the BTB. Right now I'm unsure of the implementation; it would 206019Shines@cs.fsu.edu * be nicer to have something closer to the CPUPolicy or the Impl where 216019Shines@cs.fsu.edu * this is just typedefs, but it forces the upper level stages to be 226019Shines@cs.fsu.edu * aware of the constructors of the BP and the BTB. The nicer thing 236019Shines@cs.fsu.edu * to do is have this templated on the Impl, accept the usual Params 246019Shines@cs.fsu.edu * object, and be able to call the constructors on the BP and BTB. 256019Shines@cs.fsu.edu */ 266019Shines@cs.fsu.edutemplate<class Impl> 276019Shines@cs.fsu.educlass TwobitBPredUnit 286019Shines@cs.fsu.edu{ 296019Shines@cs.fsu.edu public: 306019Shines@cs.fsu.edu typedef typename Impl::Params Params; 316019Shines@cs.fsu.edu typedef typename Impl::DynInstPtr DynInstPtr; 326019Shines@cs.fsu.edu 336019Shines@cs.fsu.edu TwobitBPredUnit(Params ¶ms); 346019Shines@cs.fsu.edu 356019Shines@cs.fsu.edu void regStats(); 366019Shines@cs.fsu.edu 376019Shines@cs.fsu.edu bool predict(DynInstPtr &inst, Addr &PC); 386019Shines@cs.fsu.edu 396019Shines@cs.fsu.edu void update(const InstSeqNum &done_sn); 406019Shines@cs.fsu.edu 416019Shines@cs.fsu.edu void squash(const InstSeqNum &squashed_sn); 426019Shines@cs.fsu.edu 438449Sgblack@eecs.umich.edu void squash(const InstSeqNum &squashed_sn, const Addr &corr_target, 448449Sgblack@eecs.umich.edu bool actually_taken); 458449Sgblack@eecs.umich.edu 468449Sgblack@eecs.umich.edu bool BPLookup(Addr &inst_PC) 478449Sgblack@eecs.umich.edu { return BP.lookup(inst_PC); } 488449Sgblack@eecs.umich.edu 4913759Sgiacomo.gabrielli@arm.com bool BTBValid(Addr &inst_PC) 508449Sgblack@eecs.umich.edu { return BTB.valid(inst_PC); } 5112386Sgabeblack@google.com 528449Sgblack@eecs.umich.edu Addr BTBLookup(Addr &inst_PC) 5312110SRekai.GonzalezAlberquilla@arm.com { return BTB.lookup(inst_PC); } 5413915Sgabeblack@google.com 5512110SRekai.GonzalezAlberquilla@arm.com // Will want to include global history. 5612110SRekai.GonzalezAlberquilla@arm.com void BPUpdate(Addr &inst_PC, bool taken) 5713759Sgiacomo.gabrielli@arm.com { BP.update(inst_PC, taken); } 5813759Sgiacomo.gabrielli@arm.com 5913915Sgabeblack@google.com void BTBUpdate(Addr &inst_PC, Addr &target_PC) 6013759Sgiacomo.gabrielli@arm.com { BTB.update(inst_PC, target_PC); } 616019Shines@cs.fsu.edu 626019Shines@cs.fsu.edu private: 636312Sgblack@eecs.umich.edu struct PredictorHistory { 646312Sgblack@eecs.umich.edu PredictorHistory(const InstSeqNum &seq_num, const Addr &inst_PC, 657720Sgblack@eecs.umich.edu const bool pred_taken) 666312Sgblack@eecs.umich.edu : seqNum(seq_num), PC(inst_PC), predTaken(pred_taken), 677186Sgblack@eecs.umich.edu globalHistory(0), usedRAS(0), wasCall(0), RASIndex(0), 687720Sgblack@eecs.umich.edu RASTarget(0) 697186Sgblack@eecs.umich.edu { } 707186Sgblack@eecs.umich.edu 716312Sgblack@eecs.umich.edu InstSeqNum seqNum; 727093Sgblack@eecs.umich.edu 736312Sgblack@eecs.umich.edu Addr PC; 746312Sgblack@eecs.umich.edu 757148Sgblack@eecs.umich.edu bool predTaken; 767148Sgblack@eecs.umich.edu 777148Sgblack@eecs.umich.edu unsigned globalHistory; 787148Sgblack@eecs.umich.edu 797184Sgblack@eecs.umich.edu bool usedRAS; 807184Sgblack@eecs.umich.edu 817289Sgblack@eecs.umich.edu bool wasCall; 827289Sgblack@eecs.umich.edu 837289Sgblack@eecs.umich.edu unsigned RASIndex; 847289Sgblack@eecs.umich.edu 857184Sgblack@eecs.umich.edu Addr RASTarget; 867184Sgblack@eecs.umich.edu }; 877184Sgblack@eecs.umich.edu 887184Sgblack@eecs.umich.edu std::list<PredictorHistory> predHist; 897184Sgblack@eecs.umich.edu 907184Sgblack@eecs.umich.edu DefaultBP BP; 9110037SARM gem5 Developers 9210037SARM gem5 Developers DefaultBTB BTB; 9310037SARM gem5 Developers 9410037SARM gem5 Developers ReturnAddrStack RAS; 9510037SARM gem5 Developers 9610037SARM gem5 Developers Stats::Scalar<> lookups; 9710037SARM gem5 Developers Stats::Scalar<> condPredicted; 9810037SARM gem5 Developers Stats::Scalar<> condIncorrect; 9910037SARM gem5 Developers Stats::Scalar<> BTBLookups; 10010037SARM gem5 Developers Stats::Scalar<> BTBHits; 10110037SARM gem5 Developers Stats::Scalar<> BTBCorrect; 10210037SARM gem5 Developers Stats::Scalar<> usedRAS; 10310037SARM gem5 Developers Stats::Scalar<> RASIncorrect; 10410037SARM gem5 Developers}; 10510037SARM gem5 Developers 10610037SARM gem5 Developers#endif // __BPRED_UNIT_HH__ 10710037SARM gem5 Developers