2011-04-05 01:20:40 +02: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 03:50:00 +01:00
|
|
|
virtual void anchor();
|
2012-06-06 21:47:08 +02:00
|
|
|
OwningPtr<JITMemoryManager> JMM;
|
2011-04-05 01:20:40 +02:00
|
|
|
|
|
|
|
public:
|
2012-06-06 21:47:08 +02:00
|
|
|
MCJITMemoryManager(JITMemoryManager *jmm) :
|
|
|
|
JMM(jmm?jmm:JITMemoryManager::CreateDefaultMemManager()) {}
|
2011-04-05 01:20:40 +02:00
|
|
|
|
2012-01-16 23:26:39 +01:00
|
|
|
uint8_t *allocateDataSection(uintptr_t Size, unsigned Alignment,
|
|
|
|
unsigned SectionID) {
|
2012-05-16 20:50:11 +02:00
|
|
|
return JMM->allocateDataSection(Size, Alignment, SectionID);
|
2012-01-16 23:26:39 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
uint8_t *allocateCodeSection(uintptr_t Size, unsigned Alignment,
|
|
|
|
unsigned SectionID) {
|
2012-05-16 20:50:11 +02:00
|
|
|
return JMM->allocateCodeSection(Size, Alignment, SectionID);
|
2012-01-16 23:26:39 +01:00
|
|
|
}
|
|
|
|
|
2012-03-28 23:46:36 +02:00
|
|
|
virtual void *getPointerToNamedFunction(const std::string &Name,
|
|
|
|
bool AbortOnFailure = true) {
|
|
|
|
return JMM->getPointerToNamedFunction(Name, AbortOnFailure);
|
|
|
|
}
|
|
|
|
|
2011-04-05 01:20:40 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
} // End llvm namespace
|
|
|
|
|
|
|
|
#endif
|