1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-10-25 05:52:53 +02:00
llvm-mirror/lib/ExecutionEngine/MCJIT/MCJITMemoryManager.h
Jim Grosbach 8a1f712b53 RuntimeDyld should use the memory manager API.
Start teaching the runtime Dyld interface to use the memory manager API
for allocating space. Rather than mapping directly into the MachO object,
we extract the payload for each object and copy it into a dedicated buffer
allocated via the memory manager. For now, just do Segment64, so this works
on x86_64, but not yet on ARM.

llvm-svn: 128973
2011-04-06 01:11:05 +00:00

54 lines
1.8 KiB
C++

//===-- 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 {
JITMemoryManager *JMM;
// FIXME: Multiple modules.
Module *M;
public:
MCJITMemoryManager(JITMemoryManager *jmm) : JMM(jmm) {}
// Allocate ActualSize bytes, or more, for the named function. Return
// a pointer to the allocated memory and update Size to reflect how much
// memory was acutally allocated.
uint8_t *startFunctionBody(const char *Name, uintptr_t &Size) {
Function *F = M->getFunction(Name);
assert(F && "No matching function in JIT IR Module!");
return JMM->startFunctionBody(F, Size);
}
// Mark the end of the function, including how much of the allocated
// memory was actually used.
void endFunctionBody(const char *Name, uint8_t *FunctionStart,
uint8_t *FunctionEnd) {
Function *F = M->getFunction(Name);
assert(F && "No matching function in JIT IR Module!");
JMM->endFunctionBody(F, FunctionStart, FunctionEnd);
}
};
} // End llvm namespace
#endif