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 267 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
278 listener)); | 278 listener)); |
279 } | 279 } |
280 | 280 |
281 private: | 281 private: |
282 const Matcher<T> value_matcher_; | 282 const Matcher<T> value_matcher_; |
283 }; | 283 }; |
284 | 284 |
285 | 285 |
286 class IsPhiMatcher FINAL : public NodeMatcher { | 286 class IsPhiMatcher FINAL : public NodeMatcher { |
287 public: | 287 public: |
288 IsPhiMatcher(const Matcher<Node*>& value0_matcher, | 288 IsPhiMatcher(const Matcher<MachineType>& type_matcher, |
| 289 const Matcher<Node*>& value0_matcher, |
289 const Matcher<Node*>& value1_matcher, | 290 const Matcher<Node*>& value1_matcher, |
290 const Matcher<Node*>& control_matcher) | 291 const Matcher<Node*>& control_matcher) |
291 : NodeMatcher(IrOpcode::kPhi), | 292 : NodeMatcher(IrOpcode::kPhi), |
| 293 type_matcher_(type_matcher), |
292 value0_matcher_(value0_matcher), | 294 value0_matcher_(value0_matcher), |
293 value1_matcher_(value1_matcher), | 295 value1_matcher_(value1_matcher), |
294 control_matcher_(control_matcher) {} | 296 control_matcher_(control_matcher) {} |
295 | 297 |
296 virtual void DescribeTo(std::ostream* os) const OVERRIDE { | 298 virtual void DescribeTo(std::ostream* os) const OVERRIDE { |
297 NodeMatcher::DescribeTo(os); | 299 NodeMatcher::DescribeTo(os); |
298 *os << " whose value0 ("; | 300 *os << " whose type ("; |
| 301 type_matcher_.DescribeTo(os); |
| 302 *os << "), value0 ("; |
299 value0_matcher_.DescribeTo(os); | 303 value0_matcher_.DescribeTo(os); |
300 *os << "), value1 ("; | 304 *os << "), value1 ("; |
301 value1_matcher_.DescribeTo(os); | 305 value1_matcher_.DescribeTo(os); |
302 *os << ") and control ("; | 306 *os << ") and control ("; |
303 control_matcher_.DescribeTo(os); | 307 control_matcher_.DescribeTo(os); |
304 *os << ")"; | 308 *os << ")"; |
305 } | 309 } |
306 | 310 |
307 virtual bool MatchAndExplain(Node* node, MatchResultListener* listener) const | 311 virtual bool MatchAndExplain(Node* node, MatchResultListener* listener) const |
308 OVERRIDE { | 312 OVERRIDE { |
309 return (NodeMatcher::MatchAndExplain(node, listener) && | 313 return (NodeMatcher::MatchAndExplain(node, listener) && |
| 314 PrintMatchAndExplain(OpParameter<MachineType>(node), "type", |
| 315 type_matcher_, listener) && |
310 PrintMatchAndExplain(NodeProperties::GetValueInput(node, 0), | 316 PrintMatchAndExplain(NodeProperties::GetValueInput(node, 0), |
311 "value0", value0_matcher_, listener) && | 317 "value0", value0_matcher_, listener) && |
312 PrintMatchAndExplain(NodeProperties::GetValueInput(node, 1), | 318 PrintMatchAndExplain(NodeProperties::GetValueInput(node, 1), |
313 "value1", value1_matcher_, listener) && | 319 "value1", value1_matcher_, listener) && |
314 PrintMatchAndExplain(NodeProperties::GetControlInput(node), | 320 PrintMatchAndExplain(NodeProperties::GetControlInput(node), |
315 "control", control_matcher_, listener)); | 321 "control", control_matcher_, listener)); |
316 } | 322 } |
317 | 323 |
318 private: | 324 private: |
| 325 const Matcher<MachineType> type_matcher_; |
319 const Matcher<Node*> value0_matcher_; | 326 const Matcher<Node*> value0_matcher_; |
320 const Matcher<Node*> value1_matcher_; | 327 const Matcher<Node*> value1_matcher_; |
321 const Matcher<Node*> control_matcher_; | 328 const Matcher<Node*> control_matcher_; |
322 }; | 329 }; |
323 | 330 |
324 | 331 |
325 class IsProjectionMatcher FINAL : public NodeMatcher { | 332 class IsProjectionMatcher FINAL : public NodeMatcher { |
326 public: | 333 public: |
327 IsProjectionMatcher(const Matcher<int32_t>& index_matcher, | 334 IsProjectionMatcher(const Matcher<int32_t>& index_matcher, |
328 const Matcher<Node*>& base_matcher) | 335 const Matcher<Node*>& base_matcher) |
329 : NodeMatcher(IrOpcode::kProjection), | 336 : NodeMatcher(IrOpcode::kProjection), |
330 index_matcher_(index_matcher), | 337 index_matcher_(index_matcher), |
331 base_matcher_(base_matcher) {} | 338 base_matcher_(base_matcher) {} |
332 | 339 |
333 virtual void DescribeTo(std::ostream* os) const OVERRIDE { | 340 virtual void DescribeTo(std::ostream* os) const OVERRIDE { |
334 NodeMatcher::DescribeTo(os); | 341 NodeMatcher::DescribeTo(os); |
335 *os << " whose index ("; | 342 *os << " whose index ("; |
336 index_matcher_.DescribeTo(os); | 343 index_matcher_.DescribeTo(os); |
337 *os << ") and base ("; | 344 *os << ") and base ("; |
338 base_matcher_.DescribeTo(os); | 345 base_matcher_.DescribeTo(os); |
339 *os << ")"; | 346 *os << ")"; |
340 } | 347 } |
341 | 348 |
342 virtual bool MatchAndExplain(Node* node, MatchResultListener* listener) const | 349 virtual bool MatchAndExplain(Node* node, MatchResultListener* listener) const |
343 OVERRIDE { | 350 OVERRIDE { |
344 return (NodeMatcher::MatchAndExplain(node, listener) && | 351 return (NodeMatcher::MatchAndExplain(node, listener) && |
345 PrintMatchAndExplain(OpParameter<int32_t>(node), "index", | 352 PrintMatchAndExplain(OpParameter<int>(node), "index", |
346 index_matcher_, listener) && | 353 index_matcher_, listener) && |
347 PrintMatchAndExplain(NodeProperties::GetValueInput(node, 0), "base", | 354 PrintMatchAndExplain(NodeProperties::GetValueInput(node, 0), "base", |
348 base_matcher_, listener)); | 355 base_matcher_, listener)); |
349 } | 356 } |
350 | 357 |
351 private: | 358 private: |
352 const Matcher<int32_t> index_matcher_; | 359 const Matcher<int32_t> index_matcher_; |
353 const Matcher<Node*> base_matcher_; | 360 const Matcher<Node*> base_matcher_; |
354 }; | 361 }; |
355 | 362 |
(...skipping 306 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
662 new IsConstantMatcher<double>(IrOpcode::kFloat64Constant, value_matcher)); | 669 new IsConstantMatcher<double>(IrOpcode::kFloat64Constant, value_matcher)); |
663 } | 670 } |
664 | 671 |
665 | 672 |
666 Matcher<Node*> IsNumberConstant(const Matcher<double>& value_matcher) { | 673 Matcher<Node*> IsNumberConstant(const Matcher<double>& value_matcher) { |
667 return MakeMatcher( | 674 return MakeMatcher( |
668 new IsConstantMatcher<double>(IrOpcode::kNumberConstant, value_matcher)); | 675 new IsConstantMatcher<double>(IrOpcode::kNumberConstant, value_matcher)); |
669 } | 676 } |
670 | 677 |
671 | 678 |
672 Matcher<Node*> IsPhi(const Matcher<Node*>& value0_matcher, | 679 Matcher<Node*> IsPhi(const Matcher<MachineType>& type_matcher, |
| 680 const Matcher<Node*>& value0_matcher, |
673 const Matcher<Node*>& value1_matcher, | 681 const Matcher<Node*>& value1_matcher, |
674 const Matcher<Node*>& merge_matcher) { | 682 const Matcher<Node*>& merge_matcher) { |
675 return MakeMatcher( | 683 return MakeMatcher(new IsPhiMatcher(type_matcher, value0_matcher, |
676 new IsPhiMatcher(value0_matcher, value1_matcher, merge_matcher)); | 684 value1_matcher, merge_matcher)); |
677 } | 685 } |
678 | 686 |
679 | 687 |
680 Matcher<Node*> IsProjection(const Matcher<int32_t>& index_matcher, | 688 Matcher<Node*> IsProjection(const Matcher<int32_t>& index_matcher, |
681 const Matcher<Node*>& base_matcher) { | 689 const Matcher<Node*>& base_matcher) { |
682 return MakeMatcher(new IsProjectionMatcher(index_matcher, base_matcher)); | 690 return MakeMatcher(new IsProjectionMatcher(index_matcher, base_matcher)); |
683 } | 691 } |
684 | 692 |
685 | 693 |
686 Matcher<Node*> IsCall(const Matcher<CallDescriptor*>& descriptor_matcher, | 694 Matcher<Node*> IsCall(const Matcher<CallDescriptor*>& descriptor_matcher, |
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
748 IS_UNOP_MATCHER(ChangeInt32ToInt64) | 756 IS_UNOP_MATCHER(ChangeInt32ToInt64) |
749 IS_UNOP_MATCHER(ChangeUint32ToFloat64) | 757 IS_UNOP_MATCHER(ChangeUint32ToFloat64) |
750 IS_UNOP_MATCHER(ChangeUint32ToUint64) | 758 IS_UNOP_MATCHER(ChangeUint32ToUint64) |
751 IS_UNOP_MATCHER(TruncateFloat64ToInt32) | 759 IS_UNOP_MATCHER(TruncateFloat64ToInt32) |
752 IS_UNOP_MATCHER(TruncateInt64ToInt32) | 760 IS_UNOP_MATCHER(TruncateInt64ToInt32) |
753 #undef IS_UNOP_MATCHER | 761 #undef IS_UNOP_MATCHER |
754 | 762 |
755 } // namespace compiler | 763 } // namespace compiler |
756 } // namespace internal | 764 } // namespace internal |
757 } // namespace v8 | 765 } // namespace v8 |
OLD | NEW |