Did my commit for the last patch for the .loc directory from the wrong place and
authorKevin Enderby <enderby@apple.com>
Thu, 30 Sep 2010 17:16:09 +0000 (17:16 +0000)
committerKevin Enderby <enderby@apple.com>
Thu, 30 Sep 2010 17:16:09 +0000 (17:16 +0000)
missed a bunch of files.  Here the rest.  Sorry about that.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@115173 91177308-0d34-0410-b5e6-96231b3b80d8

include/llvm/MC/MCAssembler.h
include/llvm/MC/MCContext.h
include/llvm/MC/MCDwarf.h
include/llvm/MC/MCObjectWriter.h
include/llvm/MC/MCStreamer.h
include/llvm/Support/Dwarf.h

index 8d899d30d21bd813af6c414eb6c4fa401ae95ab8..d48a0b40a7b7582d832232652c3ab0f2c4f674e1 100644 (file)
@@ -49,7 +49,8 @@ public:
     FT_Data,
     FT_Fill,
     FT_Inst,
-    FT_Org
+    FT_Org,
+    FT_Dwarf
   };
 
 private:
@@ -337,6 +338,36 @@ public:
   static bool classof(const MCOrgFragment *) { return true; }
 };
 
+class MCDwarfLineAddrFragment : public MCFragment {
+  /// LineDelta - the value of the difference between the two line numbers
+  /// between two .loc dwarf directives.
+  int64_t LineDelta;
+
+  /// AddrDelta - The expression for the difference of the two symbols that
+  /// make up the address delta between two .loc dwarf directives.
+  const MCExpr *AddrDelta;
+
+public:
+  MCDwarfLineAddrFragment(int64_t _LineDelta, const MCExpr &_AddrDelta,
+                      MCSectionData *SD = 0)
+    : MCFragment(FT_Dwarf, SD),
+      LineDelta(_LineDelta), AddrDelta(&_AddrDelta) {}
+
+  /// @name Accessors
+  /// @{
+
+  int64_t getLineDelta() const { return LineDelta; }
+
+  const MCExpr &getAddrDelta() const { return *AddrDelta; }
+
+  /// @}
+
+  static bool classof(const MCFragment *F) {
+    return F->getKind() == MCFragment::FT_Dwarf;
+  }
+  static bool classof(const MCDwarfLineAddrFragment *) { return true; }
+};
+
 // FIXME: Should this be a separate class, or just merged into MCSection? Since
 // we anticipate the fast path being through an MCAssembler, the only reason to
 // keep it out is for API abstraction.
