1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-11-22 18:54:02 +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/IR/Module.h"
#include "llvm/MC/MCContext.h"
#include "llvm/MC/MCObjectFileInfo.h"
#include "llvm/Target/Mangler.h"
#include "llvm/Target/TargetMachine.h"
#include <string>
@ -49,6 +50,7 @@ private:
llvm::OwningPtr<llvm::Module> _module;
llvm::OwningPtr<llvm::TargetMachine> _target;
llvm::MCObjectFileInfo ObjFileInfo;
std::vector<NameAndAttributes> _symbols;
// _defines and _undefines only needed to disambiguate tentative definitions

View File

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

View File

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

View File

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