OLD | NEW |
1 // Copyright 2014 the V8 project authors. All rights reserved. | 1 // Copyright 2014 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/graph-unittest.h" | 5 #include "src/compiler/graph-unittest.h" |
6 | 6 |
7 #include <ostream> // NOLINT(readability/streams) | 7 #include <ostream> // NOLINT(readability/streams) |
8 | 8 |
9 #include "src/compiler/node-properties-inl.h" | 9 #include "src/compiler/node-properties-inl.h" |
10 | 10 |
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
108 return false; | 108 return false; |
109 } | 109 } |
110 return true; | 110 return true; |
111 } | 111 } |
112 | 112 |
113 | 113 |
114 class NodeMatcher : public MatcherInterface<Node*> { | 114 class NodeMatcher : public MatcherInterface<Node*> { |
115 public: | 115 public: |
116 explicit NodeMatcher(IrOpcode::Value opcode) : opcode_(opcode) {} | 116 explicit NodeMatcher(IrOpcode::Value opcode) : opcode_(opcode) {} |
117 | 117 |
118 virtual void DescribeTo(std::ostream* os) const V8_OVERRIDE { | 118 virtual void DescribeTo(std::ostream* os) const OVERRIDE { |
119 *os << "is a " << IrOpcode::Mnemonic(opcode_) << " node"; | 119 *os << "is a " << IrOpcode::Mnemonic(opcode_) << " node"; |
120 } | 120 } |
121 | 121 |
122 virtual bool MatchAndExplain(Node* node, MatchResultListener* listener) const | 122 virtual bool MatchAndExplain(Node* node, MatchResultListener* listener) const |
123 V8_OVERRIDE { | 123 OVERRIDE { |
124 if (node == NULL) { | 124 if (node == NULL) { |
125 *listener << "which is NULL"; | 125 *listener << "which is NULL"; |
126 return false; | 126 return false; |
127 } | 127 } |
128 if (node->opcode() != opcode_) { | 128 if (node->opcode() != opcode_) { |
129 *listener << "whose opcode is " << IrOpcode::Mnemonic(node->opcode()) | 129 *listener << "whose opcode is " << IrOpcode::Mnemonic(node->opcode()) |
130 << " but should have been " << IrOpcode::Mnemonic(opcode_); | 130 << " but should have been " << IrOpcode::Mnemonic(opcode_); |
131 return false; | 131 return false; |
132 } | 132 } |
133 return true; | 133 return true; |
134 } | 134 } |
135 | 135 |
136 private: | 136 private: |
137 const IrOpcode::Value opcode_; | 137 const IrOpcode::Value opcode_; |
138 }; | 138 }; |
139 | 139 |
140 | 140 |
141 class IsBranchMatcher V8_FINAL : public NodeMatcher { | 141 class IsBranchMatcher FINAL : public NodeMatcher { |
142 public: | 142 public: |
143 IsBranchMatcher(const Matcher<Node*>& value_matcher, | 143 IsBranchMatcher(const Matcher<Node*>& value_matcher, |
144 const Matcher<Node*>& control_matcher) | 144 const Matcher<Node*>& control_matcher) |
145 : NodeMatcher(IrOpcode::kBranch), | 145 : NodeMatcher(IrOpcode::kBranch), |
146 value_matcher_(value_matcher), | 146 value_matcher_(value_matcher), |
147 control_matcher_(control_matcher) {} | 147 control_matcher_(control_matcher) {} |
148 | 148 |
149 virtual void DescribeTo(std::ostream* os) const V8_OVERRIDE { | 149 virtual void DescribeTo(std::ostream* os) const OVERRIDE { |
150 NodeMatcher::DescribeTo(os); | 150 NodeMatcher::DescribeTo(os); |
151 *os << " whose value ("; | 151 *os << " whose value ("; |
152 value_matcher_.DescribeTo(os); | 152 value_matcher_.DescribeTo(os); |
153 *os << ") and control ("; | 153 *os << ") and control ("; |
154 control_matcher_.DescribeTo(os); | 154 control_matcher_.DescribeTo(os); |
155 *os << ")"; | 155 *os << ")"; |
156 } | 156 } |
157 | 157 |
158 virtual bool MatchAndExplain(Node* node, MatchResultListener* listener) const | 158 virtual bool MatchAndExplain(Node* node, MatchResultListener* listener) const |
159 V8_OVERRIDE { | 159 OVERRIDE { |
160 return (NodeMatcher::MatchAndExplain(node, listener) && | 160 return (NodeMatcher::MatchAndExplain(node, listener) && |
161 PrintMatchAndExplain(NodeProperties::GetValueInput(node, 0), | 161 PrintMatchAndExplain(NodeProperties::GetValueInput(node, 0), |
162 "value", value_matcher_, listener) && | 162 "value", value_matcher_, listener) && |
163 PrintMatchAndExplain(NodeProperties::GetControlInput(node), | 163 PrintMatchAndExplain(NodeProperties::GetControlInput(node), |
164 "control", control_matcher_, listener)); | 164 "control", control_matcher_, listener)); |
165 } | 165 } |
166 | 166 |
167 private: | 167 private: |
168 const Matcher<Node*> value_matcher_; | 168 const Matcher<Node*> value_matcher_; |
169 const Matcher<Node*> control_matcher_; | 169 const Matcher<Node*> control_matcher_; |
170 }; | 170 }; |
171 | 171 |
172 | 172 |
173 class IsMergeMatcher V8_FINAL : public NodeMatcher { | 173 class IsMergeMatcher FINAL : public NodeMatcher { |
174 public: | 174 public: |
175 IsMergeMatcher(const Matcher<Node*>& control0_matcher, | 175 IsMergeMatcher(const Matcher<Node*>& control0_matcher, |
176 const Matcher<Node*>& control1_matcher) | 176 const Matcher<Node*>& control1_matcher) |
177 : NodeMatcher(IrOpcode::kMerge), | 177 : NodeMatcher(IrOpcode::kMerge), |
178 control0_matcher_(control0_matcher), | 178 control0_matcher_(control0_matcher), |
179 control1_matcher_(control1_matcher) {} | 179 control1_matcher_(control1_matcher) {} |
180 | 180 |
181 virtual void DescribeTo(std::ostream* os) const V8_OVERRIDE { | 181 virtual void DescribeTo(std::ostream* os) const OVERRIDE { |
182 NodeMatcher::DescribeTo(os); | 182 NodeMatcher::DescribeTo(os); |
183 *os << " whose control0 ("; | 183 *os << " whose control0 ("; |
184 control0_matcher_.DescribeTo(os); | 184 control0_matcher_.DescribeTo(os); |
185 *os << ") and control1 ("; | 185 *os << ") and control1 ("; |
186 control1_matcher_.DescribeTo(os); | 186 control1_matcher_.DescribeTo(os); |
187 *os << ")"; | 187 *os << ")"; |
188 } | 188 } |
189 | 189 |
190 virtual bool MatchAndExplain(Node* node, MatchResultListener* listener) const | 190 virtual bool MatchAndExplain(Node* node, MatchResultListener* listener) const |
191 V8_OVERRIDE { | 191 OVERRIDE { |
192 return (NodeMatcher::MatchAndExplain(node, listener) && | 192 return (NodeMatcher::MatchAndExplain(node, listener) && |
193 PrintMatchAndExplain(NodeProperties::GetControlInput(node, 0), | 193 PrintMatchAndExplain(NodeProperties::GetControlInput(node, 0), |
194 "control0", control0_matcher_, listener) && | 194 "control0", control0_matcher_, listener) && |
195 PrintMatchAndExplain(NodeProperties::GetControlInput(node, 1), | 195 PrintMatchAndExplain(NodeProperties::GetControlInput(node, 1), |
196 "control1", control1_matcher_, listener)); | 196 "control1", control1_matcher_, listener)); |
197 } | 197 } |
198 | 198 |
199 private: | 199 private: |
200 const Matcher<Node*> control0_matcher_; | 200 const Matcher<Node*> control0_matcher_; |
201 const Matcher<Node*> control1_matcher_; | 201 const Matcher<Node*> control1_matcher_; |
202 }; | 202 }; |
203 | 203 |
204 | 204 |
205 class IsControl1Matcher V8_FINAL : public NodeMatcher { | 205 class IsControl1Matcher FINAL : public NodeMatcher { |
206 public: | 206 public: |
207 IsControl1Matcher(IrOpcode::Value opcode, | 207 IsControl1Matcher(IrOpcode::Value opcode, |
208 const Matcher<Node*>& control_matcher) | 208 const Matcher<Node*>& control_matcher) |
209 : NodeMatcher(opcode), control_matcher_(control_matcher) {} | 209 : NodeMatcher(opcode), control_matcher_(control_matcher) {} |
210 | 210 |
211 virtual void DescribeTo(std::ostream* os) const V8_OVERRIDE { | 211 virtual void DescribeTo(std::ostream* os) const OVERRIDE { |
212 NodeMatcher::DescribeTo(os); | 212 NodeMatcher::DescribeTo(os); |
213 *os << " whose control ("; | 213 *os << " whose control ("; |
214 control_matcher_.DescribeTo(os); | 214 control_matcher_.DescribeTo(os); |
215 *os << ")"; | 215 *os << ")"; |
216 } | 216 } |
217 | 217 |
218 virtual bool MatchAndExplain(Node* node, MatchResultListener* listener) const | 218 virtual bool MatchAndExplain(Node* node, MatchResultListener* listener) const |
219 V8_OVERRIDE { | 219 OVERRIDE { |
220 return (NodeMatcher::MatchAndExplain(node, listener) && | 220 return (NodeMatcher::MatchAndExplain(node, listener) && |
221 PrintMatchAndExplain(NodeProperties::GetControlInput(node), | 221 PrintMatchAndExplain(NodeProperties::GetControlInput(node), |
222 "control", control_matcher_, listener)); | 222 "control", control_matcher_, listener)); |
223 } | 223 } |
224 | 224 |
225 private: | 225 private: |
226 const Matcher<Node*> control_matcher_; | 226 const Matcher<Node*> control_matcher_; |
227 }; | 227 }; |
228 | 228 |
229 | 229 |
230 class IsFinishMatcher V8_FINAL : public NodeMatcher { | 230 class IsFinishMatcher FINAL : public NodeMatcher { |
231 public: | 231 public: |
232 IsFinishMatcher(const Matcher<Node*>& value_matcher, | 232 IsFinishMatcher(const Matcher<Node*>& value_matcher, |
233 const Matcher<Node*>& effect_matcher) | 233 const Matcher<Node*>& effect_matcher) |
234 : NodeMatcher(IrOpcode::kFinish), | 234 : NodeMatcher(IrOpcode::kFinish), |
235 value_matcher_(value_matcher), | 235 value_matcher_(value_matcher), |
236 effect_matcher_(effect_matcher) {} | 236 effect_matcher_(effect_matcher) {} |
237 | 237 |
238 virtual void DescribeTo(std::ostream* os) const V8_OVERRIDE { | 238 virtual void DescribeTo(std::ostream* os) const OVERRIDE { |
239 NodeMatcher::DescribeTo(os); | 239 NodeMatcher::DescribeTo(os); |
240 *os << " whose value ("; | 240 *os << " whose value ("; |
241 value_matcher_.DescribeTo(os); | 241 value_matcher_.DescribeTo(os); |
242 *os << ") and effect ("; | 242 *os << ") and effect ("; |
243 effect_matcher_.DescribeTo(os); | 243 effect_matcher_.DescribeTo(os); |
244 *os << ")"; | 244 *os << ")"; |
245 } | 245 } |
246 | 246 |
247 virtual bool MatchAndExplain(Node* node, MatchResultListener* listener) const | 247 virtual bool MatchAndExplain(Node* node, MatchResultListener* listener) const |
248 V8_OVERRIDE { | 248 OVERRIDE { |
249 return (NodeMatcher::MatchAndExplain(node, listener) && | 249 return (NodeMatcher::MatchAndExplain(node, listener) && |
250 PrintMatchAndExplain(NodeProperties::GetValueInput(node, 0), | 250 PrintMatchAndExplain(NodeProperties::GetValueInput(node, 0), |
251 "value", value_matcher_, listener) && | 251 "value", value_matcher_, listener) && |
252 PrintMatchAndExplain(NodeProperties::GetEffectInput(node), "effect", | 252 PrintMatchAndExplain(NodeProperties::GetEffectInput(node), "effect", |
253 effect_matcher_, listener)); | 253 effect_matcher_, listener)); |
254 } | 254 } |
255 | 255 |
256 private: | 256 private: |
257 const Matcher<Node*> value_matcher_; | 257 const Matcher<Node*> value_matcher_; |
258 const Matcher<Node*> effect_matcher_; | 258 const Matcher<Node*> effect_matcher_; |
259 }; | 259 }; |
260 | 260 |
261 | 261 |
262 template <typename T> | 262 template <typename T> |
263 class IsConstantMatcher V8_FINAL : public NodeMatcher { | 263 class IsConstantMatcher FINAL : public NodeMatcher { |
264 public: | 264 public: |
265 IsConstantMatcher(IrOpcode::Value opcode, const Matcher<T>& value_matcher) | 265 IsConstantMatcher(IrOpcode::Value opcode, const Matcher<T>& value_matcher) |
266 : NodeMatcher(opcode), value_matcher_(value_matcher) {} | 266 : NodeMatcher(opcode), value_matcher_(value_matcher) {} |
267 | 267 |
268 virtual void DescribeTo(std::ostream* os) const V8_OVERRIDE { | 268 virtual void DescribeTo(std::ostream* os) const OVERRIDE { |
269 NodeMatcher::DescribeTo(os); | 269 NodeMatcher::DescribeTo(os); |
270 *os << " whose value ("; | 270 *os << " whose value ("; |
271 value_matcher_.DescribeTo(os); | 271 value_matcher_.DescribeTo(os); |
272 *os << ")"; | 272 *os << ")"; |
273 } | 273 } |
274 | 274 |
275 virtual bool MatchAndExplain(Node* node, MatchResultListener* listener) const | 275 virtual bool MatchAndExplain(Node* node, MatchResultListener* listener) const |
276 V8_OVERRIDE { | 276 OVERRIDE { |
277 return (NodeMatcher::MatchAndExplain(node, listener) && | 277 return (NodeMatcher::MatchAndExplain(node, listener) && |
278 PrintMatchAndExplain(OpParameter<T>(node), "value", value_matcher_, | 278 PrintMatchAndExplain(OpParameter<T>(node), "value", value_matcher_, |
279 listener)); | 279 listener)); |
280 } | 280 } |
281 | 281 |
282 private: | 282 private: |
283 const Matcher<T> value_matcher_; | 283 const Matcher<T> value_matcher_; |
284 }; | 284 }; |
285 | 285 |
286 | 286 |
287 class IsPhiMatcher V8_FINAL : public NodeMatcher { | 287 class IsPhiMatcher FINAL : public NodeMatcher { |
288 public: | 288 public: |
289 IsPhiMatcher(const Matcher<Node*>& value0_matcher, | 289 IsPhiMatcher(const Matcher<Node*>& value0_matcher, |
290 const Matcher<Node*>& value1_matcher, | 290 const Matcher<Node*>& value1_matcher, |
291 const Matcher<Node*>& control_matcher) | 291 const Matcher<Node*>& control_matcher) |
292 : NodeMatcher(IrOpcode::kPhi), | 292 : NodeMatcher(IrOpcode::kPhi), |
293 value0_matcher_(value0_matcher), | 293 value0_matcher_(value0_matcher), |
294 value1_matcher_(value1_matcher), | 294 value1_matcher_(value1_matcher), |
295 control_matcher_(control_matcher) {} | 295 control_matcher_(control_matcher) {} |
296 | 296 |
297 virtual void DescribeTo(std::ostream* os) const V8_OVERRIDE { | 297 virtual void DescribeTo(std::ostream* os) const OVERRIDE { |
298 NodeMatcher::DescribeTo(os); | 298 NodeMatcher::DescribeTo(os); |
299 *os << " whose value0 ("; | 299 *os << " whose value0 ("; |
300 value0_matcher_.DescribeTo(os); | 300 value0_matcher_.DescribeTo(os); |
301 *os << "), value1 ("; | 301 *os << "), value1 ("; |
302 value1_matcher_.DescribeTo(os); | 302 value1_matcher_.DescribeTo(os); |
303 *os << ") and control ("; | 303 *os << ") and control ("; |
304 control_matcher_.DescribeTo(os); | 304 control_matcher_.DescribeTo(os); |
305 *os << ")"; | 305 *os << ")"; |
306 } | 306 } |
307 | 307 |
308 virtual bool MatchAndExplain(Node* node, MatchResultListener* listener) const | 308 virtual bool MatchAndExplain(Node* node, MatchResultListener* listener) const |
309 V8_OVERRIDE { | 309 OVERRIDE { |
310 return (NodeMatcher::MatchAndExplain(node, listener) && | 310 return (NodeMatcher::MatchAndExplain(node, listener) && |
311 PrintMatchAndExplain(NodeProperties::GetValueInput(node, 0), | 311 PrintMatchAndExplain(NodeProperties::GetValueInput(node, 0), |
312 "value0", value0_matcher_, listener) && | 312 "value0", value0_matcher_, listener) && |
313 PrintMatchAndExplain(NodeProperties::GetValueInput(node, 1), | 313 PrintMatchAndExplain(NodeProperties::GetValueInput(node, 1), |
314 "value1", value1_matcher_, listener) && | 314 "value1", value1_matcher_, listener) && |
315 PrintMatchAndExplain(NodeProperties::GetControlInput(node), | 315 PrintMatchAndExplain(NodeProperties::GetControlInput(node), |
316 "control", control_matcher_, listener)); | 316 "control", control_matcher_, listener)); |
317 } | 317 } |
318 | 318 |
319 private: | 319 private: |
320 const Matcher<Node*> value0_matcher_; | 320 const Matcher<Node*> value0_matcher_; |
321 const Matcher<Node*> value1_matcher_; | 321 const Matcher<Node*> value1_matcher_; |
322 const Matcher<Node*> control_matcher_; | 322 const Matcher<Node*> control_matcher_; |
323 }; | 323 }; |
324 | 324 |
325 | 325 |
326 class IsProjectionMatcher V8_FINAL : public NodeMatcher { | 326 class IsProjectionMatcher FINAL : public NodeMatcher { |
327 public: | 327 public: |
328 IsProjectionMatcher(const Matcher<int32_t>& index_matcher, | 328 IsProjectionMatcher(const Matcher<int32_t>& index_matcher, |
329 const Matcher<Node*>& base_matcher) | 329 const Matcher<Node*>& base_matcher) |
330 : NodeMatcher(IrOpcode::kProjection), | 330 : NodeMatcher(IrOpcode::kProjection), |
331 index_matcher_(index_matcher), | 331 index_matcher_(index_matcher), |
332 base_matcher_(base_matcher) {} | 332 base_matcher_(base_matcher) {} |
333 | 333 |
334 virtual void DescribeTo(std::ostream* os) const V8_OVERRIDE { | 334 virtual void DescribeTo(std::ostream* os) const OVERRIDE { |
335 NodeMatcher::DescribeTo(os); | 335 NodeMatcher::DescribeTo(os); |
336 *os << " whose index ("; | 336 *os << " whose index ("; |
337 index_matcher_.DescribeTo(os); | 337 index_matcher_.DescribeTo(os); |
338 *os << ") and base ("; | 338 *os << ") and base ("; |
339 base_matcher_.DescribeTo(os); | 339 base_matcher_.DescribeTo(os); |
340 *os << ")"; | 340 *os << ")"; |
341 } | 341 } |
342 | 342 |
343 virtual bool MatchAndExplain(Node* node, MatchResultListener* listener) const | 343 virtual bool MatchAndExplain(Node* node, MatchResultListener* listener) const |
344 V8_OVERRIDE { | 344 OVERRIDE { |
345 return (NodeMatcher::MatchAndExplain(node, listener) && | 345 return (NodeMatcher::MatchAndExplain(node, listener) && |
346 PrintMatchAndExplain(OpParameter<int32_t>(node), "index", | 346 PrintMatchAndExplain(OpParameter<int32_t>(node), "index", |
347 index_matcher_, listener) && | 347 index_matcher_, listener) && |
348 PrintMatchAndExplain(NodeProperties::GetValueInput(node, 0), "base", | 348 PrintMatchAndExplain(NodeProperties::GetValueInput(node, 0), "base", |
349 base_matcher_, listener)); | 349 base_matcher_, listener)); |
350 } | 350 } |
351 | 351 |
352 private: | 352 private: |
353 const Matcher<int32_t> index_matcher_; | 353 const Matcher<int32_t> index_matcher_; |
354 const Matcher<Node*> base_matcher_; | 354 const Matcher<Node*> base_matcher_; |
355 }; | 355 }; |
356 | 356 |
357 | 357 |
358 class IsCallMatcher V8_FINAL : public NodeMatcher { | 358 class IsCallMatcher FINAL : public NodeMatcher { |
359 public: | 359 public: |
360 IsCallMatcher(const Matcher<CallDescriptor*>& descriptor_matcher, | 360 IsCallMatcher(const Matcher<CallDescriptor*>& descriptor_matcher, |
361 const Matcher<Node*>& value0_matcher, | 361 const Matcher<Node*>& value0_matcher, |
362 const Matcher<Node*>& value1_matcher, | 362 const Matcher<Node*>& value1_matcher, |
363 const Matcher<Node*>& value2_matcher, | 363 const Matcher<Node*>& value2_matcher, |
364 const Matcher<Node*>& value3_matcher, | 364 const Matcher<Node*>& value3_matcher, |
365 const Matcher<Node*>& effect_matcher, | 365 const Matcher<Node*>& effect_matcher, |
366 const Matcher<Node*>& control_matcher) | 366 const Matcher<Node*>& control_matcher) |
367 : NodeMatcher(IrOpcode::kCall), | 367 : NodeMatcher(IrOpcode::kCall), |
368 descriptor_matcher_(descriptor_matcher), | 368 descriptor_matcher_(descriptor_matcher), |
369 value0_matcher_(value0_matcher), | 369 value0_matcher_(value0_matcher), |
370 value1_matcher_(value1_matcher), | 370 value1_matcher_(value1_matcher), |
371 value2_matcher_(value2_matcher), | 371 value2_matcher_(value2_matcher), |
372 value3_matcher_(value3_matcher), | 372 value3_matcher_(value3_matcher), |
373 effect_matcher_(effect_matcher), | 373 effect_matcher_(effect_matcher), |
374 control_matcher_(control_matcher) {} | 374 control_matcher_(control_matcher) {} |
375 | 375 |
376 virtual void DescribeTo(std::ostream* os) const V8_OVERRIDE { | 376 virtual void DescribeTo(std::ostream* os) const OVERRIDE { |
377 NodeMatcher::DescribeTo(os); | 377 NodeMatcher::DescribeTo(os); |
378 *os << " whose value0 ("; | 378 *os << " whose value0 ("; |
379 value0_matcher_.DescribeTo(os); | 379 value0_matcher_.DescribeTo(os); |
380 *os << ") and value1 ("; | 380 *os << ") and value1 ("; |
381 value1_matcher_.DescribeTo(os); | 381 value1_matcher_.DescribeTo(os); |
382 *os << ") and value2 ("; | 382 *os << ") and value2 ("; |
383 value2_matcher_.DescribeTo(os); | 383 value2_matcher_.DescribeTo(os); |
384 *os << ") and value3 ("; | 384 *os << ") and value3 ("; |
385 value3_matcher_.DescribeTo(os); | 385 value3_matcher_.DescribeTo(os); |
386 *os << ") and effect ("; | 386 *os << ") and effect ("; |
387 effect_matcher_.DescribeTo(os); | 387 effect_matcher_.DescribeTo(os); |
388 *os << ") and control ("; | 388 *os << ") and control ("; |
389 control_matcher_.DescribeTo(os); | 389 control_matcher_.DescribeTo(os); |
390 *os << ")"; | 390 *os << ")"; |
391 } | 391 } |
392 | 392 |
393 virtual bool MatchAndExplain(Node* node, MatchResultListener* listener) const | 393 virtual bool MatchAndExplain(Node* node, MatchResultListener* listener) const |
394 V8_OVERRIDE { | 394 OVERRIDE { |
395 return (NodeMatcher::MatchAndExplain(node, listener) && | 395 return (NodeMatcher::MatchAndExplain(node, listener) && |
396 PrintMatchAndExplain(OpParameter<CallDescriptor*>(node), | 396 PrintMatchAndExplain(OpParameter<CallDescriptor*>(node), |
397 "descriptor", descriptor_matcher_, listener) && | 397 "descriptor", descriptor_matcher_, listener) && |
398 PrintMatchAndExplain(NodeProperties::GetValueInput(node, 0), | 398 PrintMatchAndExplain(NodeProperties::GetValueInput(node, 0), |
399 "value0", value0_matcher_, listener) && | 399 "value0", value0_matcher_, listener) && |
400 PrintMatchAndExplain(NodeProperties::GetValueInput(node, 1), | 400 PrintMatchAndExplain(NodeProperties::GetValueInput(node, 1), |
401 "value1", value1_matcher_, listener) && | 401 "value1", value1_matcher_, listener) && |
402 PrintMatchAndExplain(NodeProperties::GetValueInput(node, 2), | 402 PrintMatchAndExplain(NodeProperties::GetValueInput(node, 2), |
403 "value2", value2_matcher_, listener) && | 403 "value2", value2_matcher_, listener) && |
404 PrintMatchAndExplain(NodeProperties::GetValueInput(node, 3), | 404 PrintMatchAndExplain(NodeProperties::GetValueInput(node, 3), |
405 "value3", value3_matcher_, listener) && | 405 "value3", value3_matcher_, listener) && |
406 PrintMatchAndExplain(NodeProperties::GetEffectInput(node), "effect", | 406 PrintMatchAndExplain(NodeProperties::GetEffectInput(node), "effect", |
407 effect_matcher_, listener) && | 407 effect_matcher_, listener) && |
408 PrintMatchAndExplain(NodeProperties::GetControlInput(node), | 408 PrintMatchAndExplain(NodeProperties::GetControlInput(node), |
409 "control", control_matcher_, listener)); | 409 "control", control_matcher_, listener)); |
410 } | 410 } |
411 | 411 |
412 private: | 412 private: |
413 const Matcher<CallDescriptor*> descriptor_matcher_; | 413 const Matcher<CallDescriptor*> descriptor_matcher_; |
414 const Matcher<Node*> value0_matcher_; | 414 const Matcher<Node*> value0_matcher_; |
415 const Matcher<Node*> value1_matcher_; | 415 const Matcher<Node*> value1_matcher_; |
416 const Matcher<Node*> value2_matcher_; | 416 const Matcher<Node*> value2_matcher_; |
417 const Matcher<Node*> value3_matcher_; | 417 const Matcher<Node*> value3_matcher_; |
418 const Matcher<Node*> effect_matcher_; | 418 const Matcher<Node*> effect_matcher_; |
419 const Matcher<Node*> control_matcher_; | 419 const Matcher<Node*> control_matcher_; |
420 }; | 420 }; |
421 | 421 |
422 | 422 |
423 class IsLoadMatcher V8_FINAL : public NodeMatcher { | 423 class IsLoadMatcher FINAL : public NodeMatcher { |
424 public: | 424 public: |
425 IsLoadMatcher(const Matcher<MachineType>& type_matcher, | 425 IsLoadMatcher(const Matcher<MachineType>& type_matcher, |
426 const Matcher<Node*>& base_matcher, | 426 const Matcher<Node*>& base_matcher, |
427 const Matcher<Node*>& index_matcher, | 427 const Matcher<Node*>& index_matcher, |
428 const Matcher<Node*>& effect_matcher) | 428 const Matcher<Node*>& effect_matcher) |
429 : NodeMatcher(IrOpcode::kLoad), | 429 : NodeMatcher(IrOpcode::kLoad), |
430 type_matcher_(type_matcher), | 430 type_matcher_(type_matcher), |
431 base_matcher_(base_matcher), | 431 base_matcher_(base_matcher), |
432 index_matcher_(index_matcher), | 432 index_matcher_(index_matcher), |
433 effect_matcher_(effect_matcher) {} | 433 effect_matcher_(effect_matcher) {} |
434 | 434 |
435 virtual void DescribeTo(std::ostream* os) const V8_OVERRIDE { | 435 virtual void DescribeTo(std::ostream* os) const OVERRIDE { |
436 NodeMatcher::DescribeTo(os); | 436 NodeMatcher::DescribeTo(os); |
437 *os << " whose type ("; | 437 *os << " whose type ("; |
438 type_matcher_.DescribeTo(os); | 438 type_matcher_.DescribeTo(os); |
439 *os << "), base ("; | 439 *os << "), base ("; |
440 base_matcher_.DescribeTo(os); | 440 base_matcher_.DescribeTo(os); |
441 *os << "), index ("; | 441 *os << "), index ("; |
442 index_matcher_.DescribeTo(os); | 442 index_matcher_.DescribeTo(os); |
443 *os << ") and effect ("; | 443 *os << ") and effect ("; |
444 effect_matcher_.DescribeTo(os); | 444 effect_matcher_.DescribeTo(os); |
445 *os << ")"; | 445 *os << ")"; |
446 } | 446 } |
447 | 447 |
448 virtual bool MatchAndExplain(Node* node, MatchResultListener* listener) const | 448 virtual bool MatchAndExplain(Node* node, MatchResultListener* listener) const |
449 V8_OVERRIDE { | 449 OVERRIDE { |
450 return (NodeMatcher::MatchAndExplain(node, listener) && | 450 return (NodeMatcher::MatchAndExplain(node, listener) && |
451 PrintMatchAndExplain(OpParameter<MachineType>(node), "type", | 451 PrintMatchAndExplain(OpParameter<MachineType>(node), "type", |
452 type_matcher_, listener) && | 452 type_matcher_, listener) && |
453 PrintMatchAndExplain(NodeProperties::GetValueInput(node, 0), "base", | 453 PrintMatchAndExplain(NodeProperties::GetValueInput(node, 0), "base", |
454 base_matcher_, listener) && | 454 base_matcher_, listener) && |
455 PrintMatchAndExplain(NodeProperties::GetValueInput(node, 1), | 455 PrintMatchAndExplain(NodeProperties::GetValueInput(node, 1), |
456 "index", index_matcher_, listener) && | 456 "index", index_matcher_, listener) && |
457 PrintMatchAndExplain(NodeProperties::GetEffectInput(node), "effect", | 457 PrintMatchAndExplain(NodeProperties::GetEffectInput(node), "effect", |
458 effect_matcher_, listener)); | 458 effect_matcher_, listener)); |
459 } | 459 } |
460 | 460 |
461 private: | 461 private: |
462 const Matcher<MachineType> type_matcher_; | 462 const Matcher<MachineType> type_matcher_; |
463 const Matcher<Node*> base_matcher_; | 463 const Matcher<Node*> base_matcher_; |
464 const Matcher<Node*> index_matcher_; | 464 const Matcher<Node*> index_matcher_; |
465 const Matcher<Node*> effect_matcher_; | 465 const Matcher<Node*> effect_matcher_; |
466 }; | 466 }; |
467 | 467 |
468 | 468 |
469 class IsStoreMatcher V8_FINAL : public NodeMatcher { | 469 class IsStoreMatcher FINAL : public NodeMatcher { |
470 public: | 470 public: |
471 IsStoreMatcher(const Matcher<MachineType>& type_matcher, | 471 IsStoreMatcher(const Matcher<MachineType>& type_matcher, |
472 const Matcher<WriteBarrierKind> write_barrier_matcher, | 472 const Matcher<WriteBarrierKind> write_barrier_matcher, |
473 const Matcher<Node*>& base_matcher, | 473 const Matcher<Node*>& base_matcher, |
474 const Matcher<Node*>& index_matcher, | 474 const Matcher<Node*>& index_matcher, |
475 const Matcher<Node*>& value_matcher, | 475 const Matcher<Node*>& value_matcher, |
476 const Matcher<Node*>& effect_matcher, | 476 const Matcher<Node*>& effect_matcher, |
477 const Matcher<Node*>& control_matcher) | 477 const Matcher<Node*>& control_matcher) |
478 : NodeMatcher(IrOpcode::kStore), | 478 : NodeMatcher(IrOpcode::kStore), |
479 type_matcher_(type_matcher), | 479 type_matcher_(type_matcher), |
480 write_barrier_matcher_(write_barrier_matcher), | 480 write_barrier_matcher_(write_barrier_matcher), |
481 base_matcher_(base_matcher), | 481 base_matcher_(base_matcher), |
482 index_matcher_(index_matcher), | 482 index_matcher_(index_matcher), |
483 value_matcher_(value_matcher), | 483 value_matcher_(value_matcher), |
484 effect_matcher_(effect_matcher), | 484 effect_matcher_(effect_matcher), |
485 control_matcher_(control_matcher) {} | 485 control_matcher_(control_matcher) {} |
486 | 486 |
487 virtual void DescribeTo(std::ostream* os) const V8_OVERRIDE { | 487 virtual void DescribeTo(std::ostream* os) const OVERRIDE { |
488 NodeMatcher::DescribeTo(os); | 488 NodeMatcher::DescribeTo(os); |
489 *os << " whose type ("; | 489 *os << " whose type ("; |
490 type_matcher_.DescribeTo(os); | 490 type_matcher_.DescribeTo(os); |
491 *os << "), write barrier ("; | 491 *os << "), write barrier ("; |
492 write_barrier_matcher_.DescribeTo(os); | 492 write_barrier_matcher_.DescribeTo(os); |
493 *os << "), base ("; | 493 *os << "), base ("; |
494 base_matcher_.DescribeTo(os); | 494 base_matcher_.DescribeTo(os); |
495 *os << "), index ("; | 495 *os << "), index ("; |
496 index_matcher_.DescribeTo(os); | 496 index_matcher_.DescribeTo(os); |
497 *os << "), value ("; | 497 *os << "), value ("; |
498 value_matcher_.DescribeTo(os); | 498 value_matcher_.DescribeTo(os); |
499 *os << "), effect ("; | 499 *os << "), effect ("; |
500 effect_matcher_.DescribeTo(os); | 500 effect_matcher_.DescribeTo(os); |
501 *os << ") and control ("; | 501 *os << ") and control ("; |
502 control_matcher_.DescribeTo(os); | 502 control_matcher_.DescribeTo(os); |
503 *os << ")"; | 503 *os << ")"; |
504 } | 504 } |
505 | 505 |
506 virtual bool MatchAndExplain(Node* node, MatchResultListener* listener) const | 506 virtual bool MatchAndExplain(Node* node, MatchResultListener* listener) const |
507 V8_OVERRIDE { | 507 OVERRIDE { |
508 return (NodeMatcher::MatchAndExplain(node, listener) && | 508 return (NodeMatcher::MatchAndExplain(node, listener) && |
509 PrintMatchAndExplain( | 509 PrintMatchAndExplain( |
510 OpParameter<StoreRepresentation>(node).machine_type, "type", | 510 OpParameter<StoreRepresentation>(node).machine_type, "type", |
511 type_matcher_, listener) && | 511 type_matcher_, listener) && |
512 PrintMatchAndExplain( | 512 PrintMatchAndExplain( |
513 OpParameter<StoreRepresentation>(node).write_barrier_kind, | 513 OpParameter<StoreRepresentation>(node).write_barrier_kind, |
514 "write barrier", write_barrier_matcher_, listener) && | 514 "write barrier", write_barrier_matcher_, listener) && |
515 PrintMatchAndExplain(NodeProperties::GetValueInput(node, 0), "base", | 515 PrintMatchAndExplain(NodeProperties::GetValueInput(node, 0), "base", |
516 base_matcher_, listener) && | 516 base_matcher_, listener) && |
517 PrintMatchAndExplain(NodeProperties::GetValueInput(node, 1), | 517 PrintMatchAndExplain(NodeProperties::GetValueInput(node, 1), |
(...skipping 10 matching lines...) Expand all Loading... |
528 const Matcher<MachineType> type_matcher_; | 528 const Matcher<MachineType> type_matcher_; |
529 const Matcher<WriteBarrierKind> write_barrier_matcher_; | 529 const Matcher<WriteBarrierKind> write_barrier_matcher_; |
530 const Matcher<Node*> base_matcher_; | 530 const Matcher<Node*> base_matcher_; |
531 const Matcher<Node*> index_matcher_; | 531 const Matcher<Node*> index_matcher_; |
532 const Matcher<Node*> value_matcher_; | 532 const Matcher<Node*> value_matcher_; |
533 const Matcher<Node*> effect_matcher_; | 533 const Matcher<Node*> effect_matcher_; |
534 const Matcher<Node*> control_matcher_; | 534 const Matcher<Node*> control_matcher_; |
535 }; | 535 }; |
536 | 536 |
537 | 537 |
538 class IsBinopMatcher V8_FINAL : public NodeMatcher { | 538 class IsBinopMatcher FINAL : public NodeMatcher { |
539 public: | 539 public: |
540 IsBinopMatcher(IrOpcode::Value opcode, const Matcher<Node*>& lhs_matcher, | 540 IsBinopMatcher(IrOpcode::Value opcode, const Matcher<Node*>& lhs_matcher, |
541 const Matcher<Node*>& rhs_matcher) | 541 const Matcher<Node*>& rhs_matcher) |
542 : NodeMatcher(opcode), | 542 : NodeMatcher(opcode), |
543 lhs_matcher_(lhs_matcher), | 543 lhs_matcher_(lhs_matcher), |
544 rhs_matcher_(rhs_matcher) {} | 544 rhs_matcher_(rhs_matcher) {} |
545 | 545 |
546 virtual void DescribeTo(std::ostream* os) const V8_OVERRIDE { | 546 virtual void DescribeTo(std::ostream* os) const OVERRIDE { |
547 NodeMatcher::DescribeTo(os); | 547 NodeMatcher::DescribeTo(os); |
548 *os << " whose lhs ("; | 548 *os << " whose lhs ("; |
549 lhs_matcher_.DescribeTo(os); | 549 lhs_matcher_.DescribeTo(os); |
550 *os << ") and rhs ("; | 550 *os << ") and rhs ("; |
551 rhs_matcher_.DescribeTo(os); | 551 rhs_matcher_.DescribeTo(os); |
552 *os << ")"; | 552 *os << ")"; |
553 } | 553 } |
554 | 554 |
555 virtual bool MatchAndExplain(Node* node, MatchResultListener* listener) const | 555 virtual bool MatchAndExplain(Node* node, MatchResultListener* listener) const |
556 V8_OVERRIDE { | 556 OVERRIDE { |
557 return (NodeMatcher::MatchAndExplain(node, listener) && | 557 return (NodeMatcher::MatchAndExplain(node, listener) && |
558 PrintMatchAndExplain(NodeProperties::GetValueInput(node, 0), "lhs", | 558 PrintMatchAndExplain(NodeProperties::GetValueInput(node, 0), "lhs", |
559 lhs_matcher_, listener) && | 559 lhs_matcher_, listener) && |
560 PrintMatchAndExplain(NodeProperties::GetValueInput(node, 1), "rhs", | 560 PrintMatchAndExplain(NodeProperties::GetValueInput(node, 1), "rhs", |
561 rhs_matcher_, listener)); | 561 rhs_matcher_, listener)); |
562 } | 562 } |
563 | 563 |
564 private: | 564 private: |
565 const Matcher<Node*> lhs_matcher_; | 565 const Matcher<Node*> lhs_matcher_; |
566 const Matcher<Node*> rhs_matcher_; | 566 const Matcher<Node*> rhs_matcher_; |
567 }; | 567 }; |
568 | 568 |
569 | 569 |
570 class IsUnopMatcher V8_FINAL : public NodeMatcher { | 570 class IsUnopMatcher FINAL : public NodeMatcher { |
571 public: | 571 public: |
572 IsUnopMatcher(IrOpcode::Value opcode, const Matcher<Node*>& input_matcher) | 572 IsUnopMatcher(IrOpcode::Value opcode, const Matcher<Node*>& input_matcher) |
573 : NodeMatcher(opcode), input_matcher_(input_matcher) {} | 573 : NodeMatcher(opcode), input_matcher_(input_matcher) {} |
574 | 574 |
575 virtual void DescribeTo(std::ostream* os) const V8_OVERRIDE { | 575 virtual void DescribeTo(std::ostream* os) const OVERRIDE { |
576 NodeMatcher::DescribeTo(os); | 576 NodeMatcher::DescribeTo(os); |
577 *os << " whose input ("; | 577 *os << " whose input ("; |
578 input_matcher_.DescribeTo(os); | 578 input_matcher_.DescribeTo(os); |
579 *os << ")"; | 579 *os << ")"; |
580 } | 580 } |
581 | 581 |
582 virtual bool MatchAndExplain(Node* node, MatchResultListener* listener) const | 582 virtual bool MatchAndExplain(Node* node, MatchResultListener* listener) const |
583 V8_OVERRIDE { | 583 OVERRIDE { |
584 return (NodeMatcher::MatchAndExplain(node, listener) && | 584 return (NodeMatcher::MatchAndExplain(node, listener) && |
585 PrintMatchAndExplain(NodeProperties::GetValueInput(node, 0), | 585 PrintMatchAndExplain(NodeProperties::GetValueInput(node, 0), |
586 "input", input_matcher_, listener)); | 586 "input", input_matcher_, listener)); |
587 } | 587 } |
588 | 588 |
589 private: | 589 private: |
590 const Matcher<Node*> input_matcher_; | 590 const Matcher<Node*> input_matcher_; |
591 }; | 591 }; |
592 } | 592 } |
593 | 593 |
(...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
749 IS_UNOP_MATCHER(ChangeInt32ToInt64) | 749 IS_UNOP_MATCHER(ChangeInt32ToInt64) |
750 IS_UNOP_MATCHER(ChangeUint32ToFloat64) | 750 IS_UNOP_MATCHER(ChangeUint32ToFloat64) |
751 IS_UNOP_MATCHER(ChangeUint32ToUint64) | 751 IS_UNOP_MATCHER(ChangeUint32ToUint64) |
752 IS_UNOP_MATCHER(TruncateFloat64ToInt32) | 752 IS_UNOP_MATCHER(TruncateFloat64ToInt32) |
753 IS_UNOP_MATCHER(TruncateInt64ToInt32) | 753 IS_UNOP_MATCHER(TruncateInt64ToInt32) |
754 #undef IS_UNOP_MATCHER | 754 #undef IS_UNOP_MATCHER |
755 | 755 |
756 } // namespace compiler | 756 } // namespace compiler |
757 } // namespace internal | 757 } // namespace internal |
758 } // namespace v8 | 758 } // namespace v8 |
OLD | NEW |