LLVM 24.0.0git
EPCGenericMemoryAccess.h
Go to the documentation of this file.
1//===- EPCGenericMemoryAccess.h - Generic EPC MemoryAccess impl -*- C++ -*-===//
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7//===----------------------------------------------------------------------===//
8//
9// Implements the MemoryAccess interface by calling executor-side wrapper
10// functions through rt::Proxy objects.
11//
12// This simplifies the implementaton of new ExecutorProcessControl instances,
13// as this implementation will always work (at the cost of some performance
14// overhead for the calls).
15//
16//===----------------------------------------------------------------------===//
17
18#ifndef LLVM_EXECUTIONENGINE_ORC_EPCGENERICMEMORYACCESS_H
19#define LLVM_EXECUTIONENGINE_ORC_EPCGENERICMEMORYACCESS_H
20
26
27namespace llvm {
28namespace orc {
29
31public:
32 /// Proxies for the executor-side memory-access functions. These are
33 /// protocol-agnostic: EPCGenericMemoryAccess::Create populates them for the
34 /// runtime's SPS controller interface, but a client targeting a different
35 /// protocol can build its own Funcs and pass them to the constructor.
51
52 /// Create an EPCGenericMemoryAccess instance that reaches the memory-access
53 /// wrappers in ES's bootstrap JITDylib via the runtime's SPS controller
54 /// interface.
56 namespace sps = rt::sps;
57 Funcs Fns;
58 if (auto Err = rt::buildProxies(
72 return std::move(Err);
73 return std::make_unique<EPCGenericMemoryAccess>(ES, std::move(Fns));
74 }
75
76 /// Create an EPCGenericMemoryAccess instance from a given set of memory
77 /// access proxies.
79 : ES(ES), Fns(std::move(Fns)) {}
80
82 WriteResultFn OnWriteComplete) override {
83 Fns.WriteUInt8s(std::move(OnWriteComplete), ES, Ws);
84 }
85
87 WriteResultFn OnWriteComplete) override {
88 Fns.WriteUInt16s(std::move(OnWriteComplete), ES, Ws);
89 }
90
92 WriteResultFn OnWriteComplete) override {
93 Fns.WriteUInt32s(std::move(OnWriteComplete), ES, Ws);
94 }
95
97 WriteResultFn OnWriteComplete) override {
98 Fns.WriteUInt64s(std::move(OnWriteComplete), ES, Ws);
99 }
100
102 WriteResultFn OnWriteComplete) override {
103 Fns.WritePointers(std::move(OnWriteComplete), ES, Ws);
104 }
105
107 WriteResultFn OnWriteComplete) override {
108 Fns.WriteBuffers(std::move(OnWriteComplete), ES, Ws);
109 }
110
112 OnReadUIntsCompleteFn<uint8_t> OnComplete) override {
113 Fns.ReadUInt8s(std::move(OnComplete), ES, Rs);
114 }
115
117 OnReadUIntsCompleteFn<uint16_t> OnComplete) override {
118 Fns.ReadUInt16s(std::move(OnComplete), ES, Rs);
119 }
120
122 OnReadUIntsCompleteFn<uint32_t> OnComplete) override {
123 Fns.ReadUInt32s(std::move(OnComplete), ES, Rs);
124 }
125
127 OnReadUIntsCompleteFn<uint64_t> OnComplete) override {
128 Fns.ReadUInt64s(std::move(OnComplete), ES, Rs);
129 }
130
132 OnReadPointersCompleteFn OnComplete) override {
133 Fns.ReadPointers(std::move(OnComplete), ES, Rs);
134 }
135
137 OnReadBuffersCompleteFn OnComplete) override {
138 Fns.ReadBuffers(std::move(OnComplete), ES, Rs);
139 }
140
142 OnReadStringsCompleteFn OnComplete) override {
143 Fns.ReadStrings(std::move(OnComplete), ES, Rs);
144 }
145
146private:
148 Funcs Fns;
149};
150
151} // end namespace orc
152} // end namespace llvm
153
154#endif // LLVM_EXECUTIONENGINE_ORC_EPCGENERICMEMORYACCESS_H
Represent a constant reference to an array (0 or more elements consecutively in memory),...
Definition ArrayRef.h:40
Tagged union holding either a T or a Error.
Definition Error.h:485
void readUInt8sAsync(ArrayRef< ExecutorAddr > Rs, OnReadUIntsCompleteFn< uint8_t > OnComplete) override
void readUInt32sAsync(ArrayRef< ExecutorAddr > Rs, OnReadUIntsCompleteFn< uint32_t > OnComplete) override
void writeUInt16sAsync(ArrayRef< tpctypes::UInt16Write > Ws, WriteResultFn OnWriteComplete) override
void readStringsAsync(ArrayRef< ExecutorAddr > Rs, OnReadStringsCompleteFn OnComplete) override
void readUInt16sAsync(ArrayRef< ExecutorAddr > Rs, OnReadUIntsCompleteFn< uint16_t > OnComplete) override
void readBuffersAsync(ArrayRef< ExecutorAddrRange > Rs, OnReadBuffersCompleteFn OnComplete) override
void writeUInt32sAsync(ArrayRef< tpctypes::UInt32Write > Ws, WriteResultFn OnWriteComplete) override
static Expected< std::unique_ptr< MemoryAccess > > Create(ExecutionSession &ES)
Create an EPCGenericMemoryAccess instance that reaches the memory-access wrappers in ES's bootstrap J...
void writeUInt64sAsync(ArrayRef< tpctypes::UInt64Write > Ws, WriteResultFn OnWriteComplete) override
void writePointersAsync(ArrayRef< tpctypes::PointerWrite > Ws, WriteResultFn OnWriteComplete) override
void readUInt64sAsync(ArrayRef< ExecutorAddr > Rs, OnReadUIntsCompleteFn< uint64_t > OnComplete) override
EPCGenericMemoryAccess(ExecutionSession &ES, Funcs Fns)
Create an EPCGenericMemoryAccess instance from a given set of memory access proxies.
void readPointersAsync(ArrayRef< ExecutorAddr > Rs, OnReadPointersCompleteFn OnComplete) override
void writeUInt8sAsync(ArrayRef< tpctypes::UInt8Write > Ws, WriteResultFn OnWriteComplete) override
void writeBuffersAsync(ArrayRef< tpctypes::BufferWrite > Ws, WriteResultFn OnWriteComplete) override
An ExecutionSession represents a running JIT program.
Definition Core.h:1111
APIs for manipulating memory in the target process.
unique_function< void(Expected< ReadStringsResult >)> OnReadStringsCompleteFn
unique_function< void(Expected< ReadBuffersResult >)> OnReadBuffersCompleteFn
unique_function< void(Expected< ReadPointersResult >)> OnReadPointersCompleteFn
unique_function< void(Error)> WriteResultFn
Callback function for asynchronous writes.
unique_function< void(Expected< ReadUIntsResult< T > >)> OnReadUIntsCompleteFn
Proxy< void(ArrayRef< tpctypes::PointerWrite >)> MemWritePointersProxy
ProxyInit< FnT > proxyInit(Proxy< FnT > *P, typename Proxy< FnT >::DispatchFn Dispatch, StringRef Name, SymbolLookupFlags LookupFlags=SymbolLookupFlags::RequiredSymbol)
Definition Proxy.h:167
Proxy< std::vector< ExecutorAddr >(ArrayRef< ExecutorAddr >)> MemReadPointersProxy
Proxy< std::vector< uint8_t >(ArrayRef< ExecutorAddr >)> MemReadUInt8sProxy
Proxy< std::vector< uint32_t >(ArrayRef< ExecutorAddr >)> MemReadUInt32sProxy
Proxy< std::vector< uint64_t >(ArrayRef< ExecutorAddr >)> MemReadUInt64sProxy
Proxy< std::vector< std::vector< uint8_t > >(ArrayRef< ExecutorAddrRange >)> MemReadBuffersProxy
Proxy< std::vector< std::string >(ArrayRef< ExecutorAddr >)> MemReadStringsProxy
Error buildProxies(JITDylib &JD)
buildProxies base case.
Definition Proxy.h:188
Proxy< void(ArrayRef< tpctypes::UInt64Write >)> MemWriteUInt64sProxy
Proxy< void(ArrayRef< tpctypes::UInt8Write >)> MemWriteUInt8sProxy
Proxy< void(ArrayRef< tpctypes::UInt16Write >)> MemWriteUInt16sProxy
Proxy< std::vector< uint16_t >(ArrayRef< ExecutorAddr >)> MemReadUInt16sProxy
Proxy< void(ArrayRef< tpctypes::UInt32Write >)> MemWriteUInt32sProxy
Proxy< void(ArrayRef< tpctypes::BufferWrite >)> MemWriteBuffersProxy
This is an optimization pass for GlobalISel generic memory operations.
OutputIt move(R &&Range, OutputIt Out)
Provide wrappers to std::move which take ranges instead of having to pass begin/end explicitly.
Definition STLExtras.h:1917
Implement std::hash so that hash_code can be used in STL containers.
Definition BitVector.h:878
Proxies for the executor-side memory-access functions.