14 #ifndef LLVM_EXECUTIONENGINE_ORC_IRCOMPILELAYER_H
15 #define LLVM_EXECUTIONENGINE_ORC_IRCOMPILELAYER_H
33 typedef std::function<object::OwningBinary<object::ObjectFile>(
Module &)>
37 typedef typename BaseLayerT::ObjSetHandleT ObjSetHandleT;
46 : BaseLayer(BaseLayer), Compile(std::move(Compile)), ObjCache(nullptr) {}
56 template <
typename ModuleSetT,
typename MemoryManagerPtrT,
57 typename SymbolResolverPtrT>
59 MemoryManagerPtrT MemMgr,
60 SymbolResolverPtrT Resolver) {
61 std::vector<std::unique_ptr<object::OwningBinary<object::ObjectFile>>>
64 for (
const auto &M : Ms) {
66 llvm::make_unique<object::OwningBinary<object::ObjectFile>>();
69 *Object = tryToLoadFromObjectCache(*M);
71 if (!Object->getBinary()) {
72 *Object = Compile(*M);
75 Object->getBinary()->getMemoryBufferRef());
78 Objects.push_back(std::move(Object));
82 BaseLayer.addObjectSet(std::move(Objects), std::move(MemMgr),
96 return BaseLayer.findSymbol(Name, ExportedSymbolsOnly);
108 bool ExportedSymbolsOnly) {
109 return BaseLayer.findSymbolIn(H, Name, ExportedSymbolsOnly);
116 BaseLayer.emitAndFinalize(H);
121 tryToLoadFromObjectCache(
const Module &M) {
122 std::unique_ptr<MemoryBuffer> ObjBuffer = ObjCache->
getObject(&M);
135 std::move(ObjBuffer));
138 BaseLayerT &BaseLayer;
140 ObjectCache *ObjCache;
146 #endif // LLVM_EXECUTIONENGINE_ORC_IRCOMPILINGLAYER_H
static Expected< OwningBinary< ObjectFile > > createObjectFile(StringRef ObjectPath)
Create ObjectFile from path.
Represents a symbol in the JIT.
A Module instance is used to store all the information related to an LLVM module. ...
virtual std::unique_ptr< MemoryBuffer > getObject(const Module *M)=0
Returns a pointer to a newly allocated MemoryBuffer that contains the object which corresponds with M...
ObjSetHandleT ModuleSetHandleT
Handle to a set of compiled modules.
IRCompileLayer(BaseLayerT &BaseLayer, CompileFtor Compile)
Construct an IRCompileLayer with the given BaseLayer, which must implement the ObjectLayer concept...
Tagged union holding either a T or a Error.
void setObjectCache(ObjectCache *NewCache)
Set an ObjectCache to query before compiling.
JITSymbol findSymbol(const std::string &Name, bool ExportedSymbolsOnly)
Search for the given named symbol.
Eager IR compiling layer.
std::function< object::OwningBinary< object::ObjectFile >Module &)> CompileFtor
void consumeError(Error Err)
Consume a Error without doing anything.
ModuleSetHandleT addModuleSet(ModuleSetT Ms, MemoryManagerPtrT MemMgr, SymbolResolverPtrT Resolver)
Compile each module in the given module set, then add the resulting set of objects to the base layer ...
virtual void notifyObjectCompiled(const Module *M, MemoryBufferRef Obj)=0
notifyObjectCompiled - Provides a pointer to compiled code for Module M.
void emitAndFinalize(ModuleSetHandleT H)
Immediately emit and finalize the moduleOB set represented by the given handle.
void removeModuleSet(ModuleSetHandleT H)
Remove the module set associated with the handle H.
JITSymbol findSymbolIn(ModuleSetHandleT H, const std::string &Name, bool ExportedSymbolsOnly)
Get the address of the given symbol in the context of the set of compiled modules represented by the ...
This is the base ObjectCache type which can be provided to an ExecutionEngine for the purpose of avoi...