13#ifndef LLVM_EXECUTIONENGINE_ORC_SHARED_EXECUTORADDRESS_H
14#define LLVM_EXECUTIONENGINE_ORC_SHARED_EXECUTORADDRESS_H
23#if __has_feature(ptrauth_calls)
39#if __has_feature(ptrauth_calls)
40 template <
typename T>
class PtrauthSignDefault {
42 constexpr T *operator()(
T *
P) {
43 if (std::is_function_v<T>)
44 return ptrauth_sign_unauthenticated(
P, ptrauth_key_function_pointer, 0);
50 template <
typename T>
class PtrauthStripDefault {
52 constexpr T *operator()(
T *
P) {
53 return ptrauth_strip(
P, ptrauth_key_function_pointer);
58 template <
typename T>
using defaultWrap = PtrauthSignDefault<T>;
61 template <
typename T>
using defaultUnwrap = PtrauthStripDefault<T>;
77 constexpr Tag(uintptr_t TagValue, uintptr_t TagOffset)
78 : TagMask(TagValue << TagOffset) {}
81 return reinterpret_cast<T *
>(
reinterpret_cast<uintptr_t
>(
P) | TagMask);
92 constexpr Untag(uintptr_t TagLen, uintptr_t TagOffset)
93 : UntagMask(~(((uintptr_t(1) << TagLen) - 1) << TagOffset)) {}
96 return reinterpret_cast<T *
>(
reinterpret_cast<uintptr_t
>(
P) & UntagMask);
110 template <
typename T,
typename UnwrapFn = defaultUnwrap<T>>
113 static_cast<uint64_t>(
reinterpret_cast<uintptr_t
>(Unwrap(
Ptr))));
118 template <
typename T,
typename WrapFn = defaultWrap<std::remove_po
inter_t<T>>>
119 std::enable_if_t<std::is_pointer<T>::value,
T>
120 toPtr(WrapFn &&Wrap = WrapFn())
const {
121 uintptr_t IntPtr =
static_cast<uintptr_t
>(Addr);
122 assert(IntPtr == Addr &&
"ExecutorAddr value out of range for uintptr_t");
123 return Wrap(
reinterpret_cast<T>(IntPtr));
128 template <
typename T,
typename WrapFn = defaultWrap<T>>
129 std::enable_if_t<std::is_function<T>::value,
T *>
130 toPtr(WrapFn &&Wrap = WrapFn())
const {
131 uintptr_t IntPtr =
static_cast<uintptr_t
>(Addr);
132 assert(IntPtr == Addr &&
"ExecutorAddr value out of range for uintptr_t");
133 return Wrap(
reinterpret_cast<T *
>(IntPtr));
138 bool isNull()
const {
return Addr == 0; }
140 explicit operator bool()
const {
return Addr != 0; }
143 return LHS.Addr ==
RHS.Addr;
147 return LHS.Addr !=
RHS.Addr;
151 return LHS.Addr <
RHS.Addr;
155 return LHS.Addr <=
RHS.Addr;
159 return LHS.Addr >
RHS.Addr;
163 return LHS.Addr >=
RHS.Addr;
242 return LHS.Start <
RHS.Start ||
247 return LHS.Start <
RHS.Start ||
252 return LHS.Start >
RHS.Start ||
257 return LHS.Start >
RHS.Start ||
275 return OS <<
formatv(
"{0:x} -- {1:x}", R.Start.getValue(), R.End.getValue());
static GCRegistry::Add< ErlangGC > A("erlang", "erlang-compatible garbage collector")
This file defines DenseMapInfo traits for DenseMap.
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
LLVM Value Representation.
Merges a tag into the raw address value: P' = P | (TagValue << TagOffset).
constexpr Tag(uintptr_t TagValue, uintptr_t TagOffset)
constexpr T * operator()(T *P)
Strips a tag of the given length from the given offset within the pointer: P' = P & ~(((1 << TagLen) ...
constexpr Untag(uintptr_t TagLen, uintptr_t TagOffset)
constexpr T * operator()(T *P)
Represents an address in the executor process.
rawPtr< T > defaultWrap
Default wrap function to use on this host.
ExecutorAddr & operator++()
friend bool operator==(const ExecutorAddr &LHS, const ExecutorAddr &RHS)
ExecutorAddr operator--(int)
ExecutorAddr & operator-=(const ExecutorAddrDiff &Delta)
uint64_t getValue() const
void setValue(uint64_t Addr)
std::enable_if_t< std::is_function< T >::value, T * > toPtr(WrapFn &&Wrap=WrapFn()) const
Cast this ExecutorAddr to a pointer of the given function type.
ExecutorAddr operator++(int)
friend bool operator>(const ExecutorAddr &LHS, const ExecutorAddr &RHS)
static ExecutorAddr fromPtr(T *Ptr, UnwrapFn &&Unwrap=UnwrapFn())
Create an ExecutorAddr from the given pointer.
friend bool operator>=(const ExecutorAddr &LHS, const ExecutorAddr &RHS)
ExecutorAddr & operator--()
constexpr ExecutorAddr(uint64_t Addr)
Create an ExecutorAddr from the given value.
friend bool operator<=(const ExecutorAddr &LHS, const ExecutorAddr &RHS)
friend bool operator<(const ExecutorAddr &LHS, const ExecutorAddr &RHS)
ExecutorAddr & operator+=(const ExecutorAddrDiff &Delta)
rawPtr< T > defaultUnwrap
Default unwrap function to use on this host.
friend bool operator!=(const ExecutorAddr &LHS, const ExecutorAddr &RHS)
std::enable_if_t< std::is_pointer< T >::value, T > toPtr(WrapFn &&Wrap=WrapFn()) const
Cast this ExecutorAddr to a pointer of the given type.
A utility class for serializing to a blob from a variadic list.
Output char buffer with overflow check.
SPS tag type for sequences.
static bool serialize(SPSOutputBuffer &BOB, const ExecutorAddrRange &Value)
static size_t size(const ExecutorAddrRange &Value)
static bool deserialize(SPSInputBuffer &BIB, ExecutorAddrRange &Value)
static bool serialize(SPSOutputBuffer &BOB, const ExecutorAddr &EA)
static size_t size(const ExecutorAddr &EA)
static bool deserialize(SPSInputBuffer &BIB, ExecutorAddr &EA)
Specialize to describe how to serialize/deserialize to/from the given concrete type.
This class implements an extremely fast bulk output stream that can only output to a stream.
ExecutorAddrDiff operator%(const ExecutorAddr &LHS, const ExecutorAddrDiff &RHS)
Taking the modulus of an address and a diff yields a diff.
ExecutorAddr operator+(const ExecutorAddr &LHS, const ExecutorAddrDiff &RHS)
Adding an offset and an address yields an address.
uint64_t ExecutorAddrDiff
raw_ostream & operator<<(raw_ostream &OS, const SymbolNameSet &Symbols)
Render a SymbolNameSet.
ExecutorAddrDiff operator-(const ExecutorAddr &LHS, const ExecutorAddr &RHS)
Subtracting two addresses yields an offset.
This is an optimization pass for GlobalISel generic memory operations.
auto formatv(bool Validate, const char *Fmt, Ts &&...Vals)
static unsigned getHashValue(const orc::ExecutorAddr &Addr)
static bool isEqual(const orc::ExecutorAddr &LHS, const orc::ExecutorAddr &RHS)
static orc::ExecutorAddr getTombstoneKey()
static orc::ExecutorAddr getEmptyKey()
An information struct used to provide DenseMap with the various necessary components for a given valu...
Represents an address range in the exceutor process.
friend bool operator==(const ExecutorAddrRange &LHS, const ExecutorAddrRange &RHS)
bool overlaps(const ExecutorAddrRange &Other)
friend bool operator>=(const ExecutorAddrRange &LHS, const ExecutorAddrRange &RHS)
ExecutorAddrRange(ExecutorAddr Start, ExecutorAddr End)
friend bool operator!=(const ExecutorAddrRange &LHS, const ExecutorAddrRange &RHS)
friend bool operator<(const ExecutorAddrRange &LHS, const ExecutorAddrRange &RHS)
ExecutorAddrRange(ExecutorAddr Start, ExecutorAddrDiff Size)
ExecutorAddrRange()=default
ExecutorAddrDiff size() const
friend bool operator<=(const ExecutorAddrRange &LHS, const ExecutorAddrRange &RHS)
bool contains(ExecutorAddr Addr) const
friend bool operator>(const ExecutorAddrRange &LHS, const ExecutorAddrRange &RHS)