diff options
Diffstat (limited to 'compiler/optimizing/graph_visualizer.cc')
| -rw-r--r-- | compiler/optimizing/graph_visualizer.cc | 53 |
1 files changed, 40 insertions, 13 deletions
diff --git a/compiler/optimizing/graph_visualizer.cc b/compiler/optimizing/graph_visualizer.cc index 5d1703e237..df21c8e9c3 100644 --- a/compiler/optimizing/graph_visualizer.cc +++ b/compiler/optimizing/graph_visualizer.cc @@ -30,10 +30,12 @@ class HGraphVisualizerPrinter : public HGraphVisitor { HGraphVisualizerPrinter(HGraph* graph, std::ostream& output, const char* pass_name, + bool is_after_pass, const CodeGenerator& codegen) : HGraphVisitor(graph), output_(output), pass_name_(pass_name), + is_after_pass_(is_after_pass), codegen_(codegen), indent_(0) {} @@ -136,14 +138,21 @@ class HGraphVisualizerPrinter : public HGraphVisitor { output_ << "invalid"; } else if (location.IsStackSlot()) { output_ << location.GetStackIndex() << "(sp)"; + } else if (location.IsFpuRegisterPair()) { + codegen_.DumpFloatingPointRegister(output_, location.low()); + output_ << " and "; + codegen_.DumpFloatingPointRegister(output_, location.high()); + } else if (location.IsRegisterPair()) { + codegen_.DumpCoreRegister(output_, location.low()); + output_ << " and "; + codegen_.DumpCoreRegister(output_, location.high()); } else { DCHECK(location.IsDoubleStackSlot()); output_ << "2x" << location.GetStackIndex() << "(sp)"; } } - void VisitParallelMove(HParallelMove* instruction) { - output_ << instruction->DebugName(); + void VisitParallelMove(HParallelMove* instruction) OVERRIDE { output_ << " ("; for (size_t i = 0, e = instruction->NumMoves(); i < e; ++i) { MoveOperands* move = instruction->MoveOperandsAt(i); @@ -158,8 +167,25 @@ class HGraphVisualizerPrinter : public HGraphVisitor { output_ << " (liveness: " << instruction->GetLifetimePosition() << ")"; } - void VisitInstruction(HInstruction* instruction) { + void VisitIntConstant(HIntConstant* instruction) OVERRIDE { + output_ << " " << instruction->GetValue(); + } + + void VisitLongConstant(HLongConstant* instruction) OVERRIDE { + output_ << " " << instruction->GetValue(); + } + + void VisitFloatConstant(HFloatConstant* instruction) OVERRIDE { + output_ << " " << instruction->GetValue(); + } + + void VisitDoubleConstant(HDoubleConstant* instruction) OVERRIDE { + output_ << " " << instruction->GetValue(); + } + + void PrintInstruction(HInstruction* instruction) { output_ << instruction->DebugName(); + instruction->Accept(this); if (instruction->InputCount() > 0) { output_ << " [ "; for (HInputIterator inputs(instruction); !inputs.Done(); inputs.Advance()) { @@ -201,19 +227,20 @@ class HGraphVisualizerPrinter : public HGraphVisitor { int bci = 0; output_ << bci << " " << instruction->NumberOfUses() << " " << GetTypeId(instruction->GetType()) << instruction->GetId() << " "; - instruction->Accept(this); + PrintInstruction(instruction); output_ << kEndInstructionMarker << std::endl; } } void Run() { StartTag("cfg"); - PrintProperty("name", pass_name_); + std::string pass_desc = std::string(pass_name_) + (is_after_pass_ ? " (after)" : " (before)"); + PrintProperty("name", pass_desc.c_str()); VisitInsertionOrder(); EndTag("cfg"); } - void VisitBasicBlock(HBasicBlock* block) { + void VisitBasicBlock(HBasicBlock* block) OVERRIDE { StartTag("block"); PrintProperty("name", "B", block->GetBlockId()); if (block->GetLifetimeStart() != kNoLifetime) { @@ -259,6 +286,7 @@ class HGraphVisualizerPrinter : public HGraphVisitor { private: std::ostream& output_; const char* pass_name_; + const bool is_after_pass_; const CodeGenerator& codegen_; size_t indent_; @@ -270,7 +298,7 @@ HGraphVisualizer::HGraphVisualizer(std::ostream* output, const char* string_filter, const CodeGenerator& codegen, const char* method_name) - : output_(output), graph_(graph), codegen_(codegen), is_enabled_(false) { + : output_(output), graph_(graph), codegen_(codegen), is_enabled_(false) { if (output == nullptr) { return; } @@ -279,7 +307,7 @@ HGraphVisualizer::HGraphVisualizer(std::ostream* output, } is_enabled_ = true; - HGraphVisualizerPrinter printer(graph, *output_, "", codegen_); + HGraphVisualizerPrinter printer(graph_, *output_, "", true, codegen_); printer.StartTag("compilation"); printer.PrintProperty("name", method_name); printer.PrintProperty("method", method_name); @@ -287,12 +315,11 @@ HGraphVisualizer::HGraphVisualizer(std::ostream* output, printer.EndTag("compilation"); } -void HGraphVisualizer::DumpGraph(const char* pass_name) const { - if (!is_enabled_) { - return; +void HGraphVisualizer::DumpGraph(const char* pass_name, bool is_after_pass) const { + if (is_enabled_) { + HGraphVisualizerPrinter printer(graph_, *output_, pass_name, is_after_pass, codegen_); + printer.Run(); } - HGraphVisualizerPrinter printer(graph_, *output_, pass_name, codegen_); - printer.Run(); } } // namespace art |
