[llvm-commits] [llvm] r97993 - in /llvm/trunk/lib/CodeGen/AsmPrinter: CMakeLists.txt DIE.cpp DIE.h DwarfDebug.cpp DwarfDebug.h DwarfException.cpp DwarfLabel.cpp DwarfLabel.h DwarfPrinter.cpp DwarfPrinter.h

Chris Lattner sabre at nondot.org
Mon Mar 8 14:23:36 PST 2010


Author: lattner
Date: Mon Mar  8 16:23:36 2010
New Revision: 97993

URL: http://llvm.org/viewvc/llvm-project?rev=97993&view=rev
Log:
elimiante the DWLabel class, using MCSymbol instead.  Start 
switching some stuff over to passing around MCSymbol* instead
of stem+ID.


Removed:
    llvm/trunk/lib/CodeGen/AsmPrinter/DwarfLabel.cpp
    llvm/trunk/lib/CodeGen/AsmPrinter/DwarfLabel.h
Modified:
    llvm/trunk/lib/CodeGen/AsmPrinter/CMakeLists.txt
    llvm/trunk/lib/CodeGen/AsmPrinter/DIE.cpp
    llvm/trunk/lib/CodeGen/AsmPrinter/DIE.h
    llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp
    llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.h
    llvm/trunk/lib/CodeGen/AsmPrinter/DwarfException.cpp
    llvm/trunk/lib/CodeGen/AsmPrinter/DwarfPrinter.cpp
    llvm/trunk/lib/CodeGen/AsmPrinter/DwarfPrinter.h

Modified: llvm/trunk/lib/CodeGen/AsmPrinter/CMakeLists.txt
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/AsmPrinter/CMakeLists.txt?rev=97993&r1=97992&r2=97993&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/AsmPrinter/CMakeLists.txt (original)
+++ llvm/trunk/lib/CodeGen/AsmPrinter/CMakeLists.txt Mon Mar  8 16:23:36 2010
@@ -3,7 +3,6 @@
   DIE.cpp
   DwarfDebug.cpp
   DwarfException.cpp
-  DwarfLabel.cpp
   DwarfPrinter.cpp
   DwarfWriter.cpp
   OcamlGCPrinter.cpp

Modified: llvm/trunk/lib/CodeGen/AsmPrinter/DIE.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/AsmPrinter/DIE.cpp?rev=97993&r1=97992&r2=97993&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/AsmPrinter/DIE.cpp (original)
+++ llvm/trunk/lib/CodeGen/AsmPrinter/DIE.cpp Mon Mar  8 16:23:36 2010
@@ -273,8 +273,7 @@
 
 #ifndef NDEBUG
 void DIEDwarfLabel::print(raw_ostream &O) {
-  O << "Lbl: ";
-  Label.print(O);
+  O << "Lbl: " << Label->getName();
 }
 #endif
 
@@ -310,9 +309,7 @@
 ///
 void DIESectionOffset::EmitValue(DwarfPrinter *D, unsigned Form) const {
   bool IsSmall = Form == dwarf::DW_FORM_data4;
-  D->EmitSectionOffset(Label.getTag(), Section.getTag(),
-                       Label.getNumber(), Section.getNumber(),
-                       IsSmall, IsEH, UseSet);
+  D->EmitSectionOffset(Label, Section, IsSmall, IsEH, UseSet);
   D->getAsm()->O << '\n'; // FIXME: Necesssary?
 }
 
@@ -325,11 +322,8 @@
 
 #ifndef NDEBUG
 void DIESectionOffset::print(raw_ostream &O) {
-  O << "Off: ";
-  Label.print(O);
-  O << "-";
-  Section.print(O);
-  O << "-" << IsEH << "-" << UseSet;
+  O << "Off: " << Label->getName() << "-" << Section->getName()
+    << "-" << IsEH << "-" << UseSet;
 }
 #endif
 
@@ -353,10 +347,7 @@
 
 #ifndef NDEBUG
 void DIEDelta::print(raw_ostream &O) {
-  O << "Del: ";
-  LabelHi.print(O);
-  O << "-";
-  LabelLo.print(O);
+  O << "Del: " << LabelHi->getName() << "-" << LabelLo->getName();
 }
 #endif
 

