Changes in directory llvm/lib/Target/X86:

X86AsmPrinter.cpp updated: 1.147 -> 1.148
X86AsmPrinter.h updated: 1.3 -> 1.4
---
Log message:

Start using the AsmPrinter shared SwitchSection code.  This allows the X86
backend to implement global variables in sections.



---
Diffs of the changes:  (+3 -18)

 X86AsmPrinter.cpp |   10 +++-------
 X86AsmPrinter.h   |   11 -----------
 2 files changed, 3 insertions(+), 18 deletions(-)


Index: llvm/lib/Target/X86/X86AsmPrinter.cpp
diff -u llvm/lib/Target/X86/X86AsmPrinter.cpp:1.147 
llvm/lib/Target/X86/X86AsmPrinter.cpp:1.148
--- llvm/lib/Target/X86/X86AsmPrinter.cpp:1.147 Mon Nov 21 00:55:27 2005
+++ llvm/lib/Target/X86/X86AsmPrinter.cpp       Mon Nov 21 01:11:11 2005
@@ -105,7 +105,6 @@
 
 bool X86SharedAsmPrinter::doFinalization(Module &M) {
   const TargetData &TD = TM.getTargetData();
-  std::string CurSection;
 
   // Print out module-level global variables here.
   for (Module::const_global_iterator I = M.global_begin(),
@@ -120,7 +119,7 @@
       if (C->isNullValue() &&
           (I->hasLinkOnceLinkage() || I->hasInternalLinkage() ||
            I->hasWeakLinkage() /* FIXME: Verify correct */)) {
-        switchSection(O, CurSection, ".data");
+        SwitchSection(".data", I);
         if (!forCygwin && !forDarwin && I->hasInternalLinkage())
           O << "\t.local " << name << "\n";
         if (forDarwin && I->hasInternalLinkage())
@@ -139,8 +138,8 @@
         case GlobalValue::WeakLinkage:   // FIXME: Verify correct for weak.
           // Nonnull linkonce -> weak
           O << "\t.weak " << name << "\n";
-          switchSection(O, CurSection, "");
           O << "\t.section\t.llvm.linkonce.d." << name << 
",\"aw\",@progbits\n";
+          SwitchSection("", I);
           break;
         case GlobalValue::AppendingLinkage:
           // FIXME: appending linkage variables should go into a section of
@@ -150,10 +149,7 @@
           O << "\t.globl " << name << "\n";
           // FALL THROUGH
         case GlobalValue::InternalLinkage:
-          if (C->isNullValue())
-            switchSection(O, CurSection, ".bss");
-          else
-            switchSection(O, CurSection, ".data");
+          SwitchSection(C->isNullValue() ? ".bss" : ".data", I);
           break;
         }
 


Index: llvm/lib/Target/X86/X86AsmPrinter.h
diff -u llvm/lib/Target/X86/X86AsmPrinter.h:1.3 
llvm/lib/Target/X86/X86AsmPrinter.h:1.4
--- llvm/lib/Target/X86/X86AsmPrinter.h:1.3     Mon Nov 21 00:55:27 2005
+++ llvm/lib/Target/X86/X86AsmPrinter.h Mon Nov 21 01:11:11 2005
@@ -55,17 +55,6 @@
       MI->getOperand(Op+2).isRegister() && 
(MI->getOperand(Op+3).isImmediate()||
       MI->getOperand(Op+3).isGlobalAddress());
   }
-
-  // switchSection - Switch to the specified section of the executable if we 
are
-  // not already in it!
-  inline static void switchSection(std::ostream &OS, std::string &CurSection,
-                                   const char *NewSection) {
-    if (CurSection != NewSection) {
-      CurSection = NewSection;
-      if (!CurSection.empty())
-        OS << "\t" << NewSection << "\n";
-    }
-  }
 };
 
 } // end namespace x86



_______________________________________________
llvm-commits mailing list
[email protected]
http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits

Reply via email to