forked from OSchip/llvm-project
Refactor the MCContext so that it's an ivar instead of a local which is passed
around. This is important for some future work as well. llvm-svn: 143688
This commit is contained in:
parent
4c81dfacbb
commit
ac2abde903
|
@ -32,7 +32,6 @@
|
||||||
#include "llvm/Support/system_error.h"
|
#include "llvm/Support/system_error.h"
|
||||||
#include "llvm/Target/Mangler.h"
|
#include "llvm/Target/Mangler.h"
|
||||||
#include "llvm/MC/MCAsmInfo.h"
|
#include "llvm/MC/MCAsmInfo.h"
|
||||||
#include "llvm/MC/MCContext.h"
|
|
||||||
#include "llvm/MC/MCExpr.h"
|
#include "llvm/MC/MCExpr.h"
|
||||||
#include "llvm/MC/MCInst.h"
|
#include "llvm/MC/MCInst.h"
|
||||||
#include "llvm/MC/MCParser/MCAsmParser.h"
|
#include "llvm/MC/MCParser/MCAsmParser.h"
|
||||||
|
@ -82,7 +81,8 @@ bool LTOModule::isTargetMatch(MemoryBuffer *buffer, const char *triplePrefix) {
|
||||||
|
|
||||||
|
|
||||||
LTOModule::LTOModule(Module *m, TargetMachine *t)
|
LTOModule::LTOModule(Module *m, TargetMachine *t)
|
||||||
: _module(m), _target(t)
|
: _module(m), _target(t),
|
||||||
|
_context(*_target->getMCAsmInfo(), *_target->getRegisterInfo(), NULL)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -613,17 +613,17 @@ namespace {
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
bool LTOModule::addAsmGlobalSymbols(MCContext &Context, std::string &errMsg) {
|
bool LTOModule::addAsmGlobalSymbols(std::string &errMsg) {
|
||||||
const std::string &inlineAsm = _module->getModuleInlineAsm();
|
const std::string &inlineAsm = _module->getModuleInlineAsm();
|
||||||
if (inlineAsm.empty())
|
if (inlineAsm.empty())
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
OwningPtr<RecordStreamer> Streamer(new RecordStreamer(Context));
|
OwningPtr<RecordStreamer> Streamer(new RecordStreamer(_context));
|
||||||
MemoryBuffer *Buffer = MemoryBuffer::getMemBuffer(inlineAsm);
|
MemoryBuffer *Buffer = MemoryBuffer::getMemBuffer(inlineAsm);
|
||||||
SourceMgr SrcMgr;
|
SourceMgr SrcMgr;
|
||||||
SrcMgr.AddNewSourceBuffer(Buffer, SMLoc());
|
SrcMgr.AddNewSourceBuffer(Buffer, SMLoc());
|
||||||
OwningPtr<MCAsmParser> Parser(createMCAsmParser(SrcMgr,
|
OwningPtr<MCAsmParser> Parser(createMCAsmParser(SrcMgr,
|
||||||
Context, *Streamer,
|
_context, *Streamer,
|
||||||
*_target->getMCAsmInfo()));
|
*_target->getMCAsmInfo()));
|
||||||
OwningPtr<MCSubtargetInfo> STI(_target->getTarget().
|
OwningPtr<MCSubtargetInfo> STI(_target->getTarget().
|
||||||
createMCSubtargetInfo(_target->getTargetTriple(),
|
createMCSubtargetInfo(_target->getTargetTriple(),
|
||||||
|
@ -671,8 +671,7 @@ static bool isAliasToDeclaration(const GlobalAlias &V) {
|
||||||
|
|
||||||
bool LTOModule::ParseSymbols(std::string &errMsg) {
|
bool LTOModule::ParseSymbols(std::string &errMsg) {
|
||||||
// Use mangler to add GlobalPrefix to names to match linker names.
|
// Use mangler to add GlobalPrefix to names to match linker names.
|
||||||
MCContext Context(*_target->getMCAsmInfo(), *_target->getRegisterInfo(),NULL);
|
Mangler mangler(_context, *_target->getTargetData());
|
||||||
Mangler mangler(Context, *_target->getTargetData());
|
|
||||||
|
|
||||||
// add functions
|
// add functions
|
||||||
for (Module::iterator f = _module->begin(); f != _module->end(); ++f) {
|
for (Module::iterator f = _module->begin(); f != _module->end(); ++f) {
|
||||||
|
@ -692,7 +691,7 @@ bool LTOModule::ParseSymbols(std::string &errMsg) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// add asm globals
|
// add asm globals
|
||||||
if (addAsmGlobalSymbols(Context, errMsg))
|
if (addAsmGlobalSymbols(errMsg))
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
// add aliases
|
// add aliases
|
||||||
|
|
|
@ -15,8 +15,9 @@
|
||||||
#define LTO_MODULE_H
|
#define LTO_MODULE_H
|
||||||
|
|
||||||
#include "llvm/Module.h"
|
#include "llvm/Module.h"
|
||||||
#include "llvm/ADT/OwningPtr.h"
|
#include "llvm/MC/MCContext.h"
|
||||||
#include "llvm/Target/TargetMachine.h"
|
#include "llvm/Target/TargetMachine.h"
|
||||||
|
#include "llvm/ADT/OwningPtr.h"
|
||||||
#include "llvm/ADT/StringMap.h"
|
#include "llvm/ADT/StringMap.h"
|
||||||
|
|
||||||
#include "llvm-c/lto.h"
|
#include "llvm-c/lto.h"
|
||||||
|
@ -83,11 +84,10 @@ private:
|
||||||
void addPotentialUndefinedSymbol(llvm::GlobalValue* decl,
|
void addPotentialUndefinedSymbol(llvm::GlobalValue* decl,
|
||||||
llvm::Mangler &mangler);
|
llvm::Mangler &mangler);
|
||||||
void addDefinedFunctionSymbol(llvm::Function* f,
|
void addDefinedFunctionSymbol(llvm::Function* f,
|
||||||
llvm::Mangler &mangler);
|
llvm::Mangler &mangler);
|
||||||
void addDefinedDataSymbol(llvm::GlobalValue* v,
|
void addDefinedDataSymbol(llvm::GlobalValue* v,
|
||||||
llvm::Mangler &mangler);
|
llvm::Mangler &mangler);
|
||||||
bool addAsmGlobalSymbols(llvm::MCContext &Context,
|
bool addAsmGlobalSymbols(std::string &errMsg);
|
||||||
std::string &errMsg);
|
|
||||||
void addAsmGlobalSymbol(const char *,
|
void addAsmGlobalSymbol(const char *,
|
||||||
lto_symbol_attributes scope);
|
lto_symbol_attributes scope);
|
||||||
void addAsmGlobalSymbolUndef(const char *);
|
void addAsmGlobalSymbolUndef(const char *);
|
||||||
|
@ -118,6 +118,7 @@ private:
|
||||||
StringSet _defines;
|
StringSet _defines;
|
||||||
llvm::StringMap<NameAndAttributes> _undefines;
|
llvm::StringMap<NameAndAttributes> _undefines;
|
||||||
std::vector<const char*> _asm_undefines;
|
std::vector<const char*> _asm_undefines;
|
||||||
|
llvm::MCContext _context;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // LTO_MODULE_H
|
#endif // LTO_MODULE_H
|
||||||
|
|
Loading…
Reference in New Issue