Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-05-10 08:43:52

0001 //===- EPCGenericDylibManager.h -- Generic EPC Dylib management -*- C++ -*-===//
0002 //
0003 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
0004 // See https://llvm.org/LICENSE.txt for license information.
0005 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
0006 //
0007 //===----------------------------------------------------------------------===//
0008 //
0009 // Implements dylib loading and searching by making calls to
0010 // ExecutorProcessControl::callWrapper.
0011 //
0012 // This simplifies the implementaton of new ExecutorProcessControl instances,
0013 // as this implementation will always work (at the cost of some performance
0014 // overhead for the calls).
0015 //
0016 //===----------------------------------------------------------------------===//
0017 
0018 #ifndef LLVM_EXECUTIONENGINE_ORC_EPCGENERICDYLIBMANAGER_H
0019 #define LLVM_EXECUTIONENGINE_ORC_EPCGENERICDYLIBMANAGER_H
0020 
0021 #include "llvm/ExecutionEngine/Orc/ExecutorProcessControl.h"
0022 #include "llvm/ExecutionEngine/Orc/Shared/ExecutorSymbolDef.h"
0023 #include "llvm/ExecutionEngine/Orc/Shared/SimpleRemoteEPCUtils.h"
0024 
0025 namespace llvm {
0026 namespace orc {
0027 
0028 class SymbolLookupSet;
0029 
0030 class EPCGenericDylibManager {
0031 public:
0032   /// Function addresses for memory access.
0033   struct SymbolAddrs {
0034     ExecutorAddr Instance;
0035     ExecutorAddr Open;
0036     ExecutorAddr Lookup;
0037   };
0038 
0039   /// Create an EPCGenericMemoryAccess instance from a given set of
0040   /// function addrs.
0041   static Expected<EPCGenericDylibManager>
0042   CreateWithDefaultBootstrapSymbols(ExecutorProcessControl &EPC);
0043 
0044   /// Create an EPCGenericMemoryAccess instance from a given set of
0045   /// function addrs.
0046   EPCGenericDylibManager(ExecutorProcessControl &EPC, SymbolAddrs SAs)
0047       : EPC(EPC), SAs(SAs) {}
0048 
0049   /// Loads the dylib with the given name.
0050   Expected<tpctypes::DylibHandle> open(StringRef Path, uint64_t Mode);
0051 
0052   /// Looks up symbols within the given dylib.
0053   Expected<std::vector<ExecutorSymbolDef>>
0054   lookup(tpctypes::DylibHandle H, const SymbolLookupSet &Lookup) {
0055     std::promise<MSVCPExpected<std::vector<ExecutorSymbolDef>>> RP;
0056     auto RF = RP.get_future();
0057     lookupAsync(H, Lookup, [&RP](auto R) { RP.set_value(std::move(R)); });
0058     return RF.get();
0059   }
0060 
0061   /// Looks up symbols within the given dylib.
0062   Expected<std::vector<ExecutorSymbolDef>>
0063   lookup(tpctypes::DylibHandle H, const RemoteSymbolLookupSet &Lookup) {
0064     std::promise<MSVCPExpected<std::vector<ExecutorSymbolDef>>> RP;
0065     auto RF = RP.get_future();
0066     lookupAsync(H, Lookup, [&RP](auto R) { RP.set_value(std::move(R)); });
0067     return RF.get();
0068   }
0069 
0070   using SymbolLookupCompleteFn =
0071       unique_function<void(Expected<std::vector<ExecutorSymbolDef>>)>;
0072 
0073   /// Looks up symbols within the given dylib.
0074   void lookupAsync(tpctypes::DylibHandle H, const SymbolLookupSet &Lookup,
0075                    SymbolLookupCompleteFn Complete);
0076 
0077   /// Looks up symbols within the given dylib.
0078   void lookupAsync(tpctypes::DylibHandle H, const RemoteSymbolLookupSet &Lookup,
0079                    SymbolLookupCompleteFn Complete);
0080 
0081 private:
0082   ExecutorProcessControl &EPC;
0083   SymbolAddrs SAs;
0084 };
0085 
0086 } // end namespace orc
0087 } // end namespace llvm
0088 
0089 #endif // LLVM_EXECUTIONENGINE_ORC_EPCGENERICDYLIBMANAGER_H