Gabe Black has uploaded this change for review. (
https://gem5-review.googlesource.com/c/public/gem5/+/48704 )
Change subject: arch: Promote the micropc to the base PCState class.
......................................................................
arch: Promote the micropc to the base PCState class.
The ISAs we support today mostly have a micropc, whether that's used
very heavily like on x86, or sparsely like on ARM, RISCV or SPARC. Only
MIPS and POWER don't currently use a micropc, and neither of those is
performance tuned to the point where adding some size to the PC object
should make a meaningful difference.
Because most ISAs already have a micropc anyway, and some minimal part
of managing the micropc has to be part of the guaranteed interface so
that the CPUs can work, it's a small step to make the micropc more
completely part of the base class.
This change also makes uReset part of the guaranteed interface so we can
get rid of an #if THE_ISA == in the minor CPU.
Change-Id: Ide55a8feaee0bd5fff1d7ec05f95ad30a496b196
---
M src/arch/generic/pcstate.hh
1 file changed, 32 insertions(+), 51 deletions(-)
diff --git a/src/arch/generic/pcstate.hh b/src/arch/generic/pcstate.hh
index 470e9e5..0d73470 100644
--- a/src/arch/generic/pcstate.hh
+++ b/src/arch/generic/pcstate.hh
@@ -57,11 +57,14 @@
class PCStateBase : public Serializable
{
protected:
- Addr _pc;
- Addr _npc;
+ Addr _pc = 0;
+ Addr _npc = 0;
- PCStateBase() : _pc(0), _npc(0) {}
- PCStateBase(Addr val) : _pc(0), _npc(0) { set(val); }
+ MicroPC _upc = 0;
+ MicroPC _nupc = 1;
+
+ PCStateBase() {}
+ PCStateBase(Addr val) { set(val); }
public:
/**
@@ -94,7 +97,15 @@
MicroPC
microPC() const
{
- return 0;
+ return _upc;
+ }
+
+ // Reset the macroop's upc without advancing the regular pc.
+ void
+ uReset()
+ {
+ _upc = 0;
+ _nupc = 1;
}
/**
@@ -122,6 +133,8 @@
{
SERIALIZE_SCALAR(_pc);
SERIALIZE_SCALAR(_npc);
+ SERIALIZE_SCALAR(_upc);
+ SERIALIZE_SCALAR(_nupc);
}
void
@@ -129,6 +142,8 @@
{
UNSERIALIZE_SCALAR(_pc);
UNSERIALIZE_SCALAR(_npc);
+ UNSERIALIZE_SCALAR(_upc);
+ UNSERIALIZE_SCALAR(_nupc);
}
};
@@ -200,22 +215,13 @@
protected:
typedef SimplePCState<InstWidth> Base;
- MicroPC _upc;
- MicroPC _nupc;
-
public:
- MicroPC upc() const { return _upc; }
- void upc(MicroPC val) { _upc = val; }
+ MicroPC upc() const { return this->_upc; }
+ void upc(MicroPC val) { this->_upc = val; }
- MicroPC nupc() const { return _nupc; }
- void nupc(MicroPC val) { _nupc = val; }
-
- MicroPC
- microPC() const
- {
- return _upc;
- }
+ MicroPC nupc() const { return this->_nupc; }
+ void nupc(MicroPC val) { this->_nupc = val; }
void
set(Addr val)
@@ -225,8 +231,8 @@
nupc(1);
}
- UPCState() : _upc(0), _nupc(1) {}
- UPCState(Addr val) : _upc(0), _nupc(0) { set(val); }
+ UPCState() {}
+ UPCState(Addr val) { set(val); }
bool
branching() const
@@ -239,8 +245,8 @@
void
uAdvance()
{
- _upc = _nupc;
- _nupc++;
+ upc(nupc());
+ nupc(nupc() + 1);
}
// End the macroop by resetting the upc and advancing the regular pc.
@@ -248,24 +254,15 @@
uEnd()
{
this->advance();
- _upc = 0;
- _nupc = 1;
- }
-
- // Reset the macroop's upc without advancing the regular pc.
- void
- uReset()
- {
- _upc = 0;
- _nupc = 1;
+ upc(0);
+ nupc(1);
}
bool
operator == (const UPCState<InstWidth> &opc) const
{
- return Base::_pc == opc._pc &&
- Base::_npc == opc._npc &&
- _upc == opc._upc && _nupc == opc._nupc;
+ return this->pc() == opc.pc() && this->npc() == opc.npc() &&
+ this->upc() == opc.upc() && this->nupc() == opc.nupc();
}
bool
@@ -273,22 +270,6 @@
{
return !(*this == opc);
}
-
- void
- serialize(CheckpointOut &cp) const override
- {
- Base::serialize(cp);
- SERIALIZE_SCALAR(_upc);
- SERIALIZE_SCALAR(_nupc);
- }
-
- void
- unserialize(CheckpointIn &cp) override
- {
- Base::unserialize(cp);
- UNSERIALIZE_SCALAR(_upc);
- UNSERIALIZE_SCALAR(_nupc);
- }
};
template <int InstWidth>
--
To view, visit https://gem5-review.googlesource.com/c/public/gem5/+/48704
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: Ide55a8feaee0bd5fff1d7ec05f95ad30a496b196
Gerrit-Change-Number: 48704
Gerrit-PatchSet: 1
Gerrit-Owner: Gabe Black <[email protected]>
Gerrit-MessageType: newchange
_______________________________________________
gem5-dev mailing list -- [email protected]
To unsubscribe send an email to [email protected]
%(web_page_url)slistinfo%(cgiext)s/%(_internal_name)s