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 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// This header is protocol-agnostic. To build an instance that targets the ORC
17// runtime's SPS controller interface, see EPCGenericMemoryAccessSPS.h.
18//
19//===----------------------------------------------------------------------===//
20
21#ifndef LLVM_EXECUTIONENGINE_ORC_EPCGENERICMEMORYACCESS_H
22#define LLVM_EXECUTIONENGINE_ORC_EPCGENERICMEMORYACCESS_H
23
28
29#include <cstdint>
30#include <string>
31#include <vector>
32
33namespace llvm {
34namespace orc {
35
37public:
54
55 /// Proxies for the executor-side memory-access functions. These are
56 /// protocol-agnostic: sps::createEPCGenericMemoryAccess populates them for
57 /// the runtime's SPS controller interface, but a client targeting a different
58 /// protocol can build its own Funcs and pass them to the constructor.
74
75 /// Create an EPCGenericMemoryAccess instance from a given set of memory
76 /// access proxies.
78 : ES(ES), Fns(std::move(Fns)) {}
79
81 WriteResultFn OnWriteComplete) override {
82 Fns.WriteUInt8s(std::move(OnWriteComplete), ES, Ws);
83 }
84
86 WriteResultFn OnWriteComplete) override {
87 Fns.WriteUInt16s(std::move(OnWriteComplete), ES, Ws);
88 }
89
91 WriteResultFn OnWriteComplete) override {
92 Fns.WriteUInt32s(std::move(OnWriteComplete), ES, Ws);
93 }
94
96 WriteResultFn OnWriteComplete) override {
97 Fns.WriteUInt64s(std::move(OnWriteComplete), ES, Ws);
98 }
99
101 WriteResultFn OnWriteComplete) override {
102 Fns.WritePointers(std::move(OnWriteComplete), ES, Ws);
103 }
104
106 WriteResultFn OnWriteComplete) override {
107 Fns.WriteBuffers(std::move(OnWriteComplete), ES, Ws);
108 }
109
111 OnReadUIntsCompleteFn<uint8_t> OnComplete) override {
112 Fns.ReadUInt8s(std::move(OnComplete), ES, Rs);
113 }
114
116 OnReadUIntsCompleteFn<uint16_t> OnComplete) override {
117 Fns.ReadUInt16s(std::move(OnComplete), ES, Rs);
118 }
119
121 OnReadUIntsCompleteFn<uint32_t> OnComplete) override {
122 Fns.ReadUInt32s(std::move(OnComplete), ES, Rs);
123 }
124
126 OnReadUIntsCompleteFn<uint64_t> OnComplete) override {
127 Fns.ReadUInt64s(std::move(OnComplete), ES, Rs);
128 }
129
131 OnReadPointersCompleteFn OnComplete) override {
132 Fns.ReadPointers(std::move(OnComplete), ES, Rs);
133 }
134
136 OnReadBuffersCompleteFn OnComplete) override {
137 Fns.ReadBuffers(std::move(OnComplete), ES, Rs);
138 }
139
141 OnReadStringsCompleteFn OnComplete) override {
142 Fns.ReadStrings(std::move(OnComplete), ES, Rs);
143 }
144
145private:
147 Funcs Fns;
148};
149
150} // end namespace orc
151} // end namespace llvm
152
153#endif // LLVM_EXECUTIONENGINE_ORC_EPCGENERICMEMORYACCESS_H
Represent a constant reference to an array (0 or more elements consecutively in memory),...
Definition ArrayRef.h:40
void readUInt8sAsync(ArrayRef< ExecutorAddr > Rs, OnReadUIntsCompleteFn< uint8_t > OnComplete) override
void readUInt32sAsync(ArrayRef< ExecutorAddr > Rs, OnReadUIntsCompleteFn< uint32_t > OnComplete) override
Proxy< void(ArrayRef< tpctypes::UInt32Write >)> WriteUInt32sProxy
Proxy< std::vector< uint16_t >(ArrayRef< ExecutorAddr >)> ReadUInt16sProxy
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
Proxy< std::vector< std::string >(ArrayRef< ExecutorAddr >)> ReadStringsProxy
Proxy< void(ArrayRef< tpctypes::UInt64Write >)> WriteUInt64sProxy
void readBuffersAsync(ArrayRef< ExecutorAddrRange > Rs, OnReadBuffersCompleteFn OnComplete) override
void writeUInt32sAsync(ArrayRef< tpctypes::UInt32Write > Ws, WriteResultFn OnWriteComplete) override
Proxy< void(ArrayRef< tpctypes::UInt8Write >)> WriteUInt8sProxy
void writeUInt64sAsync(ArrayRef< tpctypes::UInt64Write > Ws, WriteResultFn OnWriteComplete) override
void writePointersAsync(ArrayRef< tpctypes::PointerWrite > Ws, WriteResultFn OnWriteComplete) override
Proxy< std::vector< std::vector< uint8_t > >(ArrayRef< ExecutorAddrRange >)> ReadBuffersProxy
void readUInt64sAsync(ArrayRef< ExecutorAddr > Rs, OnReadUIntsCompleteFn< uint64_t > OnComplete) override
Proxy< std::vector< ExecutorAddr >(ArrayRef< ExecutorAddr >)> ReadPointersProxy
EPCGenericMemoryAccess(ExecutionSession &ES, Funcs Fns)
Create an EPCGenericMemoryAccess instance from a given set of memory access proxies.
Proxy< std::vector< uint64_t >(ArrayRef< ExecutorAddr >)> ReadUInt64sProxy
Proxy< void(ArrayRef< tpctypes::UInt16Write >)> WriteUInt16sProxy
void readPointersAsync(ArrayRef< ExecutorAddr > Rs, OnReadPointersCompleteFn OnComplete) override
void writeUInt8sAsync(ArrayRef< tpctypes::UInt8Write > Ws, WriteResultFn OnWriteComplete) override
Proxy< std::vector< uint8_t >(ArrayRef< ExecutorAddr >)> ReadUInt8sProxy
Proxy< void(ArrayRef< tpctypes::PointerWrite >)> WritePointersProxy
Proxy< void(ArrayRef< tpctypes::BufferWrite >)> WriteBuffersProxy
void writeBuffersAsync(ArrayRef< tpctypes::BufferWrite > Ws, WriteResultFn OnWriteComplete) override
Proxy< std::vector< uint32_t >(ArrayRef< ExecutorAddr >)> ReadUInt32sProxy
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
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.