1 // Copyright 2013 the V8 project authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #include "src/compiler/node.h"
6 #include "src/compiler/node-properties.h"
7 #include "src/compiler/node-properties-inl.h"
8 #include "src/compiler/schedule.h"
9 #include "src/ostreams.h"
15 OStream& operator<<(OStream& os, const BasicBlockData::Control& c) {
17 case BasicBlockData::kNone:
19 case BasicBlockData::kGoto:
21 case BasicBlockData::kBranch:
22 return os << "branch";
23 case BasicBlockData::kReturn:
24 return os << "return";
25 case BasicBlockData::kThrow:
33 OStream& operator<<(OStream& os, const Schedule& s) {
34 // TODO(svenpanne) Const-correct the RPO stuff/iterators.
35 BasicBlockVector* rpo = const_cast<Schedule*>(&s)->rpo_order();
36 for (BasicBlockVectorIter i = rpo->begin(); i != rpo->end(); ++i) {
37 BasicBlock* block = *i;
38 os << "--- BLOCK B" << block->id();
39 if (block->PredecessorCount() != 0) os << " <- ";
40 BasicBlock::Predecessors predecessors = block->predecessors();
42 for (BasicBlock::Predecessors::iterator j = predecessors.begin();
43 j != predecessors.end(); ++j) {
44 if (comma) os << ", ";
46 os << "B" << (*j)->id();
49 for (BasicBlock::const_iterator j = block->begin(); j != block->end();
53 if (!NodeProperties::IsControl(node)) {
54 Bounds bounds = NodeProperties::GetBounds(node);
56 bounds.lower->PrintTo(os);
57 if (!bounds.upper->Is(bounds.lower)) {
59 bounds.upper->PrintTo(os);
64 BasicBlock::Control control = block->control_;
65 if (control != BasicBlock::kNone) {
67 if (block->control_input_ != NULL) {
68 os << *block->control_input_;
73 BasicBlock::Successors successors = block->successors();
75 for (BasicBlock::Successors::iterator j = successors.begin();
76 j != successors.end(); ++j) {
77 if (comma) os << ", ";
79 os << "B" << (*j)->id();
86 } // namespace compiler
87 } // namespace internal