14
14
#define LLVM_EXECUTIONENGINE_ORC_SHARED_EXECUTORADDRESS_H
15
15
16
16
#include " llvm/ADT/DenseMapInfo.h"
17
- #include " llvm/ADT/identity.h"
18
17
#include " llvm/ExecutionEngine/Orc/Shared/SimplePackedSerialization.h"
19
18
#include " llvm/Support/FormatVariadic.h"
20
19
#include " llvm/Support/raw_ostream.h"
@@ -30,76 +29,34 @@ using ExecutorAddrDiff = uint64_t;
30
29
// / Represents an address in the executor process.
31
30
class ExecutorAddr {
32
31
public:
33
- // / A wrap/unwrap function that leaves pointers unmodified.
34
- template <typename T> using rawPtr = llvm::identity<T>;
35
-
36
- // / Default wrap function to use on this host.
37
- template <typename T> using defaultWrap = rawPtr<T>;
38
-
39
- // / Default unwrap function to use on this host.
40
- template <typename T> using defaultUnwrap = rawPtr<T>;
41
-
42
- // / Merges a tag into the raw address value:
43
- // / P' = P | (TagValue << TagOffset).
44
- class Tag {
45
- public:
46
- constexpr Tag (uintptr_t TagValue, uintptr_t TagOffset)
47
- : TagMask(TagValue << TagOffset) {}
48
-
49
- template <typename T> constexpr T *operator ()(T *P) {
50
- return reinterpret_cast <T*>(reinterpret_cast <uintptr_t >(P) | TagMask);
51
- }
52
-
53
- private:
54
- uintptr_t TagMask;
55
- };
56
-
57
- // / Strips a tag of the given length from the given offset within the pointer:
58
- // / P' = P & ~(((1 << TagLen) -1) << TagOffset)
59
- class Untag {
60
- public:
61
- constexpr Untag (uintptr_t TagLen, uintptr_t TagOffset)
62
- : UntagMask(~(((1 << TagLen) - 1) << TagOffset)) {}
63
-
64
- template <typename T> constexpr T *operator ()(T *P) {
65
- return reinterpret_cast <T *>(reinterpret_cast <uintptr_t >(P) & UntagMask);
66
- }
67
-
68
- private:
69
- uintptr_t UntagMask;
70
- };
71
-
72
32
ExecutorAddr () = default ;
73
33
74
34
// / Create an ExecutorAddr from the given value.
75
35
explicit constexpr ExecutorAddr (uint64_t Addr) : Addr(Addr) {}
76
36
77
37
// / Create an ExecutorAddr from the given pointer.
78
38
// / Warning: This should only be used when JITing in-process.
79
- template <typename T, typename UnwrapFn = defaultUnwrap<T *>>
80
- static ExecutorAddr fromPtr (T *Ptr, UnwrapFn &&Unwrap = UnwrapFn()) {
39
+ template <typename T> static ExecutorAddr fromPtr (T *Value) {
81
40
return ExecutorAddr (
82
- static_cast <uint64_t >(reinterpret_cast <uintptr_t >(Unwrap (Ptr) )));
41
+ static_cast <uint64_t >(reinterpret_cast <uintptr_t >(Value )));
83
42
}
84
43
85
44
// / Cast this ExecutorAddr to a pointer of the given type.
86
45
// / Warning: This should only be used when JITing in-process.
87
- template <typename T, typename WrapFn = defaultWrap<T>>
88
- std::enable_if_t <std::is_pointer<T>::value, T>
89
- toPtr (WrapFn &&Wrap = WrapFn()) const {
46
+ template <typename T>
47
+ std::enable_if_t <std::is_pointer<T>::value, T> toPtr () const {
90
48
uintptr_t IntPtr = static_cast <uintptr_t >(Addr);
91
49
assert (IntPtr == Addr && " ExecutorAddr value out of range for uintptr_t" );
92
- return Wrap ( reinterpret_cast <T>(IntPtr) );
50
+ return reinterpret_cast <T>(IntPtr);
93
51
}
94
52
95
53
// / Cast this ExecutorAddr to a pointer of the given function type.
96
54
// / Warning: This should only be used when JITing in-process.
97
- template <typename T, typename WrapFn = defaultWrap<T *>>
98
- std::enable_if_t <std::is_function<T>::value, T *>
99
- toPtr (WrapFn &&Wrap = WrapFn()) const {
55
+ template <typename T>
56
+ std::enable_if_t <std::is_function<T>::value, T *> toPtr () const {
100
57
uintptr_t IntPtr = static_cast <uintptr_t >(Addr);
101
58
assert (IntPtr == Addr && " ExecutorAddr value out of range for uintptr_t" );
102
- return Wrap ( reinterpret_cast <T *>(IntPtr) );
59
+ return reinterpret_cast <T *>(IntPtr);
103
60
}
104
61
105
62
uint64_t getValue () const { return Addr; }
0 commit comments