14#ifndef LLVM_EXECUTIONENGINE_ORC_EPCINDIRECTIONUTILS_H
15#define LLVM_EXECUTIONENGINE_ORC_EPCINDIRECTIONUTILS_H
26class ExecutorProcessControl;
38 ABISupport(
unsigned PointerSize,
unsigned TrampolineSize,
unsigned StubSize,
39 unsigned StubToPointerMaxDisplacement,
unsigned ResolverCodeSize)
40 : PointerSize(PointerSize), TrampolineSize(TrampolineSize),
42 StubToPointerMaxDisplacement(StubToPointerMaxDisplacement),
43 ResolverCodeSize(ResolverCodeSize) {}
52 return StubToPointerMaxDisplacement;
64 unsigned NumTrampolines)
const = 0;
67 char *StubsBlockWorkingMem,
ExecutorAddr StubsBlockTargetAddress,
68 ExecutorAddr PointersBlockTargetAddress,
unsigned NumStubs)
const = 0;
71 unsigned PointerSize = 0;
72 unsigned TrampolineSize = 0;
73 unsigned StubSize = 0;
74 unsigned StubToPointerMaxDisplacement = 0;
75 unsigned ResolverCodeSize = 0;
79 template <
typename ORCABI>
80 static std::unique_ptr<EPCIndirectionUtils>
127 assert(LCTM &&
"createLazyCallThroughManager must be called first");
134 struct IndirectStubInfo {
135 IndirectStubInfo() =
default;
137 : StubAddress(StubAddress), PointerAddress(PointerAddress) {}
138 ExecutorAddr StubAddress;
139 ExecutorAddr PointerAddress;
142 using IndirectStubInfoVector = std::vector<IndirectStubInfo>;
145 EPCIndirectionUtils(ExecutorProcessControl &EPC,
146 std::unique_ptr<ABISupport> ABI);
148 Expected<IndirectStubInfoVector> getIndirectStubs(
unsigned NumStubs);
150 std::mutex EPCUIMutex;
151 ExecutorProcessControl &EPC;
152 std::unique_ptr<ABISupport> ABI;
153 ExecutorAddr ResolverBlockAddr;
154 FinalizedAlloc ResolverBlock;
155 std::unique_ptr<TrampolinePool> TP;
156 std::unique_ptr<LazyCallThroughManager> LCTM;
158 std::vector<IndirectStubInfo> AvailableIndirectStubs;
159 std::vector<FinalizedAlloc> IndirectStubAllocs;
177template <
typename ORCABI>
181 :
ABISupport(ORCABI::PointerSize, ORCABI::TrampolineSize,
182 ORCABI::StubSize, ORCABI::StubToPointerMaxDisplacement,
183 ORCABI::ResolverCodeSize) {}
189 ORCABI::writeResolverCode(ResolverWorkingMem, ResolverTargetAddr,
190 ReentryFnAddr, ReentryCtxAddr);
196 unsigned NumTrampolines)
const override {
197 ORCABI::writeTrampolines(TrampolineBlockWorkingMem,
198 TrampolineBlockTargetAddr, ResolverAddr,
205 unsigned NumStubs)
const override {
206 ORCABI::writeIndirectStubsBlock(StubsBlockWorkingMem,
207 StubsBlockTargetAddress,
208 PointersBlockTargetAddress, NumStubs);
214template <
typename ORCABI>
215std::unique_ptr<EPCIndirectionUtils>
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
Lightweight error class with error context and mandatory checking.
Tagged union holding either a T or a Error.
Represents a finalized allocation.
virtual void writeIndirectStubsBlock(char *StubsBlockWorkingMem, ExecutorAddr StubsBlockTargetAddress, ExecutorAddr PointersBlockTargetAddress, unsigned NumStubs) const =0
ABISupport(unsigned PointerSize, unsigned TrampolineSize, unsigned StubSize, unsigned StubToPointerMaxDisplacement, unsigned ResolverCodeSize)
unsigned getStubSize() const
virtual void writeResolverCode(char *ResolverWorkingMem, ExecutorAddr ResolverTargetAddr, ExecutorAddr ReentryFnAddr, ExecutorAddr ReentryCtxAddr) const =0
unsigned getResolverCodeSize() const
virtual void writeTrampolines(char *TrampolineBlockWorkingMem, ExecutorAddr TrampolineBlockTragetAddr, ExecutorAddr ResolverAddr, unsigned NumTrampolines) const =0
unsigned getStubToPointerMaxDisplacement() const
unsigned getPointerSize() const
unsigned getTrampolineSize() const
Provides ExecutorProcessControl based indirect stubs, trampoline pool and lazy call through manager.
std::unique_ptr< IndirectStubsManager > createIndirectStubsManager()
Create an IndirectStubsManager for the executor process.
static Expected< std::unique_ptr< EPCIndirectionUtils > > Create(ExecutionSession &ES)
Create based on the ExecutorProcessControl triple.
Expected< ExecutorAddr > writeResolverBlock(ExecutorAddr ReentryFnAddr, ExecutorAddr ReentryCtxAddr)
Write resolver code to the executor process and return its address.
LazyCallThroughManager & getLazyCallThroughManager()
Create a LazyCallThroughManager for the executor process.
static std::unique_ptr< EPCIndirectionUtils > CreateWithABI(ExecutorProcessControl &EPC)
Create using the given ABI class.
ExecutorProcessControl & getExecutorProcessControl() const
Return a reference to the ExecutorProcessControl object.
LazyCallThroughManager & createLazyCallThroughManager(ExecutionSession &ES, ExecutorAddr ErrorHandlerAddr)
Create a LazyCallThroughManager.
Error cleanup()
Release memory for resources held by this instance.
TrampolinePool & getTrampolinePool()
Create a TrampolinePool for the executor process.
static Expected< std::unique_ptr< EPCIndirectionUtils > > Create(ExecutorProcessControl &EPC)
Create based on the ExecutorProcessControl triple.
ABISupport & getABISupport() const
Return a reference to the ABISupport object for this instance.
ExecutorAddr getResolverBlockAddress() const
Returns the address of the Resolver block.
An ExecutionSession represents a running JIT program.
ExecutorProcessControl & getExecutorProcessControl()
Get the ExecutorProcessControl object associated with this ExecutionSession.
Represents an address in the executor process.
ExecutorProcessControl supports interaction with a JIT target process.
Manages a set of 'lazy call-through' trampolines.
Base class for pools of compiler re-entry trampolines.
void writeTrampolines(char *TrampolineBlockWorkingMem, ExecutorAddr TrampolineBlockTargetAddr, ExecutorAddr ResolverAddr, unsigned NumTrampolines) const override
void writeIndirectStubsBlock(char *StubsBlockWorkingMem, ExecutorAddr StubsBlockTargetAddress, ExecutorAddr PointersBlockTargetAddress, unsigned NumStubs) const override
void writeResolverCode(char *ResolverWorkingMem, ExecutorAddr ResolverTargetAddr, ExecutorAddr ReentryFnAddr, ExecutorAddr ReentryCtxAddr) const override
Error setUpInProcessLCTMReentryViaEPCIU(EPCIndirectionUtils &EPCIU)
This will call writeResolver on the given EPCIndirectionUtils instance to set up re-entry via a funct...
This is an optimization pass for GlobalISel generic memory operations.