[llvm] r203856 - MCDwarf: Extract the DWARF line table header handling into its own type

David Blaikie dblaikie at gmail.com
Thu Mar 13 14:47:12 PDT 2014


Author: dblaikie
Date: Thu Mar 13 16:47:12 2014
New Revision: 203856

URL: http://llvm.org/viewvc/llvm-project?rev=203856&view=rev
Log:
MCDwarf: Extract the DWARF line table header handling into its own type

Modified:
    llvm/trunk/include/llvm/MC/MCDwarf.h
    llvm/trunk/lib/MC/MCDwarf.cpp

Modified: llvm/trunk/include/llvm/MC/MCDwarf.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/MC/MCDwarf.h?rev=203856&r1=203855&r2=203856&view=diff
==============================================================================
--- llvm/trunk/include/llvm/MC/MCDwarf.h (original)
+++ llvm/trunk/include/llvm/MC/MCDwarf.h Thu Mar 13 16:47:12 2014
@@ -23,6 +23,7 @@
 #include <map>
 #include <vector>
 #include <string>
+#include <utility>
 
 namespace llvm {
 class MCAsmBackend;
@@ -174,38 +175,49 @@ public:
   }
 };
 
-class MCDwarfFileTable {
+struct MCDwarfLineTableHeader {
   MCSymbol *Label;
   SmallVector<std::string, 3> MCDwarfDirs;
   SmallVector<MCDwarfFile, 3> MCDwarfFiles;
+  unsigned getFile(StringRef Directory, StringRef FileName, unsigned FileNumber);
+  std::pair<MCSymbol *, MCSymbol *> 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<std::string> &getMCDwarfDirs() const {
-    return MCDwarfDirs;
+    return Header.MCDwarfDirs;
   }
 
   SmallVectorImpl<std::string> &getMCDwarfDirs() {
-    return MCDwarfDirs;
+    return Header.MCDwarfDirs;
   }
 
   const SmallVectorImpl<MCDwarfFile> &getMCDwarfFiles() const {
-    return MCDwarfFiles;
+    return Header.MCDwarfFiles;
   }
 
   SmallVectorImpl<MCDwarfFile> &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 {

Modified: llvm/trunk/lib/MC/MCDwarf.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/MC/MCDwarf.cpp?rev=203856&r1=203855&r2=203856&view=diff
==============================================================================
--- llvm/trunk/lib/MC/MCDwarf.cpp (original)
+++ llvm/trunk/lib/MC/MCDwarf.cpp Thu Mar 13 16:47:12 2014
@@ -224,11 +224,9 @@ const MCSymbol *MCDwarfFileTable::Emit(M
   return LineStartSym;
 }
 
-const MCSymbol *MCDwarfFileTable::EmitCU(MCStreamer *MCOS) const {
+std::pair<MCSymbol *, MCSymbol *> 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
   // 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
 }
 
 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);
 





More information about the llvm-commits mailing list