Modified: llvm/trunk/lib/CodeGen/AsmPrinter/DIE.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/AsmPrinter/DIE.h?rev=97993&r1=97992&r2=97993&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/AsmPrinter/DIE.h (original)
+++ llvm/trunk/lib/CodeGen/AsmPrinter/DIE.h Mon Mar  8 16:23:36 2010
@@ -14,7 +14,6 @@
 #ifndef CODEGEN_ASMPRINTER_DIE_H__
 #define CODEGEN_ASMPRINTER_DIE_H__
 
-#include "DwarfLabel.h"
 #include "llvm/ADT/FoldingSet.h"
 #include "llvm/ADT/SmallVector.h"
 #include "llvm/Support/Compiler.h"
@@ -26,6 +25,7 @@
   class DwarfPrinter;
   class TargetData;
   class MCSymbol;
+  class raw_ostream;
 
   //===--------------------------------------------------------------------===//
   /// DIEAbbrevData - Dwarf abbreviation data, describes the one attribute of a
@@ -308,10 +308,11 @@
   //===--------------------------------------------------------------------===//
   /// DIEDwarfLabel - A Dwarf internal label expression DIE.
   //
+  /// FIXME: Merge into DIEObjectLabel.
   class DIEDwarfLabel : public DIEValue {
-    const DWLabel Label;
+    const MCSymbol *Label;
   public:
-    explicit DIEDwarfLabel(const DWLabel &L) : DIEValue(isLabel), Label(L) {}
+    explicit DIEDwarfLabel(const MCSymbol *L) : DIEValue(isLabel), Label(L) {}
 
     /// EmitValue - Emit label value.
     ///
@@ -362,12 +363,12 @@
   /// DIESectionOffset - A section offset DIE.
   ///
   class DIESectionOffset : public DIEValue {
-    const DWLabel Label;
-    const DWLabel Section;
+    const MCSymbol *Label;
+    const MCSymbol *Section;
     bool IsEH : 1;
     bool UseSet : 1;
   public:
-    DIESectionOffset(const DWLabel &Lab, const DWLabel &Sec,
+    DIESectionOffset(const MCSymbol *Lab, const MCSymbol *Sec,
                      bool isEH = false, bool useSet = true)
       : DIEValue(isSectionOffset), Label(Lab), Section(Sec),
         IsEH(isEH), UseSet(useSet) {}
@@ -395,10 +396,10 @@
   /// DIEDelta - A simple label difference DIE.
   ///
   class DIEDelta : public DIEValue {
-    const DWLabel LabelHi;
-    const DWLabel LabelLo;
+    const MCSymbol *LabelHi;
+    const MCSymbol *LabelLo;
   public:
-    DIEDelta(const DWLabel &Hi, const DWLabel &Lo)
+    DIEDelta(const MCSymbol *Hi, const MCSymbol *Lo)
       : DIEValue(isDelta), LabelHi(Hi), LabelLo(Lo) {}
 
     /// EmitValue - Emit delta value.

Modified: llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp?rev=97993&r1=97992&r2=97993&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp (original)
+++ llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp Mon Mar  8 16:23:36 2010
@@ -366,7 +366,8 @@
 /// addLabel - Add a Dwarf label attribute data and value.
 ///
 void DwarfDebug::addLabel(DIE *Die, unsigned Attribute, unsigned Form,
-                          const DWLabel &Label) {
+                          const MCSymbol *Label) {
+  // FIXME: Merge into DIEObjectLabel?
   DIEValue *Value = new DIEDwarfLabel(Label);
   DIEValues.push_back(Value);
   Die->addValue(Attribute, Form, Value);
@@ -384,7 +385,7 @@
 /// addSectionOffset - Add a section offset label attribute data and value.
 ///
 void DwarfDebug::addSectionOffset(DIE *Die, unsigned Attribute, unsigned Form,
-                                  const DWLabel &Label, const DWLabel &Section,
+                                  const MCSymbol *Label,const MCSymbol *Section,
                                   bool isEH, bool useSet) {
   DIEValue *Value = new DIESectionOffset(Label, Section, isEH, useSet);
   DIEValues.push_back(Value);
@@ -394,7 +395,7 @@
 /// addDelta - Add a label delta attribute data and value.
 ///
 void DwarfDebug::addDelta(DIE *Die, unsigned Attribute, unsigned Form,
-                          const DWLabel &Hi, const DWLabel &Lo) {
+                          const MCSymbol *Hi, const MCSymbol *Lo) {
   DIEValue *Value = new DIEDelta(Hi, Lo);
   DIEValues.push_back(Value);
   Die->addValue(Attribute, Form, Value);
@@ -1355,9 +1356,9 @@
  }
 
  addLabel(SPDie, dwarf::DW_AT_low_pc, dwarf::DW_FORM_addr,
-          DWLabel("func_begin", SubprogramCount));
+          getDWLabel("func_begin", SubprogramCount));
  addLabel(SPDie, dwarf::DW_AT_high_pc, dwarf::DW_FORM_addr,
-          DWLabel("func_end", SubprogramCount));
+          getDWLabel("func_end", SubprogramCount));
  MachineLocation Location(RI->getFrameRegister(*MF));
  addAddress(SPDie, dwarf::DW_AT_frame_base, Location);
 
@@ -1382,15 +1383,11 @@
     return ScopeDIE;
 
   addLabel(ScopeDIE, dwarf::DW_AT_low_pc, dwarf::DW_FORM_addr,
-           StartID ?
-             DWLabel("label", StartID)
-           : DWLabel("func_begin", SubprogramCount));
+           StartID ? getDWLabel("label", StartID)
+                   : getDWLabel("func_begin", SubprogramCount));
   addLabel(ScopeDIE, dwarf::DW_AT_high_pc, dwarf::DW_FORM_addr,
-           EndID ?
-             DWLabel("label", EndID)
-           : DWLabel("func_end", SubprogramCount));
-
-
+           EndID ? getDWLabel("label", EndID)
+                 : getDWLabel("func_end", SubprogramCount));
 
   return ScopeDIE;
 }
@@ -1418,9 +1415,9 @@
               dwarf::DW_FORM_ref4, OriginDIE);
 
   addLabel(ScopeDIE, dwarf::DW_AT_low_pc, dwarf::DW_FORM_addr,
-           DWLabel("label", StartID));
+           getDWLabel("label", StartID));
   addLabel(ScopeDIE, dwarf::DW_AT_high_pc, dwarf::DW_FORM_addr,
-           DWLabel("label", EndID));
+           getDWLabel("label", EndID));
 
   InlinedSubprogramDIEs.insert(OriginDIE);
 
