#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>
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
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.
#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"
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()) {
- PlatformParser = createCOFFAsmParser();
- PlatformParser->Initialize(*this);
- } else if (_MAI.hasSubsectionsViaSymbols()) {
- PlatformParser = createDarwinAsmParser();
- PlatformParser->Initialize(*this);
- IsDarwin = true;
- } else {
- PlatformParser = createELFAsmParser();
- PlatformParser->Initialize(*this);
+ switch (_Ctx.getObjectFileInfo()->getObjectFileType()) {
+ case MCObjectFileInfo::IsCOFF:
+ PlatformParser = createCOFFAsmParser();
+ PlatformParser->Initialize(*this);
+ break;
+ case MCObjectFileInfo::IsMachO:
+ PlatformParser = createDarwinAsmParser();
+ PlatformParser->Initialize(*this);
+ IsDarwin = true;
+ break;
+ case MCObjectFileInfo::IsELF:
+ PlatformParser = createELFAsmParser();
+ PlatformParser->Initialize(*this);
+ break;
}
initializeDirectiveKindMap();