index d22868cdbd0c1cef07b4dcc1d3bab19512be4654..c2dfb8fa7c49c2a2722365925ab972ee5feb0859 100644 (file)
@@ -162,6 +162,10 @@ namespace llvm {
 
     bool ValidateDwarfFileNumber(unsigned FileNumber);
 
+    bool hasDwarfFiles(void) {
+      return MCDwarfFiles.size() != 0;
+    }
+
     const std::vector<MCDwarfFile *> &getMCDwarfFiles() {
       return MCDwarfFiles;
     }
index dac875cf1b671856490d49631791af5de9e00086..925991eb832bbafa07e647b5718169760ce8d179 100644 (file)
@@ -8,8 +8,7 @@
 //===----------------------------------------------------------------------===//
 //
 // This file contains the declaration of the MCDwarfFile to support the dwarf
-// .file directive.
-// TODO: add the support needed for the .loc directive.
+// .file directive and the .loc directive.
 //
 //===----------------------------------------------------------------------===//
 
 #define LLVM_MC_MCDWARF_H
 
 #include "llvm/ADT/StringRef.h"
+#include "llvm/MC/MCStreamer.h"
+#include "llvm/MC/MCObjectStreamer.h"
+#include "llvm/MC/MCObjectWriter.h"
+#include "llvm/Support/raw_ostream.h"
+#include "llvm/Support/Dwarf.h"
 #include <vector>
 
 namespace llvm {
   class MCContext;
   class MCSection;
   class MCSymbol;
+  class MCObjectStreamer;
   class raw_ostream;
 
   /// MCDwarfFile - Instances of this class represent the name of the dwarf
@@ -79,6 +84,9 @@ namespace llvm {
     // Isa
     unsigned Isa;
 
+// Flag that indicates the initial value of the is_stmt_start flag.
+#define DWARF2_LINE_DEFAULT_IS_STMT     1
+
 #define DWARF2_FLAG_IS_STMT        (1 << 0)
 #define DWARF2_FLAG_BASIC_BLOCK    (1 << 1)
 #define DWARF2_FLAG_PROLOGUE_END   (1 << 2)
@@ -95,6 +103,21 @@ namespace llvm {
     // for an MCDwarfLoc object.
 
   public:
+    /// getFileNum - Get the FileNum of this MCDwarfLoc.
+    unsigned getFileNum() { return FileNum; }
+
+    /// getLine - Get the Line of this MCDwarfLoc.
+    unsigned getLine() { return Line; }
+
+    /// getColumn - Get the Column of this MCDwarfLoc.
+    unsigned getColumn() { return Column; }
+
+    /// getFlags - Get the Flags of this MCDwarfLoc.
+    unsigned getFlags() { return Flags; }
+
+    /// getIsa - Get the Isa of this MCDwarfLoc.
+    unsigned getIsa() { return Isa; }
+
     /// setFileNum - Set the FileNum of this MCDwarfLoc.
     void setFileNum(unsigned fileNum) { FileNum = fileNum; }
 
@@ -127,6 +150,13 @@ namespace llvm {
     // Constructor to create an MCLineEntry given a symbol and the dwarf loc.
     MCLineEntry(MCSymbol *label, const MCDwarfLoc loc) : MCDwarfLoc(loc),
                 Label(label) {}
+
+    MCSymbol *getLabel() { return Label; }
+
+    // This is called when an instruction is assembled into the specified
+    // section and if there is information from the last .loc directive that
+    // has yet to have a line entry made for it is made.
+    static void Make(MCObjectStreamer *MCOS, const MCSection *Section);
   };
 
   /// MCLineSection - Instances of this class represent the line information
@@ -134,7 +164,6 @@ namespace llvm {
   /// .loc directives.  This is the information used to build the dwarf line
   /// table for a section.
   class MCLineSection {
-    std::vector<MCLineEntry> MCLineEntries;
 
   private:
     MCLineSection(const MCLineSection&);  // DO NOT IMPLEMENT
@@ -149,8 +178,41 @@ namespace llvm {
     void addLineEntry(const MCLineEntry &LineEntry) {
       MCLineEntries.push_back(LineEntry);
     }
+
+    typedef std::vector<MCLineEntry> MCLineEntryCollection;
+    typedef MCLineEntryCollection::iterator iterator;
+
+  private:
+    MCLineEntryCollection MCLineEntries;
+
+  public:
+    MCLineEntryCollection *getMCLineEntries() { return &MCLineEntries; }
+  };
+
+  class MCDwarfFileTable {
+  public:
+    //
+    // This emits the Dwarf file and the line tables.
+    //
+    static void Emit(MCObjectStreamer *MCOS, const MCSection *DwarfLineSection);
   };
 
+  class MCDwarfLineAddr {
+  public:
+    /// Utility function to encode a Dwarf pair of LineDelta and AddrDeltas.
+    static void Encode(int64_t LineDelta, uint64_t AddrDelta, raw_ostream &OS);
+
+    /// Utility function to emit the encoding to a streamer.
+    static void Emit(MCObjectStreamer *MCOS,
+                     int64_t LineDelta,uint64_t AddrDelta);
+
+    /// Utility function to compute the size of the encoding.
+    static uint64_t ComputeSize(int64_t LineDelta, uint64_t AddrDelta);
+
+    /// Utility function to write the encoding to an object writer.
+    static void Write(MCObjectWriter *OW,
+                      int64_t LineDelta, uint64_t AddrDelta);
+  };
 } // end namespace llvm
 
 #endif
index 7de37f762d365ea8c44efa95352bcb6d51ef58b9..7571583e99a213d4b2f15f17e2d96ac6d93e8ba8 100644 (file)
@@ -170,6 +170,11 @@ public:
   }
 
   /// @}
+
+  /// Utility function to encode a SLEB128 value.
+  static void EncodeSLEB128(int64_t Value, raw_ostream &OS);
+  /// Utility function to encode a ULEB128 value.
+  static void EncodeULEB128(uint64_t Value, raw_ostream &OS);
 };
 
 MCObjectWriter *createWinCOFFObjectWriter(raw_ostream &OS, bool is64Bit);
index 0e43ce611d6a0837eb94ba05da8eb666491f5d9d..1f4f23de6f1d253d25b6d1caba0bb075bcd67b6e 100644 (file)
@@ -235,10 +235,18 @@ namespace llvm {
     virtual void EmitIntValue(uint64_t Value, unsigned Size,
                               unsigned AddrSpace = 0);
 
+    /// EmitULEB128Value - Special case of EmitValue that takes an ULEB128 and
+    /// emits the needed bytes for the encoded value.
+    virtual void EmitULEB128Value(uint64_t Value, unsigned AddrSpace = 0);
+
+    /// EmitSLEB128Value - Special case of EmitValue that takes an SLEB128 and
+    /// emits the needed bytes for the encoded value.
+    virtual void EmitSLEB128Value(int64_t Value, unsigned AddrSpace = 0);
+
     /// EmitSymbolValue - Special case of EmitValue that avoids the client
     /// having to pass in a MCExpr for MCSymbols.
     virtual void EmitSymbolValue(const MCSymbol *Sym, unsigned Size,
-                                 unsigned AddrSpace);
+                                 unsigned AddrSpace = 0);
 
     /// EmitGPRel32Value - Emit the expression @p Value into the output as a
     /// gprel32 (32-bit GP relative) value.
index da61dfbc1717e4fa180fb1fe972545075a2c473f..1b5d2a453846300e7b52cb46021b30e2c18fc784 100644 (file)
@@ -510,6 +510,7 @@ enum dwarf_constants {
   DW_DSC_range = 0x01,
 
   // Line Number Standard Opcode Encodings
+  DW_LNS_extended_op = 0x00,
   DW_LNS_copy = 0x01,
   DW_LNS_advance_pc = 0x02,
   DW_LNS_advance_line = 0x03,