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/IceOperand.cpp b/src/IceOperand.cpp
index b718ba5..1f232dd 100644
--- a/src/IceOperand.cpp
+++ b/src/IceOperand.cpp
@@ -201,8 +201,11 @@
Func->getTarget()->emitVariable(this, Func);
}
-void Variable::dump(const Cfg *Func) const {
- Ostream &Str = Func->getContext()->getStrDump();
+void Variable::dump(const Cfg *Func, Ostream &Str) const {
+ if (Func == NULL) {
+ Str << "%" << getName();
+ return;
+ }
const CfgNode *CurrentNode = Func->getCurrentNode();
(void)CurrentNode; // used only in assert()
assert(CurrentNode == NULL || DefNode == NULL || DefNode == CurrentNode);
@@ -241,8 +244,7 @@
}
}
-void ConstantRelocatable::dump(GlobalContext *Ctx) const {
- Ostream &Str = Ctx->getStrDump();
+void ConstantRelocatable::dump(const Cfg *, Ostream &Str) const {
Str << "@" << Name;
if (Offset)
Str << "+" << Offset;