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 "test/unittests/compiler/node-test-utils.h" | 5 #include "test/unittests/compiler/node-test-utils.h" |
6 | 6 |
7 #include <vector> | 7 #include <vector> |
8 | 8 |
9 #include "src/assembler.h" | 9 #include "src/assembler.h" |
10 #include "src/compiler/common-operator.h" | 10 #include "src/compiler/common-operator.h" |
(...skipping 305 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
316 }; | 316 }; |
317 | 317 |
318 | 318 |
319 class IsReturnMatcher final : public NodeMatcher { | 319 class IsReturnMatcher final : public NodeMatcher { |
320 public: | 320 public: |
321 IsReturnMatcher(const Matcher<Node*>& value_matcher, | 321 IsReturnMatcher(const Matcher<Node*>& value_matcher, |
322 const Matcher<Node*>& effect_matcher, | 322 const Matcher<Node*>& effect_matcher, |
323 const Matcher<Node*>& control_matcher) | 323 const Matcher<Node*>& control_matcher) |
324 : NodeMatcher(IrOpcode::kReturn), | 324 : NodeMatcher(IrOpcode::kReturn), |
325 value_matcher_(value_matcher), | 325 value_matcher_(value_matcher), |
| 326 value2_matcher_(_), |
326 effect_matcher_(effect_matcher), | 327 effect_matcher_(effect_matcher), |
327 control_matcher_(control_matcher) {} | 328 control_matcher_(control_matcher), |
| 329 has_second_return_value_(false) {} |
| 330 |
| 331 IsReturnMatcher(const Matcher<Node*>& value_matcher, |
| 332 const Matcher<Node*>& value2_matcher, |
| 333 const Matcher<Node*>& effect_matcher, |
| 334 const Matcher<Node*>& control_matcher) |
| 335 : NodeMatcher(IrOpcode::kReturn), |
| 336 value_matcher_(value_matcher), |
| 337 value2_matcher_(value2_matcher), |
| 338 effect_matcher_(effect_matcher), |
| 339 control_matcher_(control_matcher), |
| 340 has_second_return_value_(true) {} |
328 | 341 |
329 void DescribeTo(std::ostream* os) const final { | 342 void DescribeTo(std::ostream* os) const final { |
330 NodeMatcher::DescribeTo(os); | 343 NodeMatcher::DescribeTo(os); |
331 *os << " whose value ("; | 344 *os << " whose value ("; |
332 value_matcher_.DescribeTo(os); | 345 value_matcher_.DescribeTo(os); |
| 346 if (has_second_return_value_) { |
| 347 *os << ") and second value ("; |
| 348 value2_matcher_.DescribeTo(os); |
| 349 } |
333 *os << ") and effect ("; | 350 *os << ") and effect ("; |
334 effect_matcher_.DescribeTo(os); | 351 effect_matcher_.DescribeTo(os); |
335 *os << ") and control ("; | 352 *os << ") and control ("; |
336 control_matcher_.DescribeTo(os); | 353 control_matcher_.DescribeTo(os); |
337 *os << ")"; | 354 *os << ")"; |
338 } | 355 } |
339 | 356 |
340 bool MatchAndExplain(Node* node, MatchResultListener* listener) const final { | 357 bool MatchAndExplain(Node* node, MatchResultListener* listener) const final { |
341 return (NodeMatcher::MatchAndExplain(node, listener) && | 358 return (NodeMatcher::MatchAndExplain(node, listener) && |
342 PrintMatchAndExplain(NodeProperties::GetValueInput(node, 0), | 359 PrintMatchAndExplain(NodeProperties::GetValueInput(node, 0), |
343 "value", value_matcher_, listener) && | 360 "value", value_matcher_, listener) && |
| 361 (!has_second_return_value_ || |
| 362 PrintMatchAndExplain(NodeProperties::GetValueInput(node, 1), |
| 363 "value2", value2_matcher_, listener)) && |
344 PrintMatchAndExplain(NodeProperties::GetEffectInput(node), "effect", | 364 PrintMatchAndExplain(NodeProperties::GetEffectInput(node), "effect", |
345 effect_matcher_, listener) && | 365 effect_matcher_, listener) && |
346 PrintMatchAndExplain(NodeProperties::GetControlInput(node), | 366 PrintMatchAndExplain(NodeProperties::GetControlInput(node), |
347 "control", control_matcher_, listener)); | 367 "control", control_matcher_, listener)); |
348 } | 368 } |
349 | 369 |
350 private: | 370 private: |
351 const Matcher<Node*> value_matcher_; | 371 const Matcher<Node*> value_matcher_; |
| 372 const Matcher<Node*> value2_matcher_; |
352 const Matcher<Node*> effect_matcher_; | 373 const Matcher<Node*> effect_matcher_; |
353 const Matcher<Node*> control_matcher_; | 374 const Matcher<Node*> control_matcher_; |
| 375 bool has_second_return_value_; |
354 }; | 376 }; |
355 | 377 |
356 | 378 |
357 class IsTerminateMatcher final : public NodeMatcher { | 379 class IsTerminateMatcher final : public NodeMatcher { |
358 public: | 380 public: |
359 IsTerminateMatcher(const Matcher<Node*>& effect_matcher, | 381 IsTerminateMatcher(const Matcher<Node*>& effect_matcher, |
360 const Matcher<Node*>& control_matcher) | 382 const Matcher<Node*>& control_matcher) |
361 : NodeMatcher(IrOpcode::kTerminate), | 383 : NodeMatcher(IrOpcode::kTerminate), |
362 effect_matcher_(effect_matcher), | 384 effect_matcher_(effect_matcher), |
363 control_matcher_(control_matcher) {} | 385 control_matcher_(control_matcher) {} |
(...skipping 1096 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1460 const Matcher<int> index_matcher_; | 1482 const Matcher<int> index_matcher_; |
1461 }; | 1483 }; |
1462 | 1484 |
1463 } // namespace | 1485 } // namespace |
1464 | 1486 |
1465 | 1487 |
1466 Matcher<Node*> IsDead() { | 1488 Matcher<Node*> IsDead() { |
1467 return MakeMatcher(new NodeMatcher(IrOpcode::kDead)); | 1489 return MakeMatcher(new NodeMatcher(IrOpcode::kDead)); |
1468 } | 1490 } |
1469 | 1491 |
1470 | |
1471 Matcher<Node*> IsEnd(const Matcher<Node*>& control0_matcher) { | 1492 Matcher<Node*> IsEnd(const Matcher<Node*>& control0_matcher) { |
1472 return MakeMatcher(new IsControl1Matcher(IrOpcode::kEnd, control0_matcher)); | 1493 return MakeMatcher(new IsControl1Matcher(IrOpcode::kEnd, control0_matcher)); |
1473 } | 1494 } |
1474 | 1495 |
1475 | 1496 |
1476 Matcher<Node*> IsEnd(const Matcher<Node*>& control0_matcher, | 1497 Matcher<Node*> IsEnd(const Matcher<Node*>& control0_matcher, |
1477 const Matcher<Node*>& control1_matcher) { | 1498 const Matcher<Node*>& control1_matcher) { |
1478 return MakeMatcher(new IsControl2Matcher(IrOpcode::kEnd, control0_matcher, | 1499 return MakeMatcher(new IsControl2Matcher(IrOpcode::kEnd, control0_matcher, |
1479 control1_matcher)); | 1500 control1_matcher)); |
1480 } | 1501 } |
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1570 } | 1591 } |
1571 | 1592 |
1572 | 1593 |
1573 Matcher<Node*> IsReturn(const Matcher<Node*>& value_matcher, | 1594 Matcher<Node*> IsReturn(const Matcher<Node*>& value_matcher, |
1574 const Matcher<Node*>& effect_matcher, | 1595 const Matcher<Node*>& effect_matcher, |
1575 const Matcher<Node*>& control_matcher) { | 1596 const Matcher<Node*>& control_matcher) { |
1576 return MakeMatcher( | 1597 return MakeMatcher( |
1577 new IsReturnMatcher(value_matcher, effect_matcher, control_matcher)); | 1598 new IsReturnMatcher(value_matcher, effect_matcher, control_matcher)); |
1578 } | 1599 } |
1579 | 1600 |
| 1601 Matcher<Node*> IsReturn2(const Matcher<Node*>& value_matcher, |
| 1602 const Matcher<Node*>& value2_matcher, |
| 1603 const Matcher<Node*>& effect_matcher, |
| 1604 const Matcher<Node*>& control_matcher) { |
| 1605 return MakeMatcher(new IsReturnMatcher(value_matcher, value2_matcher, |
| 1606 effect_matcher, control_matcher)); |
| 1607 } |
1580 | 1608 |
1581 Matcher<Node*> IsTerminate(const Matcher<Node*>& effect_matcher, | 1609 Matcher<Node*> IsTerminate(const Matcher<Node*>& effect_matcher, |
1582 const Matcher<Node*>& control_matcher) { | 1610 const Matcher<Node*>& control_matcher) { |
1583 return MakeMatcher(new IsTerminateMatcher(effect_matcher, control_matcher)); | 1611 return MakeMatcher(new IsTerminateMatcher(effect_matcher, control_matcher)); |
1584 } | 1612 } |
1585 | 1613 |
1586 | 1614 |
1587 Matcher<Node*> IsExternalConstant( | 1615 Matcher<Node*> IsExternalConstant( |
1588 const Matcher<ExternalReference>& value_matcher) { | 1616 const Matcher<ExternalReference>& value_matcher) { |
1589 return MakeMatcher(new IsConstantMatcher<ExternalReference>( | 1617 return MakeMatcher(new IsConstantMatcher<ExternalReference>( |
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1668 const Matcher<Node*>& effect1_matcher) { | 1696 const Matcher<Node*>& effect1_matcher) { |
1669 return MakeMatcher(new IsEffectSetMatcher(effect0_matcher, effect1_matcher)); | 1697 return MakeMatcher(new IsEffectSetMatcher(effect0_matcher, effect1_matcher)); |
1670 } | 1698 } |
1671 | 1699 |
1672 | 1700 |
1673 Matcher<Node*> IsProjection(const Matcher<size_t>& index_matcher, | 1701 Matcher<Node*> IsProjection(const Matcher<size_t>& index_matcher, |
1674 const Matcher<Node*>& base_matcher) { | 1702 const Matcher<Node*>& base_matcher) { |
1675 return MakeMatcher(new IsProjectionMatcher(index_matcher, base_matcher)); | 1703 return MakeMatcher(new IsProjectionMatcher(index_matcher, base_matcher)); |
1676 } | 1704 } |
1677 | 1705 |
| 1706 Matcher<Node*> IsCall(const Matcher<const CallDescriptor*>& descriptor_matcher, |
| 1707 const Matcher<Node*>& value0_matcher, |
| 1708 const Matcher<Node*>& effect_matcher, |
| 1709 const Matcher<Node*>& control_matcher) { |
| 1710 std::vector<Matcher<Node*>> value_matchers; |
| 1711 value_matchers.push_back(value0_matcher); |
| 1712 return MakeMatcher(new IsCallMatcher(descriptor_matcher, value_matchers, |
| 1713 effect_matcher, control_matcher)); |
| 1714 } |
1678 | 1715 |
1679 Matcher<Node*> IsCall(const Matcher<const CallDescriptor*>& descriptor_matcher, | 1716 Matcher<Node*> IsCall(const Matcher<const CallDescriptor*>& descriptor_matcher, |
1680 const Matcher<Node*>& value0_matcher, | 1717 const Matcher<Node*>& value0_matcher, |
1681 const Matcher<Node*>& value1_matcher, | 1718 const Matcher<Node*>& value1_matcher, |
1682 const Matcher<Node*>& effect_matcher, | 1719 const Matcher<Node*>& effect_matcher, |
1683 const Matcher<Node*>& control_matcher) { | 1720 const Matcher<Node*>& control_matcher) { |
1684 std::vector<Matcher<Node*>> value_matchers; | 1721 std::vector<Matcher<Node*>> value_matchers; |
1685 value_matchers.push_back(value0_matcher); | 1722 value_matchers.push_back(value0_matcher); |
1686 value_matchers.push_back(value1_matcher); | 1723 value_matchers.push_back(value1_matcher); |
1687 return MakeMatcher(new IsCallMatcher(descriptor_matcher, value_matchers, | 1724 return MakeMatcher(new IsCallMatcher(descriptor_matcher, value_matchers, |
(...skipping 419 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2107 IS_UNOP_MATCHER(NumberToInt32) | 2144 IS_UNOP_MATCHER(NumberToInt32) |
2108 IS_UNOP_MATCHER(NumberToUint32) | 2145 IS_UNOP_MATCHER(NumberToUint32) |
2109 IS_UNOP_MATCHER(ObjectIsReceiver) | 2146 IS_UNOP_MATCHER(ObjectIsReceiver) |
2110 IS_UNOP_MATCHER(ObjectIsSmi) | 2147 IS_UNOP_MATCHER(ObjectIsSmi) |
2111 IS_UNOP_MATCHER(Word32Clz) | 2148 IS_UNOP_MATCHER(Word32Clz) |
2112 #undef IS_UNOP_MATCHER | 2149 #undef IS_UNOP_MATCHER |
2113 | 2150 |
2114 } // namespace compiler | 2151 } // namespace compiler |
2115 } // namespace internal | 2152 } // namespace internal |
2116 } // namespace v8 | 2153 } // namespace v8 |
OLD | NEW |