Nicolas Geoffray | f635e63 | 2014-05-14 09:43:38 +0100 | [diff] [blame] | 1 | /* |
| 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 Geoffray | a7062e0 | 2014-05-22 12:50:17 +0100 | [diff] [blame] | 19 | #include "code_generator.h" |
Nicolas Geoffray | f635e63 | 2014-05-14 09:43:38 +0100 | [diff] [blame] | 20 | #include "nodes.h" |
Nicolas Geoffray | 82091da | 2015-01-26 10:02:45 +0000 | [diff] [blame] | 21 | #include "optimization.h" |
Nicolas Geoffray | ddb311f | 2014-05-16 09:28:54 +0100 | [diff] [blame] | 22 | #include "ssa_liveness_analysis.h" |
Nicolas Geoffray | f635e63 | 2014-05-14 09:43:38 +0100 | [diff] [blame] | 23 | |
| 24 | namespace art { |
| 25 | |
| 26 | /** |
| 27 | * HGraph visitor to generate a file suitable for the c1visualizer tool and IRHydra. |
| 28 | */ |
| 29 | class HGraphVisualizerPrinter : public HGraphVisitor { |
| 30 | public: |
Nicolas Geoffray | 86dbb9a | 2014-06-04 11:12:39 +0100 | [diff] [blame] | 31 | HGraphVisualizerPrinter(HGraph* graph, |
| 32 | std::ostream& output, |
| 33 | const char* pass_name, |
Nicolas Geoffray | 840e546 | 2015-01-07 16:01:24 +0000 | [diff] [blame] | 34 | bool is_after_pass, |
Nicolas Geoffray | 86dbb9a | 2014-06-04 11:12:39 +0100 | [diff] [blame] | 35 | const CodeGenerator& codegen) |
| 36 | : HGraphVisitor(graph), |
| 37 | output_(output), |
| 38 | pass_name_(pass_name), |
Nicolas Geoffray | 840e546 | 2015-01-07 16:01:24 +0000 | [diff] [blame] | 39 | is_after_pass_(is_after_pass), |
Nicolas Geoffray | 86dbb9a | 2014-06-04 11:12:39 +0100 | [diff] [blame] | 40 | codegen_(codegen), |
| 41 | indent_(0) {} |
Nicolas Geoffray | f635e63 | 2014-05-14 09:43:38 +0100 | [diff] [blame] | 42 | |
| 43 | void StartTag(const char* name) { |
| 44 | AddIndent(); |
| 45 | output_ << "begin_" << name << std::endl; |
| 46 | indent_++; |
| 47 | } |
| 48 | |
| 49 | void EndTag(const char* name) { |
| 50 | indent_--; |
| 51 | AddIndent(); |
| 52 | output_ << "end_" << name << std::endl; |
| 53 | } |
| 54 | |
| 55 | void PrintProperty(const char* name, const char* property) { |
| 56 | AddIndent(); |
| 57 | output_ << name << " \"" << property << "\"" << std::endl; |
| 58 | } |
| 59 | |
| 60 | void PrintProperty(const char* name, const char* property, int id) { |
| 61 | AddIndent(); |
| 62 | output_ << name << " \"" << property << id << "\"" << std::endl; |
| 63 | } |
| 64 | |
| 65 | void PrintEmptyProperty(const char* name) { |
| 66 | AddIndent(); |
| 67 | output_ << name << std::endl; |
| 68 | } |
| 69 | |
| 70 | void PrintTime(const char* name) { |
| 71 | AddIndent(); |
Jean Christophe Beyler | 0ada95d | 2014-12-04 11:20:20 -0800 | [diff] [blame] | 72 | output_ << name << " " << time(nullptr) << std::endl; |
Nicolas Geoffray | f635e63 | 2014-05-14 09:43:38 +0100 | [diff] [blame] | 73 | } |
| 74 | |
| 75 | void PrintInt(const char* name, int value) { |
| 76 | AddIndent(); |
| 77 | output_ << name << " " << value << std::endl; |
| 78 | } |
| 79 | |
| 80 | void AddIndent() { |
| 81 | for (size_t i = 0; i < indent_; ++i) { |
| 82 | output_ << " "; |
| 83 | } |
| 84 | } |
| 85 | |
Nicolas Geoffray | b09aacb | 2014-09-17 18:21:53 +0100 | [diff] [blame] | 86 | char GetTypeId(Primitive::Type type) { |
Nicolas Geoffray | 18efde5 | 2014-09-22 15:51:11 +0100 | [diff] [blame] | 87 | // Note that Primitive::Descriptor would not work for us |
| 88 | // because it does not handle reference types (that is kPrimNot). |
Nicolas Geoffray | b09aacb | 2014-09-17 18:21:53 +0100 | [diff] [blame] | 89 | switch (type) { |
| 90 | case Primitive::kPrimBoolean: return 'z'; |
| 91 | case Primitive::kPrimByte: return 'b'; |
| 92 | case Primitive::kPrimChar: return 'c'; |
| 93 | case Primitive::kPrimShort: return 's'; |
| 94 | case Primitive::kPrimInt: return 'i'; |
| 95 | case Primitive::kPrimLong: return 'j'; |
| 96 | case Primitive::kPrimFloat: return 'f'; |
| 97 | case Primitive::kPrimDouble: return 'd'; |
| 98 | case Primitive::kPrimNot: return 'l'; |
| 99 | case Primitive::kPrimVoid: return 'v'; |
| 100 | } |
| 101 | LOG(FATAL) << "Unreachable"; |
| 102 | return 'v'; |
| 103 | } |
| 104 | |
Nicolas Geoffray | f635e63 | 2014-05-14 09:43:38 +0100 | [diff] [blame] | 105 | void PrintPredecessors(HBasicBlock* block) { |
| 106 | AddIndent(); |
| 107 | output_ << "predecessors"; |
| 108 | for (size_t i = 0, e = block->GetPredecessors().Size(); i < e; ++i) { |
| 109 | HBasicBlock* predecessor = block->GetPredecessors().Get(i); |
| 110 | output_ << " \"B" << predecessor->GetBlockId() << "\" "; |
| 111 | } |
| 112 | output_<< std::endl; |
| 113 | } |
| 114 | |
| 115 | void PrintSuccessors(HBasicBlock* block) { |
| 116 | AddIndent(); |
| 117 | output_ << "successors"; |
| 118 | for (size_t i = 0, e = block->GetSuccessors().Size(); i < e; ++i) { |
| 119 | HBasicBlock* successor = block->GetSuccessors().Get(i); |
| 120 | output_ << " \"B" << successor->GetBlockId() << "\" "; |
| 121 | } |
| 122 | output_<< std::endl; |
| 123 | } |
| 124 | |
Nicolas Geoffray | 102cbed | 2014-10-15 18:31:05 +0100 | [diff] [blame] | 125 | void DumpLocation(Location location) { |
Nicolas Geoffray | 86dbb9a | 2014-06-04 11:12:39 +0100 | [diff] [blame] | 126 | if (location.IsRegister()) { |
Nicolas Geoffray | 102cbed | 2014-10-15 18:31:05 +0100 | [diff] [blame] | 127 | codegen_.DumpCoreRegister(output_, location.reg()); |
| 128 | } else if (location.IsFpuRegister()) { |
| 129 | codegen_.DumpFloatingPointRegister(output_, location.reg()); |
Nicolas Geoffray | 96f89a2 | 2014-07-11 10:57:49 +0100 | [diff] [blame] | 130 | } else if (location.IsConstant()) { |
| 131 | output_ << "constant"; |
Nicolas Geoffray | 18efde5 | 2014-09-22 15:51:11 +0100 | [diff] [blame] | 132 | HConstant* constant = location.GetConstant(); |
| 133 | if (constant->IsIntConstant()) { |
| 134 | output_ << " " << constant->AsIntConstant()->GetValue(); |
| 135 | } else if (constant->IsLongConstant()) { |
| 136 | output_ << " " << constant->AsLongConstant()->GetValue(); |
| 137 | } |
Nicolas Geoffray | 96f89a2 | 2014-07-11 10:57:49 +0100 | [diff] [blame] | 138 | } else if (location.IsInvalid()) { |
| 139 | output_ << "invalid"; |
Nicolas Geoffray | 412f10c | 2014-06-19 10:00:34 +0100 | [diff] [blame] | 140 | } else if (location.IsStackSlot()) { |
Nicolas Geoffray | 86dbb9a | 2014-06-04 11:12:39 +0100 | [diff] [blame] | 141 | output_ << location.GetStackIndex() << "(sp)"; |
Nicolas Geoffray | 840e546 | 2015-01-07 16:01:24 +0000 | [diff] [blame] | 142 | } else if (location.IsFpuRegisterPair()) { |
| 143 | codegen_.DumpFloatingPointRegister(output_, location.low()); |
| 144 | output_ << " and "; |
| 145 | codegen_.DumpFloatingPointRegister(output_, location.high()); |
Nicolas Geoffray | 6c2dff8 | 2015-01-21 14:56:54 +0000 | [diff] [blame] | 146 | } else if (location.IsRegisterPair()) { |
| 147 | codegen_.DumpCoreRegister(output_, location.low()); |
| 148 | output_ << " and "; |
| 149 | codegen_.DumpCoreRegister(output_, location.high()); |
Nicolas Geoffray | 412f10c | 2014-06-19 10:00:34 +0100 | [diff] [blame] | 150 | } else { |
| 151 | DCHECK(location.IsDoubleStackSlot()); |
| 152 | output_ << "2x" << location.GetStackIndex() << "(sp)"; |
Nicolas Geoffray | 86dbb9a | 2014-06-04 11:12:39 +0100 | [diff] [blame] | 153 | } |
| 154 | } |
| 155 | |
David Brazdil | b7e4a06 | 2014-12-29 15:35:02 +0000 | [diff] [blame] | 156 | void VisitParallelMove(HParallelMove* instruction) OVERRIDE { |
Nicolas Geoffray | 86dbb9a | 2014-06-04 11:12:39 +0100 | [diff] [blame] | 157 | output_ << " ("; |
| 158 | for (size_t i = 0, e = instruction->NumMoves(); i < e; ++i) { |
| 159 | MoveOperands* move = instruction->MoveOperandsAt(i); |
Nicolas Geoffray | 102cbed | 2014-10-15 18:31:05 +0100 | [diff] [blame] | 160 | DumpLocation(move->GetSource()); |
Nicolas Geoffray | 86dbb9a | 2014-06-04 11:12:39 +0100 | [diff] [blame] | 161 | output_ << " -> "; |
Nicolas Geoffray | 102cbed | 2014-10-15 18:31:05 +0100 | [diff] [blame] | 162 | DumpLocation(move->GetDestination()); |
Nicolas Geoffray | 86dbb9a | 2014-06-04 11:12:39 +0100 | [diff] [blame] | 163 | if (i + 1 != e) { |
| 164 | output_ << ", "; |
| 165 | } |
| 166 | } |
| 167 | output_ << ")"; |
Nicolas Geoffray | 26a25ef | 2014-09-30 13:54:09 +0100 | [diff] [blame] | 168 | output_ << " (liveness: " << instruction->GetLifetimePosition() << ")"; |
Nicolas Geoffray | 86dbb9a | 2014-06-04 11:12:39 +0100 | [diff] [blame] | 169 | } |
Nicolas Geoffray | f635e63 | 2014-05-14 09:43:38 +0100 | [diff] [blame] | 170 | |
David Brazdil | 36cf095 | 2015-01-08 19:28:33 +0000 | [diff] [blame] | 171 | void VisitIntConstant(HIntConstant* instruction) OVERRIDE { |
David Brazdil | b7e4a06 | 2014-12-29 15:35:02 +0000 | [diff] [blame] | 172 | output_ << " " << instruction->GetValue(); |
| 173 | } |
| 174 | |
David Brazdil | 36cf095 | 2015-01-08 19:28:33 +0000 | [diff] [blame] | 175 | void VisitLongConstant(HLongConstant* instruction) OVERRIDE { |
David Brazdil | b7e4a06 | 2014-12-29 15:35:02 +0000 | [diff] [blame] | 176 | output_ << " " << instruction->GetValue(); |
| 177 | } |
| 178 | |
David Brazdil | 36cf095 | 2015-01-08 19:28:33 +0000 | [diff] [blame] | 179 | void VisitFloatConstant(HFloatConstant* instruction) OVERRIDE { |
David Brazdil | b7e4a06 | 2014-12-29 15:35:02 +0000 | [diff] [blame] | 180 | output_ << " " << instruction->GetValue(); |
| 181 | } |
| 182 | |
David Brazdil | 36cf095 | 2015-01-08 19:28:33 +0000 | [diff] [blame] | 183 | void VisitDoubleConstant(HDoubleConstant* instruction) OVERRIDE { |
David Brazdil | b7e4a06 | 2014-12-29 15:35:02 +0000 | [diff] [blame] | 184 | output_ << " " << instruction->GetValue(); |
| 185 | } |
| 186 | |
| 187 | void PrintInstruction(HInstruction* instruction) { |
Nicolas Geoffray | f635e63 | 2014-05-14 09:43:38 +0100 | [diff] [blame] | 188 | output_ << instruction->DebugName(); |
David Brazdil | b7e4a06 | 2014-12-29 15:35:02 +0000 | [diff] [blame] | 189 | instruction->Accept(this); |
Nicolas Geoffray | f635e63 | 2014-05-14 09:43:38 +0100 | [diff] [blame] | 190 | if (instruction->InputCount() > 0) { |
| 191 | output_ << " [ "; |
| 192 | for (HInputIterator inputs(instruction); !inputs.Done(); inputs.Advance()) { |
Nicolas Geoffray | b09aacb | 2014-09-17 18:21:53 +0100 | [diff] [blame] | 193 | output_ << GetTypeId(inputs.Current()->GetType()) << inputs.Current()->GetId() << " "; |
Nicolas Geoffray | f635e63 | 2014-05-14 09:43:38 +0100 | [diff] [blame] | 194 | } |
| 195 | output_ << "]"; |
| 196 | } |
Zheng Xu | bb7a28a | 2015-01-09 14:40:47 +0800 | [diff] [blame] | 197 | if (instruction->HasEnvironment()) { |
| 198 | HEnvironment* env = instruction->GetEnvironment(); |
| 199 | output_ << " (env: [ "; |
| 200 | for (size_t i = 0, e = env->Size(); i < e; ++i) { |
| 201 | HInstruction* insn = env->GetInstructionAt(i); |
| 202 | if (insn != nullptr) { |
| 203 | output_ << GetTypeId(insn->GetType()) << insn->GetId() << " "; |
| 204 | } else { |
| 205 | output_ << " _ "; |
| 206 | } |
| 207 | } |
| 208 | output_ << "])"; |
| 209 | } |
David Brazdil | 5e8b137 | 2015-01-23 14:39:08 +0000 | [diff] [blame] | 210 | if (pass_name_ == kLivenessPassName |
| 211 | && is_after_pass_ |
| 212 | && instruction->GetLifetimePosition() != kNoLifetime) { |
Nicolas Geoffray | ddb311f | 2014-05-16 09:28:54 +0100 | [diff] [blame] | 213 | output_ << " (liveness: " << instruction->GetLifetimePosition(); |
| 214 | if (instruction->HasLiveInterval()) { |
| 215 | output_ << " "; |
Nicolas Geoffray | a7062e0 | 2014-05-22 12:50:17 +0100 | [diff] [blame] | 216 | const LiveInterval& interval = *instruction->GetLiveInterval(); |
| 217 | interval.Dump(output_); |
Nicolas Geoffray | ddb311f | 2014-05-16 09:28:54 +0100 | [diff] [blame] | 218 | } |
| 219 | output_ << ")"; |
David Brazdil | 5e8b137 | 2015-01-23 14:39:08 +0000 | [diff] [blame] | 220 | } else if (pass_name_ == kRegisterAllocatorPassName && is_after_pass_) { |
Nicolas Geoffray | 86dbb9a | 2014-06-04 11:12:39 +0100 | [diff] [blame] | 221 | LocationSummary* locations = instruction->GetLocations(); |
| 222 | if (locations != nullptr) { |
| 223 | output_ << " ( "; |
| 224 | for (size_t i = 0; i < instruction->InputCount(); ++i) { |
Nicolas Geoffray | 102cbed | 2014-10-15 18:31:05 +0100 | [diff] [blame] | 225 | DumpLocation(locations->InAt(i)); |
Nicolas Geoffray | 86dbb9a | 2014-06-04 11:12:39 +0100 | [diff] [blame] | 226 | output_ << " "; |
| 227 | } |
| 228 | output_ << ")"; |
| 229 | if (locations->Out().IsValid()) { |
| 230 | output_ << " -> "; |
Nicolas Geoffray | 102cbed | 2014-10-15 18:31:05 +0100 | [diff] [blame] | 231 | DumpLocation(locations->Out()); |
Nicolas Geoffray | 86dbb9a | 2014-06-04 11:12:39 +0100 | [diff] [blame] | 232 | } |
| 233 | } |
Nicolas Geoffray | 26a25ef | 2014-09-30 13:54:09 +0100 | [diff] [blame] | 234 | output_ << " (liveness: " << instruction->GetLifetimePosition() << ")"; |
Nicolas Geoffray | 82091da | 2015-01-26 10:02:45 +0000 | [diff] [blame] | 235 | } else if (pass_name_ == kLoopInvariantCodeMotionPassName) { |
| 236 | output_ << " ( loop_header:"; |
| 237 | HLoopInformation* info = instruction->GetBlock()->GetLoopInformation(); |
| 238 | if (info == nullptr) { |
| 239 | output_ << "null )"; |
| 240 | } else { |
| 241 | output_ << "B" << info->GetHeader()->GetBlockId() << " )"; |
| 242 | } |
Nicolas Geoffray | ddb311f | 2014-05-16 09:28:54 +0100 | [diff] [blame] | 243 | } |
Nicolas Geoffray | f635e63 | 2014-05-14 09:43:38 +0100 | [diff] [blame] | 244 | } |
| 245 | |
| 246 | void PrintInstructions(const HInstructionList& list) { |
| 247 | const char* kEndInstructionMarker = "<|@"; |
| 248 | for (HInstructionIterator it(list); !it.Done(); it.Advance()) { |
| 249 | HInstruction* instruction = it.Current(); |
Nicolas Geoffray | f635e63 | 2014-05-14 09:43:38 +0100 | [diff] [blame] | 250 | int bci = 0; |
David Brazdil | ea55b93 | 2015-01-27 17:12:29 +0000 | [diff] [blame] | 251 | size_t num_uses = 0; |
| 252 | for (HUseIterator<HInstruction*> use_it(instruction->GetUses()); |
| 253 | !use_it.Done(); |
| 254 | use_it.Advance()) { |
| 255 | ++num_uses; |
| 256 | } |
| 257 | AddIndent(); |
| 258 | output_ << bci << " " << num_uses << " " |
| 259 | << GetTypeId(instruction->GetType()) << instruction->GetId() << " "; |
David Brazdil | b7e4a06 | 2014-12-29 15:35:02 +0000 | [diff] [blame] | 260 | PrintInstruction(instruction); |
Nicolas Geoffray | f635e63 | 2014-05-14 09:43:38 +0100 | [diff] [blame] | 261 | output_ << kEndInstructionMarker << std::endl; |
| 262 | } |
| 263 | } |
| 264 | |
Nicolas Geoffray | 86dbb9a | 2014-06-04 11:12:39 +0100 | [diff] [blame] | 265 | void Run() { |
Nicolas Geoffray | f635e63 | 2014-05-14 09:43:38 +0100 | [diff] [blame] | 266 | StartTag("cfg"); |
Nicolas Geoffray | 840e546 | 2015-01-07 16:01:24 +0000 | [diff] [blame] | 267 | std::string pass_desc = std::string(pass_name_) + (is_after_pass_ ? " (after)" : " (before)"); |
| 268 | PrintProperty("name", pass_desc.c_str()); |
Nicolas Geoffray | f635e63 | 2014-05-14 09:43:38 +0100 | [diff] [blame] | 269 | VisitInsertionOrder(); |
| 270 | EndTag("cfg"); |
| 271 | } |
| 272 | |
David Brazdil | b7e4a06 | 2014-12-29 15:35:02 +0000 | [diff] [blame] | 273 | void VisitBasicBlock(HBasicBlock* block) OVERRIDE { |
Nicolas Geoffray | f635e63 | 2014-05-14 09:43:38 +0100 | [diff] [blame] | 274 | StartTag("block"); |
| 275 | PrintProperty("name", "B", block->GetBlockId()); |
Nicolas Geoffray | ddb311f | 2014-05-16 09:28:54 +0100 | [diff] [blame] | 276 | if (block->GetLifetimeStart() != kNoLifetime) { |
| 277 | // Piggy back on these fields to show the lifetime of the block. |
| 278 | PrintInt("from_bci", block->GetLifetimeStart()); |
| 279 | PrintInt("to_bci", block->GetLifetimeEnd()); |
| 280 | } else { |
| 281 | PrintInt("from_bci", -1); |
| 282 | PrintInt("to_bci", -1); |
| 283 | } |
Nicolas Geoffray | f635e63 | 2014-05-14 09:43:38 +0100 | [diff] [blame] | 284 | PrintPredecessors(block); |
| 285 | PrintSuccessors(block); |
| 286 | PrintEmptyProperty("xhandlers"); |
| 287 | PrintEmptyProperty("flags"); |
| 288 | if (block->GetDominator() != nullptr) { |
| 289 | PrintProperty("dominator", "B", block->GetDominator()->GetBlockId()); |
| 290 | } |
| 291 | |
| 292 | StartTag("states"); |
| 293 | StartTag("locals"); |
| 294 | PrintInt("size", 0); |
| 295 | PrintProperty("method", "None"); |
| 296 | for (HInstructionIterator it(block->GetPhis()); !it.Done(); it.Advance()) { |
| 297 | AddIndent(); |
| 298 | HInstruction* instruction = it.Current(); |
Nicolas Geoffray | b09aacb | 2014-09-17 18:21:53 +0100 | [diff] [blame] | 299 | output_ << instruction->GetId() << " " << GetTypeId(instruction->GetType()) |
| 300 | << instruction->GetId() << "[ "; |
Nicolas Geoffray | f635e63 | 2014-05-14 09:43:38 +0100 | [diff] [blame] | 301 | for (HInputIterator inputs(instruction); !inputs.Done(); inputs.Advance()) { |
| 302 | output_ << inputs.Current()->GetId() << " "; |
| 303 | } |
| 304 | output_ << "]" << std::endl; |
| 305 | } |
| 306 | EndTag("locals"); |
| 307 | EndTag("states"); |
| 308 | |
| 309 | StartTag("HIR"); |
| 310 | PrintInstructions(block->GetPhis()); |
| 311 | PrintInstructions(block->GetInstructions()); |
| 312 | EndTag("HIR"); |
| 313 | EndTag("block"); |
| 314 | } |
| 315 | |
| 316 | private: |
| 317 | std::ostream& output_; |
Nicolas Geoffray | 86dbb9a | 2014-06-04 11:12:39 +0100 | [diff] [blame] | 318 | const char* pass_name_; |
Nicolas Geoffray | 840e546 | 2015-01-07 16:01:24 +0000 | [diff] [blame] | 319 | const bool is_after_pass_; |
Nicolas Geoffray | a7062e0 | 2014-05-22 12:50:17 +0100 | [diff] [blame] | 320 | const CodeGenerator& codegen_; |
Nicolas Geoffray | f635e63 | 2014-05-14 09:43:38 +0100 | [diff] [blame] | 321 | size_t indent_; |
| 322 | |
| 323 | DISALLOW_COPY_AND_ASSIGN(HGraphVisualizerPrinter); |
| 324 | }; |
| 325 | |
| 326 | HGraphVisualizer::HGraphVisualizer(std::ostream* output, |
| 327 | HGraph* graph, |
Nicolas Geoffray | a7062e0 | 2014-05-22 12:50:17 +0100 | [diff] [blame] | 328 | const CodeGenerator& codegen, |
Nicolas Geoffray | e53798a | 2014-12-01 10:31:54 +0000 | [diff] [blame] | 329 | const char* method_name) |
David Brazdil | 5e8b137 | 2015-01-23 14:39:08 +0000 | [diff] [blame] | 330 | : output_(output), graph_(graph), codegen_(codegen) { |
Nicolas Geoffray | f635e63 | 2014-05-14 09:43:38 +0100 | [diff] [blame] | 331 | if (output == nullptr) { |
| 332 | return; |
| 333 | } |
Nicolas Geoffray | f635e63 | 2014-05-14 09:43:38 +0100 | [diff] [blame] | 334 | |
Nicolas Geoffray | 840e546 | 2015-01-07 16:01:24 +0000 | [diff] [blame] | 335 | HGraphVisualizerPrinter printer(graph_, *output_, "", true, codegen_); |
Nicolas Geoffray | f635e63 | 2014-05-14 09:43:38 +0100 | [diff] [blame] | 336 | printer.StartTag("compilation"); |
Nicolas Geoffray | e53798a | 2014-12-01 10:31:54 +0000 | [diff] [blame] | 337 | printer.PrintProperty("name", method_name); |
| 338 | printer.PrintProperty("method", method_name); |
Nicolas Geoffray | 0d3f578 | 2014-05-14 09:43:38 +0100 | [diff] [blame] | 339 | printer.PrintTime("date"); |
| 340 | printer.EndTag("compilation"); |
| 341 | } |
| 342 | |
David Brazdil | ee690a3 | 2014-12-01 17:04:16 +0000 | [diff] [blame] | 343 | void HGraphVisualizer::DumpGraph(const char* pass_name, bool is_after_pass) const { |
David Brazdil | 5e8b137 | 2015-01-23 14:39:08 +0000 | [diff] [blame] | 344 | DCHECK(output_ != nullptr); |
| 345 | if (!graph_->GetBlocks().IsEmpty()) { |
Nicolas Geoffray | 840e546 | 2015-01-07 16:01:24 +0000 | [diff] [blame] | 346 | HGraphVisualizerPrinter printer(graph_, *output_, pass_name, is_after_pass, codegen_); |
David Brazdil | ee690a3 | 2014-12-01 17:04:16 +0000 | [diff] [blame] | 347 | printer.Run(); |
Nicolas Geoffray | f635e63 | 2014-05-14 09:43:38 +0100 | [diff] [blame] | 348 | } |
Nicolas Geoffray | f635e63 | 2014-05-14 09:43:38 +0100 | [diff] [blame] | 349 | } |
| 350 | |
| 351 | } // namespace art |