diff options
Diffstat (limited to 'lib/MC')
-rw-r--r-- | lib/MC/ELFObjectWriter.cpp | 39 | ||||
-rw-r--r-- | lib/MC/MCAsmBackend.cpp | 1 | ||||
-rw-r--r-- | lib/MC/MCAsmInfo.cpp | 1 | ||||
-rw-r--r-- | lib/MC/MCAsmInfoCOFF.cpp | 1 | ||||
-rw-r--r-- | lib/MC/MCAssembler.cpp | 2 | ||||
-rw-r--r-- | lib/MC/MCDisassembler/Disassembler.cpp | 9 | ||||
-rw-r--r-- | lib/MC/MCDisassembler/Disassembler.h | 10 | ||||
-rw-r--r-- | lib/MC/MCDisassembler/EDDisassembler.cpp | 10 | ||||
-rw-r--r-- | lib/MC/MCDisassembler/EDDisassembler.h | 5 | ||||
-rw-r--r-- | lib/MC/MCDwarf.cpp | 12 | ||||
-rw-r--r-- | lib/MC/MCELFObjectTargetWriter.cpp | 8 | ||||
-rw-r--r-- | lib/MC/MCExpr.cpp | 1 | ||||
-rw-r--r-- | lib/MC/MCInstPrinter.cpp | 3 | ||||
-rw-r--r-- | lib/MC/MCObjectFileInfo.cpp | 11 | ||||
-rw-r--r-- | lib/MC/MCObjectStreamer.cpp | 8 | ||||
-rw-r--r-- | lib/MC/MCParser/AsmParser.cpp | 11 | ||||
-rw-r--r-- | lib/MC/MachObjectWriter.cpp | 2 | ||||
-rw-r--r-- | lib/MC/WinCOFFStreamer.cpp | 1 |
18 files changed, 73 insertions, 62 deletions
diff --git a/lib/MC/ELFObjectWriter.cpp b/lib/MC/ELFObjectWriter.cpp index 36f94b4..9fc33b6 100644 --- a/lib/MC/ELFObjectWriter.cpp +++ b/lib/MC/ELFObjectWriter.cpp @@ -17,7 +17,6 @@ #include "llvm/ADT/SmallString.h" #include "llvm/ADT/STLExtras.h" #include "llvm/ADT/StringMap.h" -#include "llvm/ADT/Twine.h" #include "llvm/MC/MCAsmBackend.h" #include "llvm/MC/MCAsmLayout.h" #include "llvm/MC/MCAssembler.h" @@ -25,13 +24,13 @@ #include "llvm/MC/MCELFObjectWriter.h" #include "llvm/MC/MCELFSymbolFlags.h" #include "llvm/MC/MCExpr.h" +#include "llvm/MC/MCFixupKindInfo.h" +#include "llvm/MC/MCObjectWriter.h" #include "llvm/MC/MCSectionELF.h" #include "llvm/MC/MCValue.h" #include "llvm/Support/Debug.h" #include "llvm/Support/ErrorHandling.h" #include "llvm/Support/ELF.h" -#include "llvm/Support/CommandLine.h" -#include "llvm/ADT/StringSwitch.h" #include <vector> using namespace llvm; @@ -84,32 +83,6 @@ class ELFObjectWriter : public MCObjectWriter { } }; - /// @name Relocation Data - /// @{ - - struct ELFRelocationEntry { - // Make these big enough for both 32-bit and 64-bit - uint64_t r_offset; - int Index; - unsigned Type; - const MCSymbol *Symbol; - uint64_t r_addend; - - ELFRelocationEntry() - : r_offset(0), Index(0), Type(0), Symbol(0), r_addend(0) {} - - ELFRelocationEntry(uint64_t RelocOffset, int Idx, - unsigned RelType, const MCSymbol *Sym, - uint64_t Addend) - : r_offset(RelocOffset), Index(Idx), Type(RelType), - Symbol(Sym), r_addend(Addend) {} - - // Support lexicographic sorting. - bool operator<(const ELFRelocationEntry &RE) const { - return RE.r_offset < r_offset; - } - }; - /// The target specific ELF writer instance. llvm::OwningPtr<MCELFObjectTargetWriter> TargetObjectWriter; @@ -786,7 +759,7 @@ void ELFObjectWriter::RecordRelocation(const MCAssembler &Asm, else assert(isInt<32>(Addend)); - ELFRelocationEntry ERE(RelocOffset, Index, Type, RelocSymbol, Addend); + ELFRelocationEntry ERE(RelocOffset, Index, Type, RelocSymbol, Addend, Fixup); Relocations[Fragment->getParent()].push_back(ERE); } @@ -1072,8 +1045,10 @@ void ELFObjectWriter::WriteRelocationsFragment(const MCAssembler &Asm, MCDataFragment *F, const MCSectionData *SD) { std::vector<ELFRelocationEntry> &Relocs = Relocations[SD]; - // sort by the r_offset just like gnu as does - array_pod_sort(Relocs.begin(), Relocs.end()); + + // Sort the relocation entries. Most targets just sort by r_offset, but some + // (e.g., MIPS) have additional constraints. + TargetObjectWriter->sortRelocs(Asm, Relocs); for (unsigned i = 0, e = Relocs.size(); i != e; ++i) { ELFRelocationEntry entry = Relocs[e - i - 1]; diff --git a/lib/MC/MCAsmBackend.cpp b/lib/MC/MCAsmBackend.cpp index 51c3977..0b2e4ae 100644 --- a/lib/MC/MCAsmBackend.cpp +++ b/lib/MC/MCAsmBackend.cpp @@ -8,6 +8,7 @@ //===----------------------------------------------------------------------===// #include "llvm/MC/MCAsmBackend.h" +#include "llvm/MC/MCFixupKindInfo.h" using namespace llvm; MCAsmBackend::MCAsmBackend() diff --git a/lib/MC/MCAsmInfo.cpp b/lib/MC/MCAsmInfo.cpp index 582d21f..8286c1d 100644 --- a/lib/MC/MCAsmInfo.cpp +++ b/lib/MC/MCAsmInfo.cpp @@ -49,6 +49,7 @@ MCAsmInfo::MCAsmInfo() { AllowQuotesInName = false; AllowNameToStartWithDigit = false; AllowPeriodsInName = true; + AllowUTF8 = true; ZeroDirective = "\t.zero\t"; AsciiDirective = "\t.ascii\t"; AscizDirective = "\t.asciz\t"; diff --git a/lib/MC/MCAsmInfoCOFF.cpp b/lib/MC/MCAsmInfoCOFF.cpp index 767ac29..881d992 100644 --- a/lib/MC/MCAsmInfoCOFF.cpp +++ b/lib/MC/MCAsmInfoCOFF.cpp @@ -13,7 +13,6 @@ //===----------------------------------------------------------------------===// #include "llvm/MC/MCAsmInfoCOFF.h" -#include "llvm/ADT/SmallVector.h" using namespace llvm; void MCAsmInfoCOFF::anchor() { } diff --git a/lib/MC/MCAssembler.cpp b/lib/MC/MCAssembler.cpp index 5ffb6f2..bb67868 100644 --- a/lib/MC/MCAssembler.cpp +++ b/lib/MC/MCAssembler.cpp @@ -13,13 +13,13 @@ #include "llvm/MC/MCCodeEmitter.h" #include "llvm/MC/MCContext.h" #include "llvm/MC/MCExpr.h" +#include "llvm/MC/MCFixupKindInfo.h" #include "llvm/MC/MCObjectWriter.h" #include "llvm/MC/MCSection.h" #include "llvm/MC/MCSymbol.h" #include "llvm/MC/MCValue.h" #include "llvm/MC/MCDwarf.h" #include "llvm/MC/MCAsmBackend.h" -#include "llvm/ADT/OwningPtr.h" #include "llvm/ADT/Statistic.h" #include "llvm/ADT/StringExtras.h" #include "llvm/ADT/Twine.h" diff --git a/lib/MC/MCDisassembler/Disassembler.cpp b/lib/MC/MCDisassembler/Disassembler.cpp index 572a5a5..35f675d 100644 --- a/lib/MC/MCDisassembler/Disassembler.cpp +++ b/lib/MC/MCDisassembler/Disassembler.cpp @@ -15,7 +15,9 @@ #include "llvm/MC/MCDisassembler.h" #include "llvm/MC/MCInst.h" #include "llvm/MC/MCInstPrinter.h" +#include "llvm/MC/MCInstrInfo.h" #include "llvm/MC/MCRegisterInfo.h" +#include "llvm/MC/MCSubtargetInfo.h" #include "llvm/Support/MemoryObject.h" #include "llvm/Support/TargetRegistry.h" #include "llvm/Support/TargetSelect.h" @@ -57,6 +59,9 @@ LLVMDisasmContextRef LLVMCreateDisasm(const char *TripleName, void *DisInfo, const MCAsmInfo *MAI = TheTarget->createMCAsmInfo(TripleName); assert(MAI && "Unable to create target asm info!"); + const MCInstrInfo *MII = TheTarget->createMCInstrInfo(); + assert(MII && "Unable to create target instruction info!"); + const MCRegisterInfo *MRI = TheTarget->createMCRegInfo(TripleName); assert(MRI && "Unable to create target register info!"); @@ -80,13 +85,13 @@ LLVMDisasmContextRef LLVMCreateDisasm(const char *TripleName, void *DisInfo, // Set up the instruction printer. int AsmPrinterVariant = MAI->getAssemblerDialect(); MCInstPrinter *IP = TheTarget->createMCInstPrinter(AsmPrinterVariant, - *MAI, *MRI, *STI); + *MAI, *MII, *MRI, *STI); assert(IP && "Unable to create instruction printer!"); LLVMDisasmContext *DC = new LLVMDisasmContext(TripleName, DisInfo, TagType, GetOpInfo, SymbolLookUp, TheTarget, MAI, MRI, - Ctx, DisAsm, IP); + STI, MII, Ctx, DisAsm, IP); assert(DC && "Allocation failure!"); return DC; diff --git a/lib/MC/MCDisassembler/Disassembler.h b/lib/MC/MCDisassembler/Disassembler.h index 238ff7d..880a31a 100644 --- a/lib/MC/MCDisassembler/Disassembler.h +++ b/lib/MC/MCDisassembler/Disassembler.h @@ -28,7 +28,9 @@ class MCContext; class MCAsmInfo; class MCDisassembler; class MCInstPrinter; +class MCInstrInfo; class MCRegisterInfo; +class MCSubtargetInfo; class Target; // @@ -61,6 +63,10 @@ private: llvm::OwningPtr<const llvm::MCAsmInfo> MAI; // The register information for the target architecture. llvm::OwningPtr<const llvm::MCRegisterInfo> MRI; + // The subtarget information for the target architecture. + llvm::OwningPtr<const llvm::MCSubtargetInfo> MSI; + // The instruction information for the target architecture. + llvm::OwningPtr<const llvm::MCInstrInfo> MII; // The assembly context for creating symbols and MCExprs. llvm::OwningPtr<const llvm::MCContext> Ctx; // The disassembler for the target architecture. @@ -78,6 +84,8 @@ public: LLVMSymbolLookupCallback symbolLookUp, const Target *theTarget, const MCAsmInfo *mAI, const MCRegisterInfo *mRI, + const MCSubtargetInfo *mSI, + const MCInstrInfo *mII, llvm::MCContext *ctx, const MCDisassembler *disAsm, MCInstPrinter *iP) : TripleName(tripleName), DisInfo(disInfo), TagType(tagType), GetOpInfo(getOpInfo), @@ -85,6 +93,8 @@ public: CommentStream(CommentsToEmit) { MAI.reset(mAI); MRI.reset(mRI); + MSI.reset(mSI); + MII.reset(mII); Ctx.reset(ctx); DisAsm.reset(disAsm); IP.reset(iP); diff --git a/lib/MC/MCDisassembler/EDDisassembler.cpp b/lib/MC/MCDisassembler/EDDisassembler.cpp index 4c2dae8..b2672ca 100644 --- a/lib/MC/MCDisassembler/EDDisassembler.cpp +++ b/lib/MC/MCDisassembler/EDDisassembler.cpp @@ -22,6 +22,7 @@ #include "llvm/MC/MCExpr.h" #include "llvm/MC/MCInst.h" #include "llvm/MC/MCInstPrinter.h" +#include "llvm/MC/MCInstrInfo.h" #include "llvm/MC/MCRegisterInfo.h" #include "llvm/MC/MCStreamer.h" #include "llvm/MC/MCSubtargetInfo.h" @@ -165,11 +166,16 @@ EDDisassembler::EDDisassembler(CPUKey &key) : return; InstInfos = Disassembler->getEDInfo(); - + + MII.reset(Tgt->createMCInstrInfo()); + + if (!MII) + return; + InstString.reset(new std::string); InstStream.reset(new raw_string_ostream(*InstString)); InstPrinter.reset(Tgt->createMCInstPrinter(LLVMSyntaxVariant, *AsmInfo, - *MRI, *STI)); + *MII, *MRI, *STI)); if (!InstPrinter) return; diff --git a/lib/MC/MCDisassembler/EDDisassembler.h b/lib/MC/MCDisassembler/EDDisassembler.h index e97f11d..6f71908 100644 --- a/lib/MC/MCDisassembler/EDDisassembler.h +++ b/lib/MC/MCDisassembler/EDDisassembler.h @@ -36,8 +36,9 @@ class MCContext; class MCAsmInfo; class MCAsmLexer; class MCDisassembler; -class MCInstPrinter; class MCInst; +class MCInstPrinter; +class MCInstrInfo; class MCParsedAsmOperand; class MCRegisterInfo; class MCStreamer; @@ -137,6 +138,8 @@ struct EDDisassembler { llvm::OwningPtr<const llvm::MCAsmInfo> AsmInfo; /// The subtarget information for the target architecture llvm::OwningPtr<const llvm::MCSubtargetInfo> STI; + // The instruction information for the target architecture. + llvm::OwningPtr<const llvm::MCInstrInfo> MII; // The register information for the target architecture. llvm::OwningPtr<const llvm::MCRegisterInfo> MRI; /// The disassembler for the target architecture diff --git a/lib/MC/MCDwarf.cpp b/lib/MC/MCDwarf.cpp index e16f7ae..84a34f1 100644 --- a/lib/MC/MCDwarf.cpp +++ b/lib/MC/MCDwarf.cpp @@ -21,7 +21,7 @@ #include "llvm/Support/raw_ostream.h" #include "llvm/Support/Path.h" #include "llvm/Support/SourceMgr.h" -#include "llvm/ADT/FoldingSet.h" +#include "llvm/ADT/Hashing.h" #include "llvm/ADT/SmallString.h" #include "llvm/ADT/Twine.h" #include "llvm/Config/config.h" @@ -1361,12 +1361,10 @@ namespace llvm { return CIEKey::getTombstoneKey(); } static unsigned getHashValue(const CIEKey &Key) { - FoldingSetNodeID ID; - ID.AddPointer(Key.Personality); - ID.AddInteger(Key.PersonalityEncoding); - ID.AddInteger(Key.LsdaEncoding); - ID.AddBoolean(Key.IsSignalFrame); - return ID.ComputeHash(); + return static_cast<unsigned>(hash_combine(Key.Personality, + Key.PersonalityEncoding, + Key.LsdaEncoding, + Key.IsSignalFrame)); } static bool isEqual(const CIEKey &LHS, const CIEKey &RHS) { diff --git a/lib/MC/MCELFObjectTargetWriter.cpp b/lib/MC/MCELFObjectTargetWriter.cpp index 15bf476..171ab4d 100644 --- a/lib/MC/MCELFObjectTargetWriter.cpp +++ b/lib/MC/MCELFObjectTargetWriter.cpp @@ -7,6 +7,7 @@ // //===----------------------------------------------------------------------===// +#include "llvm/ADT/STLExtras.h" #include "llvm/MC/MCELFObjectWriter.h" using namespace llvm; @@ -36,3 +37,10 @@ const MCSymbol *MCELFObjectTargetWriter::ExplicitRelSym(const MCAssembler &Asm, void MCELFObjectTargetWriter::adjustFixupOffset(const MCFixup &Fixup, uint64_t &RelocOffset) { } + +void +MCELFObjectTargetWriter::sortRelocs(const MCAssembler &Asm, + std::vector<ELFRelocationEntry> &Relocs) { + // Sort by the r_offset, just like gnu as does. + array_pod_sort(Relocs.begin(), Relocs.end()); +} diff --git a/lib/MC/MCExpr.cpp b/lib/MC/MCExpr.cpp index ceaecd0..7880155 100644 --- a/lib/MC/MCExpr.cpp +++ b/lib/MC/MCExpr.cpp @@ -14,6 +14,7 @@ #include "llvm/MC/MCAsmLayout.h" #include "llvm/MC/MCAssembler.h" #include "llvm/MC/MCContext.h" +#include "llvm/MC/MCObjectWriter.h" #include "llvm/MC/MCSymbol.h" #include "llvm/MC/MCValue.h" #include "llvm/Support/Debug.h" diff --git a/lib/MC/MCInstPrinter.cpp b/lib/MC/MCInstPrinter.cpp index 3060ad6..847bcc0 100644 --- a/lib/MC/MCInstPrinter.cpp +++ b/lib/MC/MCInstPrinter.cpp @@ -8,6 +8,7 @@ //===----------------------------------------------------------------------===// #include "llvm/MC/MCInstPrinter.h" +#include "llvm/MC/MCInstrInfo.h" #include "llvm/MC/MCAsmInfo.h" #include "llvm/ADT/StringRef.h" #include "llvm/Support/ErrorHandling.h" @@ -20,7 +21,7 @@ MCInstPrinter::~MCInstPrinter() { /// getOpcodeName - Return the name of the specified opcode enum (e.g. /// "MOV32ri") or empty if we can't resolve it. StringRef MCInstPrinter::getOpcodeName(unsigned Opcode) const { - return ""; + return MII.getName(Opcode); } void MCInstPrinter::printRegName(raw_ostream &OS, unsigned RegNo) const { diff --git a/lib/MC/MCObjectFileInfo.cpp b/lib/MC/MCObjectFileInfo.cpp index 7dd06e7..b22ae33 100644 --- a/lib/MC/MCObjectFileInfo.cpp +++ b/lib/MC/MCObjectFileInfo.cpp @@ -260,9 +260,14 @@ void MCObjectFileInfo::InitELFMCObjectFileInfo(Triple T) { // Solaris requires different flags for .eh_frame to seemingly every other // platform. + EHSectionType = ELF::SHT_PROGBITS; EHSectionFlags = ELF::SHF_ALLOC; - if (T.getOS() == Triple::Solaris) - EHSectionFlags |= ELF::SHF_WRITE; + if (T.getOS() == Triple::Solaris) { + if (T.getArch() == Triple::x86_64) + EHSectionType = ELF::SHT_X86_64_UNWIND; + else + EHSectionFlags |= ELF::SHF_WRITE; + } // ELF @@ -575,7 +580,7 @@ void MCObjectFileInfo::InitEHFrameSection() { SectionKind::getReadOnly()); else if (Env == IsELF) EHFrameSection = - Ctx->getELFSection(".eh_frame", ELF::SHT_PROGBITS, + Ctx->getELFSection(".eh_frame", EHSectionType, EHSectionFlags, SectionKind::getDataRel()); else diff --git a/lib/MC/MCObjectStreamer.cpp b/lib/MC/MCObjectStreamer.cpp index 906bdc3..bad7cfe 100644 --- a/lib/MC/MCObjectStreamer.cpp +++ b/lib/MC/MCObjectStreamer.cpp @@ -7,17 +7,17 @@ // //===----------------------------------------------------------------------===// -#include "llvm/MC/MCAsmInfo.h" #include "llvm/MC/MCObjectStreamer.h" - -#include "llvm/Support/ErrorHandling.h" +#include "llvm/MC/MCAsmBackend.h" +#include "llvm/MC/MCAsmInfo.h" #include "llvm/MC/MCAssembler.h" #include "llvm/MC/MCCodeEmitter.h" #include "llvm/MC/MCContext.h" #include "llvm/MC/MCDwarf.h" #include "llvm/MC/MCExpr.h" +#include "llvm/MC/MCObjectWriter.h" #include "llvm/MC/MCSymbol.h" -#include "llvm/MC/MCAsmBackend.h" +#include "llvm/Support/ErrorHandling.h" using namespace llvm; MCObjectStreamer::MCObjectStreamer(MCContext &Context, MCAsmBackend &TAB, diff --git a/lib/MC/MCParser/AsmParser.cpp b/lib/MC/MCParser/AsmParser.cpp index ab5ddaf..8aef43c 100644 --- a/lib/MC/MCParser/AsmParser.cpp +++ b/lib/MC/MCParser/AsmParser.cpp @@ -14,7 +14,6 @@ #include "llvm/ADT/APFloat.h" #include "llvm/ADT/SmallString.h" #include "llvm/ADT/StringMap.h" -#include "llvm/ADT/StringSwitch.h" #include "llvm/ADT/Twine.h" #include "llvm/MC/MCAsmInfo.h" #include "llvm/MC/MCContext.h" @@ -1528,11 +1527,11 @@ bool AsmParser::HandleMacroEntry(StringRef Name, SMLoc NameLoc, } Lex(); } - // If there weren't any arguments, erase the token vector so everything - // else knows that. Leaving around the vestigal empty token list confuses - // things. - if (MacroArguments.size() == 1 && MacroArguments.back().empty()) - MacroArguments.clear(); + // If the last argument didn't end up with any tokens, it's not a real + // argument and we should remove it from the list. This happens with either + // a tailing comma or an empty argument list. + if (MacroArguments.back().empty()) + MacroArguments.pop_back(); // Macro instantiation is lexical, unfortunately. We construct a new buffer // to hold the macro body with substitutions. diff --git a/lib/MC/MachObjectWriter.cpp b/lib/MC/MachObjectWriter.cpp index 57f90d9..8e4066c 100644 --- a/lib/MC/MachObjectWriter.cpp +++ b/lib/MC/MachObjectWriter.cpp @@ -8,13 +8,13 @@ //===----------------------------------------------------------------------===// #include "llvm/MC/MCMachObjectWriter.h" -#include "llvm/ADT/OwningPtr.h" #include "llvm/ADT/StringMap.h" #include "llvm/ADT/Twine.h" #include "llvm/MC/MCAssembler.h" #include "llvm/MC/MCAsmBackend.h" #include "llvm/MC/MCAsmLayout.h" #include "llvm/MC/MCExpr.h" +#include "llvm/MC/MCFixupKindInfo.h" #include "llvm/MC/MCObjectWriter.h" #include "llvm/MC/MCSectionMachO.h" #include "llvm/MC/MCSymbol.h" diff --git a/lib/MC/WinCOFFStreamer.cpp b/lib/MC/WinCOFFStreamer.cpp index 7238c9e..67dc649 100644 --- a/lib/MC/WinCOFFStreamer.cpp +++ b/lib/MC/WinCOFFStreamer.cpp @@ -25,7 +25,6 @@ #include "llvm/MC/MCSectionCOFF.h" #include "llvm/MC/MCWin64EH.h" #include "llvm/MC/MCAsmBackend.h" -#include "llvm/ADT/StringMap.h" #include "llvm/Support/COFF.h" #include "llvm/Support/Debug.h" |