LLVM 22.0.0git
AbsoluteSymbols.h
Go to the documentation of this file.
1//===------ AbsoluteSymbols.h - Absolute symbols utilities ------*- 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// absoluteSymbols function and related utilities.
10//
11//===----------------------------------------------------------------------===//
12
13#ifndef LLVM_EXECUTIONENGINE_ORC_ABSOLUTESYMBOLS_H
14#define LLVM_EXECUTIONENGINE_ORC_ABSOLUTESYMBOLS_H
15
18
19namespace llvm::orc {
20
21/// A MaterializationUnit implementation for pre-existing absolute symbols.
22///
23/// All symbols will be resolved and marked ready as soon as the unit is
24/// materialized.
26public:
28
29 StringRef getName() const override;
30
31private:
32 void materialize(std::unique_ptr<MaterializationResponsibility> R) override;
33 void discard(const JITDylib &JD, const SymbolStringPtr &Name) override;
34 static MaterializationUnit::Interface extractFlags(const SymbolMap &Symbols);
35
36 SymbolMap Symbols;
37};
38
39/// Create an AbsoluteSymbolsMaterializationUnit with the given symbols.
40/// Useful for inserting absolute symbols into a JITDylib. E.g.:
41/// \code{.cpp}
42/// JITDylib &JD = ...;
43/// SymbolStringPtr Foo = ...;
44/// ExecutorSymbolDef FooSym = ...;
45/// if (auto Err = JD.define(absoluteSymbols({
46/// { Foo, FooSym },
47/// { Bar, BarSym }
48/// })))
49/// return Err;
50/// \endcode
51///
52inline std::unique_ptr<AbsoluteSymbolsMaterializationUnit>
54 return std::make_unique<AbsoluteSymbolsMaterializationUnit>(
55 std::move(Symbols));
56}
57
58} // namespace llvm::orc
59
60#endif // LLVM_EXECUTIONENGINE_ORC_ABSOLUTESYMBOLS_H
#define LLVM_ABI
Definition: Compiler.h:213
std::string Name
static StringRef getName(Value *V)
StringRef - Represent a constant reference to a string, i.e.
Definition: StringRef.h:55
A MaterializationUnit implementation for pre-existing absolute symbols.
Represents a JIT'd dynamic library.
Definition: Core.h:902
A MaterializationUnit represents a set of symbol definitions that can be materialized as a group,...
Pointer to a pooled string representing a symbol name.
std::unique_ptr< AbsoluteSymbolsMaterializationUnit > absoluteSymbols(SymbolMap Symbols)
Create an AbsoluteSymbolsMaterializationUnit with the given symbols.