1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-11-23 03:02:36 +01:00

Use a more direct check for finding out the file type.

No functionality change.

llvm-svn: 196811
This commit is contained in:
Rafael Espindola 2013-12-09 20:26:40 +00:00
parent fdd9e97c59
commit 30bfebf7cc
4 changed files with 28 additions and 16 deletions

View File

@ -19,6 +19,7 @@
#include "llvm/ADT/StringMap.h" #include "llvm/ADT/StringMap.h"
#include "llvm/IR/Module.h" #include "llvm/IR/Module.h"
#include "llvm/MC/MCContext.h" #include "llvm/MC/MCContext.h"
#include "llvm/MC/MCObjectFileInfo.h"
#include "llvm/Target/Mangler.h" #include "llvm/Target/Mangler.h"
#include "llvm/Target/TargetMachine.h" #include "llvm/Target/TargetMachine.h"
#include <string> #include <string>
@ -49,6 +50,7 @@ private:
llvm::OwningPtr<llvm::Module> _module; llvm::OwningPtr<llvm::Module> _module;
llvm::OwningPtr<llvm::TargetMachine> _target; llvm::OwningPtr<llvm::TargetMachine> _target;
llvm::MCObjectFileInfo ObjFileInfo;
std::vector<NameAndAttributes> _symbols; std::vector<NameAndAttributes> _symbols;
// _defines and _undefines only needed to disambiguate tentative definitions // _defines and _undefines only needed to disambiguate tentative definitions

View File

@ -353,8 +353,12 @@ public:
return EHFrameSection; return EHFrameSection;
} }
private:
enum Environment { IsMachO, IsELF, IsCOFF }; enum Environment { IsMachO, IsELF, IsCOFF };
Environment getObjectFileType() const {
return Env;
}
private:
Environment Env; Environment Env;
Reloc::Model RelocM; Reloc::Model RelocM;
CodeModel::Model CMModel; CodeModel::Model CMModel;

View File

@ -43,8 +43,12 @@ using namespace llvm;
LTOModule::LTOModule(llvm::Module *m, llvm::TargetMachine *t) LTOModule::LTOModule(llvm::Module *m, llvm::TargetMachine *t)
: _module(m), _target(t), : _module(m), _target(t),
_context(_target->getMCAsmInfo(), _target->getRegisterInfo(), NULL), _context(_target->getMCAsmInfo(), _target->getRegisterInfo(), &ObjFileInfo),
_mangler(t) {} _mangler(t) {
ObjFileInfo.InitMCObjectFileInfo(t->getTargetTriple(),
t->getRelocationModel(), t->getCodeModel(),
_context);
}
/// isBitcodeFile - Returns 'true' if the file (or memory contents) is LLVM /// isBitcodeFile - Returns 'true' if the file (or memory contents) is LLVM
/// bitcode. /// bitcode.

View File

@ -22,6 +22,7 @@
#include "llvm/MC/MCExpr.h" #include "llvm/MC/MCExpr.h"
#include "llvm/MC/MCInstPrinter.h" #include "llvm/MC/MCInstPrinter.h"
#include "llvm/MC/MCInstrInfo.h" #include "llvm/MC/MCInstrInfo.h"
#include "llvm/MC/MCObjectFileInfo.h"
#include "llvm/MC/MCParser/AsmCond.h" #include "llvm/MC/MCParser/AsmCond.h"
#include "llvm/MC/MCParser/AsmLexer.h" #include "llvm/MC/MCParser/AsmLexer.h"
#include "llvm/MC/MCParser/MCAsmParser.h" #include "llvm/MC/MCParser/MCAsmParser.h"
@ -491,19 +492,20 @@ AsmParser::AsmParser(SourceMgr &_SM, MCContext &_Ctx, MCStreamer &_Out,
Lexer.setBuffer(SrcMgr.getMemoryBuffer(CurBuffer)); Lexer.setBuffer(SrcMgr.getMemoryBuffer(CurBuffer));
// Initialize the platform / file format parser. // Initialize the platform / file format parser.
// switch (_Ctx.getObjectFileInfo()->getObjectFileType()) {
// FIXME: This is a hack, we need to (majorly) cleanup how these objects are case MCObjectFileInfo::IsCOFF:
// created.
if (_MAI.hasMicrosoftFastStdCallMangling()) {
PlatformParser = createCOFFAsmParser(); PlatformParser = createCOFFAsmParser();
PlatformParser->Initialize(*this); PlatformParser->Initialize(*this);
} else if (_MAI.hasSubsectionsViaSymbols()) { break;
case MCObjectFileInfo::IsMachO:
PlatformParser = createDarwinAsmParser(); PlatformParser = createDarwinAsmParser();
PlatformParser->Initialize(*this); PlatformParser->Initialize(*this);
IsDarwin = true; IsDarwin = true;
} else { break;
case MCObjectFileInfo::IsELF:
PlatformParser = createELFAsmParser(); PlatformParser = createELFAsmParser();
PlatformParser->Initialize(*this); PlatformParser->Initialize(*this);
break;
} }
initializeDirectiveKindMap(); initializeDirectiveKindMap();