1 //===------- Legacy.cpp - Adapters for ExecutionEngine API interop --------===//
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
7 //===----------------------------------------------------------------------===//
9 #include "llvm/ExecutionEngine/Orc/Legacy.h"
14 void SymbolResolver::anchor() {}
16 JITSymbolResolverAdapter::JITSymbolResolverAdapter(
17 ExecutionSession
&ES
, SymbolResolver
&R
, MaterializationResponsibility
*MR
)
18 : ES(ES
), R(R
), MR(MR
) {}
20 void JITSymbolResolverAdapter::lookup(const LookupSet
&Symbols
,
21 OnResolvedFunction OnResolved
) {
22 SymbolNameSet InternedSymbols
;
23 for (auto &S
: Symbols
)
24 InternedSymbols
.insert(ES
.intern(S
));
26 auto OnResolvedWithUnwrap
= [OnResolved
= std::move(OnResolved
)](
27 Expected
<SymbolMap
> InternedResult
) mutable {
28 if (!InternedResult
) {
29 OnResolved(InternedResult
.takeError());
34 for (auto &KV
: *InternedResult
)
35 Result
[*KV
.first
] = std::move(KV
.second
);
39 auto Q
= std::make_shared
<AsynchronousSymbolQuery
>(
40 InternedSymbols
, SymbolState::Resolved
, std::move(OnResolvedWithUnwrap
));
42 auto Unresolved
= R
.lookup(Q
, InternedSymbols
);
43 if (Unresolved
.empty()) {
45 MR
->addDependenciesForAll(Q
->QueryRegistrations
);
47 ES
.legacyFailQuery(*Q
, make_error
<SymbolsNotFound
>(std::move(Unresolved
)));
50 Expected
<JITSymbolResolverAdapter::LookupSet
>
51 JITSymbolResolverAdapter::getResponsibilitySet(const LookupSet
&Symbols
) {
52 SymbolNameSet InternedSymbols
;
53 for (auto &S
: Symbols
)
54 InternedSymbols
.insert(ES
.intern(S
));
56 auto InternedResult
= R
.getResponsibilitySet(InternedSymbols
);
58 for (auto &S
: InternedResult
) {
59 ResolvedStrings
.insert(S
);
66 } // End namespace orc.
67 } // End namespace llvm.