@@ -1643,8 +1640,9 @@
   unsigned ID = GetOrCreateSourceID(Dir, FN);
 
   DIE *Die = new DIE(dwarf::DW_TAG_compile_unit);
+  // FIXME: Why getting the delta between two identical labels??
   addSectionOffset(Die, dwarf::DW_AT_stmt_list, dwarf::DW_FORM_data4,
-                   DWLabel("section_line", 0), DWLabel("section_line", 0),
+                   getTempLabel("section_line"), getTempLabel("section_line"),
                    false);
   addString(Die, dwarf::DW_AT_producer, dwarf::DW_FORM_string,
             DIUnit.getProducer());
@@ -2445,7 +2443,8 @@
 
   Asm->EmitInt32(ContentSize);  EOL("Length of Compilation Unit Info");
   Asm->EmitInt16(dwarf::DWARF_VERSION); EOL("DWARF version number");
-  EmitSectionOffset("abbrev_begin", "section_abbrev", 0, 0, true, false);
+  EmitSectionOffset(getTempLabel("abbrev_begin"),getTempLabel("section_abbrev"),
+                    true, false);
   EOL("Offset Into Abbrev. Section");
   Asm->EmitInt8(TD->getPointerSize()); EOL("Address Size (in bytes)");
 
@@ -2726,8 +2725,8 @@
 
   EmitLabel("debug_frame_begin", DebugFrameInfo.Number);
 
