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;
70 unsigned NumStubs)
const = 0;
73 unsigned PointerSize = 0;
74 unsigned TrampolineSize = 0;
75 unsigned StubSize = 0;
76 unsigned StubToPointerMaxDisplacement = 0;
77 unsigned ResolverCodeSize = 0;
81 template <
typename ORCABI>
82 static std::unique_ptr<EPCIndirectionUtils>
124 assert(LCTM &&
"createLazyCallThroughManager must be called first");
131 struct IndirectStubInfo {
132 IndirectStubInfo() =
default;
135 : StubAddress(StubAddress), PointerAddress(PointerAddress) {}
140 using IndirectStubInfoVector = std::vector<IndirectStubInfo>;
143 EPCIndirectionUtils(ExecutorProcessControl &EPC,
144 std::unique_ptr<ABISupport> ABI);
146 Expected<IndirectStubInfoVector> getIndirectStubs(
unsigned NumStubs);
148 std::mutex EPCUIMutex;
149 ExecutorProcessControl &EPC;
150 std::unique_ptr<ABISupport> ABI;
152 FinalizedAlloc ResolverBlock;
153 std::unique_ptr<TrampolinePool> TP;
154 std::unique_ptr<LazyCallThroughManager> LCTM;
156 std::vector<IndirectStubInfo> AvailableIndirectStubs;
157 std::vector<FinalizedAlloc> IndirectStubAllocs;
175template <
typename ORCABI>
179 :
ABISupport(ORCABI::PointerSize, ORCABI::TrampolineSize,
180 ORCABI::StubSize, ORCABI::StubToPointerMaxDisplacement,
181 ORCABI::ResolverCodeSize) {}
187 ORCABI::writeResolverCode(ResolverWorkingMem, ResolverTargetAddr,
188 ReentryFnAddr, ReentryCtxAddr);
194 unsigned NumTrampolines)
const override {
195 ORCABI::writeTrampolines(TrampolineBlockWorkingMem,
196 TrampolineBlockTargetAddr, ResolverAddr,
203 unsigned NumStubs)
const override {
204 ORCABI::writeIndirectStubsBlock(StubsBlockWorkingMem,
205 StubsBlockTargetAddress,
206 PointersBlockTargetAddress, NumStubs);
212template <
typename ORCABI>
213std::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 writeResolverCode(char *ResolverWorkingMem, JITTargetAddress ResolverTargetAddr, JITTargetAddress ReentryFnAddr, JITTargetAddress ReentryCtxAddr) const =0
ABISupport(unsigned PointerSize, unsigned TrampolineSize, unsigned StubSize, unsigned StubToPointerMaxDisplacement, unsigned ResolverCodeSize)
virtual void writeTrampolines(char *TrampolineBlockWorkingMem, JITTargetAddress TrampolineBlockTragetAddr, JITTargetAddress ResolverAddr, unsigned NumTrampolines) const =0
unsigned getStubSize() const
unsigned getResolverCodeSize() const
virtual void writeIndirectStubsBlock(char *StubsBlockWorkingMem, JITTargetAddress StubsBlockTargetAddress, JITTargetAddress PointersBlockTargetAddress, unsigned NumStubs) 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.
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, JITTargetAddress ErrorHandlerAddr)
Create a LazyCallThroughManager.
Error cleanup()
Release memory for resources held by this instance.
Expected< JITTargetAddress > writeResolverBlock(JITTargetAddress ReentryFnAddr, JITTargetAddress ReentryCtxAddr)
Write resolver code to the executor process and return its address.
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.
JITTargetAddress getResolverBlockAddress() const
Returns the address of the Resolver block.
An ExecutionSession represents a running JIT program.
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 writeIndirectStubsBlock(char *StubsBlockWorkingMem, JITTargetAddress StubsBlockTargetAddress, JITTargetAddress PointersBlockTargetAddress, unsigned NumStubs) const override
void writeResolverCode(char *ResolverWorkingMem, JITTargetAddress ResolverTargetAddr, JITTargetAddress ReentryFnAddr, JITTargetAddress ReentryCtxAddr) const override
void writeTrampolines(char *TrampolineBlockWorkingMem, JITTargetAddress TrampolineBlockTargetAddr, JITTargetAddress ResolverAddr, unsigned NumTrampolines) 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.
uint64_t JITTargetAddress
Represents an address in the target process's address space.