LLVM  16.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 
18 using namespace llvm::orc::shared;
19 
20 namespace llvm {
21 namespace orc {
22 namespace rt_bootstrap {
23 
24 template <typename WriteT, typename SPSWriteT>
26 writeUIntsWrapper(const char *ArgData, size_t ArgSize) {
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 
37 writeBuffersWrapper(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 
49 runAsMainWrapper(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 
60 runAsVoidFunctionWrapper(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 
70 runAsIntFunctionWrapper(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::ExecutorAddr
Represents an address in the executor process.
Definition: ExecutorAddress.h:31
llvm::orc::rt_bootstrap::addTo
void addTo(StringMap< ExecutorAddr > &M)
Definition: OrcRTBootstrap.cpp:80
llvm::orc::ExecutorAddr::fromPtr
static ExecutorAddr fromPtr(T *Ptr, UnwrapFn &&Unwrap=UnwrapFn())
Create an ExecutorAddr from the given pointer.
Definition: ExecutorAddress.h:80
llvm
This is an optimization pass for GlobalISel generic memory operations.
Definition: AddressRanges.h:18
M
We currently emits eax Perhaps this is what we really should generate is Is imull three or four cycles eax eax The current instruction priority is based on pattern complexity The former is more complex because it folds a load so the latter will not be emitted Perhaps we should use AddedComplexity to give LEA32r a higher priority We should always try to match LEA first since the LEA matching code does some estimate to determine whether the match is profitable if we care more about code then imull is better It s two bytes shorter than movl leal On a Pentium M
Definition: README.txt:252
llvm::orc::shared::SPSSequence
SPS tag type for sequences.
Definition: SimplePackedSerialization.h:205
llvm::orc::shared::CWrapperFunctionResult
Definition: WrapperFunctionUtils.h:33
llvm_orc_registerEHFrameSectionWrapper
llvm::orc::shared::CWrapperFunctionResult llvm_orc_registerEHFrameSectionWrapper(const char *Data, uint64_t Size)
Definition: RegisterEHFrames.cpp:172
llvm::RISCVFenceField::W
@ W
Definition: RISCVBaseInfo.h:266
llvm::orc::shared::WrapperFunction
Definition: WrapperFunctionUtils.h:434
llvm::orc::rt_bootstrap::runAsIntFunctionWrapper
static llvm::orc::shared::CWrapperFunctionResult runAsIntFunctionWrapper(const char *ArgData, size_t ArgSize)
Definition: OrcRTBootstrap.cpp:70
WrapperFunctionUtils.h
llvm::orc::shared
Definition: ELFNixPlatform.h:245
llvm::AtomicOrderingCABI::release
@ release
OrcRTBootstrap.h
llvm::orc::shared::SPSTuple
SPS tag type for tuples.
Definition: SimplePackedSerialization.h:195
handle
then ret i32 result Tail recursion elimination should handle
Definition: README.txt:355
llvm::orc::rt::RegisterEHFrameSectionWrapperName
const char * RegisterEHFrameSectionWrapperName
Definition: OrcRTBridge.cpp:53
llvm::orc::rt::MemoryWriteUInt64sWrapperName
const char * MemoryWriteUInt64sWrapperName
Definition: OrcRTBridge.cpp:48
Arg
amdgpu Simplify well known AMD library false FunctionCallee Value * Arg
Definition: AMDGPULibCalls.cpp:187
llvm::orc::rt::MemoryWriteUInt32sWrapperName
const char * MemoryWriteUInt32sWrapperName
Definition: OrcRTBridge.cpp:46
llvm::orc::ExecutorAddr::toPtr
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.
Definition: ExecutorAddress.h:89
int
Clang compiles this i1 i64 store i64 i64 store i64 i64 store i64 i64 store i64 align Which gets codegen d xmm0 movaps rbp movaps rbp movaps rbp movaps rbp rbp rbp rbp rbp It would be better to have movq s of instead of the movaps s LLVM produces ret int
Definition: README.txt:536
llvm::orc::rt::MemoryWriteBuffersWrapperName
const char * MemoryWriteBuffersWrapperName
Definition: OrcRTBridge.cpp:50
RegisterEHFrames.h
llvm::StringMap
StringMap - This is an unconventional map that is specialized for handling keys that are "strings",...
Definition: StringMap.h:110
llvm::orc::rt::MemoryWriteUInt16sWrapperName
const char * MemoryWriteUInt16sWrapperName
Definition: OrcRTBridge.cpp:44
llvm::orc::rt::RunAsIntFunctionWrapperName
const char * RunAsIntFunctionWrapperName
Definition: OrcRTBridge.cpp:61
llvm::orc::rt::DeregisterEHFrameSectionWrapperName
const char * DeregisterEHFrameSectionWrapperName
Definition: OrcRTBridge.cpp:55
llvm::orc::rt_bootstrap::writeUIntsWrapper
static llvm::orc::shared::CWrapperFunctionResult writeUIntsWrapper(const char *ArgData, size_t ArgSize)
Definition: OrcRTBootstrap.cpp:26
memcpy
<%struct.s * > cast struct s *S to sbyte *< sbyte * > sbyte uint cast struct s *agg result to sbyte *< sbyte * > sbyte uint cast struct s *memtmp to sbyte *< sbyte * > sbyte uint ret void llc ends up issuing two memcpy or custom lower memcpy(of small size) to be ldmia/stmia. I think option 2 is better but the current register allocator cannot allocate a chunk of registers at a time. A feasible temporary solution is to use specific physical registers at the lowering time for small(<
llvm::orc::rt::MemoryWriteUInt8sWrapperName
const char * MemoryWriteUInt8sWrapperName
Definition: OrcRTBridge.cpp:42
llvm::orc::runAsIntFunction
int runAsIntFunction(int(*Func)(int), int Arg)
Definition: TargetExecutionUtils.cpp:44
llvm::orc::tpctypes::UIntWrite
Definition: TargetProcessControlTypes.h:56
llvm::orc::rt_bootstrap::writeBuffersWrapper
static llvm::orc::shared::CWrapperFunctionResult writeBuffersWrapper(const char *ArgData, size_t ArgSize)
Definition: OrcRTBootstrap.cpp:37
llvm_orc_deregisterEHFrameSectionWrapper
llvm::orc::shared::CWrapperFunctionResult llvm_orc_deregisterEHFrameSectionWrapper(const char *Data, uint64_t Size)
Definition: RegisterEHFrames.cpp:179
llvm::orc::rt::RunAsVoidFunctionWrapperName
const char * RunAsVoidFunctionWrapperName
Definition: OrcRTBridge.cpp:59
llvm::orc::runAsVoidFunction
int runAsVoidFunction(int(*Func)(void))
Definition: TargetExecutionUtils.cpp:42
llvm::orc::rt::RunAsMainWrapperName
const char * RunAsMainWrapperName
Definition: OrcRTBridge.cpp:58
TargetExecutionUtils.h
llvm::AMDGPU::HSAMD::Kernel::Key::Args
constexpr char Args[]
Key for Kernel::Metadata::mArgs.
Definition: AMDGPUMetadata.h:394
llvm::orc::runAsMain
int runAsMain(int(*Main)(int, char *[]), ArrayRef< std::string > Args, Optional< StringRef > ProgramName=std::nullopt)
Run a main function, returning the result.
Definition: TargetExecutionUtils.cpp:16
llvm::orc::rt_bootstrap::runAsMainWrapper
static llvm::orc::shared::CWrapperFunctionResult runAsMainWrapper(const char *ArgData, size_t ArgSize)
Definition: OrcRTBootstrap.cpp:49
OrcRTBridge.h
llvm::orc::rt_bootstrap::runAsVoidFunctionWrapper
static llvm::orc::shared::CWrapperFunctionResult runAsVoidFunctionWrapper(const char *ArgData, size_t ArgSize)
Definition: OrcRTBootstrap.cpp:60