-  EmitSectionOffset("debug_frame_common", "section_debug_frame",
-                    0, 0, true, false);
+  EmitSectionOffset(getTempLabel("debug_frame_common"),
+                    getTempLabel("section_debug_frame"), true, false);
   EOL("FDE CIE offset");
 
   EmitReference("func_begin", DebugFrameInfo.Number);
@@ -2759,8 +2758,9 @@
 
   Asm->EmitInt16(dwarf::DWARF_VERSION); EOL("DWARF Version");
 
-  EmitSectionOffset("info_begin", "section_info",
-                    ModuleCU->getID(), 0, true, false);
+  EmitSectionOffset(getDWLabel("info_begin", ModuleCU->getID()), 
+                    getTempLabel("section_info"),
+                    true, false);
   EOL("Offset of Compilation Unit Info");
 
   EmitDifference("info_end", ModuleCU->getID(), "info_begin", ModuleCU->getID(),
@@ -2798,8 +2798,8 @@
   if (Asm->VerboseAsm) Asm->OutStreamer.AddComment("DWARF Version");
   Asm->EmitInt16(dwarf::DWARF_VERSION);
 
-  EmitSectionOffset("info_begin", "section_info",
-                    ModuleCU->getID(), 0, true, false);
+  EmitSectionOffset(getDWLabel("info_begin", ModuleCU->getID()),
+                    getTempLabel("section_info"), true, false);
   EOL("Offset of Compilation ModuleCU Info");
 
   EmitDifference("info_end", ModuleCU->getID(), "info_begin", ModuleCU->getID(),
@@ -2961,12 +2961,13 @@
       Asm->OutStreamer.EmitBytes(Name, 0);
       Asm->OutStreamer.EmitIntValue(0, 1, 0); // nul terminator.
     } else 
-      EmitSectionOffset("string", "section_str",
-                      StringPool.idFor(getRealLinkageName(LName)), false, true);
+      EmitSectionOffset(getDWLabel("string",
+                                   StringPool.idFor(getRealLinkageName(LName))),
+                        getTempLabel("section_str"), true);
 
     EOL("MIPS linkage name");
-    EmitSectionOffset("string", "section_str",
-                      StringPool.idFor(Name), false, true);
+    EmitSectionOffset(getDWLabel("string", StringPool.idFor(Name)),
+                      getTempLabel("section_str"), false, true);
     EOL("Function name");
     EmitULEB128(Labels.size(), "Inline count");
 

Modified: llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.h?rev=97993&r1=97992&r2=97993&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.h (original)
+++ llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.h Mon Mar  8 16:23:36 2010
@@ -243,7 +243,7 @@
   /// addLabel - Add a Dwarf label attribute data and value.
   ///
   void addLabel(DIE *Die, unsigned Attribute, unsigned Form,
-                const DWLabel &Label);
+                const MCSymbol *Label);
 
   /// addObjectLabel - Add an non-Dwarf label attribute data and value.
   ///
@@ -253,13 +253,13 @@
   /// addSectionOffset - Add a section offset label attribute data and value.
   ///
   void addSectionOffset(DIE *Die, unsigned Attribute, unsigned Form,
-                        const DWLabel &Label, const DWLabel &Section,
+                        const MCSymbol *Label, const MCSymbol *Section,
                         bool isEH = false, bool useSet = true);
 
   /// addDelta - Add a label delta attribute data and value.
   ///
   void addDelta(DIE *Die, unsigned Attribute, unsigned Form,
-                const DWLabel &Hi, const DWLabel &Lo);
+                const MCSymbol *Hi, const MCSymbol *Lo);
 
   /// addDIEEntry - Add a DIE attribute data and value.
   ///

Modified: llvm/trunk/lib/CodeGen/AsmPrinter/DwarfException.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/AsmPrinter/DwarfException.cpp?rev=97993&r1=97992&r2=97993&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/AsmPrinter/DwarfException.cpp (original)
+++ llvm/trunk/lib/CodeGen/AsmPrinter/DwarfException.cpp Mon Mar  8 16:23:36 2010
@@ -230,8 +230,9 @@
 
     EmitLabel("eh_frame_begin", EHFrameInfo.Number);
 
