Gabe Black has submitted this change. (
https://gem5-review.googlesource.com/c/public/gem5/+/52038 )
Change subject: arch: Add a virtually backed PCState == operator.
......................................................................
arch: Add a virtually backed PCState == operator.
Define a == operator and an equals() virtual method for the PCStateBase
class which it calls. The equals method will compare the owning PCState
instance with another instance of the same PCState class.
Change-Id: Ia704f1bc9e1217ce191671fe574c226ee1b73278
Reviewed-on: https://gem5-review.googlesource.com/c/public/gem5/+/52038
Maintainer: Gabe Black <[email protected]>
Tested-by: kokoro <[email protected]>
Reviewed-by: Earl Ou <[email protected]>
Reviewed-by: Daniel Carvalho <[email protected]>
---
M src/arch/generic/pcstate.hh
M src/arch/arm/pcstate.hh
2 files changed, 46 insertions(+), 55 deletions(-)
Approvals:
Earl Ou: Looks good to me, approved
Daniel Carvalho: Looks good to me, but someone else must approve
Gabe Black: Looks good to me, approved
kokoro: Regressions pass
diff --git a/src/arch/arm/pcstate.hh b/src/arch/arm/pcstate.hh
index d2f3cef..b1d0b74 100644
--- a/src/arch/arm/pcstate.hh
+++ b/src/arch/arm/pcstate.hh
@@ -376,9 +376,10 @@
}
bool
- operator == (const PCState &opc) const
+ equals(const PCStateBase &other) const override
{
- return Base::operator == (opc) &&
+ auto &opc = other.as<PCState>();
+ return Base::equals(other) &&
flags == opc.flags && nextFlags == opc.nextFlags &&
_itstate == opc._itstate &&
_nextItstate == opc._nextItstate &&
@@ -387,12 +388,6 @@
_stepped == opc._stepped;
}
- bool
- operator != (const PCState &opc) const
- {
- return !(*this == opc);
- }
-
void
serialize(CheckpointOut &cp) const override
{
diff --git a/src/arch/generic/pcstate.hh b/src/arch/generic/pcstate.hh
index 32ee206..284797d 100644
--- a/src/arch/generic/pcstate.hh
+++ b/src/arch/generic/pcstate.hh
@@ -80,6 +80,12 @@
virtual PCStateBase *clone() const = 0;
+ virtual bool
+ equals(const PCStateBase &other) const
+ {
+ return _pc == other._pc && _upc == other._upc;
+ }
+
/**
* Returns the memory address of the instruction this PC points to.
*
@@ -117,6 +123,18 @@
}
};
+static inline bool
+operator==(const PCStateBase &a, const PCStateBase &b)
+{
+ return a.equals(b);
+}
+
+static inline bool
+operator!=(const PCStateBase &a, const PCStateBase &b)
+{
+ return !a.equals(b);
+}
+
namespace GenericISA
{
@@ -172,15 +190,11 @@
}
bool
- operator == (const PCStateCommon &opc) const
+ equals(const PCStateBase &other) const override
{
- return _pc == opc._pc && _npc == opc._npc;
- }
-
- bool
- operator != (const PCStateCommon &opc) const
- {
- return !(*this == opc);
+ auto &ps = other.as<PCStateCommon>();
+ return PCStateBase::equals(other) &&
+ _npc == ps._npc && _nupc == ps._nupc;
}
void
@@ -312,19 +326,6 @@
this->upc(0);
this->nupc(1);
}
-
- bool
- operator == (const UPCState<InstWidth> &opc) const
- {
- return this->pc() == opc.pc() && this->npc() == opc.npc() &&
- this->upc() == opc.upc() && this->nupc() == opc.nupc();
- }
-
- bool
- operator != (const UPCState<InstWidth> &opc) const
- {
- return !(*this == opc);
- }
};
template <int InstWidth>
@@ -387,17 +388,10 @@
}
bool
- operator == (const DelaySlotPCState<InstWidth> &opc) const
+ equals(const PCStateBase &other) const override
{
- return this->_pc == opc._pc &&
- this->_npc == opc._npc &&
- this->_nnpc == opc._nnpc;
- }
-
- bool
- operator != (const DelaySlotPCState<InstWidth> &opc) const
- {
- return !(*this == opc);
+ auto &ps = other.as<DelaySlotPCState<InstWidth>>();
+ return Base::equals(other) && ps._nnpc == this->_nnpc;
}
void
@@ -473,22 +467,6 @@
this->_upc = 0;
this->_nupc = 1;
}
-
- bool
- operator == (const DelaySlotUPCState<InstWidth> &opc) const
- {
- return this->_pc == opc._pc &&
- this->_npc == opc._npc &&
- this->_nnpc == opc._nnpc &&
- this->_upc == opc._upc &&
- this->_nupc == opc._nupc;
- }
-
- bool
- operator != (const DelaySlotUPCState<InstWidth> &opc) const
- {
- return !(*this == opc);
- }
};
template <int InstWidth>
--
To view, visit https://gem5-review.googlesource.com/c/public/gem5/+/52038
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: Ia704f1bc9e1217ce191671fe574c226ee1b73278
Gerrit-Change-Number: 52038
Gerrit-PatchSet: 14
Gerrit-Owner: Gabe Black <[email protected]>
Gerrit-Reviewer: Daniel Carvalho <[email protected]>
Gerrit-Reviewer: Earl Ou <[email protected]>
Gerrit-Reviewer: Gabe Black <[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