eliminate an argument from PrintRelDirective, sinking
authorChris Lattner <sabre@nondot.org>
Tue, 9 Mar 2010 00:17:58 +0000 (00:17 +0000)
committerChris Lattner <sabre@nondot.org>
Tue, 9 Mar 2010 00:17:58 +0000 (00:17 +0000)
the one special case into EmitSectionOffset.  MCize
the non-special case in EmitSectionOffset.

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

lib/CodeGen/AsmPrinter/DwarfPrinter.cpp
lib/CodeGen/AsmPrinter/DwarfPrinter.h

index a40bd54f8cfbc55fe33f9c0f24b23b1fda332041..8dd72c449645fe591b15f56ccda15ae8c3de4000 100644 (file)
@@ -77,10 +77,8 @@ unsigned DwarfPrinter::SizeOfEncodedValue(unsigned Encoding) const {
   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::EmitDifference(const MCSymbol *TagHi, const MCSymbol *TagLo,
 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
index fc9f3fe9eefde4d367e4032b5055e415b7ea60d8..cce62aa8cf0c4b7febbf7ffc865b0b0abf3fa74d 100644 (file)
@@ -89,8 +89,7 @@ public:
   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 @@ public:
   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);