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
};
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 {
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:
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:
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; }
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;
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();
}
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
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