Gabe Black has submitted this change. ( https://gem5-review.googlesource.com/c/public/gem5/+/53584 )

Change subject: cpu-minor: Ensure the pc in BranchData is always set.
......................................................................

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 <[email protected]>
Reviewed-by: Bobby Bruce <[email protected]>
Tested-by: kokoro <[email protected]>
---
M src/cpu/minor/execute.cc
M src/cpu/minor/execute.hh
M src/cpu/minor/fetch2.cc
M src/cpu/minor/pipe_data.hh
4 files changed, 29 insertions(+), 9 deletions(-)

Approvals:
  Bobby Bruce: Looks good to me, approved
  Gabe Black: Looks good to me, approved
  kokoro: Regressions pass




diff --git a/src/cpu/minor/execute.cc b/src/cpu/minor/execute.cc
index 8de0c56..c09f3be 100644
--- a/src/cpu/minor/execute.cc
+++ b/src/cpu/minor/execute.cc
@@ -296,14 +296,14 @@
         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 @@
         /* 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 @@
             cpu.stats.numFetchSuspends++;

             updateBranchData(thread_id, BranchData::SuspendThread, inst,
-                &resume_pc, branch);
+                resume_pc, branch);
         }
     }

@@ -1140,7 +1140,7 @@

             /* 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 @@
              *  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);
diff --git a/src/cpu/minor/execute.hh b/src/cpu/minor/execute.hh
index 21720bb..9d184f7 100644
--- a/src/cpu/minor/execute.hh
+++ b/src/cpu/minor/execute.hh
@@ -232,7 +232,7 @@
     /** 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.
diff --git a/src/cpu/minor/fetch2.cc b/src/cpu/minor/fetch2.cc
index 82648d0..44789e2 100644
--- a/src/cpu/minor/fetch2.cc
+++ b/src/cpu/minor/fetch2.cc
@@ -223,7 +223,7 @@
         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 */
diff --git a/src/cpu/minor/pipe_data.hh b/src/cpu/minor/pipe_data.hh
index b736ea9..97651b4 100644
--- a/src/cpu/minor/pipe_data.hh
+++ b/src/cpu/minor/pipe_data.hh
@@ -130,7 +130,7 @@

     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),

--
To view, visit https://gem5-review.googlesource.com/c/public/gem5/+/53584
To unsubscribe, or for help writing mail filters, visit https://gem5-review.googlesource.com/settings

Gerrit-Project: public/gem5
Gerrit-Branch: develop
Gerrit-Change-Id: I306ca53b33997f76217c61123e5922df612005f9
Gerrit-Change-Number: 53584
Gerrit-PatchSet: 2
Gerrit-Owner: Gabe Black <[email protected]>
Gerrit-Reviewer: Bobby Bruce <[email protected]>
Gerrit-Reviewer: Gabe Black <[email protected]>
Gerrit-Reviewer: Giacomo Travaglini <[email protected]>
Gerrit-Reviewer: Jason Lowe-Power <[email protected]>
Gerrit-Reviewer: ZHENGRONG WANG <[email protected]>
Gerrit-Reviewer: kokoro <[email protected]>
Gerrit-MessageType: merged
_______________________________________________
gem5-dev mailing list -- [email protected]
To unsubscribe send an email to [email protected]
%(web_page_url)slistinfo%(cgiext)s/%(_internal_name)s

Reply via email to