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_OPERATOR_H_ | 5 #ifndef V8_COMPILER_OPERATOR_H_ |
6 #define V8_COMPILER_OPERATOR_H_ | 6 #define V8_COMPILER_OPERATOR_H_ |
7 | 7 |
8 #include "src/base/flags.h" | 8 #include "src/base/flags.h" |
9 #include "src/ostreams.h" | 9 #include "src/ostreams.h" |
10 #include "src/unique.h" | 10 #include "src/unique.h" |
11 | 11 |
12 namespace v8 { | 12 namespace v8 { |
13 namespace internal { | 13 namespace internal { |
14 | |
15 // Forward declarations. | |
16 class ExternalReference; | |
17 | |
18 | |
19 namespace compiler { | 14 namespace compiler { |
20 | 15 |
21 // An operator represents description of the "computation" of a node in the | 16 // An operator represents description of the "computation" of a node in the |
22 // compiler IR. A computation takes values (i.e. data) as input and produces | 17 // compiler IR. A computation takes values (i.e. data) as input and produces |
23 // zero or more values as output. The side-effects of a computation must be | 18 // zero or more values as output. The side-effects of a computation must be |
24 // captured by additional control and data dependencies which are part of the | 19 // captured by additional control and data dependencies which are part of the |
25 // IR graph. | 20 // IR graph. |
26 // Operators are immutable and describe the statically-known parts of a | 21 // Operators are immutable and describe the statically-known parts of a |
27 // computation. Thus they can be safely shared by many different nodes in the | 22 // computation. Thus they can be safely shared by many different nodes in the |
28 // IR graph, or even globally between graphs. Operators can have "static | 23 // IR graph, or even globally between graphs. Operators can have "static |
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
140 struct StaticParameterTraits { | 135 struct StaticParameterTraits { |
141 static OStream& PrintTo(OStream& os, T val) { // NOLINT | 136 static OStream& PrintTo(OStream& os, T val) { // NOLINT |
142 return os << "??"; | 137 return os << "??"; |
143 } | 138 } |
144 static int HashCode(T a) { return 0; } | 139 static int HashCode(T a) { return 0; } |
145 static bool Equals(T a, T b) { | 140 static bool Equals(T a, T b) { |
146 return false; // Not every T has a ==. By default, be conservative. | 141 return false; // Not every T has a ==. By default, be conservative. |
147 } | 142 } |
148 }; | 143 }; |
149 | 144 |
150 template <> | |
151 struct StaticParameterTraits<ExternalReference> { | |
152 static OStream& PrintTo(OStream& os, ExternalReference reference); // NOLINT | |
153 static int HashCode(ExternalReference reference); | |
154 static bool Equals(ExternalReference lhs, ExternalReference rhs); | |
155 }; | |
156 | |
157 // Specialization for static parameters of type {int}. | 145 // Specialization for static parameters of type {int}. |
158 template <> | 146 template <> |
159 struct StaticParameterTraits<int> { | 147 struct StaticParameterTraits<int> { |
160 static OStream& PrintTo(OStream& os, int val) { // NOLINT | 148 static OStream& PrintTo(OStream& os, int val) { // NOLINT |
161 return os << val; | 149 return os << val; |
162 } | 150 } |
163 static int HashCode(int a) { return a; } | 151 static int HashCode(int a) { return a; } |
164 static bool Equals(int a, int b) { return a == b; } | 152 static bool Equals(int a, int b) { return a == b; } |
165 }; | 153 }; |
166 | 154 |
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
265 template <typename T> | 253 template <typename T> |
266 static inline const T& OpParameter(const Operator* op) { | 254 static inline const T& OpParameter(const Operator* op) { |
267 return reinterpret_cast<const Operator1<T>*>(op)->parameter(); | 255 return reinterpret_cast<const Operator1<T>*>(op)->parameter(); |
268 } | 256 } |
269 | 257 |
270 } // namespace compiler | 258 } // namespace compiler |
271 } // namespace internal | 259 } // namespace internal |
272 } // namespace v8 | 260 } // namespace v8 |
273 | 261 |
274 #endif // V8_COMPILER_OPERATOR_H_ | 262 #endif // V8_COMPILER_OPERATOR_H_ |
OLD | NEW |