OLD | NEW |
1 // Copyright 2013 the V8 project authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "src/compiler/node.h" | 5 #include "src/compiler/node.h" |
6 | 6 |
7 #include "src/compiler/generic-node-inl.h" | 7 #include "src/compiler/generic-node-inl.h" |
8 | 8 |
9 namespace v8 { | 9 namespace v8 { |
10 namespace internal { | 10 namespace internal { |
11 namespace compiler { | 11 namespace compiler { |
12 | 12 |
13 void Node::CollectProjections(int projection_count, Node** projections) { | 13 void Node::CollectProjections(int projection_count, Node** projections) { |
14 for (int i = 0; i < projection_count; ++i) projections[i] = NULL; | 14 for (int i = 0; i < projection_count; ++i) projections[i] = NULL; |
15 for (UseIter i = uses().begin(); i != uses().end(); ++i) { | 15 for (UseIter i = uses().begin(); i != uses().end(); ++i) { |
16 if ((*i)->opcode() != IrOpcode::kProjection) continue; | 16 if ((*i)->opcode() != IrOpcode::kProjection) continue; |
17 int32_t index = OpParameter<int32_t>(*i); | 17 int32_t index = OpParameter<int32_t>(*i); |
18 ASSERT_GE(index, 0); | 18 ASSERT_GE(index, 0); |
19 ASSERT_LT(index, projection_count); | 19 ASSERT_LT(index, projection_count); |
20 ASSERT_EQ(NULL, projections[index]); | 20 ASSERT_EQ(NULL, projections[index]); |
21 projections[index] = *i; | 21 projections[index] = *i; |
22 } | 22 } |
23 } | 23 } |
24 | 24 |
25 | 25 |
| 26 Node* Node::FindProjection(int32_t projection_index) { |
| 27 for (UseIter i = uses().begin(); i != uses().end(); ++i) { |
| 28 if ((*i)->opcode() == IrOpcode::kProjection && |
| 29 OpParameter<int32_t>(*i) == projection_index) { |
| 30 return *i; |
| 31 } |
| 32 } |
| 33 return NULL; |
| 34 } |
| 35 |
| 36 |
26 OStream& operator<<(OStream& os, const Operator& op) { return op.PrintTo(os); } | 37 OStream& operator<<(OStream& os, const Operator& op) { return op.PrintTo(os); } |
27 | 38 |
28 | 39 |
29 OStream& operator<<(OStream& os, const Node& n) { | 40 OStream& operator<<(OStream& os, const Node& n) { |
30 os << n.id() << ": " << *n.op(); | 41 os << n.id() << ": " << *n.op(); |
31 if (n.op()->InputCount() != 0) { | 42 if (n.op()->InputCount() != 0) { |
32 os << "("; | 43 os << "("; |
33 for (int i = 0; i < n.op()->InputCount(); ++i) { | 44 for (int i = 0; i < n.op()->InputCount(); ++i) { |
34 if (i != 0) os << ", "; | 45 if (i != 0) os << ", "; |
35 os << n.InputAt(i)->id(); | 46 os << n.InputAt(i)->id(); |
36 } | 47 } |
37 os << ")"; | 48 os << ")"; |
38 } | 49 } |
39 return os; | 50 return os; |
40 } | 51 } |
41 | 52 |
42 } // namespace compiler | 53 } // namespace compiler |
43 } // namespace internal | 54 } // namespace internal |
44 } // namespace v8 | 55 } // namespace v8 |
OLD | NEW |