From f8b8ab90ac2940cbc968dae48a55460bd539a330 Mon Sep 17 00:00:00 2001 From: Gabe Black Date: Sat, 16 Oct 2021 03:58:45 -0700 Subject: [PATCH] arch: Make the advance() method virtual and in PCStateBase. It's occasionally necessary to advance the PC to the next instruction without having an instruction to do it with. This makes it available without having to cast to a PCState subclass. Change-Id: I3b7d94afdfb27b34279e58158782e87ab5066a37 Reviewed-on: https://gem5-review.googlesource.com/c/public/gem5/+/52065 Tested-by: kokoro Maintainer: Gabe Black Reviewed-by: Daniel Carvalho --- src/arch/arm/pcstate.hh | 2 +- src/arch/generic/pcstate.hh | 6 ++++-- src/arch/x86/pcstate.hh | 2 +- src/cpu/nop_static_inst.cc | 4 ++-- src/sim/syscall_emul.hh | 4 ++-- 5 files changed, 10 insertions(+), 8 deletions(-) diff --git a/src/arch/arm/pcstate.hh b/src/arch/arm/pcstate.hh index 122cd9b584..f2d85d24f3 100644 --- a/src/arch/arm/pcstate.hh +++ b/src/arch/arm/pcstate.hh @@ -288,7 +288,7 @@ class PCState : public GenericISA::UPCState<4> } void - advance() + advance() override { Base::advance(); flags = nextFlags; diff --git a/src/arch/generic/pcstate.hh b/src/arch/generic/pcstate.hh index 3e7b025363..415e80d826 100644 --- a/src/arch/generic/pcstate.hh +++ b/src/arch/generic/pcstate.hh @@ -126,6 +126,8 @@ class PCStateBase : public Serializable _upc = 0; } + virtual void advance() = 0; + void serialize(CheckpointOut &cp) const override { @@ -370,7 +372,7 @@ class SimplePCState : public PCStateCommon // Advance the PC. void - advance() + advance() override { this->_pc = this->_npc; this->_npc += InstWidth; @@ -493,7 +495,7 @@ class DelaySlotPCState : public SimplePCState // Advance the PC. void - advance() + advance() override { this->_pc = this->_npc; this->_npc = this->_nnpc; diff --git a/src/arch/x86/pcstate.hh b/src/arch/x86/pcstate.hh index 8d74806e81..bfc7d4fa1d 100644 --- a/src/arch/x86/pcstate.hh +++ b/src/arch/x86/pcstate.hh @@ -95,7 +95,7 @@ class PCState : public GenericISA::UPCState<8> } void - advance() + advance() override { Base::advance(); _size = 0; diff --git a/src/cpu/nop_static_inst.cc b/src/cpu/nop_static_inst.cc index 64b542d87a..aa344819d4 100644 --- a/src/cpu/nop_static_inst.cc +++ b/src/cpu/nop_static_inst.cc @@ -50,9 +50,9 @@ class NopStaticInst : public StaticInst } void - advancePC(PCStateBase &pcState) const override + advancePC(PCStateBase &pc) const override { - pcState.as().advance(); + pc.advance(); } std::string diff --git a/src/sim/syscall_emul.hh b/src/sim/syscall_emul.hh index 54bd54b5d2..c53175b011 100644 --- a/src/sim/syscall_emul.hh +++ b/src/sim/syscall_emul.hh @@ -1662,7 +1662,7 @@ cloneFunc(SyscallDesc *desc, ThreadContext *tc, RegVal flags, RegVal newStack, desc->returnInto(ctc, 0); std::unique_ptr cpc(tc->pcState().clone()); - cpc->as().advance(); + cpc->advance(); ctc->pcState(*cpc); ctc->activate(); @@ -2226,7 +2226,7 @@ execveFunc(SyscallDesc *desc, ThreadContext *tc, new_p->initState(); tc->activate(); std::unique_ptr pc_state(tc->pcState().clone()); - pc_state->as().advance(); + pc_state->advance(); tc->pcState(*pc_state); return SyscallReturn();