Use raw_ostream throughout the AsmPrinter.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@55092 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/CodeGen/AsmPrinter/AsmPrinter.cpp b/lib/CodeGen/AsmPrinter/AsmPrinter.cpp
index 2eccc36..bf57a65 100644
--- a/lib/CodeGen/AsmPrinter/AsmPrinter.cpp
+++ b/lib/CodeGen/AsmPrinter/AsmPrinter.cpp
@@ -21,7 +21,7 @@
 #include "llvm/CodeGen/MachineJumpTableInfo.h"
 #include "llvm/CodeGen/MachineModuleInfo.h"
 #include "llvm/Support/Mangler.h"
-#include "llvm/Support/MathExtras.h"
+#include "llvm/Support/raw_ostream.h"
 #include "llvm/Support/Streams.h"
 #include "llvm/Target/TargetAsmInfo.h"
 #include "llvm/Target/TargetData.h"
@@ -31,11 +31,12 @@
 #include "llvm/Target/TargetRegisterInfo.h"
 #include "llvm/ADT/SmallPtrSet.h"
 #include "llvm/ADT/SmallString.h"
+#include "llvm/ADT/StringExtras.h"
 #include <cerrno>
 using namespace llvm;
 
 char AsmPrinter::ID = 0;
-AsmPrinter::AsmPrinter(std::ostream &o, TargetMachine &tm,
+AsmPrinter::AsmPrinter(raw_ostream &o, TargetMachine &tm,
                        const TargetAsmInfo *T)
   : MachineFunctionPass((intptr_t)&ID), FunctionNumber(0), O(o),
     TM(tm), TAI(T), TRI(tm.getRegisterInfo()),
@@ -268,8 +269,9 @@
   EmitAlignment(Alignment);
   for (unsigned i = 0, e = CP.size(); i != e; ++i) {
     O << TAI->getPrivateGlobalPrefix() << "CPI" << getFunctionNumber() << '_'
-      << CP[i].second << ":\t\t\t\t\t" << TAI->getCommentString() << ' ';
-    WriteTypeSymbolic(O, CP[i].first.getType(), 0);
+      << CP[i].second << ":\t\t\t\t\t";
+    // O << TAI->getCommentString() << ' ' << 
+    //      WriteTypeSymbolic(O, CP[i].first.getType(), 0);
     O << '\n';
     if (CP[i].first.isMachineConstantPoolEntry())
       EmitMachineConstantPoolValue(CP[i].first.Val.MachineCPVal);
@@ -495,7 +497,7 @@
     unsigned Byte = Value & 0x7f;
     Value >>= 7;
     if (Value) Byte |= 0x80;
-    O << "0x" << std::hex << Byte << std::dec;
+    O << "0x" <<  utohexstr(Byte);
     if (Value) O << ", ";
   } while (Value);
 }
@@ -511,7 +513,7 @@
     Value >>= 7;
     IsMore = Value != Sign || ((Byte ^ Sign) & 0x40) != 0;
     if (IsMore) Byte |= 0x80;
-    O << "0x" << std::hex << Byte << std::dec;
+    O << "0x" << utohexstr(Byte);
     if (IsMore) O << ", ";
   } while (IsMore);
 }
@@ -523,7 +525,7 @@
 /// PrintHex - Print a value as a hexidecimal value.
 ///
 void AsmPrinter::PrintHex(int Value) const { 
-  O << "0x" << std::hex << Value << std::dec;
+  O << "0x" << utohexstr(static_cast<unsigned>(Value));
 }
 
 /// EOL - Print a newline character to asm stream.  If a comment is present
@@ -622,7 +624,7 @@
 
 /// printStringChar - Print a char, escaped if necessary.
 ///
