Gabe Black has uploaded this change for review. (
https://gem5-review.googlesource.com/c/public/gem5/+/52039 )
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
---
M src/arch/generic/pcstate.hh
1 file changed, 49 insertions(+), 35 deletions(-)
diff --git a/src/arch/generic/pcstate.hh b/src/arch/generic/pcstate.hh
index 5e9d7ae..0acd3c9 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)
{
@@ -232,6 +241,12 @@
typedef PCStateCommon Base;
public:
+ void
+ output(std::ostream &os) const override
+ {
+ ccprintf(os, "(%#x=>%#x)", this->pc(), this->npc());
+ }
+
PCStateBase *
clone() const override
{
@@ -271,14 +286,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>
@@ -287,6 +294,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
{
@@ -331,15 +345,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>
@@ -350,6 +355,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
{
@@ -412,15 +423,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>
@@ -429,6 +431,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
{
@@ -479,15 +488,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: 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