From 91d5586086b9459d8b615da2a37f3dddbb9eff50 Mon Sep 17 00:00:00 2001 From: David Blaikie Date: Thu, 13 Mar 2014 21:47:12 +0000 Subject: [PATCH] MCDwarf: Extract the DWARF line table header handling into its own type git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@203856 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/MC/MCDwarf.h | 38 +++++++++++++++++++++----------------- lib/MC/MCDwarf.cpp | 16 +++++++++++++--- 2 files changed, 34 insertions(+), 20 deletions(-) diff --git a/include/llvm/MC/MCDwarf.h b/include/llvm/MC/MCDwarf.h index 6dc381d5dc6..951cd6bd1fc 100644 --- a/include/llvm/MC/MCDwarf.h +++ b/include/llvm/MC/MCDwarf.h @@ -23,6 +23,7 @@ #include #include #include +#include namespace llvm { class MCAsmBackend; @@ -174,38 +175,49 @@ public: } }; -class MCDwarfFileTable { +struct MCDwarfLineTableHeader { MCSymbol *Label; SmallVector MCDwarfDirs; SmallVector MCDwarfFiles; + unsigned getFile(StringRef Directory, StringRef FileName, unsigned FileNumber); + std::pair Emit(MCStreamer *MCOS) const; +}; + +class MCDwarfFileTable { + MCDwarfLineTableHeader Header; MCLineSection MCLineSections; public: - // // This emits the Dwarf file and the line tables for all Compile Units. - // static const MCSymbol *Emit(MCStreamer *MCOS); - // + // This emits the Dwarf file and the line tables for a given Compile Unit. - // const MCSymbol *EmitCU(MCStreamer *MCOS) const; unsigned getFile(StringRef Directory, StringRef FileName, unsigned FileNumber); + MCSymbol *getLabel() const { + return Header.Label; + } + + void setLabel(MCSymbol *Label) { + Header.Label = Label; + } + const SmallVectorImpl &getMCDwarfDirs() const { - return MCDwarfDirs; + return Header.MCDwarfDirs; } SmallVectorImpl &getMCDwarfDirs() { - return MCDwarfDirs; + return Header.MCDwarfDirs; } const SmallVectorImpl &getMCDwarfFiles() const { - return MCDwarfFiles; + return Header.MCDwarfFiles; } SmallVectorImpl &getMCDwarfFiles() { - return MCDwarfFiles; + return Header.MCDwarfFiles; } const MCLineSection &getMCLineSections() const { @@ -214,14 +226,6 @@ public: MCLineSection &getMCLineSections() { return MCLineSections; } - - MCSymbol *getLabel() const { - return Label; - } - - void setLabel(MCSymbol *Label) { - this->Label = Label; - } }; class MCDwarfLineAddr { diff --git a/lib/MC/MCDwarf.cpp b/lib/MC/MCDwarf.cpp index 5b633ebf8d2..81ba40e9645 100644 --- a/lib/MC/MCDwarf.cpp +++ b/lib/MC/MCDwarf.cpp @@ -224,11 +224,9 @@ const MCSymbol *MCDwarfFileTable::Emit(MCStreamer *MCOS) { return LineStartSym; } -const MCSymbol *MCDwarfFileTable::EmitCU(MCStreamer *MCOS) const { +std::pair MCDwarfLineTableHeader::Emit(MCStreamer *MCOS) const { MCContext &context = MCOS->getContext(); - - // Create a symbol at the beginning of the line table. MCSymbol *LineStartSym = Label; if (!LineStartSym) @@ -302,6 +300,14 @@ const MCSymbol *MCDwarfFileTable::EmitCU(MCStreamer *MCOS) const { // end of the prologue (that was used in a previous expression). MCOS->EmitLabel(ProEndSym); + return std::make_pair(LineStartSym, LineEndSym); +} + +const MCSymbol *MCDwarfFileTable::EmitCU(MCStreamer *MCOS) const { + MCSymbol *LineStartSym; + MCSymbol *LineEndSym; + std::tie(LineStartSym, LineEndSym) = Header.Emit(MCOS); + // Put out the line tables. for (const auto &LineSec : MCLineSections.getMCLineEntries()) EmitDwarfLineTable(MCOS, LineSec.first, LineSec.second); @@ -326,6 +332,10 @@ const MCSymbol *MCDwarfFileTable::EmitCU(MCStreamer *MCOS) const { } unsigned MCDwarfFileTable::getFile(StringRef Directory, StringRef FileName, unsigned FileNumber) { + return Header.getFile(Directory, FileName, FileNumber); +} + +unsigned MCDwarfLineTableHeader::getFile(StringRef Directory, StringRef FileName, unsigned FileNumber) { // Make space for this FileNumber in the MCDwarfFiles vector if needed. MCDwarfFiles.resize(FileNumber + 1); -- 2.34.1