mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2024-12-15 04:30:12 +00:00
unique_ptrify passing the TargetMachine to ExecutionEngine::MCJITCtor
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@216988 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
41b6e327f7
commit
4becee113c
@ -139,11 +139,10 @@ protected:
|
||||
/// getMemoryforGV - Allocate memory for a global variable.
|
||||
virtual char *getMemoryForGV(const GlobalVariable *GV);
|
||||
|
||||
static ExecutionEngine *(*MCJITCtor)(
|
||||
std::unique_ptr<Module> M,
|
||||
std::string *ErrorStr,
|
||||
RTDyldMemoryManager *MCJMM,
|
||||
TargetMachine *TM);
|
||||
static ExecutionEngine *(*MCJITCtor)(std::unique_ptr<Module> M,
|
||||
std::string *ErrorStr,
|
||||
RTDyldMemoryManager *MCJMM,
|
||||
std::unique_ptr<TargetMachine> TM);
|
||||
static ExecutionEngine *(*InterpCtor)(std::unique_ptr<Module> M,
|
||||
std::string *ErrorStr);
|
||||
|
||||
|
@ -49,10 +49,8 @@ void ObjectBuffer::anchor() {}
|
||||
void ObjectBufferStream::anchor() {}
|
||||
|
||||
ExecutionEngine *(*ExecutionEngine::MCJITCtor)(
|
||||
std::unique_ptr<Module >M,
|
||||
std::string *ErrorStr,
|
||||
RTDyldMemoryManager *MCJMM,
|
||||
TargetMachine *TM) = nullptr;
|
||||
std::unique_ptr<Module> M, std::string *ErrorStr,
|
||||
RTDyldMemoryManager *MCJMM, std::unique_ptr<TargetMachine> TM) = nullptr;
|
||||
ExecutionEngine *(*ExecutionEngine::InterpCtor)(std::unique_ptr<Module> M,
|
||||
std::string *ErrorStr) =nullptr;
|
||||
|
||||
@ -453,7 +451,7 @@ ExecutionEngine *EngineBuilder::create(TargetMachine *TM) {
|
||||
ExecutionEngine *EE = nullptr;
|
||||
if (ExecutionEngine::MCJITCtor)
|
||||
EE = ExecutionEngine::MCJITCtor(std::move(M), ErrorStr,
|
||||
MCJMM ? MCJMM : JMM, TheTM.release());
|
||||
MCJMM ? MCJMM : JMM, std::move(TheTM));
|
||||
if (EE) {
|
||||
EE->setVerifyModules(VerifyModules);
|
||||
return EE;
|
||||
|
@ -46,20 +46,20 @@ extern "C" void LLVMLinkInMCJIT() {
|
||||
ExecutionEngine *MCJIT::createJIT(std::unique_ptr<Module> M,
|
||||
std::string *ErrorStr,
|
||||
RTDyldMemoryManager *MemMgr,
|
||||
TargetMachine *TM) {
|
||||
std::unique_ptr<TargetMachine> TM) {
|
||||
// Try to register the program as a source of symbols to resolve against.
|
||||
//
|
||||
// FIXME: Don't do this here.
|
||||
sys::DynamicLibrary::LoadLibraryPermanently(nullptr, nullptr);
|
||||
|
||||
return new MCJIT(std::move(M), TM,
|
||||
return new MCJIT(std::move(M), std::move(TM),
|
||||
MemMgr ? MemMgr : new SectionMemoryManager());
|
||||
}
|
||||
|
||||
MCJIT::MCJIT(std::unique_ptr<Module> M, TargetMachine *tm,
|
||||
MCJIT::MCJIT(std::unique_ptr<Module> M, std::unique_ptr<TargetMachine> tm,
|
||||
RTDyldMemoryManager *MM)
|
||||
: ExecutionEngine(std::move(M)), TM(tm), Ctx(nullptr), MemMgr(this, MM),
|
||||
Dyld(&MemMgr), ObjCache(nullptr) {
|
||||
: ExecutionEngine(std::move(M)), TM(std::move(tm)), Ctx(nullptr),
|
||||
MemMgr(this, MM), Dyld(&MemMgr), ObjCache(nullptr) {
|
||||
// FIXME: We are managing our modules, so we do not want the base class
|
||||
// ExecutionEngine to manage them as well. To avoid double destruction
|
||||
// of the first (and only) module added in ExecutionEngine constructor
|
||||
@ -93,8 +93,6 @@ MCJIT::~MCJIT() {
|
||||
LoadedObjects.clear();
|
||||
|
||||
Archives.clear();
|
||||
|
||||
delete TM;
|
||||
}
|
||||
|
||||
void MCJIT::addModule(std::unique_ptr<Module> M) {
|
||||
|
@ -101,7 +101,7 @@ private:
|
||||
// called.
|
||||
|
||||
class MCJIT : public ExecutionEngine {
|
||||
MCJIT(std::unique_ptr<Module> M, TargetMachine *tm,
|
||||
MCJIT(std::unique_ptr<Module> M, std::unique_ptr<TargetMachine> tm,
|
||||
RTDyldMemoryManager *MemMgr);
|
||||
|
||||
typedef llvm::SmallPtrSet<Module *, 4> ModulePtrSet;
|
||||
@ -208,7 +208,7 @@ class MCJIT : public ExecutionEngine {
|
||||
}
|
||||
};
|
||||
|
||||
TargetMachine *TM;
|
||||
std::unique_ptr<TargetMachine> TM;
|
||||
MCContext *Ctx;
|
||||
LinkingMemoryManager MemMgr;
|
||||
RuntimeDyld Dyld;
|
||||
@ -311,7 +311,7 @@ public:
|
||||
uint64_t getGlobalValueAddress(const std::string &Name) override;
|
||||
uint64_t getFunctionAddress(const std::string &Name) override;
|
||||
|
||||
TargetMachine *getTargetMachine() override { return TM; }
|
||||
TargetMachine *getTargetMachine() override { return TM.get(); }
|
||||
|
||||
/// @}
|
||||
/// @name (Private) Registration Interfaces
|
||||
@ -324,7 +324,7 @@ public:
|
||||
static ExecutionEngine *createJIT(std::unique_ptr<Module> M,
|
||||
std::string *ErrorStr,
|
||||
RTDyldMemoryManager *MemMgr,
|
||||
TargetMachine *TM);
|
||||
std::unique_ptr<TargetMachine> TM);
|
||||
|
||||
// @}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user