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

Chris Lattner lattner at cs.uiuc.edu
Tue Aug 17 12:26:14 PDT 2004



Changes in directory llvm/lib/Target/PowerPC:

PPC32AsmPrinter.cpp updated: 1.50 -> 1.51
---
Log message:

Start using alignment output routines from AsmPrinter.
Changes to make this more similar to the X86 asmprinter

Fix overalignment of globals.



---
Diffs of the changes:  (+12 -12)

Index: llvm/lib/Target/PowerPC/PPC32AsmPrinter.cpp
diff -u llvm/lib/Target/PowerPC/PPC32AsmPrinter.cpp:1.50 llvm/lib/Target/PowerPC/PPC32AsmPrinter.cpp:1.51
--- llvm/lib/Target/PowerPC/PPC32AsmPrinter.cpp:1.50	Tue Aug 17 11:27:26 2004
+++ llvm/lib/Target/PowerPC/PPC32AsmPrinter.cpp	Tue Aug 17 14:26:03 2004
@@ -49,6 +49,7 @@
       GlobalPrefix = "_";
       ZeroDirective = "\t.space\t";  // ".space N" emits N zeros.
       Data64bitsDirective = 0;       // we can't emit a 64-bit unit
+      AlignmentIsInBytes = false;    // Alignment is by power of 2.
     }
 
     /// Unique incrementer for label values for referencing Global values.
@@ -121,9 +122,8 @@
 
   for (unsigned i = 0, e = CP.size(); i != e; ++i) {
     O << "\t.const\n";
-    O << "\t.align " << (unsigned)TD.getTypeAlignment(CP[i]->getType())
-      << "\n";
-    O << ".CPI" << CurrentFnName << "_" << i << ":\t\t\t\t\t;"
+    emitAlignment(TD.getTypeAlignmentShift(CP[i]->getType()));
+    O << ".CPI" << CurrentFnName << "_" << i << ":\t\t\t\t\t" << CommentChar
       << *CP[i] << "\n";
     emitGlobalConstant(CP[i]);
   }
@@ -140,19 +140,19 @@
   printConstantPool(MF.getConstantPool());
 
   // Print out labels for the function.
-  O << "\t.text\n"; 
+  O << "\t.text\n";
+  emitAlignment(2);
   O << "\t.globl\t" << CurrentFnName << "\n";
-  O << "\t.align 2\n";
   O << CurrentFnName << ":\n";
 
   // Print out code for the function.
   for (MachineFunction::const_iterator I = MF.begin(), E = MF.end();
        I != E; ++I) {
     // Print a label for the basic block.
-    O << ".LBB" << CurrentFnName << "_" << I->getNumber() << ":\t; "
-      << I->getBasicBlock()->getName() << "\n";
+    O << ".LBB" << CurrentFnName << "_" << I->getNumber() << ":\t"
+      << CommentChar << " " << I->getBasicBlock()->getName() << "\n";
     for (MachineBasicBlock::const_iterator II = I->begin(), E = I->end();
-      II != E; ++II) {
+         II != E; ++II) {
       // Print the assembly for the instruction.
       O << "\t";
       printMachineInstruction(II);
@@ -399,14 +399,14 @@
       std::string name = Mang->getValueName(I);
       Constant *C = I->getInitializer();
       unsigned Size = TD.getTypeSize(C->getType());
-      unsigned Align = TD.getTypeAlignment(C->getType());
+      unsigned Align = TD.getTypeAlignmentShift(C->getType());
 
       if (C->isNullValue() && /* FIXME: Verify correct */
           (I->hasInternalLinkage() || I->hasWeakLinkage())) {
         SwitchSection(O, CurSection, ".data");
         if (I->hasInternalLinkage())
           O << ".lcomm " << name << "," << TD.getTypeSize(C->getType())
-            << "," << (unsigned)TD.getTypeAlignment(C->getType());
+            << "," << Align;
         else 
           O << ".comm " << name << "," << TD.getTypeSize(C->getType());
         O << "\t\t; ";
@@ -439,7 +439,7 @@
           break;
         }
 
-        O << "\t.align " << Align << "\n";
+        emitAlignment(Align);
         O << name << ":\t\t\t\t; ";
         WriteAsOperand(O, I, true, true, &M);
         O << " = ";
@@ -455,7 +455,7 @@
   {
     O << ".data\n";
     O << ".section __TEXT,__picsymbolstub1,symbol_stubs,pure_instructions,32\n";
-    O << "\t.align 2\n";
+    emitAlignment(2);
     O << "L" << *i << "$stub:\n";
     O << "\t.indirect_symbol " << *i << "\n";
     O << "\tmflr r0\n";






More information about the llvm-commits mailing list