mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-01-14 16:33:28 +00:00
Move LTOModule and LTOCodeGenerator to the llvm namespace.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@207911 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
10e8f9521b
commit
dd326086fc
@ -84,10 +84,10 @@ typedef enum {
|
|||||||
} lto_codegen_model;
|
} lto_codegen_model;
|
||||||
|
|
||||||
/** opaque reference to a loaded object module */
|
/** opaque reference to a loaded object module */
|
||||||
typedef struct LTOModule* lto_module_t;
|
typedef struct LLVMOpaqueLTOModule *lto_module_t;
|
||||||
|
|
||||||
/** opaque reference to a code generator */
|
/** opaque reference to a code generator */
|
||||||
typedef struct LTOCodeGenerator* lto_code_gen_t;
|
typedef struct LLVMOpaqueLTOCodeGenerator *lto_code_gen_t;
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
extern "C" {
|
extern "C" {
|
||||||
|
@ -53,7 +53,6 @@ namespace llvm {
|
|||||||
class TargetLibraryInfo;
|
class TargetLibraryInfo;
|
||||||
class TargetMachine;
|
class TargetMachine;
|
||||||
class raw_ostream;
|
class raw_ostream;
|
||||||
}
|
|
||||||
|
|
||||||
//===----------------------------------------------------------------------===//
|
//===----------------------------------------------------------------------===//
|
||||||
/// C++ class which implements the opaque lto_code_gen_t type.
|
/// C++ class which implements the opaque lto_code_gen_t type.
|
||||||
@ -67,7 +66,7 @@ struct LTOCodeGenerator {
|
|||||||
// Merge given module, return true on success.
|
// Merge given module, return true on success.
|
||||||
bool addModule(struct LTOModule*, std::string &errMsg);
|
bool addModule(struct LTOModule*, std::string &errMsg);
|
||||||
|
|
||||||
void setTargetOptions(llvm::TargetOptions options);
|
void setTargetOptions(TargetOptions options);
|
||||||
void setDebugInfo(lto_debug_model);
|
void setDebugInfo(lto_debug_model);
|
||||||
void setCodePICModel(lto_codegen_model);
|
void setCodePICModel(lto_codegen_model);
|
||||||
|
|
||||||
@ -120,41 +119,37 @@ struct LTOCodeGenerator {
|
|||||||
private:
|
private:
|
||||||
void initializeLTOPasses();
|
void initializeLTOPasses();
|
||||||
|
|
||||||
bool generateObjectFile(llvm::raw_ostream &out,
|
bool generateObjectFile(raw_ostream &out, bool disableOpt, bool disableInline,
|
||||||
bool disableOpt,
|
bool disableGVNLoadPRE, std::string &errMsg);
|
||||||
bool disableInline,
|
|
||||||
bool disableGVNLoadPRE,
|
|
||||||
std::string &errMsg);
|
|
||||||
void applyScopeRestrictions();
|
void applyScopeRestrictions();
|
||||||
void applyRestriction(llvm::GlobalValue &GV,
|
void applyRestriction(GlobalValue &GV, const ArrayRef<StringRef> &Libcalls,
|
||||||
const llvm::ArrayRef<llvm::StringRef> &Libcalls,
|
std::vector<const char *> &MustPreserveList,
|
||||||
std::vector<const char*> &MustPreserveList,
|
SmallPtrSet<GlobalValue *, 8> &AsmUsed,
|
||||||
llvm::SmallPtrSet<llvm::GlobalValue*, 8> &AsmUsed,
|
Mangler &Mangler);
|
||||||
llvm::Mangler &Mangler);
|
|
||||||
bool determineTarget(std::string &errMsg);
|
bool determineTarget(std::string &errMsg);
|
||||||
|
|
||||||
static void DiagnosticHandler(const llvm::DiagnosticInfo &DI, void *Context);
|
static void DiagnosticHandler(const DiagnosticInfo &DI, void *Context);
|
||||||
|
|
||||||
void DiagnosticHandler2(const llvm::DiagnosticInfo &DI);
|
void DiagnosticHandler2(const DiagnosticInfo &DI);
|
||||||
|
|
||||||
typedef llvm::StringMap<uint8_t> StringSet;
|
typedef StringMap<uint8_t> StringSet;
|
||||||
|
|
||||||
llvm::LLVMContext &Context;
|
LLVMContext &Context;
|
||||||
llvm::Linker Linker;
|
Linker Linker;
|
||||||
llvm::TargetMachine *TargetMach;
|
TargetMachine *TargetMach;
|
||||||
bool EmitDwarfDebugInfo;
|
bool EmitDwarfDebugInfo;
|
||||||
bool ScopeRestrictionsDone;
|
bool ScopeRestrictionsDone;
|
||||||
lto_codegen_model CodeModel;
|
lto_codegen_model CodeModel;
|
||||||
StringSet MustPreserveSymbols;
|
StringSet MustPreserveSymbols;
|
||||||
StringSet AsmUndefinedRefs;
|
StringSet AsmUndefinedRefs;
|
||||||
llvm::MemoryBuffer *NativeObjectFile;
|
MemoryBuffer *NativeObjectFile;
|
||||||
std::vector<char *> CodegenOptions;
|
std::vector<char *> CodegenOptions;
|
||||||
std::string MCpu;
|
std::string MCpu;
|
||||||
std::string MAttr;
|
std::string MAttr;
|
||||||
std::string NativeObjectPath;
|
std::string NativeObjectPath;
|
||||||
llvm::TargetOptions Options;
|
TargetOptions Options;
|
||||||
lto_diagnostic_handler_t DiagHandler;
|
lto_diagnostic_handler_t DiagHandler;
|
||||||
void *DiagContext;
|
void *DiagContext;
|
||||||
};
|
};
|
||||||
|
}
|
||||||
#endif // LTO_CODE_GENERATOR_H
|
#endif // LTO_CODE_GENERATOR_H
|
||||||
|
@ -31,25 +31,24 @@ namespace llvm {
|
|||||||
class MemoryBuffer;
|
class MemoryBuffer;
|
||||||
class TargetOptions;
|
class TargetOptions;
|
||||||
class Value;
|
class Value;
|
||||||
}
|
|
||||||
|
|
||||||
//===----------------------------------------------------------------------===//
|
//===----------------------------------------------------------------------===//
|
||||||
/// C++ class which implements the opaque lto_module_t type.
|
/// C++ class which implements the opaque lto_module_t type.
|
||||||
///
|
///
|
||||||
struct LTOModule {
|
struct LTOModule {
|
||||||
private:
|
private:
|
||||||
typedef llvm::StringMap<uint8_t> StringSet;
|
typedef StringMap<uint8_t> StringSet;
|
||||||
|
|
||||||
struct NameAndAttributes {
|
struct NameAndAttributes {
|
||||||
const char *name;
|
const char *name;
|
||||||
uint32_t attributes;
|
uint32_t attributes;
|
||||||
bool isFunction;
|
bool isFunction;
|
||||||
const llvm::GlobalValue *symbol;
|
const GlobalValue *symbol;
|
||||||
};
|
};
|
||||||
|
|
||||||
std::unique_ptr<llvm::Module> _module;
|
std::unique_ptr<Module> _module;
|
||||||
std::unique_ptr<llvm::TargetMachine> _target;
|
std::unique_ptr<TargetMachine> _target;
|
||||||
llvm::MCObjectFileInfo ObjFileInfo;
|
MCObjectFileInfo ObjFileInfo;
|
||||||
StringSet _linkeropt_strings;
|
StringSet _linkeropt_strings;
|
||||||
std::vector<const char *> _deplibs;
|
std::vector<const char *> _deplibs;
|
||||||
std::vector<const char *> _linkeropts;
|
std::vector<const char *> _linkeropts;
|
||||||
@ -57,14 +56,15 @@ private:
|
|||||||
|
|
||||||
// _defines and _undefines only needed to disambiguate tentative definitions
|
// _defines and _undefines only needed to disambiguate tentative definitions
|
||||||
StringSet _defines;
|
StringSet _defines;
|
||||||
llvm::StringMap<NameAndAttributes> _undefines;
|
StringMap<NameAndAttributes> _undefines;
|
||||||
std::vector<const char*> _asm_undefines;
|
std::vector<const char*> _asm_undefines;
|
||||||
llvm::MCContext _context;
|
MCContext _context;
|
||||||
|
|
||||||
// Use mangler to add GlobalPrefix to names to match linker names.
|
// Use mangler to add GlobalPrefix to names to match linker names.
|
||||||
llvm::Mangler _mangler;
|
Mangler _mangler;
|
||||||
|
|
||||||
|
LTOModule(Module *m, TargetMachine *t);
|
||||||
|
|
||||||
LTOModule(llvm::Module *m, llvm::TargetMachine *t);
|
|
||||||
public:
|
public:
|
||||||
/// Returns 'true' if the file or memory contents is LLVM bitcode.
|
/// Returns 'true' if the file or memory contents is LLVM bitcode.
|
||||||
static bool isBitcodeFile(const void *mem, size_t length);
|
static bool isBitcodeFile(const void *mem, size_t length);
|
||||||
@ -86,20 +86,16 @@ public:
|
|||||||
/// InitializeAllTargetMCs();
|
/// InitializeAllTargetMCs();
|
||||||
/// InitializeAllAsmPrinters();
|
/// InitializeAllAsmPrinters();
|
||||||
/// InitializeAllAsmParsers();
|
/// InitializeAllAsmParsers();
|
||||||
static LTOModule *makeLTOModule(const char* path,
|
static LTOModule *makeLTOModule(const char *path, TargetOptions options,
|
||||||
llvm::TargetOptions options,
|
|
||||||
std::string &errMsg);
|
std::string &errMsg);
|
||||||
static LTOModule *makeLTOModule(int fd, const char *path,
|
static LTOModule *makeLTOModule(int fd, const char *path, size_t size,
|
||||||
size_t size, llvm::TargetOptions options,
|
TargetOptions options, std::string &errMsg);
|
||||||
|
static LTOModule *makeLTOModule(int fd, const char *path, size_t map_size,
|
||||||
|
off_t offset, TargetOptions options,
|
||||||
std::string &errMsg);
|
std::string &errMsg);
|
||||||
static LTOModule *makeLTOModule(int fd, const char *path,
|
|
||||||
size_t map_size,
|
|
||||||
off_t offset, llvm::TargetOptions options,
|
|
||||||
std::string& errMsg);
|
|
||||||
static LTOModule *makeLTOModule(const void *mem, size_t length,
|
static LTOModule *makeLTOModule(const void *mem, size_t length,
|
||||||
llvm::TargetOptions options,
|
TargetOptions options, std::string &errMsg,
|
||||||
std::string &errMsg,
|
StringRef path = "");
|
||||||
llvm::StringRef path = "");
|
|
||||||
|
|
||||||
/// Return the Module's target triple.
|
/// Return the Module's target triple.
|
||||||
const char *getTargetTriple() {
|
const char *getTargetTriple() {
|
||||||
@ -155,7 +151,7 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Return the Module.
|
/// Return the Module.
|
||||||
llvm::Module *getLLVVMModule() { return _module.get(); }
|
Module *getLLVVMModule() { return _module.get(); }
|
||||||
|
|
||||||
const std::vector<const char*> &getAsmUndefinedRefs() {
|
const std::vector<const char*> &getAsmUndefinedRefs() {
|
||||||
return _asm_undefines;
|
return _asm_undefines;
|
||||||
@ -171,16 +167,16 @@ private:
|
|||||||
bool parseSymbols(std::string &errMsg);
|
bool parseSymbols(std::string &errMsg);
|
||||||
|
|
||||||
/// Add a symbol which isn't defined just yet to a list to be resolved later.
|
/// Add a symbol which isn't defined just yet to a list to be resolved later.
|
||||||
void addPotentialUndefinedSymbol(const llvm::GlobalValue *dcl, bool isFunc);
|
void addPotentialUndefinedSymbol(const GlobalValue *dcl, bool isFunc);
|
||||||
|
|
||||||
/// Add a defined symbol to the list.
|
/// Add a defined symbol to the list.
|
||||||
void addDefinedSymbol(const llvm::GlobalValue *def, bool isFunction);
|
void addDefinedSymbol(const GlobalValue *def, bool isFunction);
|
||||||
|
|
||||||
/// Add a function symbol as defined to the list.
|
/// Add a function symbol as defined to the list.
|
||||||
void addDefinedFunctionSymbol(const llvm::Function *f);
|
void addDefinedFunctionSymbol(const Function *f);
|
||||||
|
|
||||||
/// Add a data symbol as defined to the list.
|
/// Add a data symbol as defined to the list.
|
||||||
void addDefinedDataSymbol(const llvm::GlobalValue *v);
|
void addDefinedDataSymbol(const GlobalValue *v);
|
||||||
|
|
||||||
/// Add global symbols from module-level ASM to the defined or undefined
|
/// Add global symbols from module-level ASM to the defined or undefined
|
||||||
/// lists.
|
/// lists.
|
||||||
@ -193,30 +189,28 @@ private:
|
|||||||
void addAsmGlobalSymbolUndef(const char *);
|
void addAsmGlobalSymbolUndef(const char *);
|
||||||
|
|
||||||
/// Parse i386/ppc ObjC class data structure.
|
/// Parse i386/ppc ObjC class data structure.
|
||||||
void addObjCClass(const llvm::GlobalVariable *clgv);
|
void addObjCClass(const GlobalVariable *clgv);
|
||||||
|
|
||||||
/// Parse i386/ppc ObjC category data structure.
|
/// Parse i386/ppc ObjC category data structure.
|
||||||
void addObjCCategory(const llvm::GlobalVariable *clgv);
|
void addObjCCategory(const GlobalVariable *clgv);
|
||||||
|
|
||||||
/// Parse i386/ppc ObjC class list data structure.
|
/// Parse i386/ppc ObjC class list data structure.
|
||||||
void addObjCClassRef(const llvm::GlobalVariable *clgv);
|
void addObjCClassRef(const GlobalVariable *clgv);
|
||||||
|
|
||||||
/// Get string that the data pointer points to.
|
/// Get string that the data pointer points to.
|
||||||
bool objcClassNameFromExpression(const llvm::Constant* c, std::string &name);
|
bool objcClassNameFromExpression(const Constant *c, std::string &name);
|
||||||
|
|
||||||
/// Returns 'true' if the memory buffer is for the specified target triple.
|
/// Returns 'true' if the memory buffer is for the specified target triple.
|
||||||
static bool isTargetMatch(llvm::MemoryBuffer *memBuffer,
|
static bool isTargetMatch(MemoryBuffer *memBuffer, const char *triplePrefix);
|
||||||
const char *triplePrefix);
|
|
||||||
|
|
||||||
/// Create an LTOModule (private version). N.B. This method takes ownership of
|
/// Create an LTOModule (private version). N.B. This method takes ownership of
|
||||||
/// the buffer.
|
/// the buffer.
|
||||||
static LTOModule *makeLTOModule(llvm::MemoryBuffer *buffer,
|
static LTOModule *makeLTOModule(MemoryBuffer *buffer, TargetOptions options,
|
||||||
llvm::TargetOptions options,
|
|
||||||
std::string &errMsg);
|
std::string &errMsg);
|
||||||
|
|
||||||
/// Create a MemoryBuffer from a memory range with an optional name.
|
/// Create a MemoryBuffer from a memory range with an optional name.
|
||||||
static llvm::MemoryBuffer *makeBuffer(const void *mem, size_t length,
|
static MemoryBuffer *makeBuffer(const void *mem, size_t length,
|
||||||
llvm::StringRef name = "");
|
StringRef name = "");
|
||||||
};
|
};
|
||||||
|
}
|
||||||
#endif // LTO_MODULE_H
|
#endif // LTO_MODULE_H
|
||||||
|
@ -56,8 +56,12 @@ static void lto_initialize() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
DEFINE_SIMPLE_CONVERSION_FUNCTIONS(LTOCodeGenerator, lto_code_gen_t);
|
||||||
|
DEFINE_SIMPLE_CONVERSION_FUNCTIONS(LTOModule, lto_module_t);
|
||||||
|
|
||||||
// Convert the subtarget features into a string to pass to LTOCodeGenerator.
|
// Convert the subtarget features into a string to pass to LTOCodeGenerator.
|
||||||
static void lto_add_attrs(lto_code_gen_t cg) {
|
static void lto_add_attrs(lto_code_gen_t cg) {
|
||||||
|
LTOCodeGenerator *CG = unwrap(cg);
|
||||||
if (MAttrs.size()) {
|
if (MAttrs.size()) {
|
||||||
std::string attrs;
|
std::string attrs;
|
||||||
for (unsigned i = 0; i < MAttrs.size(); ++i) {
|
for (unsigned i = 0; i < MAttrs.size(); ++i) {
|
||||||
@ -66,7 +70,7 @@ static void lto_add_attrs(lto_code_gen_t cg) {
|
|||||||
attrs.append(MAttrs[i]);
|
attrs.append(MAttrs[i]);
|
||||||
}
|
}
|
||||||
|
|
||||||
cg->setAttr(attrs.c_str());
|
CG->setAttr(attrs.c_str());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -101,13 +105,14 @@ lto_module_is_object_file_in_memory_for_target(const void* mem,
|
|||||||
lto_module_t lto_module_create(const char* path) {
|
lto_module_t lto_module_create(const char* path) {
|
||||||
lto_initialize();
|
lto_initialize();
|
||||||
llvm::TargetOptions Options = InitTargetOptionsFromCodeGenFlags();
|
llvm::TargetOptions Options = InitTargetOptionsFromCodeGenFlags();
|
||||||
return LTOModule::makeLTOModule(path, Options, sLastErrorString);
|
return wrap(LTOModule::makeLTOModule(path, Options, sLastErrorString));
|
||||||
}
|
}
|
||||||
|
|
||||||
lto_module_t lto_module_create_from_fd(int fd, const char *path, size_t size) {
|
lto_module_t lto_module_create_from_fd(int fd, const char *path, size_t size) {
|
||||||
lto_initialize();
|
lto_initialize();
|
||||||
llvm::TargetOptions Options = InitTargetOptionsFromCodeGenFlags();
|
llvm::TargetOptions Options = InitTargetOptionsFromCodeGenFlags();
|
||||||
return LTOModule::makeLTOModule(fd, path, size, Options, sLastErrorString);
|
return wrap(
|
||||||
|
LTOModule::makeLTOModule(fd, path, size, Options, sLastErrorString));
|
||||||
}
|
}
|
||||||
|
|
||||||
lto_module_t lto_module_create_from_fd_at_offset(int fd, const char *path,
|
lto_module_t lto_module_create_from_fd_at_offset(int fd, const char *path,
|
||||||
@ -116,14 +121,14 @@ lto_module_t lto_module_create_from_fd_at_offset(int fd, const char *path,
|
|||||||
off_t offset) {
|
off_t offset) {
|
||||||
lto_initialize();
|
lto_initialize();
|
||||||
llvm::TargetOptions Options = InitTargetOptionsFromCodeGenFlags();
|
llvm::TargetOptions Options = InitTargetOptionsFromCodeGenFlags();
|
||||||
return LTOModule::makeLTOModule(fd, path, map_size, offset, Options,
|
return wrap(LTOModule::makeLTOModule(fd, path, map_size, offset, Options,
|
||||||
sLastErrorString);
|
sLastErrorString));
|
||||||
}
|
}
|
||||||
|
|
||||||
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) {
|
||||||
lto_initialize();
|
lto_initialize();
|
||||||
llvm::TargetOptions Options = InitTargetOptionsFromCodeGenFlags();
|
llvm::TargetOptions Options = InitTargetOptionsFromCodeGenFlags();
|
||||||
return LTOModule::makeLTOModule(mem, length, Options, sLastErrorString);
|
return wrap(LTOModule::makeLTOModule(mem, length, Options, sLastErrorString));
|
||||||
}
|
}
|
||||||
|
|
||||||
lto_module_t lto_module_create_from_memory_with_path(const void* mem,
|
lto_module_t lto_module_create_from_memory_with_path(const void* mem,
|
||||||
@ -131,54 +136,53 @@ lto_module_t lto_module_create_from_memory_with_path(const void* mem,
|
|||||||
const char *path) {
|
const char *path) {
|
||||||
lto_initialize();
|
lto_initialize();
|
||||||
llvm::TargetOptions Options = InitTargetOptionsFromCodeGenFlags();
|
llvm::TargetOptions Options = InitTargetOptionsFromCodeGenFlags();
|
||||||
return LTOModule::makeLTOModule(mem, length, Options, sLastErrorString, path);
|
return wrap(
|
||||||
|
LTOModule::makeLTOModule(mem, length, Options, sLastErrorString, path));
|
||||||
}
|
}
|
||||||
|
|
||||||
void lto_module_dispose(lto_module_t mod) {
|
void lto_module_dispose(lto_module_t mod) { delete unwrap(mod); }
|
||||||
delete mod;
|
|
||||||
}
|
|
||||||
|
|
||||||
const char* lto_module_get_target_triple(lto_module_t mod) {
|
const char* lto_module_get_target_triple(lto_module_t mod) {
|
||||||
return mod->getTargetTriple();
|
return unwrap(mod)->getTargetTriple();
|
||||||
}
|
}
|
||||||
|
|
||||||
void lto_module_set_target_triple(lto_module_t mod, const char *triple) {
|
void lto_module_set_target_triple(lto_module_t mod, const char *triple) {
|
||||||
return mod->setTargetTriple(triple);
|
return unwrap(mod)->setTargetTriple(triple);
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned int lto_module_get_num_symbols(lto_module_t mod) {
|
unsigned int lto_module_get_num_symbols(lto_module_t mod) {
|
||||||
return mod->getSymbolCount();
|
return unwrap(mod)->getSymbolCount();
|
||||||
}
|
}
|
||||||
|
|
||||||
const char* lto_module_get_symbol_name(lto_module_t mod, unsigned int index) {
|
const char* lto_module_get_symbol_name(lto_module_t mod, unsigned int index) {
|
||||||
return mod->getSymbolName(index);
|
return unwrap(mod)->getSymbolName(index);
|
||||||
}
|
}
|
||||||
|
|
||||||
lto_symbol_attributes lto_module_get_symbol_attribute(lto_module_t mod,
|
lto_symbol_attributes lto_module_get_symbol_attribute(lto_module_t mod,
|
||||||
unsigned int index) {
|
unsigned int index) {
|
||||||
return mod->getSymbolAttributes(index);
|
return unwrap(mod)->getSymbolAttributes(index);
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned int lto_module_get_num_deplibs(lto_module_t mod) {
|
unsigned int lto_module_get_num_deplibs(lto_module_t mod) {
|
||||||
return mod->getDependentLibraryCount();
|
return unwrap(mod)->getDependentLibraryCount();
|
||||||
}
|
}
|
||||||
|
|
||||||
const char* lto_module_get_deplib(lto_module_t mod, unsigned int index) {
|
const char* lto_module_get_deplib(lto_module_t mod, unsigned int index) {
|
||||||
return mod->getDependentLibrary(index);
|
return unwrap(mod)->getDependentLibrary(index);
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned int lto_module_get_num_linkeropts(lto_module_t mod) {
|
unsigned int lto_module_get_num_linkeropts(lto_module_t mod) {
|
||||||
return mod->getLinkerOptCount();
|
return unwrap(mod)->getLinkerOptCount();
|
||||||
}
|
}
|
||||||
|
|
||||||
const char* lto_module_get_linkeropt(lto_module_t mod, unsigned int index) {
|
const char* lto_module_get_linkeropt(lto_module_t mod, unsigned int index) {
|
||||||
return mod->getLinkerOpt(index);
|
return unwrap(mod)->getLinkerOpt(index);
|
||||||
}
|
}
|
||||||
|
|
||||||
void lto_codegen_set_diagnostic_handler(lto_code_gen_t cg,
|
void lto_codegen_set_diagnostic_handler(lto_code_gen_t cg,
|
||||||
lto_diagnostic_handler_t diag_handler,
|
lto_diagnostic_handler_t diag_handler,
|
||||||
void *ctxt) {
|
void *ctxt) {
|
||||||
cg->setDiagnosticHandler(diag_handler, ctxt);
|
unwrap(cg)->setDiagnosticHandler(diag_handler, ctxt);
|
||||||
}
|
}
|
||||||
|
|
||||||
lto_code_gen_t lto_codegen_create(void) {
|
lto_code_gen_t lto_codegen_create(void) {
|
||||||
@ -189,33 +193,31 @@ lto_code_gen_t lto_codegen_create(void) {
|
|||||||
LTOCodeGenerator *CodeGen = new LTOCodeGenerator();
|
LTOCodeGenerator *CodeGen = new LTOCodeGenerator();
|
||||||
if (CodeGen)
|
if (CodeGen)
|
||||||
CodeGen->setTargetOptions(Options);
|
CodeGen->setTargetOptions(Options);
|
||||||
return CodeGen;
|
return wrap(CodeGen);
|
||||||
}
|
}
|
||||||
|
|
||||||
void lto_codegen_dispose(lto_code_gen_t cg) {
|
void lto_codegen_dispose(lto_code_gen_t cg) { delete unwrap(cg); }
|
||||||
delete cg;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool lto_codegen_add_module(lto_code_gen_t cg, lto_module_t mod) {
|
bool lto_codegen_add_module(lto_code_gen_t cg, lto_module_t mod) {
|
||||||
return !cg->addModule(mod, sLastErrorString);
|
return !unwrap(cg)->addModule(unwrap(mod), sLastErrorString);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool lto_codegen_set_debug_model(lto_code_gen_t cg, lto_debug_model debug) {
|
bool lto_codegen_set_debug_model(lto_code_gen_t cg, lto_debug_model debug) {
|
||||||
cg->setDebugInfo(debug);
|
unwrap(cg)->setDebugInfo(debug);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool lto_codegen_set_pic_model(lto_code_gen_t cg, lto_codegen_model model) {
|
bool lto_codegen_set_pic_model(lto_code_gen_t cg, lto_codegen_model model) {
|
||||||
cg->setCodePICModel(model);
|
unwrap(cg)->setCodePICModel(model);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
void lto_codegen_set_cpu(lto_code_gen_t cg, const char *cpu) {
|
void lto_codegen_set_cpu(lto_code_gen_t cg, const char *cpu) {
|
||||||
return cg->setCpu(cpu);
|
return unwrap(cg)->setCpu(cpu);
|
||||||
}
|
}
|
||||||
|
|
||||||
void lto_codegen_set_attr(lto_code_gen_t cg, const char *attr) {
|
void lto_codegen_set_attr(lto_code_gen_t cg, const char *attr) {
|
||||||
return cg->setAttr(attr);
|
return unwrap(cg)->setAttr(attr);
|
||||||
}
|
}
|
||||||
|
|
||||||
void lto_codegen_set_assembler_path(lto_code_gen_t cg, const char *path) {
|
void lto_codegen_set_assembler_path(lto_code_gen_t cg, const char *path) {
|
||||||
@ -229,38 +231,38 @@ void lto_codegen_set_assembler_args(lto_code_gen_t cg, const char **args,
|
|||||||
|
|
||||||
void lto_codegen_add_must_preserve_symbol(lto_code_gen_t cg,
|
void lto_codegen_add_must_preserve_symbol(lto_code_gen_t cg,
|
||||||
const char *symbol) {
|
const char *symbol) {
|
||||||
cg->addMustPreserveSymbol(symbol);
|
unwrap(cg)->addMustPreserveSymbol(symbol);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool lto_codegen_write_merged_modules(lto_code_gen_t cg, const char *path) {
|
bool lto_codegen_write_merged_modules(lto_code_gen_t cg, const char *path) {
|
||||||
if (!parsedOptions) {
|
if (!parsedOptions) {
|
||||||
cg->parseCodeGenDebugOptions();
|
unwrap(cg)->parseCodeGenDebugOptions();
|
||||||
lto_add_attrs(cg);
|
lto_add_attrs(cg);
|
||||||
parsedOptions = true;
|
parsedOptions = true;
|
||||||
}
|
}
|
||||||
return !cg->writeMergedModules(path, sLastErrorString);
|
return !unwrap(cg)->writeMergedModules(path, sLastErrorString);
|
||||||
}
|
}
|
||||||
|
|
||||||
const void *lto_codegen_compile(lto_code_gen_t cg, size_t *length) {
|
const void *lto_codegen_compile(lto_code_gen_t cg, size_t *length) {
|
||||||
if (!parsedOptions) {
|
if (!parsedOptions) {
|
||||||
cg->parseCodeGenDebugOptions();
|
unwrap(cg)->parseCodeGenDebugOptions();
|
||||||
lto_add_attrs(cg);
|
lto_add_attrs(cg);
|
||||||
parsedOptions = true;
|
parsedOptions = true;
|
||||||
}
|
}
|
||||||
return cg->compile(length, DisableOpt, DisableInline, DisableGVNLoadPRE,
|
return unwrap(cg)->compile(length, DisableOpt, DisableInline,
|
||||||
sLastErrorString);
|
DisableGVNLoadPRE, sLastErrorString);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool lto_codegen_compile_to_file(lto_code_gen_t cg, const char **name) {
|
bool lto_codegen_compile_to_file(lto_code_gen_t cg, const char **name) {
|
||||||
if (!parsedOptions) {
|
if (!parsedOptions) {
|
||||||
cg->parseCodeGenDebugOptions();
|
unwrap(cg)->parseCodeGenDebugOptions();
|
||||||
lto_add_attrs(cg);
|
lto_add_attrs(cg);
|
||||||
parsedOptions = true;
|
parsedOptions = true;
|
||||||
}
|
}
|
||||||
return !cg->compile_to_file(name, DisableOpt, DisableInline, DisableGVNLoadPRE,
|
return !unwrap(cg)->compile_to_file(name, DisableOpt, DisableInline,
|
||||||
sLastErrorString);
|
DisableGVNLoadPRE, sLastErrorString);
|
||||||
}
|
}
|
||||||
|
|
||||||
void lto_codegen_debug_options(lto_code_gen_t cg, const char *opt) {
|
void lto_codegen_debug_options(lto_code_gen_t cg, const char *opt) {
|
||||||
cg->setCodeGenDebugOptions(opt);
|
unwrap(cg)->setCodeGenDebugOptions(opt);
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user