[llvm-commits] [llvm] r98014 - in /llvm/trunk/lib/CodeGen/AsmPrinter: DwarfPrinter.cpp DwarfPrinter.h

Chris Lattner sabre at nondot.org
Mon Mar 8 16:17:59 PST 2010


Author: lattner
Date: Mon Mar  8 18:17:58 2010
New Revision: 98014

URL: http://llvm.org/viewvc/llvm-project?rev=98014&view=rev
Log:
eliminate an argument from PrintRelDirective, sinking
the one special case into EmitSectionOffset.  MCize
the non-special case in EmitSectionOffset.

Modified:
    llvm/trunk/lib/CodeGen/AsmPrinter/DwarfPrinter.cpp
    llvm/trunk/lib/CodeGen/AsmPrinter/DwarfPrinter.h

Modified: llvm/trunk/lib/CodeGen/AsmPrinter/DwarfPrinter.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/AsmPrinter/DwarfPrinter.cpp?rev=98014&r1=98013&r2=98014&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/AsmPrinter/DwarfPrinter.cpp (original)
+++ llvm/trunk/lib/CodeGen/AsmPrinter/DwarfPrinter.cpp Mon Mar  8 18:17:58 2010
@@ -77,10 +77,8 @@
   return 0;
 }
 
-void DwarfPrinter::PrintRelDirective(bool Force32Bit, bool isInSection) const {
-  if (isInSection && MAI->getDwarfSectionOffsetDirective())
-    O << MAI->getDwarfSectionOffsetDirective();
-  else if (Force32Bit || TD->getPointerSize() == sizeof(int32_t))
+void DwarfPrinter::PrintRelDirective(bool Force32Bit) const {
+  if (Force32Bit || TD->getPointerSize() == sizeof(int32_t))
     O << MAI->getData32bitsDirective();
   else
     O << MAI->getData64bitsDirective();
@@ -253,17 +251,23 @@
 void DwarfPrinter::EmitSectionOffset(const MCSymbol *Label,
                                      const MCSymbol *Section,
                                      bool IsSmall, bool isEH) {
-  bool printAbsolute = false;
+  bool isAbsolute;
   if (isEH)
-    printAbsolute = MAI->isAbsoluteEHSectionOffsets();
+    isAbsolute = MAI->isAbsoluteEHSectionOffsets();
   else
-    printAbsolute = MAI->isAbsoluteDebugSectionOffsets();
+    isAbsolute = MAI->isAbsoluteDebugSectionOffsets();
 
-  if (!printAbsolute)
+  if (!isAbsolute)
     return EmitDifference(Label, Section, IsSmall);
   
-  PrintRelDirective(IsSmall, true);
-  PrintLabelName(Label);
+  // On COFF targets, we have to emit the weird .secrel32 directive.
+  if (const char *SecOffDir = MAI->getDwarfSectionOffsetDirective())
+    O << SecOffDir << Label->getName();
+  else {
+    unsigned Size = IsSmall ? 4 : TD->getPointerSize();
+    Asm->OutStreamer.EmitValue(MCSymbolRefExpr::Create(Label, Asm->OutContext),
+                               Size, 0/*AddrSpace*/);
+  }
 }
 
 /// EmitFrameMoves - Emit frame instructions to describe the layout of the

Modified: llvm/trunk/lib/CodeGen/AsmPrinter/DwarfPrinter.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/AsmPrinter/DwarfPrinter.h?rev=98014&r1=98013&r2=98014&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/AsmPrinter/DwarfPrinter.h (original)
+++ llvm/trunk/lib/CodeGen/AsmPrinter/DwarfPrinter.h Mon Mar  8 18:17:58 2010
@@ -89,8 +89,7 @@
   unsigned SizeOfEncodedValue(unsigned Encoding) const;
 
   void PrintRelDirective(unsigned Encoding) const;
-  void PrintRelDirective(bool Force32Bit = false,
-                         bool isInSection = false) const;
+  void PrintRelDirective(bool Force32Bit = false) const;
 
   /// EOL - Print a newline character to asm stream.  If a comment is present
   /// then it will be printed first.  Comments should not contain '\n'.
@@ -130,6 +129,8 @@
   void EmitDifference(const MCSymbol *LabelHi, const MCSymbol *LabelLo,
                       bool IsSmall = false);
 
+  /// EmitSectionOffset - Emit Label-Section or use a special purpose directive
+  /// to emit a section offset if the target has one.
   void EmitSectionOffset(const MCSymbol *Label, const MCSymbol *Section,
                          bool IsSmall = false, bool isEH = false);
   





More information about the llvm-commits mailing list