[llvm-commits] CVS: llvm/lib/Target/PowerPC/PPCAsmPrinter.cpp

Chris Lattner lattner at cs.uiuc.edu
Mon Dec 12 22:33:02 PST 2005



Changes in directory llvm/lib/Target/PowerPC:

PPCAsmPrinter.cpp updated: 1.125 -> 1.126
---
Log message:

Use the shared asmprinter code for printing special llvm globals


---
Diffs of the changes:  (+5 -33)

 PPCAsmPrinter.cpp |   38 +++++---------------------------------
 1 files changed, 5 insertions(+), 33 deletions(-)


Index: llvm/lib/Target/PowerPC/PPCAsmPrinter.cpp
diff -u llvm/lib/Target/PowerPC/PPCAsmPrinter.cpp:1.125 llvm/lib/Target/PowerPC/PPCAsmPrinter.cpp:1.126
--- llvm/lib/Target/PowerPC/PPCAsmPrinter.cpp:1.125	Mon Dec 12 22:33:58 2005
+++ llvm/lib/Target/PowerPC/PPCAsmPrinter.cpp	Tue Dec 13 00:32:50 2005
@@ -198,14 +198,14 @@
       AlignmentIsInBytes = false;    // Alignment is by power of 2.
       ConstantPoolSection = "\t.const\t";
       LCOMMDirective = "\t.lcomm\t";
+      StaticCtorsSection = ".mod_init_func";
+      StaticDtorsSection = ".mod_term_func";
     }
 
     virtual const char *getPassName() const {
       return "Darwin PPC Assembly Printer";
     }
     
-    void EmitXXStructorList(Constant *List);
-
     bool runOnMachineFunction(MachineFunction &F);
     bool doInitialization(Module &M);
     bool doFinalization(Module &M);
@@ -415,21 +415,6 @@
   return false;
 }
 
-/// EmitXXStructorList - Emit the ctor or dtor list.  On darwin, this just 
-/// prints out the function pointers.
-void DarwinAsmPrinter::EmitXXStructorList(Constant *List) {
-  // Should be an array of '{ int, void ()* }' structs.  The first value is the
-  // init priority, which we ignore.
-  if (!isa<ConstantArray>(List)) return;
-  ConstantArray *InitList = cast<ConstantArray>(List);
-  for (unsigned i = 0, e = InitList->getNumOperands(); i != e; ++i)
-    if (ConstantStruct *CS = dyn_cast<ConstantStruct>(InitList->getOperand(i))){
-      if (CS->getNumOperands() != 2) return;  // Not array of 2-element structs.
-      // Emit the function pointer.
-      EmitGlobalConstant(CS->getOperand(1));
-    }
-}
-
 bool DarwinAsmPrinter::doFinalization(Module &M) {
   const TargetData &TD = TM.getTargetData();
 
@@ -438,22 +423,9 @@
        I != E; ++I) {
     if (!I->hasInitializer()) continue;   // External global require no code
     
-    // Check to see if this is a special global used by LLVM.
-    if (I->hasAppendingLinkage()) {
-      if (I->getName() == "llvm.used")
-        continue;  // No need to emit this at all.
-      if (I->getName() == "llvm.global_ctors") {
-        SwitchSection(".mod_init_func", 0);
-        EmitAlignment(2, 0);
-        EmitXXStructorList(I->getInitializer());
-        continue;
-      } else if (I->getName() == "llvm.global_dtors") {
-        SwitchSection(".mod_term_func", 0);
-        EmitAlignment(2, 0);
-        EmitXXStructorList(I->getInitializer());
-        continue;
-      }
-    }
+    // Check to see if this is a special global used by LLVM, if so, emit it.
+    if (I->hasAppendingLinkage() && EmitSpecialLLVMGlobal(I))
+      continue;
     
     O << '\n';
     std::string name = Mang->getValueName(I);






More information about the llvm-commits mailing list