Gabe Black has uploaded this change for review. ( https://gem5-review.googlesource.com/c/public/gem5/+/52033 )

Change subject: arch: Add some helpers to make it easier to cast PCState.
......................................................................

arch: Add some helpers to make it easier to cast PCState.

These helpers will make it easier to cast a PCStatePtr into an ISA
specific class with less syntactic fluff. They are currently implemented
with a static_cast for performance reasons, but could be implemented
with a dynamic_cast and an assert for extra debugging if you were
willing to pay the performance overhead. In the future this might be
switched/enabled as an extra debugging mode, like how locking can have
extra checks enabled in the Linux kernel.

Change-Id: Ibc2443c6b991ebc2e5d0240a88436849cb6de2b9
---
M src/arch/generic/pcstate.hh
1 file changed, 31 insertions(+), 0 deletions(-)



diff --git a/src/arch/generic/pcstate.hh b/src/arch/generic/pcstate.hh
index 8fb5ba1..43e32fd 100644
--- a/src/arch/generic/pcstate.hh
+++ b/src/arch/generic/pcstate.hh
@@ -54,6 +54,20 @@
 {
   public:
     virtual ~PCStateBase() = default;
+
+    template<class Target>
+    Target &
+    as()
+    {
+        return static_cast<Target &>(*this);
+    }
+
+    template<class Target>
+    const Target &
+    as() const
+    {
+        return static_cast<const Target &>(*this);
+    }
 };

 namespace GenericISA

--
To view, visit https://gem5-review.googlesource.com/c/public/gem5/+/52033
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: Ibc2443c6b991ebc2e5d0240a88436849cb6de2b9
Gerrit-Change-Number: 52033
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

Reply via email to