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 #ifndef V8_COMPILER_GRAPH_H_ | 5 #ifndef V8_COMPILER_GRAPH_H_ |
6 #define V8_COMPILER_GRAPH_H_ | 6 #define V8_COMPILER_GRAPH_H_ |
7 | 7 |
8 #include "src/base/compiler-specific.h" | 8 #include "src/base/compiler-specific.h" |
9 #include "src/globals.h" | 9 #include "src/globals.h" |
10 #include "src/zone/zone-containers.h" | 10 #include "src/zone/zone-containers.h" |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
59 Node* const* inputs, bool incomplete = false); | 59 Node* const* inputs, bool incomplete = false); |
60 | 60 |
61 // Factory that checks the input count. | 61 // Factory that checks the input count. |
62 Node* NewNode(const Operator* op, int input_count, Node* const* inputs, | 62 Node* NewNode(const Operator* op, int input_count, Node* const* inputs, |
63 bool incomplete = false); | 63 bool incomplete = false); |
64 | 64 |
65 // Factories for nodes with static input counts. | 65 // Factories for nodes with static input counts. |
66 Node* NewNode(const Operator* op) { | 66 Node* NewNode(const Operator* op) { |
67 return NewNode(op, 0, static_cast<Node* const*>(nullptr)); | 67 return NewNode(op, 0, static_cast<Node* const*>(nullptr)); |
68 } | 68 } |
69 Node* NewNode(const Operator* op, Node* n1) { return NewNode(op, 1, &n1); } | 69 Node* NewNode(const Operator* op, Node* n) { return NewNode(op, 1, &n); } |
titzer
2017/01/25 09:47:25
This is a nice simplification, but IIRC there was
bbudge
2017/01/26 02:04:43
Agreed. Changed to explicit overloads up to 17 par
| |
70 Node* NewNode(const Operator* op, Node* n1, Node* n2) { | 70 // Factories for nodes with more than one input. |
71 Node* nodes[] = {n1, n2}; | 71 template <typename... Nodes> |
72 return NewNode(op, arraysize(nodes), nodes); | 72 Node* NewNode(const Operator* op, Nodes*... nodes) { |
73 } | 73 Node* arr[] = {nodes...}; |
74 Node* NewNode(const Operator* op, Node* n1, Node* n2, Node* n3) { | 74 return NewNode(op, arraysize(arr), arr); |
75 Node* nodes[] = {n1, n2, n3}; | |
76 return NewNode(op, arraysize(nodes), nodes); | |
77 } | |
78 Node* NewNode(const Operator* op, Node* n1, Node* n2, Node* n3, Node* n4) { | |
79 Node* nodes[] = {n1, n2, n3, n4}; | |
80 return NewNode(op, arraysize(nodes), nodes); | |
81 } | |
82 Node* NewNode(const Operator* op, Node* n1, Node* n2, Node* n3, Node* n4, | |
83 Node* n5) { | |
84 Node* nodes[] = {n1, n2, n3, n4, n5}; | |
85 return NewNode(op, arraysize(nodes), nodes); | |
86 } | |
87 Node* NewNode(const Operator* op, Node* n1, Node* n2, Node* n3, Node* n4, | |
88 Node* n5, Node* n6) { | |
89 Node* nodes[] = {n1, n2, n3, n4, n5, n6}; | |
90 return NewNode(op, arraysize(nodes), nodes); | |
91 } | |
92 Node* NewNode(const Operator* op, Node* n1, Node* n2, Node* n3, Node* n4, | |
93 Node* n5, Node* n6, Node* n7) { | |
94 Node* nodes[] = {n1, n2, n3, n4, n5, n6, n7}; | |
95 return NewNode(op, arraysize(nodes), nodes); | |
96 } | |
97 Node* NewNode(const Operator* op, Node* n1, Node* n2, Node* n3, Node* n4, | |
98 Node* n5, Node* n6, Node* n7, Node* n8) { | |
99 Node* nodes[] = {n1, n2, n3, n4, n5, n6, n7, n8}; | |
100 return NewNode(op, arraysize(nodes), nodes); | |
101 } | |
102 Node* NewNode(const Operator* op, Node* n1, Node* n2, Node* n3, Node* n4, | |
103 Node* n5, Node* n6, Node* n7, Node* n8, Node* n9) { | |
104 Node* nodes[] = {n1, n2, n3, n4, n5, n6, n7, n8, n9}; | |
105 return NewNode(op, arraysize(nodes), nodes); | |
106 } | 75 } |
107 | 76 |
108 // Clone the {node}, and assign a new node id to the copy. | 77 // Clone the {node}, and assign a new node id to the copy. |
109 Node* CloneNode(const Node* node); | 78 Node* CloneNode(const Node* node); |
110 | 79 |
111 Zone* zone() const { return zone_; } | 80 Zone* zone() const { return zone_; } |
112 Node* start() const { return start_; } | 81 Node* start() const { return start_; } |
113 Node* end() const { return end_; } | 82 Node* end() const { return end_; } |
114 | 83 |
115 void SetStart(Node* start) { start_ = start; } | 84 void SetStart(Node* start) { start_ = start; } |
(...skipping 30 matching lines...) Expand all Loading... | |
146 public: | 115 public: |
147 virtual ~GraphDecorator() {} | 116 virtual ~GraphDecorator() {} |
148 virtual void Decorate(Node* node) = 0; | 117 virtual void Decorate(Node* node) = 0; |
149 }; | 118 }; |
150 | 119 |
151 } // namespace compiler | 120 } // namespace compiler |
152 } // namespace internal | 121 } // namespace internal |
153 } // namespace v8 | 122 } // namespace v8 |
154 | 123 |
155 #endif // V8_COMPILER_GRAPH_H_ | 124 #endif // V8_COMPILER_GRAPH_H_ |
OLD | NEW |