cpu-minor: Ensure the pc in BranchData is always set.
Change the type passed to updateBranchData in execute to be a reference, and replace the nullptr being passed in from Execute::evaluate() with the current thread's pc. We could use any generic PC instead which might be slightly faster, but there is likely not a significant difference and this is a lot easier. Change-Id: I306ca53b33997f76217c61123e5922df612005f9 Reviewed-on: https://gem5-review.googlesource.com/c/public/gem5/+/53584 Maintainer: Gabe Black <gabe.black@gmail.com> Reviewed-by: Bobby Bruce <bbruce@ucdavis.edu> Tested-by: kokoro <noreply+kokoro@google.com>
This commit is contained in:
@@ -296,14 +296,14 @@ Execute::tryToBranch(MinorDynInstPtr inst, Fault fault, BranchData &branch)
|
||||
reason = BranchData::NoBranch;
|
||||
}
|
||||
|
||||
updateBranchData(inst->id.threadId, reason, inst, target.get(), branch);
|
||||
updateBranchData(inst->id.threadId, reason, inst, *target, branch);
|
||||
}
|
||||
|
||||
void
|
||||
Execute::updateBranchData(
|
||||
ThreadID tid,
|
||||
BranchData::Reason reason,
|
||||
MinorDynInstPtr inst, const PCStateBase *target,
|
||||
MinorDynInstPtr inst, const PCStateBase &target,
|
||||
BranchData &branch)
|
||||
{
|
||||
if (reason != BranchData::NoBranch) {
|
||||
@@ -443,7 +443,7 @@ Execute::takeInterrupt(ThreadID thread_id, BranchData &branch)
|
||||
/* Assume that an interrupt *must* cause a branch. Assert this? */
|
||||
|
||||
updateBranchData(thread_id, BranchData::Interrupt,
|
||||
MinorDynInst::bubble(), &cpu.getContext(thread_id)->pcState(),
|
||||
MinorDynInst::bubble(), cpu.getContext(thread_id)->pcState(),
|
||||
branch);
|
||||
}
|
||||
|
||||
@@ -1032,7 +1032,7 @@ Execute::commitInst(MinorDynInstPtr inst, bool early_memory_issue,
|
||||
cpu.stats.numFetchSuspends++;
|
||||
|
||||
updateBranchData(thread_id, BranchData::SuspendThread, inst,
|
||||
&resume_pc, branch);
|
||||
resume_pc, branch);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1140,7 +1140,7 @@ Execute::commit(ThreadID thread_id, bool only_commit_microops, bool discard,
|
||||
|
||||
/* Branch as there was a change in PC */
|
||||
updateBranchData(thread_id, BranchData::UnpredictedBranch,
|
||||
MinorDynInst::bubble(), &thread->pcState(), branch);
|
||||
MinorDynInst::bubble(), thread->pcState(), branch);
|
||||
} else if (mem_response &&
|
||||
num_mem_refs_committed < memoryCommitLimit)
|
||||
{
|
||||
@@ -1495,7 +1495,8 @@ Execute::evaluate()
|
||||
* the bag */
|
||||
if (commit_info.drainState == DrainHaltFetch) {
|
||||
updateBranchData(commit_tid, BranchData::HaltFetch,
|
||||
MinorDynInst::bubble(), nullptr, branch);
|
||||
MinorDynInst::bubble(),
|
||||
cpu.getContext(commit_tid)->pcState(), branch);
|
||||
|
||||
cpu.wakeupOnEvent(Pipeline::ExecuteStageId);
|
||||
setDrainState(commit_tid, DrainAllInsts);
|
||||
|
||||
@@ -232,7 +232,7 @@ class Execute : public Named
|
||||
/** Actually create a branch to communicate to Fetch1/Fetch2 and,
|
||||
* if that is a stream-changing branch update the streamSeqNum */
|
||||
void updateBranchData(ThreadID tid, BranchData::Reason reason,
|
||||
MinorDynInstPtr inst, const PCStateBase *target, BranchData &branch);
|
||||
MinorDynInstPtr inst, const PCStateBase &target, BranchData &branch);
|
||||
|
||||
/** Handle extracting mem ref responses from the memory queues and
|
||||
* completing the associated instructions.
|
||||
|
||||
@@ -223,7 +223,7 @@ Fetch2::predictBranch(MinorDynInstPtr inst, BranchData &branch)
|
||||
BranchData new_branch = BranchData(BranchData::BranchPrediction,
|
||||
inst->id.threadId,
|
||||
inst->id.streamSeqNum, thread.predictionSeqNum + 1,
|
||||
inst->predictedTarget.get(), inst);
|
||||
*inst->predictedTarget, inst);
|
||||
|
||||
/* Mark with a new prediction number by the stream number of the
|
||||
* instruction causing the prediction */
|
||||
|
||||
@@ -130,7 +130,7 @@ class BranchData /* : public ReportIF, public BubbleIF */
|
||||
|
||||
BranchData(Reason reason_, ThreadID thread_id,
|
||||
InstSeqNum new_stream_seq_num, InstSeqNum new_prediction_seq_num,
|
||||
const PCStateBase *_target, MinorDynInstPtr inst_) :
|
||||
const PCStateBase &_target, MinorDynInstPtr inst_) :
|
||||
reason(reason_), threadId(thread_id),
|
||||
newStreamSeqNum(new_stream_seq_num),
|
||||
newPredictionSeqNum(new_prediction_seq_num),
|
||||
|
||||
Reference in New Issue
Block a user