LLVM 20.0.0git
OrcRTBootstrap.cpp
Go to the documentation of this file.
1//===------------------------ OrcRTBootstrap.cpp --------------------------===//
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#include "OrcRTBootstrap.h"
10
15
16#define DEBUG_TYPE "orc"
17
18using namespace llvm::orc::shared;
19
20namespace llvm {
21namespace orc {
22namespace rt_bootstrap {
23
24template <typename WriteT, typename SPSWriteT>
26writeUIntsWrapper(const char *ArgData, size_t ArgSize) {
27 return WrapperFunction<void(SPSSequence<SPSWriteT>)>::handle(
28 ArgData, ArgSize,
29 [](std::vector<WriteT> Ws) {
30 for (auto &W : Ws)
31 *W.Addr.template toPtr<decltype(W.Value) *>() = W.Value;
32 })
33 .release();
34}
35
37writeBuffersWrapper(const char *ArgData, size_t ArgSize) {
39 ArgData, ArgSize,
40 [](std::vector<tpctypes::BufferWrite> Ws) {
41 for (auto &W : Ws)
42 memcpy(W.Addr.template toPtr<char *>(), W.Buffer.data(),
43 W.Buffer.size());
44 })
45 .release();
46}
47
49writePointersWrapper(const char *ArgData, size_t ArgSize) {
51 handle(ArgData, ArgSize,
52 [](std::vector<tpctypes::PointerWrite> Ws) {
53 for (auto &W : Ws)
54 *W.Addr.template toPtr<void **>() =
55 W.Value.template toPtr<void *>();
56 })
57 .release();
58}
59
61runAsMainWrapper(const char *ArgData, size_t ArgSize) {
63 ArgData, ArgSize,
64 [](ExecutorAddr MainAddr,
65 std::vector<std::string> Args) -> int64_t {
66 return runAsMain(MainAddr.toPtr<int (*)(int, char *[])>(), Args);
67 })
68 .release();
69}
70
72runAsVoidFunctionWrapper(const char *ArgData, size_t ArgSize) {
74 ArgData, ArgSize,
75 [](ExecutorAddr MainAddr) -> int32_t {
76 return runAsVoidFunction(MainAddr.toPtr<int32_t (*)(void)>());
77 })
78 .release();
79}
80
82runAsIntFunctionWrapper(const char *ArgData, size_t ArgSize) {
84 ArgData, ArgSize,
85 [](ExecutorAddr MainAddr, int32_t Arg) -> int32_t {
86 return runAsIntFunction(MainAddr.toPtr<int32_t (*)(int32_t)>(),
87 Arg);
88 })
89 .release();
90}
91
118}
119
120} // end namespace rt_bootstrap
121} // end namespace orc
122} // end namespace llvm
LLVM_ABI llvm::orc::shared::CWrapperFunctionResult llvm_orc_deregisterEHFrameSectionWrapper(const char *Data, uint64_t Size)
LLVM_ABI llvm::orc::shared::CWrapperFunctionResult llvm_orc_registerEHFrameSectionWrapper(const char *Data, uint64_t Size)
StringMap - This is an unconventional map that is specialized for handling keys that are "strings",...
Definition: StringMap.h:128
Represents an address in the executor process.
static ExecutorAddr fromPtr(T *Ptr, UnwrapFn &&Unwrap=UnwrapFn())
Create an ExecutorAddr from the given pointer.
std::enable_if_t< std::is_pointer< T >::value, T > toPtr(WrapFn &&Wrap=WrapFn()) const
Cast this ExecutorAddr to a pointer of the given type.
static llvm::orc::shared::CWrapperFunctionResult writeUIntsWrapper(const char *ArgData, size_t ArgSize)
static llvm::orc::shared::CWrapperFunctionResult runAsVoidFunctionWrapper(const char *ArgData, size_t ArgSize)
void addTo(StringMap< ExecutorAddr > &M)
static llvm::orc::shared::CWrapperFunctionResult writePointersWrapper(const char *ArgData, size_t ArgSize)
static llvm::orc::shared::CWrapperFunctionResult runAsMainWrapper(const char *ArgData, size_t ArgSize)
static llvm::orc::shared::CWrapperFunctionResult writeBuffersWrapper(const char *ArgData, size_t ArgSize)
static llvm::orc::shared::CWrapperFunctionResult runAsIntFunctionWrapper(const char *ArgData, size_t ArgSize)
const char * MemoryWriteUInt16sWrapperName
Definition: OrcRTBridge.cpp:44
const char * RunAsIntFunctionWrapperName
Definition: OrcRTBridge.cpp:63
const char * DeregisterEHFrameSectionWrapperName
Definition: OrcRTBridge.cpp:57
const char * RegisterEHFrameSectionWrapperName
Definition: OrcRTBridge.cpp:55
const char * MemoryWriteUInt64sWrapperName
Definition: OrcRTBridge.cpp:48
const char * MemoryWriteUInt8sWrapperName
Definition: OrcRTBridge.cpp:42
const char * MemoryWritePointersWrapperName
Definition: OrcRTBridge.cpp:52
const char * MemoryWriteUInt32sWrapperName
Definition: OrcRTBridge.cpp:46
const char * RunAsVoidFunctionWrapperName
Definition: OrcRTBridge.cpp:61
const char * MemoryWriteBuffersWrapperName
Definition: OrcRTBridge.cpp:50
const char * RunAsMainWrapperName
Definition: OrcRTBridge.cpp:60
int runAsVoidFunction(int(*Func)(void))
int runAsIntFunction(int(*Func)(int), int Arg)
int runAsMain(int(*Main)(int, char *[]), ArrayRef< std::string > Args, std::optional< StringRef > ProgramName=std::nullopt)
Run a main function, returning the result.
This is an optimization pass for GlobalISel generic memory operations.
Definition: AddressRanges.h:18