LLVM  10.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"
20 #include <memory>
21 
22 namespace llvm {
23 namespace orc {
24 
25 template <typename DylibLookupFtorT, typename ExternalLookupFtorT>
27 public:
29  LambdaResolver(DylibLookupFtorT DylibLookupFtor,
30  ExternalLookupFtorT ExternalLookupFtor),
31  "ORCv1 utilities (including resolvers) are deprecated and will be "
32  "removed "
33  "in the next release. Please use ORCv2 (see docs/ORCv2.rst)");
34 
36  DylibLookupFtorT DylibLookupFtor,
37  ExternalLookupFtorT ExternalLookupFtor)
38  : DylibLookupFtor(DylibLookupFtor),
39  ExternalLookupFtor(ExternalLookupFtor) {}
40 
41  JITSymbol findSymbolInLogicalDylib(const std::string &Name) final {
42  return DylibLookupFtor(Name);
43  }
44 
45  JITSymbol findSymbol(const std::string &Name) final {
46  return ExternalLookupFtor(Name);
47  }
48 
49 private:
50  DylibLookupFtorT DylibLookupFtor;
51  ExternalLookupFtorT ExternalLookupFtor;
52 };
53 
54 template <typename DylibLookupFtorT, typename ExternalLookupFtorT>
56  DylibLookupFtorT DylibLookupFtor, ExternalLookupFtorT ExternalLookupFtor)
57  : DylibLookupFtor(DylibLookupFtor), ExternalLookupFtor(ExternalLookupFtor) {
58 }
59 
60 template <typename DylibLookupFtorT,
61  typename ExternalLookupFtorT>
62 std::shared_ptr<LambdaResolver<DylibLookupFtorT, ExternalLookupFtorT>>
63 createLambdaResolver(DylibLookupFtorT DylibLookupFtor,
64  ExternalLookupFtorT ExternalLookupFtor) {
66  return std::make_unique<LR>(std::move(DylibLookupFtor),
67  std::move(ExternalLookupFtor));
68 }
69 
70 template <typename DylibLookupFtorT, typename ExternalLookupFtorT>
71 std::shared_ptr<LambdaResolver<DylibLookupFtorT, ExternalLookupFtorT>>
73  DylibLookupFtorT DylibLookupFtor,
74  ExternalLookupFtorT ExternalLookupFtor) {
76  return std::make_unique<LR>(AcknowledgeORCv1Deprecation,
77  std::move(DylibLookupFtor),
78  std::move(ExternalLookupFtor));
79 }
80 
81 } // end namespace orc
82 } // end namespace llvm
83 
84 #endif // LLVM_EXECUTIONENGINE_ORC_LAMBDARESOLVER_H
Represents a symbol in the JIT.
Definition: JITSymbol.h:219
This class represents lattice values for constants.
Definition: AllocatorList.h:23
LambdaResolver(ORCv1DeprecationAcknowledgement, DylibLookupFtorT DylibLookupFtor, ExternalLookupFtorT ExternalLookupFtor)
amdgpu Simplify well known AMD library false FunctionCallee Value const Twine & Name
Legacy symbol resolution interface.
Definition: JITSymbol.h:352
ORCv1DeprecationAcknowledgement
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)
LLVM_ATTRIBUTE_DEPRECATED(LambdaResolver(DylibLookupFtorT DylibLookupFtor, ExternalLookupFtorT ExternalLookupFtor), "ORCv1 utilities (including resolvers) are deprecated and will be " "removed " "in the next release. Please use ORCv2 (see docs/ORCv2.rst)")