Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(37)

Side by Side Diff: vm/il_printer.cc

Issue 10544206: Second step for computing SSA: renaming. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/runtime/
Patch Set: Created 8 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 #include "vm/il_printer.h" 5 #include "vm/il_printer.h"
6 6
7 #include "vm/intermediate_language.h" 7 #include "vm/intermediate_language.h"
8 #include "vm/os.h" 8 #include "vm/os.h"
9 9
10 namespace dart { 10 namespace dart {
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
79 79
80 void Computation::PrintOperandsTo(BufferFormatter* f) const { 80 void Computation::PrintOperandsTo(BufferFormatter* f) const {
81 for (int i = 0; i < InputCount(); ++i) { 81 for (int i = 0; i < InputCount(); ++i) {
82 if (i > 0) f->Print(", "); 82 if (i > 0) f->Print(", ");
83 if (InputAt(i) != NULL) InputAt(i)->PrintTo(f); 83 if (InputAt(i) != NULL) InputAt(i)->PrintTo(f);
84 } 84 }
85 } 85 }
86 86
87 87
88 void UseVal::PrintTo(BufferFormatter* f) const { 88 void UseVal::PrintTo(BufferFormatter* f) const {
89 f->Print("t%d", definition()->temp_index()); 89 if (definition()->ssa_temp_index() != -1) {
90 f->Print("t%d", definition()->ssa_temp_index());
91 } else {
92 f->Print("t%d", definition()->temp_index());
93 }
90 } 94 }
91 95
92 96
93 void ConstantVal::PrintTo(BufferFormatter* f) const { 97 void ConstantVal::PrintTo(BufferFormatter* f) const {
94 f->Print("#%s", value().ToCString()); 98 f->Print("#%s", value().ToCString());
95 } 99 }
96 100
97 101
98 void AssertAssignableComp::PrintOperandsTo(BufferFormatter* f) const { 102 void AssertAssignableComp::PrintOperandsTo(BufferFormatter* f) const {
99 value()->PrintTo(f); 103 value()->PrintTo(f);
(...skipping 225 matching lines...) Expand 10 before | Expand all | Expand 10 after
325 329
326 void ToDoubleComp::PrintOperandsTo(BufferFormatter* f) const { 330 void ToDoubleComp::PrintOperandsTo(BufferFormatter* f) const {
327 ASSERT(from() == kDouble || from() == kSmi); 331 ASSERT(from() == kDouble || from() == kSmi);
328 f->Print("%s ", from() == kDouble ? "double2double" : "smi2double"); 332 f->Print("%s ", from() == kDouble ? "double2double" : "smi2double");
329 value()->PrintTo(f); 333 value()->PrintTo(f);
330 } 334 }
331 335
332 336
333 void GraphEntryInstr::PrintTo(BufferFormatter* f) const { 337 void GraphEntryInstr::PrintTo(BufferFormatter* f) const {
334 f->Print("%2d: [graph]", block_id()); 338 f->Print("%2d: [graph]", block_id());
339 if (start_env_ != NULL) {
340 for (intptr_t i = 0; i < start_env_->length(); ++i) {
341 f->Print("\n ");
342 (*start_env_)[i]->PrintTo(f);
343 }
344 }
335 } 345 }
336 346
337 347
338 void JoinEntryInstr::PrintTo(BufferFormatter* f) const { 348 void JoinEntryInstr::PrintTo(BufferFormatter* f) const {
339 f->Print("%2d: [join]", block_id()); 349 f->Print("%2d: [join]", block_id());
340 if (phis_ != NULL) { 350 if (phis_ != NULL) {
341 for (intptr_t i = 0; i < phis_->length(); ++i) { 351 for (intptr_t i = 0; i < phis_->length(); ++i) {
342 if ((*phis_)[i] == NULL) continue; 352 if ((*phis_)[i] == NULL) continue;
343 f->Print("\n"); 353 f->Print("\n");
344 (*phis_)[i]->PrintTo(f); 354 (*phis_)[i]->PrintTo(f);
345 } 355 }
346 } 356 }
347 } 357 }
348 358
349 359
350 void PhiInstr::PrintTo(BufferFormatter* f) const { 360 void PhiInstr::PrintTo(BufferFormatter* f) const {
351 f->Print(" phi("); 361 f->Print(" t%d <- phi(", ssa_temp_index());
352 for (intptr_t i = 0; i < inputs_.length(); ++i) { 362 for (intptr_t i = 0; i < inputs_.length(); ++i) {
353 if (inputs_[i] != NULL) inputs_[i]->PrintTo(f); 363 if (inputs_[i] != NULL) inputs_[i]->PrintTo(f);
354 if (i < inputs_.length() - 1) f->Print(","); 364 if (i < inputs_.length() - 1) f->Print(",");
355 } 365 }
356 f->Print(")"); 366 f->Print(")");
357 } 367 }
358 368
359 369
360 void TargetEntryInstr::PrintTo(BufferFormatter* f) const { 370 void TargetEntryInstr::PrintTo(BufferFormatter* f) const {
361 f->Print("%2d: [target", block_id()); 371 f->Print("%2d: [target", block_id());
362 if (HasTryIndex()) { 372 if (HasTryIndex()) {
363 f->Print(" catch %d]", try_index()); 373 f->Print(" catch %d]", try_index());
364 } else { 374 } else {
365 f->Print("]"); 375 f->Print("]");
366 } 376 }
367 } 377 }
368 378
369 379
370 void DoInstr::PrintTo(BufferFormatter* f) const { 380 void DoInstr::PrintTo(BufferFormatter* f) const {
371 f->Print(" "); 381 f->Print(" ");
372 computation()->PrintTo(f); 382 computation()->PrintTo(f);
373 } 383 }
374 384
375 385
376 void BindInstr::PrintTo(BufferFormatter* f) const { 386 void BindInstr::PrintTo(BufferFormatter* f) const {
377 f->Print(" t%d <- ", temp_index()); 387 if (ssa_temp_index() != -1) {
388 f->Print(" t%d <- ", ssa_temp_index());
389 } else {
390 f->Print(" t%d <- ", temp_index());
391 }
378 computation()->PrintTo(f); 392 computation()->PrintTo(f);
379 } 393 }
380 394
381 395
382 void ReturnInstr::PrintTo(BufferFormatter* f) const { 396 void ReturnInstr::PrintTo(BufferFormatter* f) const {
383 f->Print(" %s ", DebugName()); 397 f->Print(" %s ", DebugName());
384 value()->PrintTo(f); 398 value()->PrintTo(f);
385 } 399 }
386 400
387 401
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
421 f.VPrint(format, args); 435 f.VPrint(format, args);
422 va_end(args); 436 va_end(args);
423 (*Dart::flow_graph_writer())(str, strlen(str)); 437 (*Dart::flow_graph_writer())(str, strlen(str));
424 } 438 }
425 439
426 440
427 void FlowGraphVisualizer::PrintInstruction(Instruction* instr) { 441 void FlowGraphVisualizer::PrintInstruction(Instruction* instr) {
428 char str[120]; 442 char str[120];
429 BufferFormatter f(str, sizeof(str)); 443 BufferFormatter f(str, sizeof(str));
430 instr->PrintToVisualizer(&f); 444 instr->PrintToVisualizer(&f);
431 f.Print("%s <|@\n", str); 445 f.Print(" <|@\n");
432 (*Dart::flow_graph_writer())(str, strlen(str)); 446 (*Dart::flow_graph_writer())(str, strlen(str));
433 } 447 }
434 448
435 449
436 void FlowGraphVisualizer::PrintFunction() { 450 void FlowGraphVisualizer::PrintFunction() {
437 #define BEGIN(name) \ 451 #define BEGIN(name) \
438 Print("begin_%s\n", name); \ 452 Print("begin_%s\n", name); \
439 indent_++; 453 indent_++;
440 #define END(name) \ 454 #define END(name) \
441 Print("end_%s\n", name); \ 455 Print("end_%s\n", name); \
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after
549 f->Print("_ [graph]"); 563 f->Print("_ [graph]");
550 } 564 }
551 565
552 566
553 void JoinEntryInstr::PrintToVisualizer(BufferFormatter* f) const { 567 void JoinEntryInstr::PrintToVisualizer(BufferFormatter* f) const {
554 f->Print("_ [join]"); 568 f->Print("_ [join]");
555 } 569 }
556 570
557 571
558 void PhiInstr::PrintToVisualizer(BufferFormatter* f) const { 572 void PhiInstr::PrintToVisualizer(BufferFormatter* f) const {
559 // TODO(fschneider): Print operands when SSA renaming is implemented. 573 f->Print("t%d [", ssa_temp_index());
560 f->Print("v ["); 574 bool has_constant = false;
561 for (intptr_t i = 0; i < InputCount(); ++i) { 575 for (intptr_t i = 0; i < InputCount(); ++i) {
562 f->Print(" v "); 576 if (i > 0) f->Print(" ");
577 if (InputAt(i)->IsConstant()) {
578 f->Print("const");
579 has_constant = true;
580 } else {
581 InputAt(i)->PrintTo(f);
582 }
563 } 583 }
564 f->Print("]"); 584 f->Print("]");
585 // The vizualizer file format does not allow arbitrary strings inside the phi.
586 // Print constants as a line-end comment instead.
587 if (has_constant) {
588 f->Print("\"");
589 for (intptr_t i = 0; i < InputCount(); ++i) {
590 if (i > 0) f->Print(" ");
591 if (InputAt(i)->IsConstant()) {
592 InputAt(i)->PrintTo(f);
593 }
594 }
595 f->Print("\"");
596 }
565 } 597 }
566 598
567 599
568 void TargetEntryInstr::PrintToVisualizer(BufferFormatter* f) const { 600 void TargetEntryInstr::PrintToVisualizer(BufferFormatter* f) const {
569 f->Print("_ [target"); 601 f->Print("_ [target");
570 if (HasTryIndex()) { 602 if (HasTryIndex()) {
571 f->Print(" catch %d]", try_index()); 603 f->Print(" catch %d]", try_index());
572 } else { 604 } else {
573 f->Print("]"); 605 f->Print("]");
574 } 606 }
575 } 607 }
576 608
577 609
578 void DoInstr::PrintToVisualizer(BufferFormatter* f) const { 610 void DoInstr::PrintToVisualizer(BufferFormatter* f) const {
579 f->Print("_ "); 611 f->Print("_ ");
580 computation()->PrintTo(f); 612 computation()->PrintTo(f);
581 } 613 }
582 614
583 615
584 void BindInstr::PrintToVisualizer(BufferFormatter* f) const { 616 void BindInstr::PrintToVisualizer(BufferFormatter* f) const {
585 f->Print("t%d ", temp_index()); 617 if (ssa_temp_index() != -1) {
618 f->Print("t%d ", ssa_temp_index());
619 } else {
620 f->Print("t%d ", temp_index());
621 }
586 computation()->PrintTo(f); 622 computation()->PrintTo(f);
587 } 623 }
588 624
589 625
590 void ReturnInstr::PrintToVisualizer(BufferFormatter* f) const { 626 void ReturnInstr::PrintToVisualizer(BufferFormatter* f) const {
591 f->Print("_ %s ", DebugName()); 627 f->Print("_ %s ", DebugName());
592 value()->PrintTo(f); 628 value()->PrintTo(f);
593 } 629 }
594 630
595 631
(...skipping 15 matching lines...) Expand all
611 f->Print("_ %s ", DebugName()); 647 f->Print("_ %s ", DebugName());
612 f->Print("if "); 648 f->Print("if ");
613 value()->PrintTo(f); 649 value()->PrintTo(f);
614 f->Print(" goto (B%d, B%d)", 650 f->Print(" goto (B%d, B%d)",
615 true_successor()->block_id(), 651 true_successor()->block_id(),
616 false_successor()->block_id()); 652 false_successor()->block_id());
617 } 653 }
618 654
619 655
620 } // namespace dart 656 } // namespace dart
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698