Gabe Black has submitted this change. (
https://gem5-review.googlesource.com/c/public/gem5/+/52033 )
(
5 is the latest approved patch-set.
No files were changed between the latest approved patch-set and the
submitted one.
)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
Reviewed-on: https://gem5-review.googlesource.com/c/public/gem5/+/52033
Tested-by: kokoro <[email protected]>
Maintainer: Bobby R. Bruce <[email protected]>
Reviewed-by: Daniel Carvalho <[email protected]>
---
M src/arch/generic/pcstate.hh
1 file changed, 35 insertions(+), 0 deletions(-)
Approvals:
Daniel Carvalho: Looks good to me, approved
Bobby R. Bruce: Looks good to me, approved
kokoro: Regressions pass
diff --git a/src/arch/generic/pcstate.hh b/src/arch/generic/pcstate.hh
index 190d3c9..c12b5cf 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: 9
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