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
](Expected
<SymbolMap
> InternedResult
) {
27 if (!InternedResult
) {
28 OnResolved(InternedResult
.takeError());
33 for (auto &KV
: *InternedResult
)
34 Result
[*KV
.first
] = std::move(KV
.second
);
38 auto Q
= std::make_shared
<AsynchronousSymbolQuery
>(
39 InternedSymbols
, SymbolState::Resolved
, OnResolvedWithUnwrap
);
41 auto Unresolved
= R
.lookup(Q
, InternedSymbols
);
42 if (Unresolved
.empty()) {
44 MR
->addDependenciesForAll(Q
->QueryRegistrations
);
46 ES
.legacyFailQuery(*Q
, make_error
<SymbolsNotFound
>(std::move(Unresolved
)));
49 Expected
<JITSymbolResolverAdapter::LookupSet
>
50 JITSymbolResolverAdapter::getResponsibilitySet(const LookupSet
&Symbols
) {
51 SymbolNameSet InternedSymbols
;
52 for (auto &S
: Symbols
)
53 InternedSymbols
.insert(ES
.intern(S
));
55 auto InternedResult
= R
.getResponsibilitySet(InternedSymbols
);
57 for (auto &S
: InternedResult
) {
58 ResolvedStrings
.insert(S
);
65 } // End namespace orc.
66 } // End namespace llvm.