mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-09-25 17:20:48 +00:00
[MCJIT][Orc] Refactor RTDyldMemoryManager, weave RuntimeDyld::SymbolInfo through
MCJIT. This patch decouples the two responsibilities of the RTDyldMemoryManager class, memory management and symbol resolution, into two new classes: RuntimeDyld::MemoryManager and RuntimeDyld::SymbolResolver. The symbol resolution interface is modified slightly, from: uint64_t getSymbolAddress(const std::string &Name); to: RuntimeDyld::SymbolInfo findSymbol(const std::string &Name); The latter passes symbol flags along with symbol addresses, allowing RuntimeDyld and others to reason about non-strong/non-exported symbols. The memory management interface removes the following method: void notifyObjectLoaded(ExecutionEngine *EE, const object::ObjectFile &) {} as it is not related to memory management. (Note: Backwards compatibility *is* maintained for this method in MCJIT and OrcMCJITReplacement, see below). The RTDyldMemoryManager class remains in-tree for backwards compatibility. It inherits directly from RuntimeDyld::SymbolResolver, and indirectly from RuntimeDyld::MemoryManager via the new MCJITMemoryManager class, which just subclasses RuntimeDyld::MemoryManager and reintroduces the notifyObjectLoaded method for backwards compatibility). The EngineBuilder class retains the existing method: EngineBuilder& setMCJITMemoryManager(std::unique_ptr<RTDyldMemoryManager> mcjmm); and includes two new methods: EngineBuilder& setMemoryManager(std::unique_ptr<MCJITMemoryManager> MM); EngineBuilder& setSymbolResolver(std::unique_ptr<RuntimeDyld::SymbolResolver> SR); Clients should use EITHER: A single call to setMCJITMemoryManager with an RTDyldMemoryManager. OR (exclusive) One call each to each of setMemoryManager and setSymbolResolver. This patch should be fully compatible with existing uses of RTDyldMemoryManager. If it is not it should be considered a bug, and the patch either fixed or reverted. If clients find the new API to be an improvement the goal will be to deprecate and eventually remove the RTDyldMemoryManager class in favor of the new classes. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@233509 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@@ -15,6 +15,7 @@
|
||||
#ifndef LLVM_EXECUTIONENGINE_EXECUTIONENGINE_H
|
||||
#define LLVM_EXECUTIONENGINE_EXECUTIONENGINE_H
|
||||
|
||||
#include "RuntimeDyld.h"
|
||||
#include "llvm-c/ExecutionEngine.h"
|
||||
#include "llvm/ADT/SmallVector.h"
|
||||
#include "llvm/ADT/StringRef.h"
|
||||
@@ -42,6 +43,7 @@ class GlobalVariable;
|
||||
class GlobalValue;
|
||||
class JITEventListener;
|
||||
class MachineCodeInfo;
|
||||
class MCJITMemoryManager;
|
||||
class MutexGuard;
|
||||
class ObjectCache;
|
||||
class RTDyldMemoryManager;
|
||||
@@ -139,15 +141,17 @@ protected:
|
||||
virtual char *getMemoryForGV(const GlobalVariable *GV);
|
||||
|
||||
static ExecutionEngine *(*MCJITCtor)(
|
||||
std::unique_ptr<Module> M,
|
||||
std::string *ErrorStr,
|
||||
std::unique_ptr<RTDyldMemoryManager> MCJMM,
|
||||
std::unique_ptr<TargetMachine> TM);
|
||||
std::unique_ptr<Module> M,
|
||||
std::string *ErrorStr,
|
||||
std::shared_ptr<MCJITMemoryManager> MM,
|
||||
std::shared_ptr<RuntimeDyld::SymbolResolver> SR,
|
||||
std::unique_ptr<TargetMachine> TM);
|
||||
|
||||
static ExecutionEngine *(*OrcMCJITReplacementCtor)(
|
||||
std::string *ErrorStr,
|
||||
std::unique_ptr<RTDyldMemoryManager> OrcJMM,
|
||||
std::unique_ptr<TargetMachine> TM);
|
||||
std::string *ErrorStr,
|
||||
std::shared_ptr<MCJITMemoryManager> MM,
|
||||
std::shared_ptr<RuntimeDyld::SymbolResolver> SR,
|
||||
std::unique_ptr<TargetMachine> TM);
|
||||
|
||||
static ExecutionEngine *(*InterpCtor)(std::unique_ptr<Module> M,
|
||||
std::string *ErrorStr);
|
||||
@@ -500,7 +504,8 @@ private:
|
||||
EngineKind::Kind WhichEngine;
|
||||
std::string *ErrorStr;
|
||||
CodeGenOpt::Level OptLevel;
|
||||
std::unique_ptr<RTDyldMemoryManager> MCJMM;
|
||||
std::shared_ptr<MCJITMemoryManager> MemMgr;
|
||||
std::shared_ptr<RuntimeDyld::SymbolResolver> Resolver;
|
||||
TargetOptions Options;
|
||||
Reloc::Model RelocModel;
|
||||
CodeModel::Model CMModel;
|
||||
@@ -535,6 +540,12 @@ public:
|
||||
/// memory manager. This option defaults to NULL.
|
||||
EngineBuilder &setMCJITMemoryManager(std::unique_ptr<RTDyldMemoryManager> mcjmm);
|
||||
|
||||
EngineBuilder&
|
||||
setMemoryManager(std::unique_ptr<MCJITMemoryManager> MM);
|
||||
|
||||
EngineBuilder&
|
||||
setSymbolResolver(std::unique_ptr<RuntimeDyld::SymbolResolver> SR);
|
||||
|
||||
/// setErrorStr - Set the error string to write to on error. This option
|
||||
/// defaults to NULL.
|
||||
EngineBuilder &setErrorStr(std::string *e) {
|
||||
|
Reference in New Issue
Block a user