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"
7 #include "src/compiler/generic-node-inl.h"
14 DCHECK_NOT_NULL(op());
16 DCHECK(uses().empty());
20 void Node::CollectProjections(NodeVector* projections) {
21 for (size_t i = 0; i < projections->size(); i++) {
22 (*projections)[i] = NULL;
24 for (UseIter i = uses().begin(); i != uses().end(); ++i) {
25 if ((*i)->opcode() != IrOpcode::kProjection) continue;
26 size_t index = OpParameter<size_t>(*i);
27 DCHECK_LT(index, projections->size());
28 DCHECK_EQ(NULL, (*projections)[index]);
29 (*projections)[index] = *i;
34 Node* Node::FindProjection(size_t projection_index) {
35 for (UseIter i = uses().begin(); i != uses().end(); ++i) {
36 if ((*i)->opcode() == IrOpcode::kProjection &&
37 OpParameter<size_t>(*i) == projection_index) {
45 std::ostream& operator<<(std::ostream& os, const Node& n) {
46 os << n.id() << ": " << *n.op();
47 if (n.InputCount() > 0) {
49 for (int i = 0; i < n.InputCount(); ++i) {
50 if (i != 0) os << ", ";
51 os << n.InputAt(i)->id();
58 } // namespace compiler
59 } // namespace internal