cpu: Add a StaticInst::advancePC which takes a ThreadContext.

This will avoid having to create a new heap allocated PCState, since the
instruction will know what type of backing storage to allocate on the
stack for the working copy.

Change-Id: Id208e015f6cb764bf7b13e0faf1677278b7e4641
Reviewed-on: https://gem5-review.googlesource.com/c/public/gem5/+/52069
Reviewed-by: Daniel Carvalho <odanrc@yahoo.com.br>
Maintainer: Gabe Black <gabe.black@gmail.com>
Tested-by: kokoro <noreply+kokoro@google.com>
This commit is contained in:
Gabe Black
2021-10-24 23:33:10 -07:00
parent 7216fc8e29
commit 0f90b7cb09
4 changed files with 14 additions and 7 deletions

View File

@@ -74,10 +74,8 @@ Checker<DynInstPtr>::advancePC(const Fault &fault)
if (curStaticInst) {
if (curStaticInst->isLastMicroop())
curMacroStaticInst = nullStaticInstPtr;
std::unique_ptr<PCStateBase> pc_ptr(thread->pcState().clone());
curStaticInst->advancePC(*pc_ptr);
thread->pcState(*pc_ptr);
DPRINTF(Checker, "Advancing PC to %s.\n", *pc_ptr);
curStaticInst->advancePC(thread);
DPRINTF(Checker, "Advancing PC to %s.\n", thread->pcState());
}
}
}

View File

@@ -474,9 +474,7 @@ BaseSimpleCPU::advancePC(const Fault &fault)
if (curStaticInst) {
if (curStaticInst->isLastMicroop())
curMacroStaticInst = nullStaticInstPtr;
std::unique_ptr<PCStateBase> pc(thread->pcState().clone());
curStaticInst->advancePC(*pc);
thread->pcState(*pc);
curStaticInst->advancePC(thread);
}
}

View File

@@ -30,6 +30,8 @@
#include <iostream>
#include "cpu/thread_context.hh"
namespace gem5
{
@@ -82,4 +84,12 @@ StaticInst::printFlags(std::ostream &outs,
}
}
void
StaticInst::advancePC(ThreadContext *tc) const
{
std::unique_ptr<PCStateBase> pc(tc->pcState().clone());
advancePC(*pc);
tc->pcState(*pc);
}
} // namespace gem5

View File

@@ -320,6 +320,7 @@ class StaticInst : public RefCounted, public StaticInstFlags
}
virtual void advancePC(PCStateBase &pc_state) const = 0;
virtual void advancePC(ThreadContext *tc) const;
virtual std::unique_ptr<PCStateBase>
buildRetPC(const PCStateBase &cur_pc, const PCStateBase &call_pc) const