#include "cpu/inorder/resources/branch_predictor.hh"
#include "debug/InOrderBPred.hh"
#include "debug/InOrderStage.hh"
+#include "debug/Resource.hh"
using namespace std;
using namespace TheISA;
using namespace ThePipeline;
-BranchPredictor::BranchPredictor(std::string res_name, int res_id, int res_width,
- int res_latency, InOrderCPU *_cpu,
+BranchPredictor::BranchPredictor(std::string res_name, int res_id,
+ int res_width, Cycles res_latency,
+ InOrderCPU *_cpu,
ThePipeline::Params *params)
: Resource(res_name, res_id, res_width, res_latency, _cpu),
- branchPred(this, params)
+ branchPred(params->branchPred)
{
instSize = sizeof(MachInst);
}
.desc("Number of Branches Predicted As Not Taken (False).");
Resource::regStats();
-
- branchPred.regStats();
}
void
DPRINTF(InOrderStage, "[tid:%u]: [sn:%i]: squashed, "
"skipping prediction \n", tid, inst->seqNum);
} else {
+ TheISA::PCState instPC = inst->pcState();
TheISA::PCState pred_PC = inst->pcState();
TheISA::advancePC(pred_PC, inst->staticInst);
// If not, the pred_PC be updated to pc+8
// If predicted, the pred_PC will be updated to new target
// value
- bool predict_taken = branchPred.predict(inst, pred_PC, tid);
+ bool predict_taken = branchPred->predictInOrder(
+ inst->staticInst, inst->seqNum,
+ inst->asid, instPC, pred_PC, tid);
if (predict_taken) {
DPRINTF(InOrderBPred, "[tid:%i]: [sn:%i]: Branch "
inst->setBranchPred(predict_taken);
}
- //@todo: Check to see how hw_rei is handled here...how does PC,NPC get
- // updated to compare mispredict against???
+ //@todo: Check to see how hw_rei is handled here...how does
+ //PC,NPC get updated to compare mispredict against???
inst->setPredTarg(pred_PC);
DPRINTF(InOrderBPred, "[tid:%i]: [sn:%i]: %s Predicted PC is "
"%s.\n", tid, seq_num, inst->instName(), pred_PC);
tid, seq_num);
- branchPred.update(seq_num, tid);
+ branchPred->update(seq_num, tid);
}
bpred_req->done();
// update due to branch resolution
if (squash_stage >= ThePipeline::BackEndStartStage) {
- branchPred.squash(bpred_squash_num,
- inst->pcState(),
- inst->pcState().branching(),
- tid);
+ branchPred->squash(bpred_squash_num, inst->pcState(),
+ inst->pcState().branching(), tid);
} else {
// update due to predicted taken branch
- branchPred.squash(bpred_squash_num, tid);
+ branchPred->squash(bpred_squash_num, tid);
}
}
void
BranchPredictor::instGraduated(InstSeqNum seq_num, ThreadID tid)
{
- branchPred.update(seq_num, tid);
+ branchPred->update(seq_num, tid);
}