xref: /freebsd-src/contrib/llvm-project/llvm/lib/ExecutionEngine/MCJIT/MCJIT.h (revision 81ad626541db97eb356e2c1d4a20eb2a26a766ab)
10b57cec5SDimitry Andric //===-- MCJIT.h - Class definition for the MCJIT ----------------*- C++ -*-===//
20b57cec5SDimitry Andric //
30b57cec5SDimitry Andric // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
40b57cec5SDimitry Andric // See https://llvm.org/LICENSE.txt for license information.
50b57cec5SDimitry Andric // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
60b57cec5SDimitry Andric //
70b57cec5SDimitry Andric //===----------------------------------------------------------------------===//
80b57cec5SDimitry Andric 
90b57cec5SDimitry Andric #ifndef LLVM_LIB_EXECUTIONENGINE_MCJIT_MCJIT_H
100b57cec5SDimitry Andric #define LLVM_LIB_EXECUTIONENGINE_MCJIT_MCJIT_H
110b57cec5SDimitry Andric 
120b57cec5SDimitry Andric #include "llvm/ADT/SmallPtrSet.h"
130b57cec5SDimitry Andric #include "llvm/ADT/SmallVector.h"
140b57cec5SDimitry Andric #include "llvm/ExecutionEngine/ExecutionEngine.h"
150b57cec5SDimitry Andric #include "llvm/ExecutionEngine/RTDyldMemoryManager.h"
160b57cec5SDimitry Andric #include "llvm/ExecutionEngine/RuntimeDyld.h"
170b57cec5SDimitry Andric 
180b57cec5SDimitry Andric namespace llvm {
190b57cec5SDimitry Andric class MCJIT;
205ffd83dbSDimitry Andric class Module;
215ffd83dbSDimitry Andric class ObjectCache;
220b57cec5SDimitry Andric 
230b57cec5SDimitry Andric // This is a helper class that the MCJIT execution engine uses for linking
240b57cec5SDimitry Andric // functions across modules that it owns.  It aggregates the memory manager
250b57cec5SDimitry Andric // that is passed in to the MCJIT constructor and defers most functionality
260b57cec5SDimitry Andric // to that object.
270b57cec5SDimitry Andric class LinkingSymbolResolver : public LegacyJITSymbolResolver {
280b57cec5SDimitry Andric public:
LinkingSymbolResolver(MCJIT & Parent,std::shared_ptr<LegacyJITSymbolResolver> Resolver)290b57cec5SDimitry Andric   LinkingSymbolResolver(MCJIT &Parent,
300b57cec5SDimitry Andric                         std::shared_ptr<LegacyJITSymbolResolver> Resolver)
310b57cec5SDimitry Andric       : ParentEngine(Parent), ClientResolver(std::move(Resolver)) {}
320b57cec5SDimitry Andric 
330b57cec5SDimitry Andric   JITSymbol findSymbol(const std::string &Name) override;
340b57cec5SDimitry Andric 
350b57cec5SDimitry Andric   // MCJIT doesn't support logical dylibs.
findSymbolInLogicalDylib(const std::string & Name)360b57cec5SDimitry Andric   JITSymbol findSymbolInLogicalDylib(const std::string &Name) override {
370b57cec5SDimitry Andric     return nullptr;
380b57cec5SDimitry Andric   }
390b57cec5SDimitry Andric 
400b57cec5SDimitry Andric private:
410b57cec5SDimitry Andric   MCJIT &ParentEngine;
420b57cec5SDimitry Andric   std::shared_ptr<LegacyJITSymbolResolver> ClientResolver;
430b57cec5SDimitry Andric   void anchor() override;
440b57cec5SDimitry Andric };
450b57cec5SDimitry Andric 
460b57cec5SDimitry Andric // About Module states: added->loaded->finalized.
470b57cec5SDimitry Andric //
480b57cec5SDimitry Andric // The purpose of the "added" state is having modules in standby. (added=known
490b57cec5SDimitry Andric // but not compiled). The idea is that you can add a module to provide function
500b57cec5SDimitry Andric // definitions but if nothing in that module is referenced by a module in which
510b57cec5SDimitry Andric // a function is executed (note the wording here because it's not exactly the
520b57cec5SDimitry Andric // ideal case) then the module never gets compiled. This is sort of lazy
530b57cec5SDimitry Andric // compilation.
540b57cec5SDimitry Andric //
550b57cec5SDimitry Andric // The purpose of the "loaded" state (loaded=compiled and required sections
560b57cec5SDimitry Andric // copied into local memory but not yet ready for execution) is to have an
570b57cec5SDimitry Andric // intermediate state wherein clients can remap the addresses of sections, using
580b57cec5SDimitry Andric // MCJIT::mapSectionAddress, (in preparation for later copying to a new location
590b57cec5SDimitry Andric // or an external process) before relocations and page permissions are applied.
600b57cec5SDimitry Andric //
610b57cec5SDimitry Andric // It might not be obvious at first glance, but the "remote-mcjit" case in the
620b57cec5SDimitry Andric // lli tool does this.  In that case, the intermediate action is taken by the
630b57cec5SDimitry Andric // RemoteMemoryManager in response to the notifyObjectLoaded function being
640b57cec5SDimitry Andric // called.
650b57cec5SDimitry Andric 
660b57cec5SDimitry Andric class MCJIT : public ExecutionEngine {
670b57cec5SDimitry Andric   MCJIT(std::unique_ptr<Module> M, std::unique_ptr<TargetMachine> tm,
680b57cec5SDimitry Andric         std::shared_ptr<MCJITMemoryManager> MemMgr,
690b57cec5SDimitry Andric         std::shared_ptr<LegacyJITSymbolResolver> Resolver);
700b57cec5SDimitry Andric 
710b57cec5SDimitry Andric   typedef llvm::SmallPtrSet<Module *, 4> ModulePtrSet;
720b57cec5SDimitry Andric 
730b57cec5SDimitry Andric   class OwningModuleContainer {
740b57cec5SDimitry Andric   public:
75*81ad6265SDimitry Andric     OwningModuleContainer() = default;
~OwningModuleContainer()760b57cec5SDimitry Andric     ~OwningModuleContainer() {
770b57cec5SDimitry Andric       freeModulePtrSet(AddedModules);
780b57cec5SDimitry Andric       freeModulePtrSet(LoadedModules);
790b57cec5SDimitry Andric       freeModulePtrSet(FinalizedModules);
800b57cec5SDimitry Andric     }
810b57cec5SDimitry Andric 
begin_added()820b57cec5SDimitry Andric     ModulePtrSet::iterator begin_added() { return AddedModules.begin(); }
end_added()830b57cec5SDimitry Andric     ModulePtrSet::iterator end_added() { return AddedModules.end(); }
added()840b57cec5SDimitry Andric     iterator_range<ModulePtrSet::iterator> added() {
850b57cec5SDimitry Andric       return make_range(begin_added(), end_added());
860b57cec5SDimitry Andric     }
870b57cec5SDimitry Andric 
begin_loaded()880b57cec5SDimitry Andric     ModulePtrSet::iterator begin_loaded() { return LoadedModules.begin(); }
end_loaded()890b57cec5SDimitry Andric     ModulePtrSet::iterator end_loaded() { return LoadedModules.end(); }
900b57cec5SDimitry Andric 
begin_finalized()910b57cec5SDimitry Andric     ModulePtrSet::iterator begin_finalized() { return FinalizedModules.begin(); }
end_finalized()920b57cec5SDimitry Andric     ModulePtrSet::iterator end_finalized() { return FinalizedModules.end(); }
930b57cec5SDimitry Andric 
addModule(std::unique_ptr<Module> M)940b57cec5SDimitry Andric     void addModule(std::unique_ptr<Module> M) {
950b57cec5SDimitry Andric       AddedModules.insert(M.release());
960b57cec5SDimitry Andric     }
970b57cec5SDimitry Andric 
removeModule(Module * M)980b57cec5SDimitry Andric     bool removeModule(Module *M) {
990b57cec5SDimitry Andric       return AddedModules.erase(M) || LoadedModules.erase(M) ||
1000b57cec5SDimitry Andric              FinalizedModules.erase(M);
1010b57cec5SDimitry Andric     }
1020b57cec5SDimitry Andric 
hasModuleBeenAddedButNotLoaded(Module * M)1030b57cec5SDimitry Andric     bool hasModuleBeenAddedButNotLoaded(Module *M) {
104e8d8bef9SDimitry Andric       return AddedModules.contains(M);
1050b57cec5SDimitry Andric     }
1060b57cec5SDimitry Andric 
hasModuleBeenLoaded(Module * M)1070b57cec5SDimitry Andric     bool hasModuleBeenLoaded(Module *M) {
1080b57cec5SDimitry Andric       // If the module is in either the "loaded" or "finalized" sections it
1090b57cec5SDimitry Andric       // has been loaded.
110e8d8bef9SDimitry Andric       return LoadedModules.contains(M) || FinalizedModules.contains(M);
1110b57cec5SDimitry Andric     }
1120b57cec5SDimitry Andric 
hasModuleBeenFinalized(Module * M)1130b57cec5SDimitry Andric     bool hasModuleBeenFinalized(Module *M) {
114e8d8bef9SDimitry Andric       return FinalizedModules.contains(M);
1150b57cec5SDimitry Andric     }
1160b57cec5SDimitry Andric 
ownsModule(Module * M)1170b57cec5SDimitry Andric     bool ownsModule(Module* M) {
118e8d8bef9SDimitry Andric       return AddedModules.contains(M) || LoadedModules.contains(M) ||
119e8d8bef9SDimitry Andric              FinalizedModules.contains(M);
1200b57cec5SDimitry Andric     }
1210b57cec5SDimitry Andric 
markModuleAsLoaded(Module * M)1220b57cec5SDimitry Andric     void markModuleAsLoaded(Module *M) {
1230b57cec5SDimitry Andric       // This checks against logic errors in the MCJIT implementation.
1240b57cec5SDimitry Andric       // This function should never be called with either a Module that MCJIT
1250b57cec5SDimitry Andric       // does not own or a Module that has already been loaded and/or finalized.
1260b57cec5SDimitry Andric       assert(AddedModules.count(M) &&
1270b57cec5SDimitry Andric              "markModuleAsLoaded: Module not found in AddedModules");
1280b57cec5SDimitry Andric 
1290b57cec5SDimitry Andric       // Remove the module from the "Added" set.
1300b57cec5SDimitry Andric       AddedModules.erase(M);
1310b57cec5SDimitry Andric 
1320b57cec5SDimitry Andric       // Add the Module to the "Loaded" set.
1330b57cec5SDimitry Andric       LoadedModules.insert(M);
1340b57cec5SDimitry Andric     }
1350b57cec5SDimitry Andric 
markModuleAsFinalized(Module * M)1360b57cec5SDimitry Andric     void markModuleAsFinalized(Module *M) {
1370b57cec5SDimitry Andric       // This checks against logic errors in the MCJIT implementation.
1380b57cec5SDimitry Andric       // This function should never be called with either a Module that MCJIT
1390b57cec5SDimitry Andric       // does not own, a Module that has not been loaded or a Module that has
1400b57cec5SDimitry Andric       // already been finalized.
1410b57cec5SDimitry Andric       assert(LoadedModules.count(M) &&
1420b57cec5SDimitry Andric              "markModuleAsFinalized: Module not found in LoadedModules");
1430b57cec5SDimitry Andric 
1440b57cec5SDimitry Andric       // Remove the module from the "Loaded" section of the list.
1450b57cec5SDimitry Andric       LoadedModules.erase(M);
1460b57cec5SDimitry Andric 
1470b57cec5SDimitry Andric       // Add the Module to the "Finalized" section of the list by inserting it
1480b57cec5SDimitry Andric       // before the 'end' iterator.
1490b57cec5SDimitry Andric       FinalizedModules.insert(M);
1500b57cec5SDimitry Andric     }
1510b57cec5SDimitry Andric 
markAllLoadedModulesAsFinalized()1520b57cec5SDimitry Andric     void markAllLoadedModulesAsFinalized() {
1530eae32dcSDimitry Andric       for (Module *M : LoadedModules)
1540b57cec5SDimitry Andric         FinalizedModules.insert(M);
1550b57cec5SDimitry Andric       LoadedModules.clear();
1560b57cec5SDimitry Andric     }
1570b57cec5SDimitry Andric 
1580b57cec5SDimitry Andric   private:
1590b57cec5SDimitry Andric     ModulePtrSet AddedModules;
1600b57cec5SDimitry Andric     ModulePtrSet LoadedModules;
1610b57cec5SDimitry Andric     ModulePtrSet FinalizedModules;
1620b57cec5SDimitry Andric 
freeModulePtrSet(ModulePtrSet & MPS)1630b57cec5SDimitry Andric     void freeModulePtrSet(ModulePtrSet& MPS) {
1640b57cec5SDimitry Andric       // Go through the module set and delete everything.
1650eae32dcSDimitry Andric       for (Module *M : MPS)
1660b57cec5SDimitry Andric         delete M;
1670b57cec5SDimitry Andric       MPS.clear();
1680b57cec5SDimitry Andric     }
1690b57cec5SDimitry Andric   };
1700b57cec5SDimitry Andric 
1710b57cec5SDimitry Andric   std::unique_ptr<TargetMachine> TM;
1720b57cec5SDimitry Andric   MCContext *Ctx;
1730b57cec5SDimitry Andric   std::shared_ptr<MCJITMemoryManager> MemMgr;
1740b57cec5SDimitry Andric   LinkingSymbolResolver Resolver;
1750b57cec5SDimitry Andric   RuntimeDyld Dyld;
1760b57cec5SDimitry Andric   std::vector<JITEventListener*> EventListeners;
1770b57cec5SDimitry Andric 
1780b57cec5SDimitry Andric   OwningModuleContainer OwnedModules;
1790b57cec5SDimitry Andric 
1800b57cec5SDimitry Andric   SmallVector<object::OwningBinary<object::Archive>, 2> Archives;
1810b57cec5SDimitry Andric   SmallVector<std::unique_ptr<MemoryBuffer>, 2> Buffers;
1820b57cec5SDimitry Andric 
1830b57cec5SDimitry Andric   SmallVector<std::unique_ptr<object::ObjectFile>, 2> LoadedObjects;
1840b57cec5SDimitry Andric 
1850b57cec5SDimitry Andric   // An optional ObjectCache to be notified of compiled objects and used to
1860b57cec5SDimitry Andric   // perform lookup of pre-compiled code to avoid re-compilation.
1870b57cec5SDimitry Andric   ObjectCache *ObjCache;
1880b57cec5SDimitry Andric 
1890b57cec5SDimitry Andric   Function *FindFunctionNamedInModulePtrSet(StringRef FnName,
1900b57cec5SDimitry Andric                                             ModulePtrSet::iterator I,
1910b57cec5SDimitry Andric                                             ModulePtrSet::iterator E);
1920b57cec5SDimitry Andric 
1930b57cec5SDimitry Andric   GlobalVariable *FindGlobalVariableNamedInModulePtrSet(StringRef Name,
1940b57cec5SDimitry Andric                                                         bool AllowInternal,
1950b57cec5SDimitry Andric                                                         ModulePtrSet::iterator I,
1960b57cec5SDimitry Andric                                                         ModulePtrSet::iterator E);
1970b57cec5SDimitry Andric 
1980b57cec5SDimitry Andric   void runStaticConstructorsDestructorsInModulePtrSet(bool isDtors,
1990b57cec5SDimitry Andric                                                       ModulePtrSet::iterator I,
2000b57cec5SDimitry Andric                                                       ModulePtrSet::iterator E);
2010b57cec5SDimitry Andric 
2020b57cec5SDimitry Andric public:
2030b57cec5SDimitry Andric   ~MCJIT() override;
2040b57cec5SDimitry Andric 
2050b57cec5SDimitry Andric   /// @name ExecutionEngine interface implementation
2060b57cec5SDimitry Andric   /// @{
2070b57cec5SDimitry Andric   void addModule(std::unique_ptr<Module> M) override;
2080b57cec5SDimitry Andric   void addObjectFile(std::unique_ptr<object::ObjectFile> O) override;
2090b57cec5SDimitry Andric   void addObjectFile(object::OwningBinary<object::ObjectFile> O) override;
2100b57cec5SDimitry Andric   void addArchive(object::OwningBinary<object::Archive> O) override;
2110b57cec5SDimitry Andric   bool removeModule(Module *M) override;
2120b57cec5SDimitry Andric 
2130b57cec5SDimitry Andric   /// FindFunctionNamed - Search all of the active modules to find the function that
2140b57cec5SDimitry Andric   /// defines FnName.  This is very slow operation and shouldn't be used for
2150b57cec5SDimitry Andric   /// general code.
2160b57cec5SDimitry Andric   Function *FindFunctionNamed(StringRef FnName) override;
2170b57cec5SDimitry Andric 
2180b57cec5SDimitry Andric   /// FindGlobalVariableNamed - Search all of the active modules to find the
2190b57cec5SDimitry Andric   /// global variable that defines Name.  This is very slow operation and
2200b57cec5SDimitry Andric   /// shouldn't be used for general code.
2210b57cec5SDimitry Andric   GlobalVariable *FindGlobalVariableNamed(StringRef Name,
2220b57cec5SDimitry Andric                                           bool AllowInternal = false) override;
2230b57cec5SDimitry Andric 
2240b57cec5SDimitry Andric   /// Sets the object manager that MCJIT should use to avoid compilation.
2250b57cec5SDimitry Andric   void setObjectCache(ObjectCache *manager) override;
2260b57cec5SDimitry Andric 
setProcessAllSections(bool ProcessAllSections)2270b57cec5SDimitry Andric   void setProcessAllSections(bool ProcessAllSections) override {
2280b57cec5SDimitry Andric     Dyld.setProcessAllSections(ProcessAllSections);
2290b57cec5SDimitry Andric   }
2300b57cec5SDimitry Andric 
2310b57cec5SDimitry Andric   void generateCodeForModule(Module *M) override;
2320b57cec5SDimitry Andric 
2330b57cec5SDimitry Andric   /// finalizeObject - ensure the module is fully processed and is usable.
2340b57cec5SDimitry Andric   ///
2350b57cec5SDimitry Andric   /// It is the user-level function for completing the process of making the
2360b57cec5SDimitry Andric   /// object usable for execution. It should be called after sections within an
2370b57cec5SDimitry Andric   /// object have been relocated using mapSectionAddress.  When this method is
2380b57cec5SDimitry Andric   /// called the MCJIT execution engine will reapply relocations for a loaded
2390b57cec5SDimitry Andric   /// object.
2400b57cec5SDimitry Andric   /// Is it OK to finalize a set of modules, add modules and finalize again.
2410b57cec5SDimitry Andric   // FIXME: Do we really need both of these?
2420b57cec5SDimitry Andric   void finalizeObject() override;
2430b57cec5SDimitry Andric   virtual void finalizeModule(Module *);
2440b57cec5SDimitry Andric   void finalizeLoadedModules();
2450b57cec5SDimitry Andric 
2460b57cec5SDimitry Andric   /// runStaticConstructorsDestructors - This method is used to execute all of
2470b57cec5SDimitry Andric   /// the static constructors or destructors for a program.
2480b57cec5SDimitry Andric   ///
2490b57cec5SDimitry Andric   /// \param isDtors - Run the destructors instead of constructors.
2500b57cec5SDimitry Andric   void runStaticConstructorsDestructors(bool isDtors) override;
2510b57cec5SDimitry Andric 
2520b57cec5SDimitry Andric   void *getPointerToFunction(Function *F) override;
2530b57cec5SDimitry Andric 
2540b57cec5SDimitry Andric   GenericValue runFunction(Function *F,
2550b57cec5SDimitry Andric                            ArrayRef<GenericValue> ArgValues) override;
2560b57cec5SDimitry Andric 
2570b57cec5SDimitry Andric   /// getPointerToNamedFunction - This method returns the address of the
2580b57cec5SDimitry Andric   /// specified function by using the dlsym function call.  As such it is only
2590b57cec5SDimitry Andric   /// useful for resolving library symbols, not code generated symbols.
2600b57cec5SDimitry Andric   ///
2610b57cec5SDimitry Andric   /// If AbortOnFailure is false and no function with the given name is
2620b57cec5SDimitry Andric   /// found, this function silently returns a null pointer. Otherwise,
2630b57cec5SDimitry Andric   /// it prints a message to stderr and aborts.
2640b57cec5SDimitry Andric   ///
2650b57cec5SDimitry Andric   void *getPointerToNamedFunction(StringRef Name,
2660b57cec5SDimitry Andric                                   bool AbortOnFailure = true) override;
2670b57cec5SDimitry Andric 
2680b57cec5SDimitry Andric   /// mapSectionAddress - map a section to its target address space value.
2690b57cec5SDimitry Andric   /// Map the address of a JIT section as returned from the memory manager
2700b57cec5SDimitry Andric   /// to the address in the target process as the running code will see it.
2710b57cec5SDimitry Andric   /// This is the address which will be used for relocation resolution.
mapSectionAddress(const void * LocalAddress,uint64_t TargetAddress)2720b57cec5SDimitry Andric   void mapSectionAddress(const void *LocalAddress,
2730b57cec5SDimitry Andric                          uint64_t TargetAddress) override {
2740b57cec5SDimitry Andric     Dyld.mapSectionAddress(LocalAddress, TargetAddress);
2750b57cec5SDimitry Andric   }
2760b57cec5SDimitry Andric   void RegisterJITEventListener(JITEventListener *L) override;
2770b57cec5SDimitry Andric   void UnregisterJITEventListener(JITEventListener *L) override;
2780b57cec5SDimitry Andric 
2790b57cec5SDimitry Andric   // If successful, these function will implicitly finalize all loaded objects.
2800b57cec5SDimitry Andric   // To get a function address within MCJIT without causing a finalize, use
2810b57cec5SDimitry Andric   // getSymbolAddress.
2820b57cec5SDimitry Andric   uint64_t getGlobalValueAddress(const std::string &Name) override;
2830b57cec5SDimitry Andric   uint64_t getFunctionAddress(const std::string &Name) override;
2840b57cec5SDimitry Andric 
getTargetMachine()2850b57cec5SDimitry Andric   TargetMachine *getTargetMachine() override { return TM.get(); }
2860b57cec5SDimitry Andric 
2870b57cec5SDimitry Andric   /// @}
2880b57cec5SDimitry Andric   /// @name (Private) Registration Interfaces
2890b57cec5SDimitry Andric   /// @{
2900b57cec5SDimitry Andric 
Register()2910b57cec5SDimitry Andric   static void Register() {
2920b57cec5SDimitry Andric     MCJITCtor = createJIT;
2930b57cec5SDimitry Andric   }
2940b57cec5SDimitry Andric 
2950b57cec5SDimitry Andric   static ExecutionEngine *
2960b57cec5SDimitry Andric   createJIT(std::unique_ptr<Module> M, std::string *ErrorStr,
2970b57cec5SDimitry Andric             std::shared_ptr<MCJITMemoryManager> MemMgr,
2980b57cec5SDimitry Andric             std::shared_ptr<LegacyJITSymbolResolver> Resolver,
2990b57cec5SDimitry Andric             std::unique_ptr<TargetMachine> TM);
3000b57cec5SDimitry Andric 
3010b57cec5SDimitry Andric   // @}
3020b57cec5SDimitry Andric 
3030b57cec5SDimitry Andric   // Takes a mangled name and returns the corresponding JITSymbol (if a
3040b57cec5SDimitry Andric   // definition of that mangled name has been added to the JIT).
3050b57cec5SDimitry Andric   JITSymbol findSymbol(const std::string &Name, bool CheckFunctionsOnly);
3060b57cec5SDimitry Andric 
3070b57cec5SDimitry Andric   // DEPRECATED - Please use findSymbol instead.
3080b57cec5SDimitry Andric   //
3090b57cec5SDimitry Andric   // This is not directly exposed via the ExecutionEngine API, but it is
3100b57cec5SDimitry Andric   // used by the LinkingMemoryManager.
3110b57cec5SDimitry Andric   //
3120b57cec5SDimitry Andric   // getSymbolAddress takes an unmangled name and returns the corresponding
3130b57cec5SDimitry Andric   // JITSymbol if a definition of the name has been added to the JIT.
3140b57cec5SDimitry Andric   uint64_t getSymbolAddress(const std::string &Name,
3150b57cec5SDimitry Andric                             bool CheckFunctionsOnly);
3160b57cec5SDimitry Andric 
3170b57cec5SDimitry Andric protected:
3180b57cec5SDimitry Andric   /// emitObject -- Generate a JITed object in memory from the specified module
3190b57cec5SDimitry Andric   /// Currently, MCJIT only supports a single module and the module passed to
3200b57cec5SDimitry Andric   /// this function call is expected to be the contained module.  The module
3210b57cec5SDimitry Andric   /// is passed as a parameter here to prepare for multiple module support in
3220b57cec5SDimitry Andric   /// the future.
3230b57cec5SDimitry Andric   std::unique_ptr<MemoryBuffer> emitObject(Module *M);
3240b57cec5SDimitry Andric 
3250b57cec5SDimitry Andric   void notifyObjectLoaded(const object::ObjectFile &Obj,
3260b57cec5SDimitry Andric                           const RuntimeDyld::LoadedObjectInfo &L);
3270b57cec5SDimitry Andric   void notifyFreeingObject(const object::ObjectFile &Obj);
3280b57cec5SDimitry Andric 
3290b57cec5SDimitry Andric   JITSymbol findExistingSymbol(const std::string &Name);
3300b57cec5SDimitry Andric   Module *findModuleForSymbol(const std::string &Name, bool CheckFunctionsOnly);
3310b57cec5SDimitry Andric };
3320b57cec5SDimitry Andric 
3330b57cec5SDimitry Andric } // end llvm namespace
3340b57cec5SDimitry Andric 
3350b57cec5SDimitry Andric #endif // LLVM_LIB_EXECUTIONENGINE_MCJIT_MCJIT_H
336