LLVM 22.0.0git
ObjectLinkingLayer.h
Go to the documentation of this file.
1//===-- ObjectLinkingLayer.h - JITLink-based jit linking layer --*- C++ -*-===//
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// Contains the definition for an JITLink-based, in-process object linking
10// layer.
11//
12//===----------------------------------------------------------------------===//
13
14#ifndef LLVM_EXECUTIONENGINE_ORC_OBJECTLINKINGLAYER_H
15#define LLVM_EXECUTIONENGINE_ORC_OBJECTLINKINGLAYER_H
16
17#include "llvm/ADT/STLExtras.h"
18#include "llvm/ADT/StringRef.h"
23#include "llvm/Support/Error.h"
24
25#include <memory>
26
27namespace llvm {
28
29namespace jitlink {
30class EHFrameRegistrar;
31class LinkGraph;
32class Symbol;
33} // namespace jitlink
34
35namespace orc {
36
37/// An ObjectLayer implementation built on JITLink.
38///
39/// Clients can use this class to add relocatable object files to an
40/// ExecutionSession, and it typically serves as the base layer (underneath
41/// a compiling layer like IRCompileLayer) for the rest of the JIT.
43 : public LinkGraphLinkingLayer,
44 public RTTIExtends<ObjectLinkingLayer, ObjectLayer> {
45private:
47
48public:
49 static char ID;
50
52 std::function<void(std::unique_ptr<MemoryBuffer>)>;
53
54 /// Construct an ObjectLinkingLayer using the ExecutorProcessControl
55 /// instance's memory manager.
58
59 /// Construct an ObjectLinkingLayer using a custom memory manager.
62 : LinkGraphLinkingLayer(ES, MemMgr), BaseObjectLayer(ES) {}
63
64 /// Construct an ObjectLinkingLayer. Takes ownership of the given
65 /// JITLinkMemoryManager. This method is a temporary hack to simplify
66 /// co-existence with RTDyldObjectLinkingLayer (which also owns its
67 /// allocators).
69 std::unique_ptr<jitlink::JITLinkMemoryManager> MemMgr)
70 : LinkGraphLinkingLayer(ES, std::move(MemMgr)), BaseObjectLayer(ES) {}
71
72 using LinkGraphLinkingLayer::getExecutionSession;
73
74 /// Set an object buffer return function. By default object buffers are
75 /// deleted once the JIT has linked them. If a return function is set then
76 /// it will be called to transfer ownership of the buffer instead.
78 this->ReturnObjectBuffer = std::move(ReturnObjectBuffer);
79 }
80
81 using LinkGraphLinkingLayer::add;
82 using LinkGraphLinkingLayer::emit;
83
84 using ObjectLayer::add;
85
86 /// Emit an object file.
87 void emit(std::unique_ptr<MaterializationResponsibility> R,
88 std::unique_ptr<MemoryBuffer> O) override;
89};
90
91} // end namespace orc
92} // end namespace llvm
93
94#endif // LLVM_EXECUTIONENGINE_ORC_OBJECTLINKINGLAYER_H
#define LLVM_ABI
Definition: Compiler.h:213
This file contains some templates that are useful if you are working with the STL at all.
Inheritance utility for extensible RTTI.
An ExecutionSession represents a running JIT program.
Definition: Core.h:1355
LinkGraphLinkingLayer links LinkGraphs into the Executor using JITLink.
An ObjectLayer implementation built on JITLink.
void setReturnObjectBuffer(ReturnObjectBufferFunction ReturnObjectBuffer)
Set an object buffer return function.
ObjectLinkingLayer(ExecutionSession &ES)
Construct an ObjectLinkingLayer using the ExecutorProcessControl instance's memory manager.
std::function< void(std::unique_ptr< MemoryBuffer >)> ReturnObjectBufferFunction
ObjectLinkingLayer(ExecutionSession &ES, jitlink::JITLinkMemoryManager &MemMgr)
Construct an ObjectLinkingLayer using a custom memory manager.
ObjectLinkingLayer(ExecutionSession &ES, std::unique_ptr< jitlink::JITLinkMemoryManager > MemMgr)
Construct an ObjectLinkingLayer.
This is an optimization pass for GlobalISel generic memory operations.
Definition: AddressRanges.h:18
OutputIt move(R &&Range, OutputIt Out)
Provide wrappers to std::move which take ranges instead of having to pass begin/end explicitly.
Definition: STLExtras.h:1886
Implement std::hash so that hash_code can be used in STL containers.
Definition: BitVector.h:856