1 | //===-- LookupAndRecordAddrs.h - Symbol lookup support utility --*- 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 | // Record the addresses of a set of symbols into ExecutorAddr objects. |
10 | // |
11 | // This can be used to avoid repeated lookup (via ExecutionSession::lookup) of |
12 | // the given symbols. |
13 | // |
14 | //===----------------------------------------------------------------------===// |
15 | |
16 | #ifndef LLVM_EXECUTIONENGINE_ORC_LOOKUPANDRECORDADDRS_H |
17 | #define LLVM_EXECUTIONENGINE_ORC_LOOKUPANDRECORDADDRS_H |
18 | |
19 | #include "llvm/ADT/FunctionExtras.h" |
20 | #include "llvm/ExecutionEngine/Orc/Core.h" |
21 | #include "llvm/ExecutionEngine/Orc/Shared/ExecutorAddress.h" |
22 | |
23 | #include <vector> |
24 | |
25 | namespace llvm { |
26 | namespace orc { |
27 | |
28 | /// Record addresses of the given symbols in the given ExecutorAddrs. |
29 | /// |
30 | /// Useful for making permanent records of symbol addreses to call or |
31 | /// access in the executor (e.g. runtime support functions in Platform |
32 | /// subclasses). |
33 | /// |
34 | /// By default the symbols are looked up using |
35 | /// SymbolLookupFlags::RequiredSymbol, and an error will be generated if any of |
36 | /// the requested symbols are not defined. |
37 | /// |
38 | /// If SymbolLookupFlags::WeaklyReferencedSymbol is used then any missing |
39 | /// symbols will have their corresponding address objects set to zero, and |
40 | /// this function will never generate an error (the caller will need to check |
41 | /// addresses before using them). |
42 | /// |
43 | /// Asynchronous version. |
44 | void lookupAndRecordAddrs( |
45 | unique_function<void(Error)> OnRecorded, ExecutionSession &ES, LookupKind K, |
46 | const JITDylibSearchOrder &SearchOrder, |
47 | std::vector<std::pair<SymbolStringPtr, ExecutorAddr *>> Pairs, |
48 | SymbolLookupFlags LookupFlags = SymbolLookupFlags::RequiredSymbol); |
49 | |
50 | /// Record addresses of the given symbols in the given ExecutorAddrs. |
51 | /// |
52 | /// Blocking version. |
53 | Error lookupAndRecordAddrs( |
54 | ExecutionSession &ES, LookupKind K, const JITDylibSearchOrder &SearchOrder, |
55 | std::vector<std::pair<SymbolStringPtr, ExecutorAddr *>> Pairs, |
56 | SymbolLookupFlags LookupFlags = SymbolLookupFlags::RequiredSymbol); |
57 | |
58 | /// Record addresses of given symbols in the given ExecutorAddrs. |
59 | /// |
60 | /// ExecutorProcessControl lookup version. Lookups are always implicitly |
61 | /// weak. |
62 | Error lookupAndRecordAddrs( |
63 | ExecutorProcessControl &EPC, tpctypes::DylibHandle H, |
64 | std::vector<std::pair<SymbolStringPtr, ExecutorAddr *>> Pairs, |
65 | SymbolLookupFlags LookupFlags = SymbolLookupFlags::RequiredSymbol); |
66 | |
67 | } // End namespace orc |
68 | } // End namespace llvm |
69 | |
70 | #endif // LLVM_EXECUTIONENGINE_ORC_LOOKUPANDRECORDADDRS_H |
71 | |