-static void printStringChar(std::ostream &O, unsigned char C) {
+static void printStringChar(raw_ostream &O, char C) {
   if (C == '"') {
     O << "\\\"";
   } else if (C == '\\') {
@@ -706,7 +708,7 @@
 
   unsigned FillValue = TAI->getTextAlignFillValue();
   UseFillExpr &= IsInTextSection && FillValue;
-  if (UseFillExpr) O << ",0x" << std::hex << FillValue << std::dec;
+  if (UseFillExpr) O << ",0x" << utohexstr(FillValue);
   O << '\n';
 }
 
@@ -855,7 +857,7 @@
 /// printAsCString - Print the specified array as a C compatible string, only if
 /// the predicate isString is true.
 ///
-static void printAsCString(std::ostream &O, const ConstantArray *CVA,
+static void printAsCString(raw_ostream &O, const ConstantArray *CVA,
                            unsigned LastElt) {
   assert(CVA->isString() && "Array is not string compatible!");
 
diff --git a/lib/CodeGen/AsmPrinter/DwarfWriter.cpp b/lib/CodeGen/AsmPrinter/DwarfWriter.cpp
index 5d6acc3..99e94e2 100644
--- a/lib/CodeGen/AsmPrinter/DwarfWriter.cpp
+++ b/lib/CodeGen/AsmPrinter/DwarfWriter.cpp
@@ -28,6 +28,7 @@
 #include "llvm/Support/CommandLine.h"
 #include "llvm/Support/DataTypes.h"
 #include "llvm/Support/Mangler.h"
+#include "llvm/Support/raw_ostream.h"
 #include "llvm/System/Path.h"
 #include "llvm/Target/TargetAsmInfo.h"
 #include "llvm/Target/TargetRegisterInfo.h"
@@ -820,7 +821,7 @@
   //
   /// O - Stream to .s file.
   ///
-  std::ostream &O;
+  raw_ostream &O;
 
   /// Asm - Target of Dwarf emission.
   ///
@@ -856,7 +857,7 @@
   const char * const Flavor;
 
   unsigned SetCounter;
-  Dwarf(std::ostream &OS, AsmPrinter *A, const TargetAsmInfo *T,
+  Dwarf(raw_ostream &OS, AsmPrinter *A, const TargetAsmInfo *T,
         const char *flavor)
   : O(OS)
   , Asm(A)
@@ -2673,7 +2674,7 @@
   //===--------------------------------------------------------------------===//
   // Main entry points.
   //
-  DwarfDebug(std::ostream &OS, AsmPrinter *A, const TargetAsmInfo *T)
+  DwarfDebug(raw_ostream &OS, AsmPrinter *A, const TargetAsmInfo *T)
   : Dwarf(OS, A, T, "dbg")
   , CompileUnits()
   , AbbreviationsSet(InitAbbreviationsSetSize)
@@ -3479,7 +3480,7 @@
   //===--------------------------------------------------------------------===//
   // Main entry points.
   //
-  DwarfException(std::ostream &OS, AsmPrinter *A, const TargetAsmInfo *T)
+  DwarfException(raw_ostream &OS, AsmPrinter *A, const TargetAsmInfo *T)
   : Dwarf(OS, A, T, "eh")
   , shouldEmitTable(false)
   , shouldEmitMoves(false)
@@ -3879,7 +3880,7 @@
 /// DwarfWriter Implementation
 ///
 
-DwarfWriter::DwarfWriter(std::ostream &OS, AsmPrinter *A,
+DwarfWriter::DwarfWriter(raw_ostream &OS, AsmPrinter *A,
                          const TargetAsmInfo *T) {
   DE = new DwarfException(OS, A, T);
   DD = new DwarfDebug(OS, A, T);
diff --git a/lib/CodeGen/AsmPrinter/OcamlGCPrinter.cpp b/lib/CodeGen/AsmPrinter/OcamlGCPrinter.cpp
index 761e910..16abca2 100644
--- a/lib/CodeGen/AsmPrinter/OcamlGCPrinter.cpp
+++ b/lib/CodeGen/AsmPrinter/OcamlGCPrinter.cpp
@@ -15,6 +15,7 @@
 #include "llvm/CodeGen/AsmPrinter.h"
 #include "llvm/CodeGen/GCMetadataPrinter.h"
 #include "llvm/Module.h"
+#include "llvm/Support/raw_ostream.h"
 #include "llvm/Target/TargetAsmInfo.h"
 #include "llvm/Target/TargetData.h"
 #include "llvm/Target/TargetMachine.h"
@@ -25,10 +26,10 @@
 
   class VISIBILITY_HIDDEN OcamlGCMetadataPrinter : public GCMetadataPrinter {
   public:
-    void beginAssembly(std::ostream &OS, AsmPrinter &AP,
+    void beginAssembly(raw_ostream &OS, AsmPrinter &AP,
                        const TargetAsmInfo &TAI);
     
-    void finishAssembly(std::ostream &OS, AsmPrinter &AP,
+    void finishAssembly(raw_ostream &OS, AsmPrinter &AP,
                         const TargetAsmInfo &TAI);
   };
   
@@ -39,7 +40,7 @@
 
 void llvm::linkOcamlGCPrinter() { }
 
-static void EmitCamlGlobal(const Module &M, std::ostream &OS, AsmPrinter &AP,
+static void EmitCamlGlobal(const Module &M, raw_ostream &OS, AsmPrinter &AP,
                            const TargetAsmInfo &TAI, const char *Id) {
   const std::string &MId = M.getModuleIdentifier();
   
@@ -59,7 +60,7 @@
   OS << Mangled << ":\n";
 }
 
-void OcamlGCMetadataPrinter::beginAssembly(std::ostream &OS, AsmPrinter &AP,
+void OcamlGCMetadataPrinter::beginAssembly(raw_ostream &OS, AsmPrinter &AP,
                                            const TargetAsmInfo &TAI) {
   AP.SwitchToTextSection(TAI.getTextSection());
   EmitCamlGlobal(getModule(), OS, AP, TAI, "code_begin");
@@ -84,7 +85,7 @@
 /// (FrameSize and LiveOffsets would overflow). FrameTablePrinter will abort if
 /// either condition is detected in a function which uses the GC.
 /// 
-void OcamlGCMetadataPrinter::finishAssembly(std::ostream &OS, AsmPrinter &AP,
+void OcamlGCMetadataPrinter::finishAssembly(raw_ostream &OS, AsmPrinter &AP,
                                             const TargetAsmInfo &TAI) {
   const char *AddressDirective;
   int AddressAlignLog;