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

Chris Lattner lattner at cs.uiuc.edu
Sun Nov 20 23:57:48 PST 2005



Changes in directory llvm/lib/Target/PowerPC:

PPCAsmPrinter.cpp updated: 1.117 -> 1.118
---
Log message:

unify the darwin and aix constant pool printers


---
Diffs of the changes:  (+28 -48)

 PPCAsmPrinter.cpp |   76 +++++++++++++++++++-----------------------------------
 1 files changed, 28 insertions(+), 48 deletions(-)


Index: llvm/lib/Target/PowerPC/PPCAsmPrinter.cpp
diff -u llvm/lib/Target/PowerPC/PPCAsmPrinter.cpp:1.117 llvm/lib/Target/PowerPC/PPCAsmPrinter.cpp:1.118
--- llvm/lib/Target/PowerPC/PPCAsmPrinter.cpp:1.117	Mon Nov 21 01:51:23 2005
+++ llvm/lib/Target/PowerPC/PPCAsmPrinter.cpp	Mon Nov 21 01:57:37 2005
@@ -62,6 +62,8 @@
       return static_cast<PPCTargetMachine&>(TM);
     }
 
+    void printConstantPool(MachineConstantPool *MCP);
+
     unsigned enumRegToMachineReg(unsigned enumReg) {
       switch (enumReg) {
       default: assert(0 && "Unhandled register!"); break;
@@ -197,7 +199,6 @@
       O << (0x80 >> RegNo);
     }
 
-    virtual void printConstantPool(MachineConstantPool *MCP) = 0;
     virtual bool runOnMachineFunction(MachineFunction &F) = 0;
     virtual bool doFinalization(Module &M) = 0;
   };
@@ -221,7 +222,6 @@
       return "Darwin PPC Assembly Printer";
     }
 
-    void printConstantPool(MachineConstantPool *MCP);
     bool runOnMachineFunction(MachineFunction &F);
     bool doInitialization(Module &M);
     bool doFinalization(Module &M);
@@ -247,7 +247,6 @@
       return "AIX PPC Assembly Printer";
     }
 
-    void printConstantPool(MachineConstantPool *MCP);
     bool runOnMachineFunction(MachineFunction &F);
     bool doInitialization(Module &M);
     bool doFinalization(Module &M);
@@ -378,6 +377,32 @@
   return;
 }
 
+/// printConstantPool - Print to the current output stream assembly
+/// representations of the constants in the constant pool MCP. This is
+/// used to print out constants which have been "spilled to memory" by
+/// the code generator.
+///
+void PPCAsmPrinter::printConstantPool(MachineConstantPool *MCP) {
+  const std::vector<Constant*> &CP = MCP->getConstants();
+  const TargetData &TD = TM.getTargetData();
+  
+  if (CP.empty()) return;
+  
+  SwitchSection(".const", 0);
+  for (unsigned i = 0, e = CP.size(); i != e; ++i) {
+    // FIXME: force doubles to be naturally aligned.  We should handle this
+    // more correctly in the future.
+    unsigned Alignment = TD.getTypeAlignmentShift(CP[i]->getType());
+    if (CP[i]->getType() == Type::DoubleTy && Alignment < 3) Alignment = 3;
+    
+    EmitAlignment(Alignment);
+    O << PrivateGlobalPrefix << "CPI" << FunctionNumber << '_' << i
+      << ":\t\t\t\t\t" << CommentString << *CP[i] << '\n';
+    EmitGlobalConstant(CP[i]);
+  }
+}
+
+
 /// runOnMachineFunction - This uses the printMachineInstruction()
 /// method to print assembly for each instruction.
 ///
@@ -420,30 +445,6 @@
   return false;
 }
 
-/// printConstantPool - Print to the current output stream assembly
-/// representations of the constants in the constant pool MCP. This is
-/// used to print out constants which have been "spilled to memory" by
-/// the code generator.
-///
-void DarwinAsmPrinter::printConstantPool(MachineConstantPool *MCP) {
-  const std::vector<Constant*> &CP = MCP->getConstants();
-  const TargetData &TD = TM.getTargetData();
-
-  if (CP.empty()) return;
-
-  SwitchSection(".const", 0);
-  for (unsigned i = 0, e = CP.size(); i != e; ++i) {
-    // FIXME: force doubles to be naturally aligned.  We should handle this
-    // more correctly in the future.
-    if (CP[i]->getType() == Type::DoubleTy)
-      EmitAlignment(3);
-    else
-      EmitAlignment(TD.getTypeAlignmentShift(CP[i]->getType()));
-    O << PrivateGlobalPrefix << "CPI" << FunctionNumber << '_' << i
-      << ":\t\t\t\t\t" << CommentString << *CP[i] << '\n';
-    EmitGlobalConstant(CP[i]);
-  }
-}
 
 bool DarwinAsmPrinter::doInitialization(Module &M) {
   if (TM.getSubtarget<PPCSubtarget>().isGigaProcessor())
@@ -632,27 +633,6 @@
   return false;
 }
 
-/// printConstantPool - Print to the current output stream assembly
-/// representations of the constants in the constant pool MCP. This is
-/// used to print out constants which have been "spilled to memory" by
-/// the code generator.
-///
-void AIXAsmPrinter::printConstantPool(MachineConstantPool *MCP) {
-  const std::vector<Constant*> &CP = MCP->getConstants();
-  const TargetData &TD = TM.getTargetData();
-
-  if (CP.empty()) return;
-
-  for (unsigned i = 0, e = CP.size(); i != e; ++i) {
-    SwitchSection(".const", 0);
-    O << "\t.align " << (unsigned)TD.getTypeAlignment(CP[i]->getType())
-      << "\n";
-    O << PrivateGlobalPrefix << "CPI" << FunctionNumber << '_' << i
-      << ":\t\t\t\t\t;" << *CP[i] << '\n';
-    EmitGlobalConstant(CP[i]);
-  }
-}
-
 bool AIXAsmPrinter::doInitialization(Module &M) {
   SwitchSection("", 0);
   const TargetData &TD = TM.getTargetData();






More information about the llvm-commits mailing list