Subzero: Make Ice::Ostream a typedef for llvm::raw_ostream.

Previously Ostream was a class that wrapped a raw_ostream pointer,
structured that way in case we wanted to wrap an alternate stream
type.

Also, Ostream used to include a Cfg pointer, but that had to go away
when the Ostream became associated with the GlobalContext which
persists beyond the Cfg lifetime, so the Cfg pointer was removed
leaving only the raw_ostream.

Since llvm::raw_ostream is supposed to be very lightweight, we can
just give up the abstraction and equate it to Ice::Ostream.

BUG= none
R=kschimpf@google.com

Review URL: https://codereview.chromium.org/413393005
diff --git a/src/IceDefs.h b/src/IceDefs.h
index 6aee09a..cf9052c 100644
--- a/src/IceDefs.h
+++ b/src/IceDefs.h
@@ -105,26 +105,7 @@
 };
 typedef uint32_t VerboseMask;
 
-// The Ostream class wraps an output stream and a Cfg pointer, so
-// that dump routines have access to the Cfg object and can print
-// labels and variable names.
-
-class Ostream {
-public:
-  Ostream(llvm::raw_ostream *Stream) : Stream(Stream) {}
-
-  llvm::raw_ostream *Stream;
-
-private:
-  Ostream(const Ostream &) LLVM_DELETED_FUNCTION;
-  Ostream &operator=(const Ostream &) LLVM_DELETED_FUNCTION;
-};
-
-template <typename T> inline Ostream &operator<<(Ostream &Str, const T &Val) {
-  if (Str.Stream)
-    (*Str.Stream) << Val;
-  return Str;
-}
+typedef llvm::raw_ostream Ostream;
 
 // TODO: Implement in terms of std::chrono after switching to C++11.
 class Timer {
diff --git a/src/IceGlobalContext.cpp b/src/IceGlobalContext.cpp
index a7b1b64..113ffc4 100644
--- a/src/IceGlobalContext.cpp
+++ b/src/IceGlobalContext.cpp
@@ -330,8 +330,7 @@
   case IceType_v4f32: {
     IceString Str;
     llvm::raw_string_ostream BaseOS(Str);
-    Ostream OS(&BaseOS);
-    OS << "Unsupported constant type: " << Ty;
+    BaseOS << "Unsupported constant type: " << Ty;
     llvm_unreachable(BaseOS.str().c_str());
   } break;
   case IceType_void:
@@ -362,8 +361,7 @@
   case IceType_v4f32: {
     IceString Str;
     llvm::raw_string_ostream BaseOS(Str);
-    Ostream OS(&BaseOS);
-    OS << "Unsupported constant type: " << Ty;
+    BaseOS << "Unsupported constant type: " << Ty;
     llvm_unreachable(BaseOS.str().c_str());
   } break;
   case IceType_void:
diff --git a/src/IceGlobalContext.h b/src/IceGlobalContext.h
index 1a3e4cd..e1b67ac 100644
--- a/src/IceGlobalContext.h
+++ b/src/IceGlobalContext.h
@@ -47,8 +47,8 @@
   void addVerbose(VerboseMask Mask) { VMask |= Mask; }
   void subVerbose(VerboseMask Mask) { VMask &= ~Mask; }
 
-  Ostream &getStrDump() { return StrDump; }
-  Ostream &getStrEmit() { return StrEmit; }
+  Ostream &getStrDump() { return *StrDump; }
+  Ostream &getStrEmit() { return *StrEmit; }
 
   TargetArch getTargetArch() const { return Arch; }
   OptLevel getOptLevel() const { return Opt; }
@@ -92,8 +92,8 @@
   const Intrinsics &getIntrinsicsInfo() const { return IntrinsicsInfo; }
 
 private:
-  Ostream StrDump; // Stream for dumping / diagnostics
-  Ostream StrEmit; // Stream for code emission
+  Ostream *StrDump; // Stream for dumping / diagnostics
+  Ostream *StrEmit; // Stream for code emission
 
   llvm::BumpPtrAllocator Allocator;
   VerboseMask VMask;
diff --git a/src/IceTargetLoweringX8632.cpp b/src/IceTargetLoweringX8632.cpp
index 83dc5bd..8123e74 100644
--- a/src/IceTargetLoweringX8632.cpp
+++ b/src/IceTargetLoweringX8632.cpp
@@ -128,11 +128,10 @@
 IceString typeIdentString(const Type Ty) {
   IceString Str;
   llvm::raw_string_ostream BaseOS(Str);
-  Ostream OS(&BaseOS);
   if (isVectorType(Ty)) {
-    OS << "v" << typeNumElements(Ty) << typeElementType(Ty);
+    BaseOS << "v" << typeNumElements(Ty) << typeElementType(Ty);
   } else {
-    OS << Ty;
+    BaseOS << Ty;
   }
   return BaseOS.str();
 }
diff --git a/src/IceTypes.cpp b/src/IceTypes.cpp
index 515be2d..0724e51 100644
--- a/src/IceTypes.cpp
+++ b/src/IceTypes.cpp
@@ -81,18 +81,13 @@
   return ElementType;
 }
 
-// ======================== Dump routines ======================== //
-
-template <> Ostream &operator<<(Ostream &Str, const Type &Ty) {
+const char *typeString(Type Ty) {
   size_t Index = static_cast<size_t>(Ty);
   if (Index < TypeAttributesSize) {
-    Str << TypeAttributes[Index].DisplayString;
-  } else {
-    Str << "???";
-    llvm_unreachable("Invalid type for printing");
+    return TypeAttributes[Index].DisplayString;
   }
-
-  return Str;
+  llvm_unreachable("Invalid type for typeString");
+  return "???";
 }
 
 } // end of namespace Ice
diff --git a/src/IceTypes.h b/src/IceTypes.h
index 6bc2ded..fa91763 100644
--- a/src/IceTypes.h
+++ b/src/IceTypes.h
@@ -45,10 +45,15 @@
 size_t typeAlignInBytes(Type Ty);
 size_t typeNumElements(Type Ty);
 Type typeElementType(Type Ty);
+const char *typeString(Type Ty);
 
 inline bool isVectorType(Type Ty) { return typeNumElements(Ty) > 1; }
 
-template <> Ostream &operator<<(class Ostream &Str, const Type &Ty);
+template <typename StreamType>
+inline StreamType &operator<<(StreamType &Str, const Type &Ty) {
+  Str << typeString(Ty);
+  return Str;
+}
 
 } // end of namespace Ice