LLVM 24.0.0git
RecordProxy.h
Go to the documentation of this file.
1//===- RecordProxy.h - Build a Proxy from a lookup --------------*- 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// lookupAndApply operations that build Proxy objects over the symbols they
10// resolve.
11//
12// This is kept out of Proxy.h so that clients holding or calling a Proxy do not
13// have to see the lookup machinery used to build one.
14//
15//===----------------------------------------------------------------------===//
16
17#ifndef LLVM_EXECUTIONENGINE_ORC_RECORDPROXY_H
18#define LLVM_EXECUTIONENGINE_ORC_RECORDPROXY_H
19
22
23namespace llvm::orc {
24
25/// Builds P over the symbol with the given name, dispatching through Dispatch.
26///
27/// If the symbol is weakly referenced and not found then P is left null.
28template <typename FnT>
31 StringRef Name,
33 return [P, Dispatch, Name, LF](SymbolLookupSet &LS,
35 auto N = ES.intern(Name);
36 LS.add(N, LF);
37 return [P, Dispatch, N = std::move(N)](const SymbolMap &M) {
38 auto Sym = M.lookup(N);
39 *P = Sym.getAddress() ? Proxy<FnT>(Dispatch, Sym.getAddress())
40 : Proxy<FnT>();
41 };
42 };
43}
44
45/// Builds P from the given spec, using the spec's default controller-interface
46/// name.
47template <typename ProxySpecT, typename FnT>
51 return recordProxy(P, ProxySpecT::dispatch, ProxySpecT::Name, LF);
52}
53
54/// Builds P from the given spec, but resolves it under Name rather than the
55/// spec's default controller-interface name.
56template <typename ProxySpecT, typename FnT>
60 return recordProxy(P, ProxySpecT::dispatch, Name, LF);
61}
62
63} // namespace llvm::orc
64
65#endif // LLVM_EXECUTIONENGINE_ORC_RECORDPROXY_H
#define P(N)
Represent a constant reference to a string, i.e.
Definition StringRef.h:56
An ExecutionSession represents a running JIT program.
Definition Core.h:1111
A set of symbols to look up, each associated with a SymbolLookupFlags value.
SymbolLookupFlags
Lookup flags that apply to each symbol in a lookup.
DenseMap< SymbolStringPtr, ExecutorSymbolDef > SymbolMap
A map from symbol names (as SymbolStringPtrs) to JITSymbols (address/flags pairs).
unique_function< void(const SymbolMap &M)> LookupApplyFn
Acts on the result of a completed lookup.
LookupPrepareFn recordProxy(Proxy< FnT > *P, typename Proxy< FnT >::DispatchFn Dispatch, StringRef Name, SymbolLookupFlags LF=SymbolLookupFlags::RequiredSymbol)
Builds P over the symbol with the given name, dispatching through Dispatch.
Definition RecordProxy.h:30
unique_function< LookupApplyFn( SymbolLookupSet &LS, ExecutionSession &ES) const > LookupPrepareFn
Contributes symbols to a lookup, and returns the function that will act on the result.
#define N