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
49runAsMainWrapper(const char *ArgData, size_t ArgSize) {
51 ArgData, ArgSize,
52 [](ExecutorAddr MainAddr,
53 std::vector<std::string> Args) -> int64_t {
54 return runAsMain(MainAddr.toPtr<int (*)(int, char *[])>(), Args);
55 })
56 .release();
57}
58
60runAsVoidFunctionWrapper(const char *ArgData, size_t ArgSize) {
62 ArgData, ArgSize,
63 [](ExecutorAddr MainAddr) -> int32_t {
64 return runAsVoidFunction(MainAddr.toPtr<int32_t (*)(void)>());
65 })
66 .release();
67}
68
70runAsIntFunctionWrapper(const char *ArgData, size_t ArgSize) {
72 ArgData, ArgSize,
73 [](ExecutorAddr MainAddr, int32_t Arg) -> int32_t {
74 return runAsIntFunction(MainAddr.toPtr<int32_t (*)(int32_t)>(),
75 Arg);
76 })
77 .release();
78}
79
104}
105
106} // end namespace rt_bootstrap
107} // end namespace orc
108} // end namespace llvm
llvm::orc::shared::CWrapperFunctionResult llvm_orc_deregisterEHFrameSectionWrapper(const char *Data, uint64_t Size)
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 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:61
const char * DeregisterEHFrameSectionWrapperName
Definition: OrcRTBridge.cpp:55
const char * RegisterEHFrameSectionWrapperName
Definition: OrcRTBridge.cpp:53
const char * MemoryWriteUInt64sWrapperName
Definition: OrcRTBridge.cpp:48
const char * MemoryWriteUInt8sWrapperName
Definition: OrcRTBridge.cpp:42
const char * MemoryWriteUInt32sWrapperName
Definition: OrcRTBridge.cpp:46
const char * RunAsVoidFunctionWrapperName
Definition: OrcRTBridge.cpp:59
const char * MemoryWriteBuffersWrapperName
Definition: OrcRTBridge.cpp:50
const char * RunAsMainWrapperName
Definition: OrcRTBridge.cpp:58
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