2011-04-04 23:20:40 +00:00
|
|
|
//===-- MCJITMemoryManager.h - Definition for the Memory Manager ---C++ -*-===//
|
|
|
|
//
|
|
|
|
// The LLVM Compiler Infrastructure
|
|
|
|
//
|
|
|
|
// This file is distributed under the University of Illinois Open Source
|
|
|
|
// License. See LICENSE.TXT for details.
|
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
|
|
|
#ifndef LLVM_LIB_EXECUTIONENGINE_MCJITMEMORYMANAGER_H
|
|
|
|
#define LLVM_LIB_EXECUTIONENGINE_MCJITMEMORYMANAGER_H
|
|
|
|
|
|
|
|
#include "llvm/Module.h"
|
|
|
|
#include "llvm/ExecutionEngine/JITMemoryManager.h"
|
|
|
|
#include "llvm/ExecutionEngine/RuntimeDyld.h"
|
|
|
|
#include <assert.h>
|
|
|
|
|
|
|
|
namespace llvm {
|
|
|
|
|
|
|
|
// The MCJIT memory manager is a layer between the standard JITMemoryManager
|
|
|
|
// and the RuntimeDyld interface that maps objects, by name, onto their
|
|
|
|
// matching LLVM IR counterparts in the module(s) being compiled.
|
|
|
|
class MCJITMemoryManager : public RTDyldMemoryManager {
|
2011-12-20 02:50:00 +00:00
|
|
|
virtual void anchor();
|
2011-04-04 23:20:40 +00:00
|
|
|
JITMemoryManager *JMM;
|
|
|
|
|
|
|
|
// FIXME: Multiple modules.
|
|
|
|
Module *M;
|
|
|
|
public:
|
2012-03-28 21:46:36 +00:00
|
|
|
MCJITMemoryManager(JITMemoryManager *jmm, Module *m) :
|
|
|
|
JMM(jmm?jmm:JITMemoryManager::CreateDefaultMemManager()), M(m) {}
|
2011-10-18 19:57:38 +00:00
|
|
|
// We own the JMM, so make sure to delete it.
|
|
|
|
~MCJITMemoryManager() { delete JMM; }
|
2011-04-04 23:20:40 +00:00
|
|
|
|
2012-01-16 22:26:39 +00:00
|
|
|
uint8_t *allocateDataSection(uintptr_t Size, unsigned Alignment,
|
|
|
|
unsigned SectionID) {
|
2012-03-30 16:45:19 +00:00
|
|
|
return JMM->allocateSpace(Size, Alignment);
|
2012-01-16 22:26:39 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
uint8_t *allocateCodeSection(uintptr_t Size, unsigned Alignment,
|
|
|
|
unsigned SectionID) {
|
2012-03-30 16:45:19 +00:00
|
|
|
return JMM->allocateSpace(Size, Alignment);
|
2012-01-16 22:26:39 +00:00
|
|
|
}
|
|
|
|
|
2012-03-28 21:46:36 +00:00
|
|
|
virtual void *getPointerToNamedFunction(const std::string &Name,
|
|
|
|
bool AbortOnFailure = true) {
|
|
|
|
return JMM->getPointerToNamedFunction(Name, AbortOnFailure);
|
|
|
|
}
|
|
|
|
|
2011-04-04 23:20:40 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
} // End llvm namespace
|
|
|
|
|
|
|
|
#endif
|