blob: 189fa0618eaffba89a498d4006862c3a889ef81a [file] [log] [blame]
Nicolas Geoffrayf635e632014-05-14 09:43:38 +01001/*
2 * Copyright (C) 2014 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17#include "graph_visualizer.h"
18
Nicolas Geoffraya7062e02014-05-22 12:50:17 +010019#include "code_generator.h"
David Brazdila4b8c212015-05-07 09:59:30 +010020#include "dead_code_elimination.h"
Andreas Gampe7c3952f2015-02-19 18:21:24 -080021#include "licm.h"
Nicolas Geoffrayf635e632014-05-14 09:43:38 +010022#include "nodes.h"
Nicolas Geoffray82091da2015-01-26 10:02:45 +000023#include "optimization.h"
Andreas Gampe7c3952f2015-02-19 18:21:24 -080024#include "register_allocator.h"
Nicolas Geoffrayddb311f2014-05-16 09:28:54 +010025#include "ssa_liveness_analysis.h"
Nicolas Geoffrayf635e632014-05-14 09:43:38 +010026
David Brazdilc74652862015-05-13 17:50:09 +010027#include <cctype>
28#include <sstream>
29
Nicolas Geoffrayf635e632014-05-14 09:43:38 +010030namespace art {
31
David Brazdilc74652862015-05-13 17:50:09 +010032static bool HasWhitespace(const char* str) {
33 DCHECK(str != nullptr);
34 while (str[0] != 0) {
35 if (isspace(str[0])) {
36 return true;
37 }
38 str++;
39 }
40 return false;
41}
42
43class StringList {
44 public:
45 // Create an empty list
46 StringList() : is_empty_(true) {}
47
48 // Construct StringList from a linked list. List element class T
49 // must provide methods `GetNext` and `Dump`.
50 template<class T>
51 StringList(T* first_entry)
52 : StringList() {
53 for (T* current = first_entry; current != nullptr; current = current->GetNext()) {
54 current->Dump(NewEntryStream());
55 }
56 }
57
58 std::ostream& NewEntryStream() {
59 if (is_empty_) {
60 is_empty_ = false;
61 } else {
62 sstream_ << " ";
63 }
64 return sstream_;
65 }
66
67 private:
68 bool is_empty_;
69 std::ostringstream sstream_;
70
71 friend std::ostream& operator<<(std::ostream& os, const StringList& list);
72};
73
74std::ostream& operator<<(std::ostream& os, const StringList& list) {
75 return os << "[ " << list.sstream_.str() << " ]";
76}
77
Nicolas Geoffrayf635e632014-05-14 09:43:38 +010078/**
79 * HGraph visitor to generate a file suitable for the c1visualizer tool and IRHydra.
80 */
81class HGraphVisualizerPrinter : public HGraphVisitor {
82 public:
Nicolas Geoffray86dbb9a2014-06-04 11:12:39 +010083 HGraphVisualizerPrinter(HGraph* graph,
84 std::ostream& output,
85 const char* pass_name,
Nicolas Geoffray840e5462015-01-07 16:01:24 +000086 bool is_after_pass,
Nicolas Geoffray86dbb9a2014-06-04 11:12:39 +010087 const CodeGenerator& codegen)
88 : HGraphVisitor(graph),
89 output_(output),
90 pass_name_(pass_name),
Nicolas Geoffray840e5462015-01-07 16:01:24 +000091 is_after_pass_(is_after_pass),
Nicolas Geoffray86dbb9a2014-06-04 11:12:39 +010092 codegen_(codegen),
93 indent_(0) {}
Nicolas Geoffrayf635e632014-05-14 09:43:38 +010094
95 void StartTag(const char* name) {
96 AddIndent();
97 output_ << "begin_" << name << std::endl;
98 indent_++;
99 }
100
101 void EndTag(const char* name) {
102 indent_--;
103 AddIndent();
104 output_ << "end_" << name << std::endl;
105 }
106
107 void PrintProperty(const char* name, const char* property) {
108 AddIndent();
109 output_ << name << " \"" << property << "\"" << std::endl;
110 }
111
112 void PrintProperty(const char* name, const char* property, int id) {
113 AddIndent();
114 output_ << name << " \"" << property << id << "\"" << std::endl;
115 }
116
117 void PrintEmptyProperty(const char* name) {
118 AddIndent();
119 output_ << name << std::endl;
120 }
121
122 void PrintTime(const char* name) {
123 AddIndent();
Jean Christophe Beyler0ada95d2014-12-04 11:20:20 -0800124 output_ << name << " " << time(nullptr) << std::endl;
Nicolas Geoffrayf635e632014-05-14 09:43:38 +0100125 }
126
127 void PrintInt(const char* name, int value) {
128 AddIndent();
129 output_ << name << " " << value << std::endl;
130 }
131
132 void AddIndent() {
133 for (size_t i = 0; i < indent_; ++i) {
134 output_ << " ";
135 }
136 }
137
Nicolas Geoffrayb09aacb2014-09-17 18:21:53 +0100138 char GetTypeId(Primitive::Type type) {
Nicolas Geoffray18efde52014-09-22 15:51:11 +0100139 // Note that Primitive::Descriptor would not work for us
140 // because it does not handle reference types (that is kPrimNot).
Nicolas Geoffrayb09aacb2014-09-17 18:21:53 +0100141 switch (type) {
142 case Primitive::kPrimBoolean: return 'z';
143 case Primitive::kPrimByte: return 'b';
144 case Primitive::kPrimChar: return 'c';
145 case Primitive::kPrimShort: return 's';
146 case Primitive::kPrimInt: return 'i';
147 case Primitive::kPrimLong: return 'j';
148 case Primitive::kPrimFloat: return 'f';
149 case Primitive::kPrimDouble: return 'd';
150 case Primitive::kPrimNot: return 'l';
151 case Primitive::kPrimVoid: return 'v';
152 }
153 LOG(FATAL) << "Unreachable";
154 return 'v';
155 }
156
Nicolas Geoffrayf635e632014-05-14 09:43:38 +0100157 void PrintPredecessors(HBasicBlock* block) {
158 AddIndent();
159 output_ << "predecessors";
160 for (size_t i = 0, e = block->GetPredecessors().Size(); i < e; ++i) {
161 HBasicBlock* predecessor = block->GetPredecessors().Get(i);
162 output_ << " \"B" << predecessor->GetBlockId() << "\" ";
163 }
164 output_<< std::endl;
165 }
166
167 void PrintSuccessors(HBasicBlock* block) {
168 AddIndent();
169 output_ << "successors";
170 for (size_t i = 0, e = block->GetSuccessors().Size(); i < e; ++i) {
171 HBasicBlock* successor = block->GetSuccessors().Get(i);
172 output_ << " \"B" << successor->GetBlockId() << "\" ";
173 }
174 output_<< std::endl;
175 }
176
David Brazdilc74652862015-05-13 17:50:09 +0100177 void DumpLocation(std::ostream& stream, const Location& location) {
Nicolas Geoffray86dbb9a2014-06-04 11:12:39 +0100178 if (location.IsRegister()) {
David Brazdilc74652862015-05-13 17:50:09 +0100179 codegen_.DumpCoreRegister(stream, location.reg());
Nicolas Geoffray102cbed2014-10-15 18:31:05 +0100180 } else if (location.IsFpuRegister()) {
David Brazdilc74652862015-05-13 17:50:09 +0100181 codegen_.DumpFloatingPointRegister(stream, location.reg());
Nicolas Geoffray96f89a22014-07-11 10:57:49 +0100182 } else if (location.IsConstant()) {
David Brazdilc74652862015-05-13 17:50:09 +0100183 stream << "#";
Nicolas Geoffray18efde52014-09-22 15:51:11 +0100184 HConstant* constant = location.GetConstant();
185 if (constant->IsIntConstant()) {
David Brazdilc74652862015-05-13 17:50:09 +0100186 stream << constant->AsIntConstant()->GetValue();
Nicolas Geoffray18efde52014-09-22 15:51:11 +0100187 } else if (constant->IsLongConstant()) {
David Brazdilc74652862015-05-13 17:50:09 +0100188 stream << constant->AsLongConstant()->GetValue();
Nicolas Geoffray18efde52014-09-22 15:51:11 +0100189 }
Nicolas Geoffray96f89a22014-07-11 10:57:49 +0100190 } else if (location.IsInvalid()) {
David Brazdilc74652862015-05-13 17:50:09 +0100191 stream << "invalid";
Nicolas Geoffray412f10c2014-06-19 10:00:34 +0100192 } else if (location.IsStackSlot()) {
David Brazdilc74652862015-05-13 17:50:09 +0100193 stream << location.GetStackIndex() << "(sp)";
Nicolas Geoffray840e5462015-01-07 16:01:24 +0000194 } else if (location.IsFpuRegisterPair()) {
David Brazdilc74652862015-05-13 17:50:09 +0100195 codegen_.DumpFloatingPointRegister(stream, location.low());
196 stream << "|";
197 codegen_.DumpFloatingPointRegister(stream, location.high());
Nicolas Geoffray6c2dff82015-01-21 14:56:54 +0000198 } else if (location.IsRegisterPair()) {
David Brazdilc74652862015-05-13 17:50:09 +0100199 codegen_.DumpCoreRegister(stream, location.low());
200 stream << "|";
201 codegen_.DumpCoreRegister(stream, location.high());
Mark Mendell09ed1a32015-03-25 08:30:06 -0400202 } else if (location.IsUnallocated()) {
David Brazdilc74652862015-05-13 17:50:09 +0100203 stream << "unallocated";
Nicolas Geoffray412f10c2014-06-19 10:00:34 +0100204 } else {
205 DCHECK(location.IsDoubleStackSlot());
David Brazdilc74652862015-05-13 17:50:09 +0100206 stream << "2x" << location.GetStackIndex() << "(sp)";
Nicolas Geoffray86dbb9a2014-06-04 11:12:39 +0100207 }
208 }
209
David Brazdilc74652862015-05-13 17:50:09 +0100210 std::ostream& StartAttributeStream(const char* name = nullptr) {
211 if (name == nullptr) {
212 output_ << " ";
213 } else {
214 DCHECK(!HasWhitespace(name)) << "Checker does not allow spaces in attributes";
215 output_ << " " << name << ":";
216 }
217 return output_;
218 }
219
David Brazdilb7e4a062014-12-29 15:35:02 +0000220 void VisitParallelMove(HParallelMove* instruction) OVERRIDE {
David Brazdilc74652862015-05-13 17:50:09 +0100221 StartAttributeStream("liveness") << instruction->GetLifetimePosition();
222 StringList moves;
Nicolas Geoffray86dbb9a2014-06-04 11:12:39 +0100223 for (size_t i = 0, e = instruction->NumMoves(); i < e; ++i) {
224 MoveOperands* move = instruction->MoveOperandsAt(i);
David Brazdilc74652862015-05-13 17:50:09 +0100225 std::ostream& str = moves.NewEntryStream();
226 DumpLocation(str, move->GetSource());
227 str << "->";
228 DumpLocation(str, move->GetDestination());
Nicolas Geoffray86dbb9a2014-06-04 11:12:39 +0100229 }
David Brazdilc74652862015-05-13 17:50:09 +0100230 StartAttributeStream("moves") << moves;
Nicolas Geoffray86dbb9a2014-06-04 11:12:39 +0100231 }
Nicolas Geoffrayf635e632014-05-14 09:43:38 +0100232
David Brazdil36cf0952015-01-08 19:28:33 +0000233 void VisitIntConstant(HIntConstant* instruction) OVERRIDE {
David Brazdilc74652862015-05-13 17:50:09 +0100234 StartAttributeStream() << instruction->GetValue();
David Brazdilb7e4a062014-12-29 15:35:02 +0000235 }
236
David Brazdil36cf0952015-01-08 19:28:33 +0000237 void VisitLongConstant(HLongConstant* instruction) OVERRIDE {
David Brazdilc74652862015-05-13 17:50:09 +0100238 StartAttributeStream() << instruction->GetValue();
David Brazdilb7e4a062014-12-29 15:35:02 +0000239 }
240
David Brazdil36cf0952015-01-08 19:28:33 +0000241 void VisitFloatConstant(HFloatConstant* instruction) OVERRIDE {
David Brazdilc74652862015-05-13 17:50:09 +0100242 StartAttributeStream() << instruction->GetValue();
David Brazdilb7e4a062014-12-29 15:35:02 +0000243 }
244
David Brazdil36cf0952015-01-08 19:28:33 +0000245 void VisitDoubleConstant(HDoubleConstant* instruction) OVERRIDE {
David Brazdilc74652862015-05-13 17:50:09 +0100246 StartAttributeStream() << instruction->GetValue();
David Brazdilb7e4a062014-12-29 15:35:02 +0000247 }
248
Nicolas Geoffrayd6138ef2015-02-18 14:48:53 +0000249 void VisitPhi(HPhi* phi) OVERRIDE {
David Brazdilc74652862015-05-13 17:50:09 +0100250 StartAttributeStream("reg") << phi->GetRegNumber();
Nicolas Geoffrayd6138ef2015-02-18 14:48:53 +0000251 }
252
Calin Juravle27df7582015-04-17 19:12:31 +0100253 void VisitMemoryBarrier(HMemoryBarrier* barrier) OVERRIDE {
David Brazdilc74652862015-05-13 17:50:09 +0100254 StartAttributeStream("kind") << barrier->GetBarrierKind();
Calin Juravle27df7582015-04-17 19:12:31 +0100255 }
256
Andreas Gampe7c3952f2015-02-19 18:21:24 -0800257 bool IsPass(const char* name) {
258 return strcmp(pass_name_, name) == 0;
259 }
260
David Brazdilb7e4a062014-12-29 15:35:02 +0000261 void PrintInstruction(HInstruction* instruction) {
Nicolas Geoffrayf635e632014-05-14 09:43:38 +0100262 output_ << instruction->DebugName();
263 if (instruction->InputCount() > 0) {
David Brazdilc74652862015-05-13 17:50:09 +0100264 StringList inputs;
265 for (HInputIterator it(instruction); !it.Done(); it.Advance()) {
266 inputs.NewEntryStream() << GetTypeId(it.Current()->GetType()) << it.Current()->GetId();
Nicolas Geoffrayf635e632014-05-14 09:43:38 +0100267 }
David Brazdilc74652862015-05-13 17:50:09 +0100268 StartAttributeStream() << inputs;
Nicolas Geoffrayf635e632014-05-14 09:43:38 +0100269 }
David Brazdilc74652862015-05-13 17:50:09 +0100270 instruction->Accept(this);
Zheng Xubb7a28a2015-01-09 14:40:47 +0800271 if (instruction->HasEnvironment()) {
David Brazdilc74652862015-05-13 17:50:09 +0100272 StringList envs;
Nicolas Geoffray0a23d742015-05-07 11:57:35 +0100273 for (HEnvironment* environment = instruction->GetEnvironment();
274 environment != nullptr;
275 environment = environment->GetParent()) {
David Brazdilc74652862015-05-13 17:50:09 +0100276 StringList vregs;
Nicolas Geoffray0a23d742015-05-07 11:57:35 +0100277 for (size_t i = 0, e = environment->Size(); i < e; ++i) {
278 HInstruction* insn = environment->GetInstructionAt(i);
279 if (insn != nullptr) {
David Brazdilc74652862015-05-13 17:50:09 +0100280 vregs.NewEntryStream() << GetTypeId(insn->GetType()) << insn->GetId();
Nicolas Geoffray0a23d742015-05-07 11:57:35 +0100281 } else {
David Brazdilc74652862015-05-13 17:50:09 +0100282 vregs.NewEntryStream() << "_";
Nicolas Geoffray0a23d742015-05-07 11:57:35 +0100283 }
Zheng Xubb7a28a2015-01-09 14:40:47 +0800284 }
David Brazdilc74652862015-05-13 17:50:09 +0100285 envs.NewEntryStream() << vregs;
Zheng Xubb7a28a2015-01-09 14:40:47 +0800286 }
David Brazdilc74652862015-05-13 17:50:09 +0100287 StartAttributeStream("env") << envs;
Zheng Xubb7a28a2015-01-09 14:40:47 +0800288 }
Andreas Gampe7c3952f2015-02-19 18:21:24 -0800289 if (IsPass(SsaLivenessAnalysis::kLivenessPassName)
David Brazdil5e8b1372015-01-23 14:39:08 +0000290 && is_after_pass_
291 && instruction->GetLifetimePosition() != kNoLifetime) {
David Brazdilc74652862015-05-13 17:50:09 +0100292 StartAttributeStream("liveness") << instruction->GetLifetimePosition();
Nicolas Geoffrayddb311f2014-05-16 09:28:54 +0100293 if (instruction->HasLiveInterval()) {
David Brazdilc74652862015-05-13 17:50:09 +0100294 LiveInterval* interval = instruction->GetLiveInterval();
295 StartAttributeStream("ranges") << StringList(interval->GetFirstRange());
296 StartAttributeStream("uses") << StringList(interval->GetFirstUse());
297 StartAttributeStream("env_uses") << StringList(interval->GetFirstEnvironmentUse());
298 StartAttributeStream("is_fixed") << interval->IsFixed();
299 StartAttributeStream("is_split") << interval->IsSplit();
300 StartAttributeStream("is_low") << interval->IsLowInterval();
301 StartAttributeStream("is_high") << interval->IsHighInterval();
Nicolas Geoffrayddb311f2014-05-16 09:28:54 +0100302 }
Andreas Gampe7c3952f2015-02-19 18:21:24 -0800303 } else if (IsPass(RegisterAllocator::kRegisterAllocatorPassName) && is_after_pass_) {
David Brazdilc74652862015-05-13 17:50:09 +0100304 StartAttributeStream("liveness") << instruction->GetLifetimePosition();
Nicolas Geoffray86dbb9a2014-06-04 11:12:39 +0100305 LocationSummary* locations = instruction->GetLocations();
306 if (locations != nullptr) {
David Brazdilc74652862015-05-13 17:50:09 +0100307 StringList inputs;
Nicolas Geoffray86dbb9a2014-06-04 11:12:39 +0100308 for (size_t i = 0; i < instruction->InputCount(); ++i) {
David Brazdilc74652862015-05-13 17:50:09 +0100309 DumpLocation(inputs.NewEntryStream(), locations->InAt(i));
Nicolas Geoffray86dbb9a2014-06-04 11:12:39 +0100310 }
David Brazdilc74652862015-05-13 17:50:09 +0100311 std::ostream& attr = StartAttributeStream("locations");
312 attr << inputs << "->";
313 DumpLocation(attr, locations->Out());
Nicolas Geoffray86dbb9a2014-06-04 11:12:39 +0100314 }
David Brazdila4b8c212015-05-07 09:59:30 +0100315 } else if (IsPass(LICM::kLoopInvariantCodeMotionPassName)
316 || IsPass(HDeadCodeElimination::kFinalDeadCodeEliminationPassName)) {
Nicolas Geoffray82091da2015-01-26 10:02:45 +0000317 HLoopInformation* info = instruction->GetBlock()->GetLoopInformation();
318 if (info == nullptr) {
David Brazdilc74652862015-05-13 17:50:09 +0100319 StartAttributeStream("loop") << "none";
Nicolas Geoffray82091da2015-01-26 10:02:45 +0000320 } else {
David Brazdilc74652862015-05-13 17:50:09 +0100321 StartAttributeStream("loop") << "B" << info->GetHeader()->GetBlockId();
Nicolas Geoffray82091da2015-01-26 10:02:45 +0000322 }
Nicolas Geoffrayddb311f2014-05-16 09:28:54 +0100323 }
Nicolas Geoffrayf635e632014-05-14 09:43:38 +0100324 }
325
326 void PrintInstructions(const HInstructionList& list) {
327 const char* kEndInstructionMarker = "<|@";
328 for (HInstructionIterator it(list); !it.Done(); it.Advance()) {
329 HInstruction* instruction = it.Current();
Nicolas Geoffrayf635e632014-05-14 09:43:38 +0100330 int bci = 0;
David Brazdilea55b932015-01-27 17:12:29 +0000331 size_t num_uses = 0;
332 for (HUseIterator<HInstruction*> use_it(instruction->GetUses());
333 !use_it.Done();
334 use_it.Advance()) {
335 ++num_uses;
336 }
337 AddIndent();
338 output_ << bci << " " << num_uses << " "
339 << GetTypeId(instruction->GetType()) << instruction->GetId() << " ";
David Brazdilb7e4a062014-12-29 15:35:02 +0000340 PrintInstruction(instruction);
David Brazdilc74652862015-05-13 17:50:09 +0100341 output_ << " " << kEndInstructionMarker << std::endl;
Nicolas Geoffrayf635e632014-05-14 09:43:38 +0100342 }
343 }
344
Nicolas Geoffray86dbb9a2014-06-04 11:12:39 +0100345 void Run() {
Nicolas Geoffrayf635e632014-05-14 09:43:38 +0100346 StartTag("cfg");
Nicolas Geoffray840e5462015-01-07 16:01:24 +0000347 std::string pass_desc = std::string(pass_name_) + (is_after_pass_ ? " (after)" : " (before)");
348 PrintProperty("name", pass_desc.c_str());
Nicolas Geoffrayf635e632014-05-14 09:43:38 +0100349 VisitInsertionOrder();
350 EndTag("cfg");
351 }
352
David Brazdilb7e4a062014-12-29 15:35:02 +0000353 void VisitBasicBlock(HBasicBlock* block) OVERRIDE {
Nicolas Geoffrayf635e632014-05-14 09:43:38 +0100354 StartTag("block");
355 PrintProperty("name", "B", block->GetBlockId());
Nicolas Geoffrayddb311f2014-05-16 09:28:54 +0100356 if (block->GetLifetimeStart() != kNoLifetime) {
357 // Piggy back on these fields to show the lifetime of the block.
358 PrintInt("from_bci", block->GetLifetimeStart());
359 PrintInt("to_bci", block->GetLifetimeEnd());
360 } else {
361 PrintInt("from_bci", -1);
362 PrintInt("to_bci", -1);
363 }
Nicolas Geoffrayf635e632014-05-14 09:43:38 +0100364 PrintPredecessors(block);
365 PrintSuccessors(block);
366 PrintEmptyProperty("xhandlers");
367 PrintEmptyProperty("flags");
368 if (block->GetDominator() != nullptr) {
369 PrintProperty("dominator", "B", block->GetDominator()->GetBlockId());
370 }
371
372 StartTag("states");
373 StartTag("locals");
374 PrintInt("size", 0);
375 PrintProperty("method", "None");
376 for (HInstructionIterator it(block->GetPhis()); !it.Done(); it.Advance()) {
377 AddIndent();
378 HInstruction* instruction = it.Current();
Nicolas Geoffrayb09aacb2014-09-17 18:21:53 +0100379 output_ << instruction->GetId() << " " << GetTypeId(instruction->GetType())
380 << instruction->GetId() << "[ ";
Nicolas Geoffrayf635e632014-05-14 09:43:38 +0100381 for (HInputIterator inputs(instruction); !inputs.Done(); inputs.Advance()) {
382 output_ << inputs.Current()->GetId() << " ";
383 }
384 output_ << "]" << std::endl;
385 }
386 EndTag("locals");
387 EndTag("states");
388
389 StartTag("HIR");
390 PrintInstructions(block->GetPhis());
391 PrintInstructions(block->GetInstructions());
392 EndTag("HIR");
393 EndTag("block");
394 }
395
396 private:
397 std::ostream& output_;
Nicolas Geoffray86dbb9a2014-06-04 11:12:39 +0100398 const char* pass_name_;
Nicolas Geoffray840e5462015-01-07 16:01:24 +0000399 const bool is_after_pass_;
Nicolas Geoffraya7062e02014-05-22 12:50:17 +0100400 const CodeGenerator& codegen_;
Nicolas Geoffrayf635e632014-05-14 09:43:38 +0100401 size_t indent_;
402
403 DISALLOW_COPY_AND_ASSIGN(HGraphVisualizerPrinter);
404};
405
406HGraphVisualizer::HGraphVisualizer(std::ostream* output,
407 HGraph* graph,
David Brazdil62e074f2015-04-07 18:09:37 +0100408 const CodeGenerator& codegen)
409 : output_(output), graph_(graph), codegen_(codegen) {}
Nicolas Geoffrayf635e632014-05-14 09:43:38 +0100410
David Brazdil62e074f2015-04-07 18:09:37 +0100411void HGraphVisualizer::PrintHeader(const char* method_name) const {
412 DCHECK(output_ != nullptr);
Nicolas Geoffray840e5462015-01-07 16:01:24 +0000413 HGraphVisualizerPrinter printer(graph_, *output_, "", true, codegen_);
Nicolas Geoffrayf635e632014-05-14 09:43:38 +0100414 printer.StartTag("compilation");
Nicolas Geoffraye53798a2014-12-01 10:31:54 +0000415 printer.PrintProperty("name", method_name);
416 printer.PrintProperty("method", method_name);
Nicolas Geoffray0d3f5782014-05-14 09:43:38 +0100417 printer.PrintTime("date");
418 printer.EndTag("compilation");
419}
420
David Brazdilee690a32014-12-01 17:04:16 +0000421void HGraphVisualizer::DumpGraph(const char* pass_name, bool is_after_pass) const {
David Brazdil5e8b1372015-01-23 14:39:08 +0000422 DCHECK(output_ != nullptr);
423 if (!graph_->GetBlocks().IsEmpty()) {
Nicolas Geoffray840e5462015-01-07 16:01:24 +0000424 HGraphVisualizerPrinter printer(graph_, *output_, pass_name, is_after_pass, codegen_);
David Brazdilee690a32014-12-01 17:04:16 +0000425 printer.Run();
Nicolas Geoffrayf635e632014-05-14 09:43:38 +0100426 }
Nicolas Geoffrayf635e632014-05-14 09:43:38 +0100427}
428
429} // namespace art