Gabe Black has submitted this change. (
https://gem5-review.googlesource.com/c/public/gem5/+/52039 )
(
6 is the latest approved patch-set.
No files were changed between the latest approved patch-set and the
submitted one.
)Change subject: arch: Virtualize printing a PCState.
......................................................................
arch: Virtualize printing a PCState.
Introduce a virtual output() method which prints the current PCState to
the given output stream, and define an overload for << to use that
method. This will make it possible to print a PCState without knowing
what the actual type is.
Change-Id: I663619b168c0b2b90c148b45ae16d77f03934e5b
Reviewed-on: https://gem5-review.googlesource.com/c/public/gem5/+/52039
Tested-by: kokoro <[email protected]>
Reviewed-by: Bobby R. Bruce <[email protected]>
Maintainer: Bobby R. Bruce <[email protected]>
---
M src/arch/generic/pcstate.hh
1 file changed, 53 insertions(+), 35 deletions(-)
Approvals:
Bobby R. Bruce: Looks good to me, approved; Looks good to me, approved
kokoro: Regressions pass
diff --git a/src/arch/generic/pcstate.hh b/src/arch/generic/pcstate.hh
index 284797d..d4a317e 100644
--- a/src/arch/generic/pcstate.hh
+++ b/src/arch/generic/pcstate.hh
@@ -80,6 +80,8 @@
virtual PCStateBase *clone() const = 0;
+ virtual void output(std::ostream &os) const = 0;
+
virtual bool
equals(const PCStateBase &other) const
{
@@ -123,6 +125,13 @@
}
};
+static inline std::ostream &
+operator<<(std::ostream & os, const PCStateBase &pc)
+{
+ pc.output(os);
+ return os;
+}
+
static inline bool
operator==(const PCStateBase &a, const PCStateBase &b)
{
@@ -189,6 +198,12 @@
npc(val);
}
+ void
+ output(std::ostream &os) const override
+ {
+ ccprintf(os, "(%#x=>%#x)", this->pc(), this->npc());
+ }
+
bool
equals(const PCStateBase &other) const override
{
@@ -268,14 +283,6 @@
}
};
-template <int InstWidth>
-std::ostream &
-operator<<(std::ostream & os, const SimplePCState<InstWidth> &pc)
-{
- ccprintf(os, "(%#x=>%#x)", pc.pc(), pc.npc());
- return os;
-}
-
// A PC and microcode PC.
template <int InstWidth>
class UPCState : public SimplePCState<InstWidth>
@@ -284,6 +291,13 @@
typedef SimplePCState<InstWidth> Base;
public:
+ void
+ output(std::ostream &os) const override
+ {
+ Base::output(os);
+ ccprintf(os, ".(%d=>%d)", this->upc(), this->nupc());
+ }
+
PCStateBase *
clone() const override
{
@@ -328,15 +342,6 @@
}
};
-template <int InstWidth>
-std::ostream &
-operator<<(std::ostream & os, const UPCState<InstWidth> &pc)
-{
- ccprintf(os, "(%#x=>%#x).(%d=>%d)",
- pc.pc(), pc.npc(), pc.upc(), pc.nupc());
- return os;
-}
-
// A PC with a delay slot.
template <int InstWidth>
class DelaySlotPCState : public SimplePCState<InstWidth>
@@ -347,6 +352,12 @@
Addr _nnpc;
public:
+ void
+ output(std::ostream &os) const override
+ {
+ ccprintf(os, "(%#x=>%#x=>%#x)", this->pc(), this->npc(), nnpc());
+ }
+
PCStateBase *
clone() const override
{
@@ -409,15 +420,6 @@
}
};
-template <int InstWidth>
-std::ostream &
-operator<<(std::ostream & os, const DelaySlotPCState<InstWidth> &pc)
-{
- ccprintf(os, "(%#x=>%#x=>%#x)",
- pc.pc(), pc.npc(), pc.nnpc());
- return os;
-}
-
// A PC with a delay slot and a microcode PC.
template <int InstWidth>
class DelaySlotUPCState : public DelaySlotPCState<InstWidth>
@@ -426,6 +428,13 @@
typedef DelaySlotPCState<InstWidth> Base;
public:
+ void
+ output(std::ostream &os) const override
+ {
+ Base::output(os);
+ ccprintf(os, ".(%d=>%d)", this->upc(), this->nupc());
+ }
+
PCStateBase *
clone() const override
{
@@ -469,15 +478,6 @@
}
};
-template <int InstWidth>
-std::ostream &
-operator<<(std::ostream & os, const DelaySlotUPCState<InstWidth> &pc)
-{
- ccprintf(os, "(%#x=>%#x=>%#x).(%d=>%d)",
- pc.pc(), pc.npc(), pc.nnpc(), pc.upc(), pc.nupc());
- return os;
-}
-
}
} // namespace gem5
--
To view, visit https://gem5-review.googlesource.com/c/public/gem5/+/52039
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: I663619b168c0b2b90c148b45ae16d77f03934e5b
Gerrit-Change-Number: 52039
Gerrit-PatchSet: 14
Gerrit-Owner: Gabe Black <[email protected]>
Gerrit-Reviewer: Bobby R. Bruce <[email protected]>
Gerrit-Reviewer: Daniel Carvalho <[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