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 OStream& operator<<(OStream& os, const Operator& op) { return op.PrintTo(os); }
48 OStream& operator<<(OStream& os, const Node& n) {
49 os << n.id() << ": " << *n.op();
50 if (n.op()->InputCount() != 0) {
52 for (int i = 0; i < n.op()->InputCount(); ++i) {
53 if (i != 0) os << ", ";
54 os << n.InputAt(i)->id();
61 } // namespace compiler
62 } // namespace internal