mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-10-25 10:27:04 +00:00
Maintain the old LTO API, by using the global context.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@74678 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@@ -59,8 +59,6 @@ typedef struct LTOModule* lto_module_t;
|
|||||||
/** opaque reference to a code generator */
|
/** opaque reference to a code generator */
|
||||||
typedef struct LTOCodeGenerator* lto_code_gen_t;
|
typedef struct LTOCodeGenerator* lto_code_gen_t;
|
||||||
|
|
||||||
typedef struct LTOContext* lto_context_t;
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
extern "C" {
|
extern "C" {
|
||||||
#endif
|
#endif
|
||||||
@@ -113,7 +111,7 @@ lto_module_is_object_file_in_memory_for_target(const void* mem, size_t length,
|
|||||||
* Returns NULL on error (check lto_get_error_message() for details).
|
* Returns NULL on error (check lto_get_error_message() for details).
|
||||||
*/
|
*/
|
||||||
extern lto_module_t
|
extern lto_module_t
|
||||||
lto_module_create(const char* path, LLVMContextRef Ctxt);
|
lto_module_create(const char* path);
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -121,8 +119,7 @@ lto_module_create(const char* path, LLVMContextRef Ctxt);
|
|||||||
* Returns NULL on error (check lto_get_error_message() for details).
|
* Returns NULL on error (check lto_get_error_message() for details).
|
||||||
*/
|
*/
|
||||||
extern lto_module_t
|
extern lto_module_t
|
||||||
lto_module_create_from_memory(const void* mem, size_t length,
|
lto_module_create_from_memory(const void* mem, size_t length);
|
||||||
LLVMContextRef Ctxt);
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -166,7 +163,7 @@ lto_module_get_symbol_attribute(lto_module_t mod, unsigned int index);
|
|||||||
* Returns NULL on error (check lto_get_error_message() for details).
|
* Returns NULL on error (check lto_get_error_message() for details).
|
||||||
*/
|
*/
|
||||||
extern lto_code_gen_t
|
extern lto_code_gen_t
|
||||||
lto_codegen_create(LLVMContextRef Ctxt);
|
lto_codegen_create(void);
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -19,6 +19,7 @@
|
|||||||
#include "llvm/Constants.h"
|
#include "llvm/Constants.h"
|
||||||
#include "llvm/DerivedTypes.h"
|
#include "llvm/DerivedTypes.h"
|
||||||
#include "llvm/Linker.h"
|
#include "llvm/Linker.h"
|
||||||
|
#include "llvm/LLVMContext.h"
|
||||||
#include "llvm/Module.h"
|
#include "llvm/Module.h"
|
||||||
#include "llvm/ModuleProvider.h"
|
#include "llvm/ModuleProvider.h"
|
||||||
#include "llvm/PassManager.h"
|
#include "llvm/PassManager.h"
|
||||||
@@ -69,8 +70,8 @@ const char* LTOCodeGenerator::getVersionString()
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
LTOCodeGenerator::LTOCodeGenerator(LLVMContext& Context)
|
LTOCodeGenerator::LTOCodeGenerator()
|
||||||
: _context(Context),
|
: _context(getGlobalContext()),
|
||||||
_linker("LinkTimeOptimizer", "ld-temp.o", _context), _target(NULL),
|
_linker("LinkTimeOptimizer", "ld-temp.o", _context), _target(NULL),
|
||||||
_emitDwarfDebugInfo(false), _scopeRestrictionsDone(false),
|
_emitDwarfDebugInfo(false), _scopeRestrictionsDone(false),
|
||||||
_codeModel(LTO_CODEGEN_PIC_MODEL_DYNAMIC),
|
_codeModel(LTO_CODEGEN_PIC_MODEL_DYNAMIC),
|
||||||
|
|||||||
@@ -31,7 +31,7 @@ class LTOCodeGenerator {
|
|||||||
public:
|
public:
|
||||||
static const char* getVersionString();
|
static const char* getVersionString();
|
||||||
|
|
||||||
LTOCodeGenerator(llvm::LLVMContext& Context);
|
LTOCodeGenerator();
|
||||||
~LTOCodeGenerator();
|
~LTOCodeGenerator();
|
||||||
|
|
||||||
bool addModule(class LTOModule*, std::string& errMsg);
|
bool addModule(class LTOModule*, std::string& errMsg);
|
||||||
|
|||||||
@@ -69,7 +69,7 @@ bool LTOModule::isBitcodeFileForTarget(const char* path,
|
|||||||
bool LTOModule::isTargetMatch(MemoryBuffer* buffer, const char* triplePrefix)
|
bool LTOModule::isTargetMatch(MemoryBuffer* buffer, const char* triplePrefix)
|
||||||
{
|
{
|
||||||
OwningPtr<ModuleProvider> mp(getBitcodeModuleProvider(buffer,
|
OwningPtr<ModuleProvider> mp(getBitcodeModuleProvider(buffer,
|
||||||
*new LLVMContext()));
|
getGlobalContext()));
|
||||||
// on success, mp owns buffer and both are deleted at end of this method
|
// on success, mp owns buffer and both are deleted at end of this method
|
||||||
if ( !mp ) {
|
if ( !mp ) {
|
||||||
delete buffer;
|
delete buffer;
|
||||||
@@ -87,13 +87,12 @@ LTOModule::LTOModule(Module* m, TargetMachine* t)
|
|||||||
}
|
}
|
||||||
|
|
||||||
LTOModule* LTOModule::makeLTOModule(const char* path,
|
LTOModule* LTOModule::makeLTOModule(const char* path,
|
||||||
LLVMContext& Context,
|
|
||||||
std::string& errMsg)
|
std::string& errMsg)
|
||||||
{
|
{
|
||||||
OwningPtr<MemoryBuffer> buffer(MemoryBuffer::getFile(path, &errMsg));
|
OwningPtr<MemoryBuffer> buffer(MemoryBuffer::getFile(path, &errMsg));
|
||||||
if ( !buffer )
|
if ( !buffer )
|
||||||
return NULL;
|
return NULL;
|
||||||
return makeLTOModule(buffer.get(), Context, errMsg);
|
return makeLTOModule(buffer.get(), errMsg);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// makeBuffer - create a MemoryBuffer from a memory range.
|
/// makeBuffer - create a MemoryBuffer from a memory range.
|
||||||
@@ -113,13 +112,12 @@ MemoryBuffer* LTOModule::makeBuffer(const void* mem, size_t length)
|
|||||||
|
|
||||||
|
|
||||||
LTOModule* LTOModule::makeLTOModule(const void* mem, size_t length,
|
LTOModule* LTOModule::makeLTOModule(const void* mem, size_t length,
|
||||||
LLVMContext& Context,
|
|
||||||
std::string& errMsg)
|
std::string& errMsg)
|
||||||
{
|
{
|
||||||
OwningPtr<MemoryBuffer> buffer(makeBuffer(mem, length));
|
OwningPtr<MemoryBuffer> buffer(makeBuffer(mem, length));
|
||||||
if ( !buffer )
|
if ( !buffer )
|
||||||
return NULL;
|
return NULL;
|
||||||
return makeLTOModule(buffer.get(), Context, errMsg);
|
return makeLTOModule(buffer.get(), errMsg);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// getFeatureString - Return a string listing the features associated with the
|
/// getFeatureString - Return a string listing the features associated with the
|
||||||
@@ -142,11 +140,10 @@ std::string getFeatureString(const char *TargetTriple) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
LTOModule* LTOModule::makeLTOModule(MemoryBuffer* buffer,
|
LTOModule* LTOModule::makeLTOModule(MemoryBuffer* buffer,
|
||||||
LLVMContext& Context,
|
|
||||||
std::string& errMsg)
|
std::string& errMsg)
|
||||||
{
|
{
|
||||||
// parse bitcode buffer
|
// parse bitcode buffer
|
||||||
OwningPtr<Module> m(ParseBitcodeFile(buffer, Context, &errMsg));
|
OwningPtr<Module> m(ParseBitcodeFile(buffer, getGlobalContext(), &errMsg));
|
||||||
if ( !m )
|
if ( !m )
|
||||||
return NULL;
|
return NULL;
|
||||||
// find machine architecture for this module
|
// find machine architecture for this module
|
||||||
|
|||||||
@@ -32,7 +32,6 @@ namespace llvm {
|
|||||||
class GlobalValue;
|
class GlobalValue;
|
||||||
class Value;
|
class Value;
|
||||||
class Function;
|
class Function;
|
||||||
class LLVMContext;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -52,10 +51,8 @@ public:
|
|||||||
const char* triplePrefix);
|
const char* triplePrefix);
|
||||||
|
|
||||||
static LTOModule* makeLTOModule(const char* path,
|
static LTOModule* makeLTOModule(const char* path,
|
||||||
llvm::LLVMContext& Context,
|
|
||||||
std::string& errMsg);
|
std::string& errMsg);
|
||||||
static LTOModule* makeLTOModule(const void* mem, size_t length,
|
static LTOModule* makeLTOModule(const void* mem, size_t length,
|
||||||
llvm::LLVMContext& Context,
|
|
||||||
std::string& errMsg);
|
std::string& errMsg);
|
||||||
|
|
||||||
const char* getTargetTriple();
|
const char* getTargetTriple();
|
||||||
@@ -91,7 +88,6 @@ private:
|
|||||||
const char* triplePrefix);
|
const char* triplePrefix);
|
||||||
|
|
||||||
static LTOModule* makeLTOModule(llvm::MemoryBuffer* buffer,
|
static LTOModule* makeLTOModule(llvm::MemoryBuffer* buffer,
|
||||||
llvm::LLVMContext& Context,
|
|
||||||
std::string& errMsg);
|
std::string& errMsg);
|
||||||
static llvm::MemoryBuffer* makeBuffer(const void* mem, size_t length);
|
static llvm::MemoryBuffer* makeBuffer(const void* mem, size_t length);
|
||||||
|
|
||||||
|
|||||||
@@ -86,10 +86,9 @@ bool lto_module_is_object_file_in_memory_for_target(const void* mem,
|
|||||||
// loads an object file from disk
|
// loads an object file from disk
|
||||||
// returns NULL on error (check lto_get_error_message() for details)
|
// returns NULL on error (check lto_get_error_message() for details)
|
||||||
//
|
//
|
||||||
lto_module_t lto_module_create(const char* path, LLVMContextRef Ctxt)
|
lto_module_t lto_module_create(const char* path)
|
||||||
{
|
{
|
||||||
return LTOModule::makeLTOModule(path, *llvm::unwrap(Ctxt),
|
return LTOModule::makeLTOModule(path, sLastErrorString);
|
||||||
sLastErrorString);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -97,11 +96,9 @@ lto_module_t lto_module_create(const char* path, LLVMContextRef Ctxt)
|
|||||||
// loads an object file from memory
|
// loads an object file from memory
|
||||||
// returns NULL on error (check lto_get_error_message() for details)
|
// returns NULL on error (check lto_get_error_message() for details)
|
||||||
//
|
//
|
||||||
lto_module_t lto_module_create_from_memory(const void* mem, size_t length,
|
lto_module_t lto_module_create_from_memory(const void* mem, size_t length)
|
||||||
LLVMContextRef Ctxt)
|
|
||||||
{
|
{
|
||||||
return LTOModule::makeLTOModule(mem, length, *llvm::unwrap(Ctxt),
|
return LTOModule::makeLTOModule(mem, length, sLastErrorString);
|
||||||
sLastErrorString);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -158,9 +155,9 @@ lto_symbol_attributes lto_module_get_symbol_attribute(lto_module_t mod,
|
|||||||
// instantiates a code generator
|
// instantiates a code generator
|
||||||
// returns NULL if there is an error
|
// returns NULL if there is an error
|
||||||
//
|
//
|
||||||
lto_code_gen_t lto_codegen_create(LLVMContextRef ContextRef)
|
lto_code_gen_t lto_codegen_create(void)
|
||||||
{
|
{
|
||||||
return new LTOCodeGenerator(*llvm::unwrap(ContextRef));
|
return new LTOCodeGenerator();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user