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 Reviewed-on: https://gem5-review.googlesource.com/c/public/gem5/+/40497 Maintainer: Gabe Black <gabe.black@gmail.com> Tested-by: kokoro <noreply+kokoro@google.com> Reviewed-by: Bobby R. Bruce <bbruce@ucdavis.edu>
This commit is contained in:
@@ -251,7 +251,8 @@ class ProxyPtr : public ConstProxyPtr<T, Proxy>
|
||||
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 @@ class ProxyPtr : public ConstProxyPtr<T, Proxy>
|
||||
}
|
||||
};
|
||||
|
||||
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 @@ class SETranslatingPortProxy;
|
||||
|
||||
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__
|
||||
|
||||
Reference in New Issue
Block a user