[Alignment][NFC] Use Align with TargetLowering::setMinFunctionAlignment
[llvm-core.git] / include / llvm / ExecutionEngine / Orc / LambdaResolver.h
blobb31914f12a0d332729f5ffbdecae2bde43617c17
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.
12 //===----------------------------------------------------------------------===//
14 #ifndef LLVM_EXECUTIONENGINE_ORC_LAMBDARESOLVER_H
15 #define LLVM_EXECUTIONENGINE_ORC_LAMBDARESOLVER_H
17 #include "llvm/ADT/STLExtras.h"
18 #include "llvm/ExecutionEngine/JITSymbol.h"
19 #include "llvm/ExecutionEngine/OrcV1Deprecation.h"
20 #include <memory>
22 namespace llvm {
23 namespace orc {
25 template <typename DylibLookupFtorT, typename ExternalLookupFtorT>
26 class LambdaResolver : public LegacyJITSymbolResolver {
27 public:
28 LLVM_ATTRIBUTE_DEPRECATED(
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)");
35 LambdaResolver(ORCv1DeprecationAcknowledgement,
36 DylibLookupFtorT DylibLookupFtor,
37 ExternalLookupFtorT ExternalLookupFtor)
38 : DylibLookupFtor(DylibLookupFtor),
39 ExternalLookupFtor(ExternalLookupFtor) {}
41 JITSymbol findSymbolInLogicalDylib(const std::string &Name) final {
42 return DylibLookupFtor(Name);
45 JITSymbol findSymbol(const std::string &Name) final {
46 return ExternalLookupFtor(Name);
49 private:
50 DylibLookupFtorT DylibLookupFtor;
51 ExternalLookupFtorT ExternalLookupFtor;
54 template <typename DylibLookupFtorT, typename ExternalLookupFtorT>
55 LambdaResolver<DylibLookupFtorT, ExternalLookupFtorT>::LambdaResolver(
56 DylibLookupFtorT DylibLookupFtor, ExternalLookupFtorT ExternalLookupFtor)
57 : DylibLookupFtor(DylibLookupFtor), ExternalLookupFtor(ExternalLookupFtor) {
60 template <typename DylibLookupFtorT,
61 typename ExternalLookupFtorT>
62 std::shared_ptr<LambdaResolver<DylibLookupFtorT, ExternalLookupFtorT>>
63 createLambdaResolver(DylibLookupFtorT DylibLookupFtor,
64 ExternalLookupFtorT ExternalLookupFtor) {
65 using LR = LambdaResolver<DylibLookupFtorT, ExternalLookupFtorT>;
66 return std::make_unique<LR>(std::move(DylibLookupFtor),
67 std::move(ExternalLookupFtor));
70 template <typename DylibLookupFtorT, typename ExternalLookupFtorT>
71 std::shared_ptr<LambdaResolver<DylibLookupFtorT, ExternalLookupFtorT>>
72 createLambdaResolver(ORCv1DeprecationAcknowledgement,
73 DylibLookupFtorT DylibLookupFtor,
74 ExternalLookupFtorT ExternalLookupFtor) {
75 using LR = LambdaResolver<DylibLookupFtorT, ExternalLookupFtorT>;
76 return std::make_unique<LR>(AcknowledgeORCv1Deprecation,
77 std::move(DylibLookupFtor),
78 std::move(ExternalLookupFtor));
81 } // end namespace orc
82 } // end namespace llvm
84 #endif // LLVM_EXECUTIONENGINE_ORC_LAMBDARESOLVER_H