Gabe Black has submitted this change. (
https://gem5-review.googlesource.com/c/public/gem5/+/52071 )
Change subject: cpu-simple: Use a local temporary for the PC in preExecute.
......................................................................
cpu-simple: Use a local temporary for the PC in preExecute.
This avoids having to dynamically allocate and then free a temporary
when working with the pc in preExecute.
Change-Id: Ic86e23d0f0c7e786122a6024a154bb2907a6afcb
Reviewed-on: https://gem5-review.googlesource.com/c/public/gem5/+/52071
Tested-by: kokoro <[email protected]>
Maintainer: Gabe Black <[email protected]>
Reviewed-by: Daniel Carvalho <[email protected]>
---
M src/cpu/simple/base.cc
M src/cpu/simple/base.hh
2 files changed, 31 insertions(+), 9 deletions(-)
Approvals:
Daniel Carvalho: Looks good to me, approved
Gabe Black: Looks good to me, approved
kokoro: Regressions pass
diff --git a/src/cpu/simple/base.cc b/src/cpu/simple/base.cc
index 0f11eb9..48809b5 100644
--- a/src/cpu/simple/base.cc
+++ b/src/cpu/simple/base.cc
@@ -313,14 +313,15 @@
t_info.setMemAccPredicate(true);
// decode the instruction
- std::unique_ptr<PCStateBase> pc_state(thread->pcState().clone());
+ set(preExecuteTempPC, thread->pcState());
+ auto &pc_state = *preExecuteTempPC;
auto &decoder = thread->decoder;
- if (isRomMicroPC(pc_state->microPC())) {
+ if (isRomMicroPC(pc_state.microPC())) {
t_info.stayAtPC = false;
curStaticInst = decoder.fetchRomMicroop(
- pc_state->microPC(), curMacroStaticInst);
+ pc_state.microPC(), curMacroStaticInst);
} else if (!curMacroStaticInst) {
//We're not in the middle of a macro instruction
StaticInstPtr instPtr = NULL;
@@ -328,16 +329,16 @@
//Predecode, ie bundle up an ExtMachInst
//If more fetch data is needed, pass it in.
Addr fetch_pc =
- (pc_state->instAddr() & decoder.pcMask()) + t_info.fetchOffset;
+ (pc_state.instAddr() & decoder.pcMask()) + t_info.fetchOffset;
- decoder.moreBytes(*pc_state, fetch_pc);
+ decoder.moreBytes(pc_state, fetch_pc);
//Decode an instruction if one is ready. Otherwise, we'll have to
//fetch beyond the MachInst at the current pc.
- instPtr = decoder.decode(*pc_state);
+ instPtr = decoder.decode(pc_state);
if (instPtr) {
t_info.stayAtPC = false;
- thread->pcState(*pc_state);
+ thread->pcState(pc_state);
} else {
t_info.stayAtPC = true;
t_info.fetchOffset += decoder.moreBytesSize();
@@ -348,13 +349,13 @@
if (instPtr && instPtr->isMacroop()) {
curMacroStaticInst = instPtr;
curStaticInst =
- curMacroStaticInst->fetchMicroop(pc_state->microPC());
+ curMacroStaticInst->fetchMicroop(pc_state.microPC());
} else {
curStaticInst = instPtr;
}
} else {
//Read the next micro op from the macro op
- curStaticInst =
curMacroStaticInst->fetchMicroop(pc_state->microPC());
+ curStaticInst =
curMacroStaticInst->fetchMicroop(pc_state.microPC());
}
//If we decoded an instruction this "tick", record information about
it.
diff --git a/src/cpu/simple/base.hh b/src/cpu/simple/base.hh
index 8c84ff9..45fd5ea 100644
--- a/src/cpu/simple/base.hh
+++ b/src/cpu/simple/base.hh
@@ -42,6 +42,9 @@
#ifndef __CPU_SIMPLE_BASE_HH__
#define __CPU_SIMPLE_BASE_HH__
+#include <memory>
+
+#include "arch/generic/pcstate.hh"
#include "base/statistics.hh"
#include "cpu/base.hh"
#include "cpu/checker/cpu.hh"
@@ -129,6 +132,8 @@
*/
void traceFault();
+ std::unique_ptr<PCStateBase> preExecuteTempPC;
+
public:
void checkForInterrupts();
void setupFetchRequest(const RequestPtr &req);
--
To view, visit https://gem5-review.googlesource.com/c/public/gem5/+/52071
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: Ic86e23d0f0c7e786122a6024a154bb2907a6afcb
Gerrit-Change-Number: 52071
Gerrit-PatchSet: 20
Gerrit-Owner: Gabe Black <[email protected]>
Gerrit-Reviewer: Daniel Carvalho <[email protected]>
Gerrit-Reviewer: Gabe Black <[email protected]>
Gerrit-Reviewer: Jason Lowe-Power <[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