LLVM  9.0.0svn
LambdaResolver.h
Go to the documentation of this file.
1 //===- LambdaResolverMM - Redirect symbol lookup via a functor --*- 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 // Defines a RuntimeDyld::SymbolResolver subclass that uses a user-supplied
10 // functor for symbol resolution.
11 //
12 //===----------------------------------------------------------------------===//
13 
14 #ifndef LLVM_EXECUTIONENGINE_ORC_LAMBDARESOLVER_H
15 #define LLVM_EXECUTIONENGINE_ORC_LAMBDARESOLVER_H
16 
17 #include "llvm/ADT/STLExtras.h"
19 #include <memory>
20 
21 namespace llvm {
22 namespace orc {
23 
24 template <typename DylibLookupFtorT, typename ExternalLookupFtorT>
26 public:
27  LambdaResolver(DylibLookupFtorT DylibLookupFtor,
28  ExternalLookupFtorT ExternalLookupFtor)
29  : DylibLookupFtor(DylibLookupFtor),
30  ExternalLookupFtor(ExternalLookupFtor) {}
31 
32  JITSymbol findSymbolInLogicalDylib(const std::string &Name) final {
33  return DylibLookupFtor(Name);
34  }
35 
36  JITSymbol findSymbol(const std::string &Name) final {
37  return ExternalLookupFtor(Name);
38  }
39 
40 private:
41  DylibLookupFtorT DylibLookupFtor;
42  ExternalLookupFtorT ExternalLookupFtor;
43 };
44 
45 template <typename DylibLookupFtorT,
46  typename ExternalLookupFtorT>
47 std::shared_ptr<LambdaResolver<DylibLookupFtorT, ExternalLookupFtorT>>
48 createLambdaResolver(DylibLookupFtorT DylibLookupFtor,
49  ExternalLookupFtorT ExternalLookupFtor) {
51  return make_unique<LR>(std::move(DylibLookupFtor),
52  std::move(ExternalLookupFtor));
53 }
54 
55 } // end namespace orc
56 } // end namespace llvm
57 
58 #endif // LLVM_EXECUTIONENGINE_ORC_LAMBDARESOLVER_H
Represents a symbol in the JIT.
Definition: JITSymbol.h:218
This class represents lattice values for constants.
Definition: AllocatorList.h:23
amdgpu Simplify well known AMD library false FunctionCallee Value const Twine & Name
Legacy symbol resolution interface.
Definition: JITSymbol.h:351
LambdaResolver(DylibLookupFtorT DylibLookupFtor, ExternalLookupFtorT ExternalLookupFtor)
JITSymbol findSymbolInLogicalDylib(const std::string &Name) final
This method returns the address of the specified symbol if it exists within the logical dynamic libra...
JITSymbol findSymbol(const std::string &Name) final
This method returns the address of the specified function or variable.
std::shared_ptr< LambdaResolver< DylibLookupFtorT, ExternalLookupFtorT > > createLambdaResolver(DylibLookupFtorT DylibLookupFtor, ExternalLookupFtorT ExternalLookupFtor)