Revert 42908 for now.
[oota-llvm.git] / lib / Target / Sparc / SparcAsmPrinter.cpp
index 034c8f6967c6e1856a43d56dfc05b79a714cbad7..98d59ee8cb9352e8f6d9e5aebbfe7657f68f7827 100644 (file)
@@ -12,6 +12,7 @@
 //
 //===----------------------------------------------------------------------===//
 
+#define DEBUG_TYPE "asm-printer"
 #include "Sparc.h"
 #include "SparcInstrInfo.h"
 #include "llvm/Constants.h"
 #include "llvm/Support/CommandLine.h"
 #include "llvm/Support/MathExtras.h"
 #include <cctype>
-#include <iostream>
 using namespace llvm;
 
-namespace {
-  Statistic EmittedInsts("asm-printer", "Number of machine instrs printed");
+STATISTIC(EmittedInsts, "Number of machine instrs printed");
 
+namespace {
   struct VISIBILITY_HIDDEN SparcAsmPrinter : public AsmPrinter {
     SparcAsmPrinter(std::ostream &O, TargetMachine &TM, const TargetAsmInfo *T)
       : AsmPrinter(O, TM, T) {
@@ -229,7 +229,7 @@ bool SparcAsmPrinter::doFinalization(Module &M) {
       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->getPrefTypeAlignment(C->getType());
 
       if (C->isNullValue() &&
           (I->hasLinkOnceLinkage() || I->hasInternalLinkage() ||
@@ -239,7 +239,7 @@ bool SparcAsmPrinter::doFinalization(Module &M) {
           O << "\t.local " << name << "\n";
 
         O << "\t.comm " << name << "," << TD->getTypeSize(C->getType())
-          << "," << (unsigned)TD->getTypeAlignment(C->getType());
+          << "," << Align;
         O << "\n";
       } else {
         switch (I->getLinkage()) {
@@ -266,13 +266,13 @@ bool SparcAsmPrinter::doFinalization(Module &M) {
             SwitchToDataSection(".data", I);
           break;
         case GlobalValue::GhostLinkage:
-          std::cerr << "Should not have any unmaterialized functions!\n";
+          cerr << "Should not have any unmaterialized functions!\n";
           abort();
         case GlobalValue::DLLImportLinkage:
-          std::cerr << "DLLImport linkage is not supported by this target!\n";
+          cerr << "DLLImport linkage is not supported by this target!\n";
           abort();
         case GlobalValue::DLLExportLinkage:
-          std::cerr << "DLLExport linkage is not supported by this target!\n";
+          cerr << "DLLExport linkage is not supported by this target!\n";
           abort();
         default:
           assert(0 && "Unknown linkage type!");          
@@ -286,6 +286,5 @@ bool SparcAsmPrinter::doFinalization(Module &M) {
       }
     }
 
-  AsmPrinter::doFinalization(M);
-  return false; // success
+  return AsmPrinter::doFinalization(M);
 }