LLVM 20.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
17
18namespace llvm::orc {
19
20/// A MaterializationUnit implementation for pre-existing absolute symbols.
21///
22/// All symbols will be resolved and marked ready as soon as the unit is
23/// materialized.
25public:
27
28 StringRef getName() const override;
29
30private:
31 void materialize(std::unique_ptr<MaterializationResponsibility> R) override;
32 void discard(const JITDylib &JD, const SymbolStringPtr &Name) override;
33 static MaterializationUnit::Interface extractFlags(const SymbolMap &Symbols);
34
35 SymbolMap Symbols;
36};
37
38/// Create an AbsoluteSymbolsMaterializationUnit with the given symbols.
39/// Useful for inserting absolute symbols into a JITDylib. E.g.:
40/// \code{.cpp}
41/// JITDylib &JD = ...;
42/// SymbolStringPtr Foo = ...;
43/// ExecutorSymbolDef FooSym = ...;
44/// if (auto Err = JD.define(absoluteSymbols({
45/// { Foo, FooSym },
46/// { Bar, BarSym }
47/// })))
48/// return Err;
49/// \endcode
50///
51inline std::unique_ptr<AbsoluteSymbolsMaterializationUnit>
53 return std::make_unique<AbsoluteSymbolsMaterializationUnit>(
54 std::move(Symbols));
55}
56
57} // namespace llvm::orc
58
59#endif // LLVM_EXECUTIONENGINE_ORC_ABSOLUTESYMBOLS_H
std::string Name
StringRef - Represent a constant reference to a string, i.e.
Definition: StringRef.h:51
A MaterializationUnit implementation for pre-existing absolute symbols.
StringRef getName() const override
Return the name of this materialization unit.
Represents a JIT'd dynamic library.
Definition: Core.h:897
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.