1 //===-- MCJITMemoryManager.h - Definition for the Memory Manager ---C++ -*-===//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
10 #ifndef LLVM_LIB_EXECUTIONENGINE_MCJITMEMORYMANAGER_H
11 #define LLVM_LIB_EXECUTIONENGINE_MCJITMEMORYMANAGER_H
13 #include "llvm/Module.h"
14 #include "llvm/ExecutionEngine/JITMemoryManager.h"
15 #include "llvm/ExecutionEngine/RuntimeDyld.h"
20 // The MCJIT memory manager is a layer between the standard JITMemoryManager
21 // and the RuntimeDyld interface that maps objects, by name, onto their
22 // matching LLVM IR counterparts in the module(s) being compiled.
23 class MCJITMemoryManager : public RTDyldMemoryManager {
24 virtual void anchor();
25 JITMemoryManager *JMM;
27 // FIXME: Multiple modules.
30 MCJITMemoryManager(JITMemoryManager *jmm, Module *m) :
31 JMM(jmm?jmm:JITMemoryManager::CreateDefaultMemManager()), M(m) {}
32 // We own the JMM, so make sure to delete it.
33 ~MCJITMemoryManager() { delete JMM; }
35 uint8_t *allocateDataSection(uintptr_t Size, unsigned Alignment,
37 return JMM->allocateSpace(Size, Alignment);
40 uint8_t *allocateCodeSection(uintptr_t Size, unsigned Alignment,
42 return JMM->allocateSpace(Size, Alignment);
45 virtual void *getPointerToNamedFunction(const std::string &Name,
46 bool AbortOnFailure = true) {
47 return JMM->getPointerToNamedFunction(Name, AbortOnFailure);
52 } // End llvm namespace