Gabe Black has uploaded this change for review. (
https://gem5-review.googlesource.com/c/public/gem5/+/40497 )
Change subject: sim: Add a void * analogue to VPtr.
......................................................................
sim: Add a void * analogue to VPtr.
The default type for VPtr is now void, and the void partial
specialization of VPtr is basically just a fancy container for Addr. Its
purpose is to distinguish guest addresses from actual uint64_t-s in the
signature of simcalls so that types which are purposefully 64 bits will
stay that way, and addresses will scale to the size of pointers in the
target ABI.
Change-Id: I71e2201f5917005861ba678c6675dbcbaa0965b3
---
M src/sim/proxy_ptr.hh
1 file changed, 27 insertions(+), 2 deletions(-)
diff --git a/src/sim/proxy_ptr.hh b/src/sim/proxy_ptr.hh
index 968c156..cd0d409 100644
--- a/src/sim/proxy_ptr.hh
+++ b/src/sim/proxy_ptr.hh
@@ -251,7 +251,8 @@
explicit ProxyPtr(Args&&... args) : CPP(0, args...) {}
template <typename O, typename Enabled=
- typename std::enable_if_t<std::is_assignable<T *, O *>::value>>
+ typename std::enable_if_t<std::is_assignable<T *, O *>::value &&
+ !std::is_same<O, void>::value>>
ProxyPtr(const ProxyPtr<O, Proxy> &other) : CPP(other) {}
ProxyPtr(const PP &other) : CPP(other) {}
@@ -322,6 +323,30 @@
}
};
+template <typename Proxy>
+class ProxyPtr<void, Proxy>
+{
+ protected:
+ Addr _addr;
+
+ public:
+ ProxyPtr(Addr new_addr, ...) : _addr(new_addr) {}
+
+ template <typename T>
+ ProxyPtr(const ProxyPtr<T, Proxy> &other) : _addr(other.addr()) {}
+
+ ProxyPtr<void, Proxy> &
+ operator = (Addr new_addr)
+ {
+ _addr = new_addr;
+ return *this;
+ }
+
+ operator Addr() const { return _addr; }
+
+ Addr addr() const { return _addr; }
+};
+
template <typename T, typename Proxy, typename A>
typename std::enable_if_t<std::is_integral<A>::value, ProxyPtr<T, Proxy>>
operator + (A a, const ProxyPtr<T, Proxy> &other)
@@ -368,7 +393,7 @@
template <typename T>
using ConstVPtr = ConstProxyPtr<T, SETranslatingPortProxy>;
-template <typename T>
+template <typename T=void>
using VPtr = ProxyPtr<T, SETranslatingPortProxy>;
#endif // __SIM_PROXY_PTR_HH__
--
To view, visit https://gem5-review.googlesource.com/c/public/gem5/+/40497
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: I71e2201f5917005861ba678c6675dbcbaa0965b3
Gerrit-Change-Number: 40497
Gerrit-PatchSet: 1
Gerrit-Owner: Gabe Black <gabe.bl...@gmail.com>
Gerrit-MessageType: newchange
_______________________________________________
gem5-dev mailing list -- gem5-dev@gem5.org
To unsubscribe send an email to gem5-dev-le...@gem5.org
%(web_page_url)slistinfo%(cgiext)s/%(_internal_name)s