17#ifndef LLVM_EXECUTIONENGINE_ORC_RTBRIDGE_SPS_CALLS_H
18#define LLVM_EXECUTIONENGINE_ORC_RTBRIDGE_SPS_CALLS_H
40template <
typename BaseT,
typename SPSSigT,
const char *CINameV,
41 typename FnType =
typename BaseT::FnType>
44template <
typename BaseT,
typename SPSSigT,
const char *CINameV,
typename RetT,
47 using CalleeRetT =
typename BaseT::CalleeRetT;
48 using ErrorRetT =
typename BaseT::ErrorRetT;
52 static constexpr const char *
CIName = CINameV;
55 : ES(ES), CallerFnAddr(CallerFnAddr) {}
60 const char *Name =
CIName) {
61 if (
auto CallerSym = ES.lookup({&ES.getBootstrapJITDylib()}, Name))
62 return Caller(ES, CallerSym->getAddress());
64 return CallerSym.takeError();
75 if constexpr (std::is_void_v<CalleeRetT>) {
78 ES.callSPSWrapperAsync<SPSSigT>(
80 [OnComplete = std::move(OnComplete)](
Error SerErr)
mutable {
81 OnComplete(std::move(SerErr));
85 ES.callSPSWrapperAsync<SPSSigT>(
87 [OnComplete = std::move(OnComplete)](
Error SerErr,
88 CalleeRetT
Result)
mutable {
90 return OnComplete(std::move(SerErr));
92 return OnComplete(std::move(
Result));
100 callAsync(std::move(OnComplete), ES, CallerFnAddr, FnAddr, Args...);
103 using BaseT::operator();
Lightweight error class with error context and mandatory checking.
Tagged union holding either a T or a Error.
An ExecutionSession represents a running JIT program.
Represents an address in the executor process.
void operator()(unique_function< void(ErrorRetT)> OnComplete, ExecutorAddr FnAddr, ArgTs... Args) override
Caller(ExecutionSession &ES, ExecutorAddr CallerFnAddr)
static constexpr const char * CIName
Name of the controller-interface wrapper this caller targets.
static void callAsync(unique_function< void(ErrorRetT)> OnComplete, ExecutionSession &ES, ExecutorAddr CallerFnAddr, ExecutorAddr FnAddr, const ArgTs &...Args)
Asynchronously call the SPS wrapper at CallerFnAddr to invoke the executor-side function at FnAddr wi...
static Expected< Caller > Create(ExecutionSession &ES, const char *Name=CIName)
Look the wrapper up in the executor's bootstrap JITDylib and build a caller for it.
Implements the rt::Caller interface BaseT by calling an executor-side SPS wrapper function,...
SPS tag type for sequences.
unique_function is a type-erasing functor similar to std::function.
void(shared::SPSExecutorAddr) CallVoidVoidSPSSig
int32_t(shared::SPSExecutorAddr, int32_t) CallInt32Int32SPSSig
Caller< rt::Int32Int32Caller, CallInt32Int32SPSSig, CallInt32Int32CIName > Int32Int32Caller
SPS caller for rt::Int32Int32Caller: runs an int32_t(int32_t) function in the executor.
constexpr char CallInt32VoidCIName[]
Caller< rt::Int32VoidCaller, CallInt32VoidSPSSig, CallInt32VoidCIName > Int32VoidCaller
SPS caller for rt::Int32VoidCaller: runs an int32_t() function in the executor.
Caller< rt::MainCaller, CallMainSPSSig, CallMainCIName > MainCaller
SPS caller for rt::MainCaller: runs a main-like function (int(int argc, char *argv[])) in the executo...
constexpr char CallMainCIName[]
constexpr char CallInt32Int32CIName[]
Caller< rt::VoidVoidCaller, CallVoidVoidSPSSig, CallVoidVoidCIName > VoidVoidCaller
SPS caller for rt::VoidVoidCaller: runs a void() function in the executor.
constexpr char CallVoidVoidCIName[]
int64_t(shared::SPSExecutorAddr, shared::SPSSequence< shared::SPSString >) CallMainSPSSig
int32_t(shared::SPSExecutorAddr) CallInt32VoidSPSSig
RTTIExtends< ObjectTransformLayer, ObjectLayer > BaseT