-    EmitSectionOffset("eh_frame_begin", "eh_frame_common",
-                      EHFrameInfo.Number, EHFrameInfo.PersonalityIndex,
+    EmitSectionOffset(getDWLabel("eh_frame_begin", EHFrameInfo.Number),
+                      getDWLabel("eh_frame_common",
+                                 EHFrameInfo.PersonalityIndex),
                       true, true, false);
 
     EOL("FDE CIE offset");
@@ -819,12 +820,14 @@
       // Offset of the call site relative to the previous call site, counted in
       // number of 16-byte bundles. The first call site is counted relative to
       // the start of the procedure fragment.
-      EmitSectionOffset(BeginTag, "eh_func_begin", BeginNumber, SubprogramCount,
+      EmitSectionOffset(getDWLabel(BeginTag, BeginNumber),
+                        getDWLabel("eh_func_begin", SubprogramCount),
                         true, true);
       EOL("Region start");
 
       if (!S.EndLabel)
-        EmitDifference("eh_func_end", SubprogramCount, BeginTag, BeginNumber,
+        EmitDifference(getDWLabel("eh_func_end", SubprogramCount),
+                       getDWLabel(BeginTag, BeginNumber),
                        true);
       else
         EmitDifference("label", S.EndLabel, BeginTag, BeginNumber, true);
@@ -837,7 +840,8 @@
         Asm->OutStreamer.AddComment("Landing pad");
         Asm->OutStreamer.EmitIntValue(0, 4/*size*/, 0/*addrspace*/);
       } else {
-        EmitSectionOffset("label", "eh_func_begin", S.PadLabel, SubprogramCount,
+        EmitSectionOffset(getDWLabel("label", S.PadLabel),
+                          getDWLabel("eh_func_begin", SubprogramCount),
                           true, true);
         EOL("Landing pad");
       }

Removed: llvm/trunk/lib/CodeGen/AsmPrinter/DwarfLabel.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/AsmPrinter/DwarfLabel.cpp?rev=97992&view=auto
==============================================================================
--- llvm/trunk/lib/CodeGen/AsmPrinter/DwarfLabel.cpp (original)
+++ llvm/trunk/lib/CodeGen/AsmPrinter/DwarfLabel.cpp (removed)
@@ -1,32 +0,0 @@
-//===--- lib/CodeGen/DwarfLabel.cpp - Dwarf Label -------------------------===//
-//
-//                     The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
-//
-//===----------------------------------------------------------------------===//
-//
-// DWARF Labels
-// 
-//===----------------------------------------------------------------------===//
-
-#include "DwarfLabel.h"
-#include "llvm/ADT/FoldingSet.h"
-#include "llvm/Support/raw_ostream.h"
-
-using namespace llvm;
-
-/// Profile - Used to gather unique data for the folding set.
-///
-void DWLabel::Profile(FoldingSetNodeID &ID) const {
-  ID.AddString(Tag);
-  ID.AddInteger(Number);
-}
-
-#ifndef NDEBUG
-void DWLabel::print(raw_ostream &O) const {
-  O << "." << Tag;
-  if (Number) O << Number;
-}
-#endif

Removed: llvm/trunk/lib/CodeGen/AsmPrinter/DwarfLabel.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/AsmPrinter/DwarfLabel.h?rev=97992&view=auto
==============================================================================
--- llvm/trunk/lib/CodeGen/AsmPrinter/DwarfLabel.h (original)
+++ llvm/trunk/lib/CodeGen/AsmPrinter/DwarfLabel.h (removed)
@@ -1,52 +0,0 @@
-//===--- lib/CodeGen/DwarfLabel.h - Dwarf Label -----------------*- C++ -*-===//
-//
-//                     The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
-//
-//===----------------------------------------------------------------------===//
-//
-// DWARF Labels.
-// 
-//===----------------------------------------------------------------------===//
-
-#ifndef CODEGEN_ASMPRINTER_DWARFLABEL_H__
-#define CODEGEN_ASMPRINTER_DWARFLABEL_H__
-
-namespace llvm {
-  class FoldingSetNodeID;
-  class raw_ostream;
-
-  //===--------------------------------------------------------------------===//
-  /// DWLabel - Labels are used to track locations in the assembler file.
-  /// Labels appear in the form @verbatim <prefix><Tag><Number> @endverbatim,
-  /// where the tag is a category of label (Ex. location) and number is a value
-  /// unique in that category.
-  class DWLabel {
-    /// Tag - Label category tag. Should always be a statically declared C
-    /// string.
-    /// 
-    const char *Tag;
-
-    /// Number - Value to make label unique.
-    /// 
-    unsigned Number;
-  public:
-    DWLabel(const char *T, unsigned N) : Tag(T), Number(N) {}
-
-    // Accessors.
-    const char *getTag() const { return Tag; }
-    unsigned getNumber() const { return Number; }
-
-    /// Profile - Used to gather unique data for the folding set.
-    ///
-    void Profile(FoldingSetNodeID &ID) const;
-
-#ifndef NDEBUG
-    void print(raw_ostream &O) const;
-#endif
-  };
-} // end llvm namespace
-
-#endif

Modified: llvm/trunk/lib/CodeGen/AsmPrinter/DwarfPrinter.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/AsmPrinter/DwarfPrinter.cpp?rev=97993&r1=97992&r2=97993&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/AsmPrinter/DwarfPrinter.cpp (original)
+++ llvm/trunk/lib/CodeGen/AsmPrinter/DwarfPrinter.cpp Mon Mar  8 16:23:36 2010
@@ -37,6 +37,27 @@
   RI(Asm->TM.getRegisterInfo()), M(NULL), MF(NULL), MMI(NULL),
   SubprogramCount(0), Flavor(flavor), SetCounter(1) {}
 
+
+/// getDWLabel - Return the MCSymbol corresponding to the assembler temporary
+/// label with the specified stem and unique ID.
+MCSymbol *DwarfPrinter::getDWLabel(const char *Name, unsigned ID) const {
+  // FIXME: REMOVE this.  However, there is stuff in EH that passes counters in
+  // here that can be zero.
+  
+  //assert(ID && "Should use getTempLabel if no ID");
+  if (ID == 0) return getTempLabel(Name);
+  return Asm->OutContext.GetOrCreateSymbol(Twine(MAI->getPrivateGlobalPrefix())
+                                           + Twine(Name) + Twine(ID));
+}
+
+/// getTempLabel - Return the MCSymbol corresponding to the assembler temporary
+/// label with the specified name.
+MCSymbol *DwarfPrinter::getTempLabel(const char *Name) const {
+  return Asm->OutContext.GetOrCreateSymbol(Twine(MAI->getPrivateGlobalPrefix())
+                                           + Name);
+}
+
+
 /// SizeOfEncodedValue - Return the size of the encoding in bytes.
 unsigned DwarfPrinter::SizeOfEncodedValue(unsigned Encoding) const {
   if (Encoding == dwarf::DW_EH_PE_omit)
@@ -193,12 +214,19 @@
 
 /// PrintLabelName - Print label name in form used by Dwarf writer.
 ///
+void DwarfPrinter::PrintLabelName(const MCSymbol *Label) const {
+  // FIXME: REMOVE.
+  O << Label->getName();
+}
+
 void DwarfPrinter::PrintLabelName(const char *Tag, unsigned Number) const {
+  // FIXME: REMOVE.
   O << MAI->getPrivateGlobalPrefix() << Tag;
   if (Number) O << Number;
 }
 void DwarfPrinter::PrintLabelName(const char *Tag, unsigned Number,
                                   const char *Suffix) const {
+  // FIXME: REMOVE.
   O << MAI->getPrivateGlobalPrefix() << Tag;
   if (Number) O << Number;
   O << Suffix;
@@ -207,6 +235,7 @@
 /// EmitLabel - Emit location label for internal use by Dwarf.
 ///
 void DwarfPrinter::EmitLabel(const char *Tag, unsigned Number) const {
+  // FIXME: REMOVE.
   PrintLabelName(Tag, Number);
   O << ":\n";
 }
@@ -235,12 +264,8 @@
 
 void DwarfPrinter::EmitReference(const char *Tag, unsigned Number,
                                  unsigned Encoding) const {
-  SmallString<64> Name;
-  raw_svector_ostream(Name) << MAI->getPrivateGlobalPrefix()
-                            << Tag << Number;
-
-  MCSymbol *Sym = Asm->OutContext.GetOrCreateSymbol(Name.str());
-  EmitReference(Sym, Encoding);
+  // FIXME: REMOVE.
+  EmitReference(getDWLabel(Tag, Number), Encoding);
 }
 
 void DwarfPrinter::EmitReference(const MCSymbol *Sym, unsigned Encoding) const {
@@ -260,6 +285,31 @@
 
 /// EmitDifference - Emit the difference between two labels.  If this assembler
 /// supports .set, we emit a .set of a temporary and then use it in the .word.
+void DwarfPrinter::EmitDifference(const MCSymbol *TagHi, const MCSymbol *TagLo,
+                                  bool IsSmall) {
+  if (MAI->hasSetDirective()) {
+    // FIXME: switch to OutStreamer.EmitAssignment.
+    O << "\t.set\t";
+    PrintLabelName("set", SetCounter, Flavor);
+    O << ",";
+    PrintLabelName(TagHi);
+    O << "-";
+    PrintLabelName(TagLo);
+    O << "\n";
+
+    PrintRelDirective(IsSmall);
+    PrintLabelName("set", SetCounter, Flavor);
+    ++SetCounter;
+  } else {
+    PrintRelDirective(IsSmall);
+    PrintLabelName(TagHi);
+    O << "-";
+    PrintLabelName(TagLo);
+  }
+}
+
+/// EmitDifference - Emit the difference between two labels.  If this assembler
+/// supports .set, we emit a .set of a temporary and then use it in the .word.
 void DwarfPrinter::EmitDifference(const char *TagHi, unsigned NumberHi,
                                   const char *TagLo, unsigned NumberLo,
                                   bool IsSmall) {
@@ -272,7 +322,7 @@
     O << "-";
     PrintLabelName(TagLo, NumberLo);
     O << "\n";
-
+    
     PrintRelDirective(IsSmall);
     PrintLabelName("set", SetCounter, Flavor);
     ++SetCounter;
@@ -284,9 +334,8 @@
   }
 }
 
-void DwarfPrinter::EmitSectionOffset(const char* Label, const char* Section,
-                                     unsigned LabelNumber,
-                                     unsigned SectionNumber,
+void DwarfPrinter::EmitSectionOffset(const MCSymbol *Label,
+                                     const MCSymbol *Section,
                                      bool IsSmall, bool isEH,
                                      bool useSet) {
   bool printAbsolute = false;
@@ -300,11 +349,11 @@
     O << "\t.set\t";
     PrintLabelName("set", SetCounter, Flavor);
     O << ",";
-    PrintLabelName(Label, LabelNumber);
+    PrintLabelName(Label);
 
     if (!printAbsolute) {
       O << "-";
-      PrintLabelName(Section, SectionNumber);
+      PrintLabelName(Section);
     }
 
     O << "\n";
@@ -313,11 +362,11 @@
     ++SetCounter;
   } else {
     PrintRelDirective(IsSmall, true);
-    PrintLabelName(Label, LabelNumber);
+    PrintLabelName(Label);
 
     if (!printAbsolute) {
       O << "-";
-      PrintLabelName(Section, SectionNumber);
+      PrintLabelName(Section);
     }
   }
 }

Modified: llvm/trunk/lib/CodeGen/AsmPrinter/DwarfPrinter.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/AsmPrinter/DwarfPrinter.h?rev=97993&r1=97992&r2=97993&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/AsmPrinter/DwarfPrinter.h (original)
+++ llvm/trunk/lib/CodeGen/AsmPrinter/DwarfPrinter.h Mon Mar  8 16:23:36 2010
@@ -14,7 +14,6 @@
 #ifndef CODEGEN_ASMPRINTER_DWARFPRINTER_H__
 #define CODEGEN_ASMPRINTER_DWARFPRINTER_H__
 
-#include "DwarfLabel.h"
 #include "llvm/CodeGen/MachineLocation.h"
 #include "llvm/Support/Compiler.h"
 #include "llvm/Support/FormattedStream.h"
@@ -86,6 +85,14 @@
   const MCAsmInfo *getMCAsmInfo() const { return MAI; }
   const TargetData *getTargetData() const { return TD; }
 
+  /// getDWLabel - Return the MCSymbol corresponding to the assembler temporary
+  /// label with the specified stem and unique ID.
+  MCSymbol *getDWLabel(const char *Name, unsigned ID) const;
+  
+  /// getTempLabel - Return an assembler temporary label with the specified
+  /// name.
+  MCSymbol *getTempLabel(const char *Name) const;
+
   /// SizeOfEncodedValue - Return the size of the encoding in bytes.
   unsigned SizeOfEncodedValue(unsigned Encoding) const;
 
@@ -117,54 +124,47 @@
   
   /// PrintLabelName - Print label name in form used by Dwarf writer.
   ///
-  void PrintLabelName(const DWLabel &Label) const {
-    PrintLabelName(Label.getTag(), Label.getNumber());
-  }
+  void PrintLabelName(const MCSymbol *Label) const;
   void PrintLabelName(const char *Tag, unsigned Number) const;
   void PrintLabelName(const char *Tag, unsigned Number,
                       const char *Suffix) const;
 
   /// EmitLabel - Emit location label for internal use by Dwarf.
   ///
-  void EmitLabel(const DWLabel &Label) const {
-    EmitLabel(Label.getTag(), Label.getNumber());
-  }
+  void EmitLabel(const MCSymbol *Label) const;
   void EmitLabel(const char *Tag, unsigned Number) const;
 
   /// EmitReference - Emit a reference to a label.
   ///
-  void EmitReference(const DWLabel &Label, bool IsPCRelative = false,
-                     bool Force32Bit = false) const {
-    EmitReference(Label.getTag(), Label.getNumber(),
-                  IsPCRelative, Force32Bit);
-  }
+  void EmitReference(const MCSymbol *Label, bool IsPCRelative = false,
+                     bool Force32Bit = false) const;
   void EmitReference(const char *Tag, unsigned Number,
                      bool IsPCRelative = false,
                      bool Force32Bit = false) const;
   void EmitReference(const std::string &Name, bool IsPCRelative = false,
                      bool Force32Bit = false) const;
-  void EmitReference(const MCSymbol *Sym, bool IsPCRelative = false,
-                     bool Force32Bit = false) const;
 
   void EmitReference(const char *Tag, unsigned Number, unsigned Encoding) const;
   void EmitReference(const MCSymbol *Sym, unsigned Encoding) const;
   void EmitReference(const GlobalValue *GV, unsigned Encoding) const;
 
   /// EmitDifference - Emit the difference between two labels.
-  void EmitDifference(const DWLabel &LabelHi, const DWLabel &LabelLo,
-                      bool IsSmall = false) {
-    EmitDifference(LabelHi.getTag(), LabelHi.getNumber(),
-                   LabelLo.getTag(), LabelLo.getNumber(),
-                   IsSmall);
-  }
+  void EmitDifference(const MCSymbol *LabelHi, const MCSymbol *LabelLo,
+                      bool IsSmall = false);
   void EmitDifference(const char *TagHi, unsigned NumberHi,
                       const char *TagLo, unsigned NumberLo,
                       bool IsSmall = false);
 
+  void EmitSectionOffset(const MCSymbol *Label, const MCSymbol *Section,
+                         bool IsSmall = false, bool isEH = false,
+                         bool useSet = true);
+  
+#if 0
   void EmitSectionOffset(const char* Label, const char* Section,
                          unsigned LabelNumber, unsigned SectionNumber,
                          bool IsSmall = false, bool isEH = false,
                          bool useSet = true);
+#endif
 
   /// EmitFrameMoves - Emit frame instructions to describe the layout of the
   /// frame.





More information about the llvm-commits mailing list