[InstCombine] Signed saturation patterns
[llvm-complete.git] / lib / ExecutionEngine / Orc / Legacy.cpp
blob9f9a6730b2c3071aa2477cd7cf856faa19c4357b
1 //===------- Legacy.cpp - Adapters for ExecutionEngine API interop --------===//
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 //===----------------------------------------------------------------------===//
9 #include "llvm/ExecutionEngine/Orc/Legacy.h"
11 namespace llvm {
12 namespace orc {
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());
30 return;
33 LookupResult Result;
34 for (auto &KV : *InternedResult)
35 Result[*KV.first] = std::move(KV.second);
36 OnResolved(Result);
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()) {
44 if (MR)
45 MR->addDependenciesForAll(Q->QueryRegistrations);
46 } else
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);
57 LookupSet Result;
58 for (auto &S : InternedResult) {
59 ResolvedStrings.insert(S);
60 Result.insert(*S);
63 return Result;
66 } // End namespace orc.
67 } // End namespace llvm.