mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-07-30 17:25:21 +00:00
Add a pointer to the owning LLVMContext to Module. This requires threading LLVMContext through a lot
of the bitcode reader and ASM parser APIs, as well as supporting it in all of the tools. Patches for Clang and LLVM-GCC to follow. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@74614 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@@ -15,6 +15,7 @@
|
||||
#include "LTOModule.h"
|
||||
|
||||
#include "llvm/Constants.h"
|
||||
#include "llvm/LLVMContext.h"
|
||||
#include "llvm/Module.h"
|
||||
#include "llvm/ModuleProvider.h"
|
||||
#include "llvm/ADT/OwningPtr.h"
|
||||
@@ -67,7 +68,8 @@ bool LTOModule::isBitcodeFileForTarget(const char* path,
|
||||
// takes ownership of buffer
|
||||
bool LTOModule::isTargetMatch(MemoryBuffer* buffer, const char* triplePrefix)
|
||||
{
|
||||
OwningPtr<ModuleProvider> mp(getBitcodeModuleProvider(buffer));
|
||||
OwningPtr<ModuleProvider> mp(getBitcodeModuleProvider(buffer,
|
||||
new LLVMContext()));
|
||||
// on success, mp owns buffer and both are deleted at end of this method
|
||||
if ( !mp ) {
|
||||
delete buffer;
|
||||
@@ -84,12 +86,13 @@ LTOModule::LTOModule(Module* m, TargetMachine* t)
|
||||
{
|
||||
}
|
||||
|
||||
LTOModule* LTOModule::makeLTOModule(const char* path, std::string& errMsg)
|
||||
LTOModule* LTOModule::makeLTOModule(const char* path, LLVMContext* Context,
|
||||
std::string& errMsg)
|
||||
{
|
||||
OwningPtr<MemoryBuffer> buffer(MemoryBuffer::getFile(path, &errMsg));
|
||||
if ( !buffer )
|
||||
return NULL;
|
||||
return makeLTOModule(buffer.get(), errMsg);
|
||||
return makeLTOModule(buffer.get(), Context, errMsg);
|
||||
}
|
||||
|
||||
/// makeBuffer - create a MemoryBuffer from a memory range.
|
||||
@@ -109,12 +112,13 @@ MemoryBuffer* LTOModule::makeBuffer(const void* mem, size_t length)
|
||||
|
||||
|
||||
LTOModule* LTOModule::makeLTOModule(const void* mem, size_t length,
|
||||
LLVMContext* Context,
|
||||
std::string& errMsg)
|
||||
{
|
||||
OwningPtr<MemoryBuffer> buffer(makeBuffer(mem, length));
|
||||
if ( !buffer )
|
||||
return NULL;
|
||||
return makeLTOModule(buffer.get(), errMsg);
|
||||
return makeLTOModule(buffer.get(), Context, errMsg);
|
||||
}
|
||||
|
||||
/// getFeatureString - Return a string listing the features associated with the
|
||||
@@ -136,10 +140,11 @@ std::string getFeatureString(const char *TargetTriple) {
|
||||
return Features.getString();
|
||||
}
|
||||
|
||||
LTOModule* LTOModule::makeLTOModule(MemoryBuffer* buffer, std::string& errMsg)
|
||||
LTOModule* LTOModule::makeLTOModule(MemoryBuffer* buffer, LLVMContext* Context,
|
||||
std::string& errMsg)
|
||||
{
|
||||
// parse bitcode buffer
|
||||
OwningPtr<Module> m(ParseBitcodeFile(buffer, &errMsg));
|
||||
OwningPtr<Module> m(ParseBitcodeFile(buffer, Context, &errMsg));
|
||||
if ( !m )
|
||||
return NULL;
|
||||
// find machine architecture for this module
|
||||
|
Reference in New Issue
Block a user