diff options
author | Rafael Espindola <rafael.espindola@gmail.com> | 2015-08-14 13:31:17 +0000 |
---|---|---|
committer | Rafael Espindola <rafael.espindola@gmail.com> | 2015-08-14 13:31:17 +0000 |
commit | 90eb70c8a76db399d9128a4f70af8cd393374694 (patch) | |
tree | 4e14ff48776f0434aaf21deed18abe88d4f70103 /llvm/lib/MC | |
parent | 078ab134ea73c01059acaa45f1d52d964727b612 (diff) | |
download | bcm5719-llvm-90eb70c8a76db399d9128a4f70af8cd393374694.tar.gz bcm5719-llvm-90eb70c8a76db399d9128a4f70af8cd393374694.zip |
Centralize the information about which object format we are using.
Other than some places that were handling unknown as ELF, this should
have no change. The test updates are because we were detecting
arm-coff or x86_64-win64-coff as ELF targets before.
It is not clear if the enum should live on the Triple. At least now it lives
in a single location and should be easier to move somewhere else.
llvm-svn: 245047
Diffstat (limited to 'llvm/lib/MC')
-rw-r--r-- | llvm/lib/MC/MCContext.cpp | 10 | ||||
-rw-r--r-- | llvm/lib/MC/MCObjectFileInfo.cpp | 40 | ||||
-rw-r--r-- | llvm/lib/MC/MCParser/AsmParser.cpp | 10 |
3 files changed, 33 insertions, 27 deletions
diff --git a/llvm/lib/MC/MCContext.cpp b/llvm/lib/MC/MCContext.cpp index c601c56f395..e8fb6a95ebe 100644 --- a/llvm/lib/MC/MCContext.cpp +++ b/llvm/lib/MC/MCContext.cpp @@ -162,13 +162,15 @@ MCSymbol *MCContext::getOrCreateLSDASymbol(StringRef FuncName) { MCSymbol *MCContext::createSymbolImpl(const StringMapEntry<bool> *Name, bool IsTemporary) { if (MOFI) { - switch (MOFI->getObjectFileType()) { - case MCObjectFileInfo::IsCOFF: + switch (MOFI->getTargetTriple().getObjectFormat()) { + case Triple::COFF: return new (Name, *this) MCSymbolCOFF(Name, IsTemporary); - case MCObjectFileInfo::IsELF: + case Triple::ELF: return new (Name, *this) MCSymbolELF(Name, IsTemporary); - case MCObjectFileInfo::IsMachO: + case Triple::MachO: return new (Name, *this) MCSymbolMachO(Name, IsTemporary); + case Triple::UnknownObjectFormat: + break; } } return new (Name, *this) MCSymbol(MCSymbol::SymbolKindUnset, Name, diff --git a/llvm/lib/MC/MCObjectFileInfo.cpp b/llvm/lib/MC/MCObjectFileInfo.cpp index 576827a72d5..ade4b496ec7 100644 --- a/llvm/lib/MC/MCObjectFileInfo.cpp +++ b/llvm/lib/MC/MCObjectFileInfo.cpp @@ -767,25 +767,19 @@ void MCObjectFileInfo::InitMCObjectFileInfo(const Triple &TheTriple, TT = TheTriple; - Triple::ArchType Arch = TT.getArch(); - // FIXME: Checking for Arch here to filter out bogus triples such as - // cellspu-apple-darwin. Perhaps we should fix in Triple? - if ((Arch == Triple::x86 || Arch == Triple::x86_64 || - Arch == Triple::arm || Arch == Triple::thumb || - Arch == Triple::aarch64 || - Arch == Triple::ppc || Arch == Triple::ppc64 || - Arch == Triple::UnknownArch) && - TT.isOSBinFormatMachO()) { - Env = IsMachO; + Triple::ObjectFormatType Format = TT.getObjectFormat(); + switch (Format) { + case Triple::MachO: initMachOMCObjectFileInfo(TT); - } else if ((Arch == Triple::x86 || Arch == Triple::x86_64 || - Arch == Triple::arm || Arch == Triple::thumb) && - (TT.isOSWindows() && TT.getObjectFormat() == Triple::COFF)) { - Env = IsCOFF; + break; + case Triple::COFF: initCOFFMCObjectFileInfo(TT); - } else { - Env = IsELF; + break; + case Triple::ELF: initELFMCObjectFileInfo(TT); + break; + case Triple::UnknownObjectFormat: + break; } } @@ -801,7 +795,9 @@ MCSection *MCObjectFileInfo::getDwarfTypesSection(uint64_t Hash) const { } void MCObjectFileInfo::InitEHFrameSection() { - if (Env == IsMachO) + Triple::ObjectFormatType Format = TT.getObjectFormat(); + switch (Format) { + case Triple::MachO: EHFrameSection = Ctx->getMachOSection("__TEXT", "__eh_frame", MachO::S_COALESCED | @@ -809,14 +805,20 @@ void MCObjectFileInfo::InitEHFrameSection() { MachO::S_ATTR_STRIP_STATIC_SYMS | MachO::S_ATTR_LIVE_SUPPORT, SectionKind::getReadOnly()); - else if (Env == IsELF) + break; + case Triple::ELF: EHFrameSection = Ctx->getELFSection(".eh_frame", EHSectionType, EHSectionFlags); - else + break; + case Triple::COFF: EHFrameSection = Ctx->getCOFFSection(".eh_frame", COFF::IMAGE_SCN_CNT_INITIALIZED_DATA | COFF::IMAGE_SCN_MEM_READ | COFF::IMAGE_SCN_MEM_WRITE, SectionKind::getDataRel()); + break; + case Triple::UnknownObjectFormat: + break; + } } diff --git a/llvm/lib/MC/MCParser/AsmParser.cpp b/llvm/lib/MC/MCParser/AsmParser.cpp index 3f45b3d85a3..0089f8f4ebc 100644 --- a/llvm/lib/MC/MCParser/AsmParser.cpp +++ b/llvm/lib/MC/MCParser/AsmParser.cpp @@ -513,17 +513,19 @@ AsmParser::AsmParser(SourceMgr &SM, MCContext &Ctx, MCStreamer &Out, Lexer.setBuffer(SrcMgr.getMemoryBuffer(CurBuffer)->getBuffer()); // Initialize the platform / file format parser. - switch (Ctx.getObjectFileInfo()->getObjectFileType()) { - case MCObjectFileInfo::IsCOFF: + switch (Ctx.getObjectFileInfo()->getTargetTriple().getObjectFormat()) { + case Triple::COFF: PlatformParser.reset(createCOFFAsmParser()); break; - case MCObjectFileInfo::IsMachO: + case Triple::MachO: PlatformParser.reset(createDarwinAsmParser()); IsDarwin = true; break; - case MCObjectFileInfo::IsELF: + case Triple::ELF: PlatformParser.reset(createELFAsmParser()); break; + case Triple::UnknownObjectFormat: + break; } PlatformParser->Initialize(*this); |