bpred_unit.hh revision 1684
12SN/A 213575Sciro.santilli@arm.com#ifndef __BPRED_UNIT_HH__ 313575Sciro.santilli@arm.com#define __BPRED_UNIT_HH__ 413575Sciro.santilli@arm.com 513575Sciro.santilli@arm.com// For Addr type. 613575Sciro.santilli@arm.com#include "arch/alpha/isa_traits.hh" 713575Sciro.santilli@arm.com#include "base/statistics.hh" 813575Sciro.santilli@arm.com#include "cpu/inst_seq.hh" 913575Sciro.santilli@arm.com 1013575Sciro.santilli@arm.com#include "cpu/beta_cpu/2bit_local_pred.hh" 1113575Sciro.santilli@arm.com#include "cpu/beta_cpu/tournament_pred.hh" 1213575Sciro.santilli@arm.com#include "cpu/beta_cpu/btb.hh" 1311274Sshingarov@labware.com#include "cpu/beta_cpu/ras.hh" 1410595Sgabeblack@google.com 151762SN/A#include <list> 162SN/A 172SN/A/** 182SN/A * Basically a wrapper class to hold both the branch predictor 192SN/A * and the BTB. Right now I'm unsure of the implementation; it would 202SN/A * be nicer to have something closer to the CPUPolicy or the Impl where 212SN/A * this is just typedefs, but it forces the upper level stages to be 222SN/A * aware of the constructors of the BP and the BTB. The nicer thing 232SN/A * to do is have this templated on the Impl, accept the usual Params 242SN/A * object, and be able to call the constructors on the BP and BTB. 252SN/A */ 262SN/Atemplate<class Impl> 272SN/Aclass TwobitBPredUnit 282SN/A{ 292SN/A public: 302SN/A typedef typename Impl::Params Params; 312SN/A typedef typename Impl::DynInstPtr DynInstPtr; 322SN/A 332SN/A TwobitBPredUnit(Params ¶ms); 342SN/A 352SN/A void regStats(); 362SN/A 372SN/A bool predict(DynInstPtr &inst, Addr &PC); 382SN/A 392SN/A void update(const InstSeqNum &done_sn); 402665Ssaidi@eecs.umich.edu 412665Ssaidi@eecs.umich.edu void squash(const InstSeqNum &squashed_sn); 4211274Sshingarov@labware.com 432SN/A void squash(const InstSeqNum &squashed_sn, const Addr &corr_target, 442SN/A bool actually_taken); 452SN/A 462SN/A bool BPLookup(Addr &inst_PC) 472SN/A { return BP.lookup(inst_PC); } 483960Sgblack@eecs.umich.edu 4977SN/A bool BTBValid(Addr &inst_PC) 5012031Sgabeblack@google.com { return BTB.valid(inst_PC); } 518229Snate@binkert.org 5212031Sgabeblack@google.com Addr BTBLookup(Addr &inst_PC) 538229Snate@binkert.org { return BTB.lookup(inst_PC); } 542986Sgblack@eecs.umich.edu 5510595Sgabeblack@google.com // Will want to include global history. 5656SN/A void BPUpdate(Addr &inst_PC, bool taken) 5756SN/A { BP.update(inst_PC, taken); } 588229Snate@binkert.org 592SN/A void BTBUpdate(Addr &inst_PC, Addr &target_PC) 602SN/A { BTB.update(inst_PC, target_PC); } 612680Sktlim@umich.edu 622SN/A private: 6312449Sgabeblack@google.com struct PredictorHistory { 6412449Sgabeblack@google.com PredictorHistory(const InstSeqNum &seq_num, const Addr &inst_PC, 653536Sgblack@eecs.umich.edu const bool pred_taken) 6612449Sgabeblack@google.com : seqNum(seq_num), PC(inst_PC), predTaken(pred_taken), 6712449Sgabeblack@google.com globalHistory(0), usedRAS(0), wasCall(0), RASIndex(0), 6812449Sgabeblack@google.com RASTarget(0) 6912449Sgabeblack@google.com { } 7012449Sgabeblack@google.com 7112449Sgabeblack@google.com InstSeqNum seqNum; 7212449Sgabeblack@google.com 7312449Sgabeblack@google.com Addr PC; 742SN/A 7512031Sgabeblack@google.com bool predTaken; 7612031Sgabeblack@google.com 7712449Sgabeblack@google.com unsigned globalHistory; 7812449Sgabeblack@google.com 7912449Sgabeblack@google.com bool usedRAS; 8012449Sgabeblack@google.com 8112449Sgabeblack@google.com bool wasCall; 8212449Sgabeblack@google.com 8312031Sgabeblack@google.com unsigned RASIndex; 8412449Sgabeblack@google.com 8512449Sgabeblack@google.com Addr RASTarget; 8612449Sgabeblack@google.com }; 8712449Sgabeblack@google.com 8812449Sgabeblack@google.com std::list<PredictorHistory> predHist; 8912031Sgabeblack@google.com 9012449Sgabeblack@google.com DefaultBP BP; 9112449Sgabeblack@google.com 9212449Sgabeblack@google.com DefaultBTB BTB; 9312449Sgabeblack@google.com 9412449Sgabeblack@google.com ReturnAddrStack RAS; 9512449Sgabeblack@google.com 9612449Sgabeblack@google.com Stats::Scalar<> lookups; 9712449Sgabeblack@google.com Stats::Scalar<> condPredicted; 9812449Sgabeblack@google.com Stats::Scalar<> condIncorrect; 9912449Sgabeblack@google.com Stats::Scalar<> BTBLookups; 10012449Sgabeblack@google.com Stats::Scalar<> BTBHits; 10112449Sgabeblack@google.com Stats::Scalar<> BTBCorrect; 10212449Sgabeblack@google.com Stats::Scalar<> usedRAS; 10312449Sgabeblack@google.com Stats::Scalar<> RASIncorrect; 10412449Sgabeblack@google.com}; 10512449Sgabeblack@google.com 10612449Sgabeblack@google.com#endif // __BPRED_UNIT_HH__ 10712449Sgabeblack@google.com