Home | History | Annotate | Download | only in MCJIT
      1 //===-- MCJITMemoryManager.h - Definition for the Memory Manager ---C++ -*-===//
      2 //
      3 //                     The LLVM Compiler Infrastructure
      4 //
      5 // This file is distributed under the University of Illinois Open Source
      6 // License. See LICENSE.TXT for details.
      7 //
      8 //===----------------------------------------------------------------------===//
      9 
     10 #ifndef LLVM_LIB_EXECUTIONENGINE_MCJITMEMORYMANAGER_H
     11 #define LLVM_LIB_EXECUTIONENGINE_MCJITMEMORYMANAGER_H
     12 
     13 #include "llvm/Module.h"
     14 #include "llvm/ExecutionEngine/JITMemoryManager.h"
     15 #include "llvm/ExecutionEngine/RuntimeDyld.h"
     16 #include <assert.h>
     17 
     18 namespace llvm {
     19 
     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   OwningPtr<JITMemoryManager> JMM;
     26 
     27 public:
     28   MCJITMemoryManager(JITMemoryManager *jmm) :
     29     JMM(jmm?jmm:JITMemoryManager::CreateDefaultMemManager()) {}
     30 
     31   uint8_t *allocateDataSection(uintptr_t Size, unsigned Alignment,
     32                                unsigned SectionID) {
     33     return JMM->allocateDataSection(Size, Alignment, SectionID);
     34   }
     35 
     36   uint8_t *allocateCodeSection(uintptr_t Size, unsigned Alignment,
     37                                unsigned SectionID) {
     38     return JMM->allocateCodeSection(Size, Alignment, SectionID);
     39   }
     40 
     41   virtual void *getPointerToNamedFunction(const std::string &Name,
     42                                           bool AbortOnFailure = true) {
     43     return JMM->getPointerToNamedFunction(Name, AbortOnFailure);
     44   }
     45 
     46 };
     47 
     48 } // End llvm namespace
     49 
     50 #endif
     51