29#ifndef __SIM_PROXY_PTR_HH__
30#define __SIM_PROXY_PTR_HH__
43template <
typename Proxy>
51 std::unique_ptr<uint8_t[]>
data;
68 assert(
sizeof(T) <=
size);
70 return *
reinterpret_cast<T *
>(
data.get());
77 assert(
sizeof(T) <=
size);
78 return *
reinterpret_cast<T *
>(
data.get());
108template <
typename T,
typename Proxy>
113 std::shared_ptr<ProxyPtrBuffer<Proxy>>
buffer;
115 template <
typename O,
typename P>
139 template <
typename ...Args,
140 typename std::enable_if_t<std::is_constructible_v<
141 Proxy, Args&&...>,
int> = 0>
143 proxy(
std::make_shared<Proxy>(args...))
147 template <
typename ...Args,
148 typename std::enable_if_t<std::is_constructible_v<
149 Proxy, Args&&...>,
int> = 0>
151 proxy(
std::make_shared<Proxy>(args...))
156 template <
typename O,
typename Enabled=
157 typename std::enable_if_t<std::is_assignable_v<T *, O *>>>
174 operator bool()
const {
return (
bool)
buffer; }
176 template <
typename A>
177 typename std::enable_if_t<std::is_integral_v<A>,
CPP>
183 template <
typename A>
184 typename std::enable_if_t<std::is_integral_v<A>,
CPP>
193 return (
addr() - other.
addr()) /
sizeof(T);
211 operator const T *()
const
213 return buffer ? &
buffer->template asConst<T>() :
nullptr;
220 return buffer->template asConst<T>();
226 return &
buffer->template asConst<T>();
230template <
typename T,
typename Proxy,
typename A>
231typename std::enable_if_t<std::is_integral_v<A>, ConstProxyPtr<T, Proxy>>
237template <
typename T,
typename Proxy>
247 template <
typename ...Args,
248 typename std::enable_if_t<std::is_constructible_v<
249 Proxy, Args&&...>,
int> = 0>
251 template <
typename ...Args,
252 typename std::enable_if_t<std::is_constructible_v<
253 Proxy, Args&&...>,
int> = 0>
256 template <
typename O,
typename Enabled=
257 typename std::enable_if_t<std::is_assignable_v<T *, O *> &&
258 !std::is_same_v<O, void>>>
262 operator bool()
const {
return (
bool)this->
buffer; }
268 this->
buffer->flush(force);
271 template <
typename A>
272 typename std::enable_if_t<std::is_integral_v<A>,
PP>
275 return PP(this->
addr() + a *
sizeof(T), this->
proxy);
278 template <
typename A>
279 typename std::enable_if_t<std::is_integral_v<A>,
PP>
282 return PP(this->
addr() - a *
sizeof(T), this->
proxy);
288 return (this->
addr() - other.
addr()) /
sizeof(T);
306 using CPP::operator
const T *;
312 using CPP::operator *;
320 using CPP::operator ->;
329template <
typename Proxy>
338 template <
typename T>
348 operator Addr()
const {
return _addr; }
353template <
typename T,
typename Proxy,
typename A>
354typename std::enable_if_t<std::is_integral_v<A>, ProxyPtr<T, Proxy>>
363template <
typename ABI,
typename T,
typename Proxy>
374template <
typename ABI,
typename T,
typename Proxy>
387template <
typename T,
typename Proxy>
395class SETranslatingPortProxy;
399template <
typename T=
void>
Defines global host-dependent types: Counter, Tick, and (indirectly) {int,uint}{8,...
std::shared_ptr< ProxyPtrBuffer< Proxy > > buffer
CPP & operator=(const CPP &other)
ConstProxyPtr< T, Proxy > CPP
const T * operator->() const
ConstProxyPtr(Addr _ptr, Args &&... args)
ConstProxyPtr(Args &&... args)
const T & operator*() const
std::enable_if_t< std::is_integral_v< A >, CPP > operator-(A a) const
ConstProxyPtr(Addr _ptr, std::shared_ptr< Proxy > _proxy)
std::shared_ptr< Proxy > proxy
std::enable_if_t< std::is_integral_v< A >, CPP > operator+(A a) const
ConstProxyPtr(const CPP &other)
ConstProxyPtr(const ConstProxyPtr< O, Proxy > &other)
std::shared_ptr< Proxy > getProxy() const
std::unique_ptr< uint8_t[]> data
ProxyPtrBuffer(std::shared_ptr< Proxy > _proxy, Addr _ptr, size_t _size)
const T & asConst() const
std::shared_ptr< Proxy > proxy
void flush(bool force=false)
ProxyPtr(Addr new_addr,...)
ProxyPtr(const ProxyPtr< T, Proxy > &other)
ProxyPtr(Addr _ptr, std::shared_ptr< Proxy > _proxy)
void flush(bool force=false)
std::enable_if_t< std::is_integral_v< A >, PP > operator-(A a) const
ProxyPtr(const ProxyPtr< O, Proxy > &other)
std::enable_if_t< std::is_integral_v< A >, PP > operator+(A a) const
ProxyPtr(const PP &other)
ProxyPtr(Addr _ptr, Args &&... args)
PP & operator=(const PP &other)
ProxyPtr(Args &&... args)
ThreadContext is the external interface to all thread state for anything outside of the CPU.
#define panic_if(cond,...)
Conditional panic macro that checks the supplied condition and only panics if the condition is true a...
Temp operator+(Temp l, Temp r)
Copyright (c) 2024 - Pranith Kumar Copyright (c) 2020 Inria All rights reserved.
uint64_t Addr
Address type This will probably be moved somewhere else in the near future.
static std::ostream & operator<<(std::ostream &os, const DummyMatRegContainer &d)
void ccprintf(cp::Print &print)
Overload hash function for BasicBlockRange type.
static ConstProxyPtr< T, Proxy > get(ThreadContext *tc, typename ABI::State &state)
static ProxyPtr< T, Proxy > get(ThreadContext *tc, typename ABI::State &state)