Subzero: Refactor Operand::dump().

A "standalone" version of dump() is provided, taking just an Ostream
argument and not requiring a Cfg or GlobalContext argument.

BUG= none
R=kschimpf@google.com

Review URL: https://codereview.chromium.org/570713006
diff --git a/src/IceInstX8632.cpp b/src/IceInstX8632.cpp
index 373ab59..06804f3 100644
--- a/src/IceInstX8632.cpp
+++ b/src/IceInstX8632.cpp
@@ -1356,11 +1356,6 @@
   dumpSources(Func);
 }
 
-void OperandX8632::dump(const Cfg *Func) const {
-  Ostream &Str = Func->getContext()->getStrDump();
-  Str << "<OperandX8632>";
-}
-
 void OperandX8632Mem::emit(const Cfg *Func) const {
   Ostream &Str = Func->getContext()->getStrEmit();
   Str << TypeX8632Attributes[getType()].WidthString << " ";
@@ -1405,8 +1400,7 @@
   Str << "]";
 }
 
-void OperandX8632Mem::dump(const Cfg *Func) const {
-  Ostream &Str = Func->getContext()->getStrDump();
+void OperandX8632Mem::dump(const Cfg *Func, Ostream &Str) const {
   if (SegmentReg != DefaultSegment) {
     assert(SegmentReg >= 0 && SegmentReg < SegReg_NUM);
     Str << InstX8632SegmentRegNames[SegmentReg] << ":";
@@ -1414,7 +1408,10 @@
   bool Dumped = false;
   Str << "[";
   if (Base) {
-    Base->dump(Func);
+    if (Func)
+      Base->dump(Func);
+    else
+      Base->dump(Str);
     Dumped = true;
   }
   if (Index) {
@@ -1422,7 +1419,10 @@
     Str << "+";
     if (Shift > 0)
       Str << (1u << Shift) << "*";
-    Index->dump(Func);
+    if (Func)
+      Index->dump(Func);
+    else
+      Index->dump(Str);
     Dumped = true;
   }
   // Pretty-print the Offset.
@@ -1438,11 +1438,11 @@
     if (!OffsetIsZero) {     // Suppress if Offset is known to be 0
       if (!OffsetIsNegative) // Suppress if Offset is known to be negative
         Str << "+";
-      Offset->dump(Func);
+      Offset->dump(Func, Str);
     }
   } else {
     // There is only the offset.
-    Offset->dump(Func);
+    Offset->dump(Func, Str);
   }
   Str << "]";
 }
@@ -1468,8 +1468,7 @@
   Str << "]";
 }
 
-void VariableSplit::dump(const Cfg *Func) const {
-  Ostream &Str = Func->getContext()->getStrDump();
+void VariableSplit::dump(const Cfg *Func, Ostream &Str) const {
   switch (Part) {
   case Low:
     Str << "low";
@@ -1482,7 +1481,10 @@
     break;
   }
   Str << "(";
-  Var->dump(Func);
+  if (Func)
+    Var->dump(Func);
+  else
+    Var->dump(Str);
   Str << ")";
 }