| 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 394 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 405 value0_matcher_.DescribeTo(os); | 405 value0_matcher_.DescribeTo(os); |
| 406 *os << "), value1 ("; | 406 *os << "), value1 ("; |
| 407 value1_matcher_.DescribeTo(os); | 407 value1_matcher_.DescribeTo(os); |
| 408 *os << ") and value2 ("; | 408 *os << ") and value2 ("; |
| 409 value2_matcher_.DescribeTo(os); | 409 value2_matcher_.DescribeTo(os); |
| 410 *os << ")"; | 410 *os << ")"; |
| 411 } | 411 } |
| 412 | 412 |
| 413 bool MatchAndExplain(Node* node, MatchResultListener* listener) const final { | 413 bool MatchAndExplain(Node* node, MatchResultListener* listener) const final { |
| 414 return (NodeMatcher::MatchAndExplain(node, listener) && | 414 return (NodeMatcher::MatchAndExplain(node, listener) && |
| 415 PrintMatchAndExplain(OpParameter<MachineType>(node), "type", | 415 PrintMatchAndExplain(OpParameter<SelectParameters>(node).type(), |
| 416 type_matcher_, listener) && | 416 "type", type_matcher_, listener) && |
| 417 PrintMatchAndExplain(NodeProperties::GetValueInput(node, 0), | 417 PrintMatchAndExplain(NodeProperties::GetValueInput(node, 0), |
| 418 "value0", value0_matcher_, listener) && | 418 "value0", value0_matcher_, listener) && |
| 419 PrintMatchAndExplain(NodeProperties::GetValueInput(node, 1), | 419 PrintMatchAndExplain(NodeProperties::GetValueInput(node, 1), |
| 420 "value1", value1_matcher_, listener) && | 420 "value1", value1_matcher_, listener) && |
| 421 PrintMatchAndExplain(NodeProperties::GetValueInput(node, 2), | 421 PrintMatchAndExplain(NodeProperties::GetValueInput(node, 2), |
| 422 "value2", value2_matcher_, listener)); | 422 "value2", value2_matcher_, listener)); |
| 423 } | 423 } |
| 424 | 424 |
| 425 private: | 425 private: |
| 426 const Matcher<MachineType> type_matcher_; | 426 const Matcher<MachineType> type_matcher_; |
| (...skipping 207 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 634 } | 634 } |
| 635 | 635 |
| 636 private: | 636 private: |
| 637 const Matcher<size_t> index_matcher_; | 637 const Matcher<size_t> index_matcher_; |
| 638 const Matcher<Node*> base_matcher_; | 638 const Matcher<Node*> base_matcher_; |
| 639 }; | 639 }; |
| 640 | 640 |
| 641 | 641 |
| 642 class IsCallMatcher final : public NodeMatcher { | 642 class IsCallMatcher final : public NodeMatcher { |
| 643 public: | 643 public: |
| 644 IsCallMatcher(const Matcher<CallDescriptor*>& descriptor_matcher, | 644 IsCallMatcher(const Matcher<const CallDescriptor*>& descriptor_matcher, |
| 645 const std::vector<Matcher<Node*>>& value_matchers, | 645 const std::vector<Matcher<Node*>>& value_matchers, |
| 646 const Matcher<Node*>& effect_matcher, | 646 const Matcher<Node*>& effect_matcher, |
| 647 const Matcher<Node*>& control_matcher) | 647 const Matcher<Node*>& control_matcher) |
| 648 : NodeMatcher(IrOpcode::kCall), | 648 : NodeMatcher(IrOpcode::kCall), |
| 649 descriptor_matcher_(descriptor_matcher), | 649 descriptor_matcher_(descriptor_matcher), |
| 650 value_matchers_(value_matchers), | 650 value_matchers_(value_matchers), |
| 651 effect_matcher_(effect_matcher), | 651 effect_matcher_(effect_matcher), |
| 652 control_matcher_(control_matcher) {} | 652 control_matcher_(control_matcher) {} |
| 653 | 653 |
| 654 void DescribeTo(std::ostream* os) const final { | 654 void DescribeTo(std::ostream* os) const final { |
| 655 NodeMatcher::DescribeTo(os); | 655 NodeMatcher::DescribeTo(os); |
| 656 for (size_t i = 0; i < value_matchers_.size(); ++i) { | 656 for (size_t i = 0; i < value_matchers_.size(); ++i) { |
| 657 if (i == 0) { | 657 if (i == 0) { |
| 658 *os << " whose value0 ("; | 658 *os << " whose value0 ("; |
| 659 } else { | 659 } else { |
| 660 *os << "), value" << i << " ("; | 660 *os << "), value" << i << " ("; |
| 661 } | 661 } |
| 662 value_matchers_[i].DescribeTo(os); | 662 value_matchers_[i].DescribeTo(os); |
| 663 } | 663 } |
| 664 *os << "), effect ("; | 664 *os << "), effect ("; |
| 665 effect_matcher_.DescribeTo(os); | 665 effect_matcher_.DescribeTo(os); |
| 666 *os << ") and control ("; | 666 *os << ") and control ("; |
| 667 control_matcher_.DescribeTo(os); | 667 control_matcher_.DescribeTo(os); |
| 668 *os << ")"; | 668 *os << ")"; |
| 669 } | 669 } |
| 670 | 670 |
| 671 bool MatchAndExplain(Node* node, MatchResultListener* listener) const final { | 671 bool MatchAndExplain(Node* node, MatchResultListener* listener) const final { |
| 672 if (!NodeMatcher::MatchAndExplain(node, listener) || | 672 if (!NodeMatcher::MatchAndExplain(node, listener) || |
| 673 !PrintMatchAndExplain(OpParameter<CallDescriptor*>(node), "descriptor", | 673 !PrintMatchAndExplain(OpParameter<const CallDescriptor*>(node), |
| 674 descriptor_matcher_, listener)) { | 674 "descriptor", descriptor_matcher_, listener)) { |
| 675 return false; | 675 return false; |
| 676 } | 676 } |
| 677 for (size_t i = 0; i < value_matchers_.size(); ++i) { | 677 for (size_t i = 0; i < value_matchers_.size(); ++i) { |
| 678 std::ostringstream ost; | 678 std::ostringstream ost; |
| 679 ost << "value" << i; | 679 ost << "value" << i; |
| 680 if (!PrintMatchAndExplain( | 680 if (!PrintMatchAndExplain( |
| 681 NodeProperties::GetValueInput(node, static_cast<int>(i)), | 681 NodeProperties::GetValueInput(node, static_cast<int>(i)), |
| 682 ost.str(), value_matchers_[i], listener)) { | 682 ost.str(), value_matchers_[i], listener)) { |
| 683 return false; | 683 return false; |
| 684 } | 684 } |
| 685 } | 685 } |
| 686 return (PrintMatchAndExplain(NodeProperties::GetEffectInput(node), "effect", | 686 return (PrintMatchAndExplain(NodeProperties::GetEffectInput(node), "effect", |
| 687 effect_matcher_, listener) && | 687 effect_matcher_, listener) && |
| 688 PrintMatchAndExplain(NodeProperties::GetControlInput(node), | 688 PrintMatchAndExplain(NodeProperties::GetControlInput(node), |
| 689 "control", control_matcher_, listener)); | 689 "control", control_matcher_, listener)); |
| 690 } | 690 } |
| 691 | 691 |
| 692 private: | 692 private: |
| 693 const Matcher<CallDescriptor*> descriptor_matcher_; | 693 const Matcher<const CallDescriptor*> descriptor_matcher_; |
| 694 const std::vector<Matcher<Node*>> value_matchers_; | 694 const std::vector<Matcher<Node*>> value_matchers_; |
| 695 const Matcher<Node*> effect_matcher_; | 695 const Matcher<Node*> effect_matcher_; |
| 696 const Matcher<Node*> control_matcher_; | 696 const Matcher<Node*> control_matcher_; |
| 697 }; | 697 }; |
| 698 | 698 |
| 699 | 699 |
| 700 class IsTailCallMatcher final : public NodeMatcher { | 700 class IsTailCallMatcher final : public NodeMatcher { |
| 701 public: | 701 public: |
| 702 IsTailCallMatcher(const Matcher<CallDescriptor const*>& descriptor_matcher, | 702 IsTailCallMatcher(const Matcher<CallDescriptor const*>& descriptor_matcher, |
| 703 const std::vector<Matcher<Node*>>& value_matchers, | 703 const std::vector<Matcher<Node*>>& value_matchers, |
| (...skipping 907 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1611 return MakeMatcher(new IsEffectSetMatcher(effect0_matcher, effect1_matcher)); | 1611 return MakeMatcher(new IsEffectSetMatcher(effect0_matcher, effect1_matcher)); |
| 1612 } | 1612 } |
| 1613 | 1613 |
| 1614 | 1614 |
| 1615 Matcher<Node*> IsProjection(const Matcher<size_t>& index_matcher, | 1615 Matcher<Node*> IsProjection(const Matcher<size_t>& index_matcher, |
| 1616 const Matcher<Node*>& base_matcher) { | 1616 const Matcher<Node*>& base_matcher) { |
| 1617 return MakeMatcher(new IsProjectionMatcher(index_matcher, base_matcher)); | 1617 return MakeMatcher(new IsProjectionMatcher(index_matcher, base_matcher)); |
| 1618 } | 1618 } |
| 1619 | 1619 |
| 1620 | 1620 |
| 1621 Matcher<Node*> IsCall(const Matcher<CallDescriptor*>& descriptor_matcher, | 1621 Matcher<Node*> IsCall(const Matcher<const CallDescriptor*>& descriptor_matcher, |
| 1622 const Matcher<Node*>& value0_matcher, | 1622 const Matcher<Node*>& value0_matcher, |
| 1623 const Matcher<Node*>& value1_matcher, | 1623 const Matcher<Node*>& value1_matcher, |
| 1624 const Matcher<Node*>& effect_matcher, | 1624 const Matcher<Node*>& effect_matcher, |
| 1625 const Matcher<Node*>& control_matcher) { | 1625 const Matcher<Node*>& control_matcher) { |
| 1626 std::vector<Matcher<Node*>> value_matchers; | 1626 std::vector<Matcher<Node*>> value_matchers; |
| 1627 value_matchers.push_back(value0_matcher); | 1627 value_matchers.push_back(value0_matcher); |
| 1628 value_matchers.push_back(value1_matcher); | 1628 value_matchers.push_back(value1_matcher); |
| 1629 return MakeMatcher(new IsCallMatcher(descriptor_matcher, value_matchers, | 1629 return MakeMatcher(new IsCallMatcher(descriptor_matcher, value_matchers, |
| 1630 effect_matcher, control_matcher)); | 1630 effect_matcher, control_matcher)); |
| 1631 } | 1631 } |
| 1632 | 1632 |
| 1633 | 1633 |
| 1634 Matcher<Node*> IsCall(const Matcher<CallDescriptor*>& descriptor_matcher, | 1634 Matcher<Node*> IsCall(const Matcher<const CallDescriptor*>& descriptor_matcher, |
| 1635 const Matcher<Node*>& value0_matcher, | 1635 const Matcher<Node*>& value0_matcher, |
| 1636 const Matcher<Node*>& value1_matcher, | 1636 const Matcher<Node*>& value1_matcher, |
| 1637 const Matcher<Node*>& value2_matcher, | 1637 const Matcher<Node*>& value2_matcher, |
| 1638 const Matcher<Node*>& effect_matcher, | 1638 const Matcher<Node*>& effect_matcher, |
| 1639 const Matcher<Node*>& control_matcher) { | 1639 const Matcher<Node*>& control_matcher) { |
| 1640 std::vector<Matcher<Node*>> value_matchers; | 1640 std::vector<Matcher<Node*>> value_matchers; |
| 1641 value_matchers.push_back(value0_matcher); | 1641 value_matchers.push_back(value0_matcher); |
| 1642 value_matchers.push_back(value1_matcher); | 1642 value_matchers.push_back(value1_matcher); |
| 1643 value_matchers.push_back(value2_matcher); | 1643 value_matchers.push_back(value2_matcher); |
| 1644 return MakeMatcher(new IsCallMatcher(descriptor_matcher, value_matchers, | 1644 return MakeMatcher(new IsCallMatcher(descriptor_matcher, value_matchers, |
| 1645 effect_matcher, control_matcher)); | 1645 effect_matcher, control_matcher)); |
| 1646 } | 1646 } |
| 1647 | 1647 |
| 1648 | 1648 |
| 1649 Matcher<Node*> IsCall(const Matcher<CallDescriptor*>& descriptor_matcher, | 1649 Matcher<Node*> IsCall(const Matcher<const CallDescriptor*>& descriptor_matcher, |
| 1650 const Matcher<Node*>& value0_matcher, | 1650 const Matcher<Node*>& value0_matcher, |
| 1651 const Matcher<Node*>& value1_matcher, | 1651 const Matcher<Node*>& value1_matcher, |
| 1652 const Matcher<Node*>& value2_matcher, | 1652 const Matcher<Node*>& value2_matcher, |
| 1653 const Matcher<Node*>& value3_matcher, | 1653 const Matcher<Node*>& value3_matcher, |
| 1654 const Matcher<Node*>& effect_matcher, | 1654 const Matcher<Node*>& effect_matcher, |
| 1655 const Matcher<Node*>& control_matcher) { | 1655 const Matcher<Node*>& control_matcher) { |
| 1656 std::vector<Matcher<Node*>> value_matchers; | 1656 std::vector<Matcher<Node*>> value_matchers; |
| 1657 value_matchers.push_back(value0_matcher); | 1657 value_matchers.push_back(value0_matcher); |
| 1658 value_matchers.push_back(value1_matcher); | 1658 value_matchers.push_back(value1_matcher); |
| 1659 value_matchers.push_back(value2_matcher); | 1659 value_matchers.push_back(value2_matcher); |
| 1660 value_matchers.push_back(value3_matcher); | 1660 value_matchers.push_back(value3_matcher); |
| 1661 return MakeMatcher(new IsCallMatcher(descriptor_matcher, value_matchers, | 1661 return MakeMatcher(new IsCallMatcher(descriptor_matcher, value_matchers, |
| 1662 effect_matcher, control_matcher)); | 1662 effect_matcher, control_matcher)); |
| 1663 } | 1663 } |
| 1664 | 1664 |
| 1665 | 1665 |
| 1666 Matcher<Node*> IsCall(const Matcher<CallDescriptor*>& descriptor_matcher, | 1666 Matcher<Node*> IsCall(const Matcher<const CallDescriptor*>& descriptor_matcher, |
| 1667 const Matcher<Node*>& value0_matcher, | 1667 const Matcher<Node*>& value0_matcher, |
| 1668 const Matcher<Node*>& value1_matcher, | 1668 const Matcher<Node*>& value1_matcher, |
| 1669 const Matcher<Node*>& value2_matcher, | 1669 const Matcher<Node*>& value2_matcher, |
| 1670 const Matcher<Node*>& value3_matcher, | 1670 const Matcher<Node*>& value3_matcher, |
| 1671 const Matcher<Node*>& value4_matcher, | 1671 const Matcher<Node*>& value4_matcher, |
| 1672 const Matcher<Node*>& effect_matcher, | 1672 const Matcher<Node*>& effect_matcher, |
| 1673 const Matcher<Node*>& control_matcher) { | 1673 const Matcher<Node*>& control_matcher) { |
| 1674 std::vector<Matcher<Node*>> value_matchers; | 1674 std::vector<Matcher<Node*>> value_matchers; |
| 1675 value_matchers.push_back(value0_matcher); | 1675 value_matchers.push_back(value0_matcher); |
| 1676 value_matchers.push_back(value1_matcher); | 1676 value_matchers.push_back(value1_matcher); |
| 1677 value_matchers.push_back(value2_matcher); | 1677 value_matchers.push_back(value2_matcher); |
| 1678 value_matchers.push_back(value3_matcher); | 1678 value_matchers.push_back(value3_matcher); |
| 1679 value_matchers.push_back(value4_matcher); | 1679 value_matchers.push_back(value4_matcher); |
| 1680 return MakeMatcher(new IsCallMatcher(descriptor_matcher, value_matchers, | 1680 return MakeMatcher(new IsCallMatcher(descriptor_matcher, value_matchers, |
| 1681 effect_matcher, control_matcher)); | 1681 effect_matcher, control_matcher)); |
| 1682 } | 1682 } |
| 1683 | 1683 |
| 1684 | 1684 |
| 1685 Matcher<Node*> IsCall(const Matcher<CallDescriptor*>& descriptor_matcher, | 1685 Matcher<Node*> IsCall(const Matcher<const CallDescriptor*>& descriptor_matcher, |
| 1686 const Matcher<Node*>& value0_matcher, | 1686 const Matcher<Node*>& value0_matcher, |
| 1687 const Matcher<Node*>& value1_matcher, | 1687 const Matcher<Node*>& value1_matcher, |
| 1688 const Matcher<Node*>& value2_matcher, | 1688 const Matcher<Node*>& value2_matcher, |
| 1689 const Matcher<Node*>& value3_matcher, | 1689 const Matcher<Node*>& value3_matcher, |
| 1690 const Matcher<Node*>& value4_matcher, | 1690 const Matcher<Node*>& value4_matcher, |
| 1691 const Matcher<Node*>& value5_matcher, | 1691 const Matcher<Node*>& value5_matcher, |
| 1692 const Matcher<Node*>& effect_matcher, | 1692 const Matcher<Node*>& effect_matcher, |
| 1693 const Matcher<Node*>& control_matcher) { | 1693 const Matcher<Node*>& control_matcher) { |
| 1694 std::vector<Matcher<Node*>> value_matchers; | 1694 std::vector<Matcher<Node*>> value_matchers; |
| 1695 value_matchers.push_back(value0_matcher); | 1695 value_matchers.push_back(value0_matcher); |
| 1696 value_matchers.push_back(value1_matcher); | 1696 value_matchers.push_back(value1_matcher); |
| 1697 value_matchers.push_back(value2_matcher); | 1697 value_matchers.push_back(value2_matcher); |
| 1698 value_matchers.push_back(value3_matcher); | 1698 value_matchers.push_back(value3_matcher); |
| 1699 value_matchers.push_back(value4_matcher); | 1699 value_matchers.push_back(value4_matcher); |
| 1700 value_matchers.push_back(value5_matcher); | 1700 value_matchers.push_back(value5_matcher); |
| 1701 return MakeMatcher(new IsCallMatcher(descriptor_matcher, value_matchers, | 1701 return MakeMatcher(new IsCallMatcher(descriptor_matcher, value_matchers, |
| 1702 effect_matcher, control_matcher)); | 1702 effect_matcher, control_matcher)); |
| 1703 } | 1703 } |
| 1704 | 1704 |
| 1705 | 1705 |
| 1706 Matcher<Node*> IsCall( | 1706 Matcher<Node*> IsCall( |
| 1707 const Matcher<CallDescriptor*>& descriptor_matcher, | 1707 const Matcher<const CallDescriptor*>& descriptor_matcher, |
| 1708 const Matcher<Node*>& value0_matcher, const Matcher<Node*>& value1_matcher, | 1708 const Matcher<Node*>& value0_matcher, const Matcher<Node*>& value1_matcher, |
| 1709 const Matcher<Node*>& value2_matcher, const Matcher<Node*>& value3_matcher, | 1709 const Matcher<Node*>& value2_matcher, const Matcher<Node*>& value3_matcher, |
| 1710 const Matcher<Node*>& value4_matcher, const Matcher<Node*>& value5_matcher, | 1710 const Matcher<Node*>& value4_matcher, const Matcher<Node*>& value5_matcher, |
| 1711 const Matcher<Node*>& value6_matcher, const Matcher<Node*>& effect_matcher, | 1711 const Matcher<Node*>& value6_matcher, const Matcher<Node*>& effect_matcher, |
| 1712 const Matcher<Node*>& control_matcher) { | 1712 const Matcher<Node*>& control_matcher) { |
| 1713 std::vector<Matcher<Node*>> value_matchers; | 1713 std::vector<Matcher<Node*>> value_matchers; |
| 1714 value_matchers.push_back(value0_matcher); | 1714 value_matchers.push_back(value0_matcher); |
| 1715 value_matchers.push_back(value1_matcher); | 1715 value_matchers.push_back(value1_matcher); |
| 1716 value_matchers.push_back(value2_matcher); | 1716 value_matchers.push_back(value2_matcher); |
| 1717 value_matchers.push_back(value3_matcher); | 1717 value_matchers.push_back(value3_matcher); |
| (...skipping 328 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2046 IS_UNOP_MATCHER(NumberToInt32) | 2046 IS_UNOP_MATCHER(NumberToInt32) |
| 2047 IS_UNOP_MATCHER(NumberToUint32) | 2047 IS_UNOP_MATCHER(NumberToUint32) |
| 2048 IS_UNOP_MATCHER(ObjectIsSmi) | 2048 IS_UNOP_MATCHER(ObjectIsSmi) |
| 2049 IS_UNOP_MATCHER(ObjectIsNonNegativeSmi) | 2049 IS_UNOP_MATCHER(ObjectIsNonNegativeSmi) |
| 2050 IS_UNOP_MATCHER(Word32Clz) | 2050 IS_UNOP_MATCHER(Word32Clz) |
| 2051 #undef IS_UNOP_MATCHER | 2051 #undef IS_UNOP_MATCHER |
| 2052 | 2052 |
| 2053 } // namespace compiler | 2053 } // namespace compiler |
| 2054 } // namespace internal | 2054 } // namespace internal |
| 2055 } // namespace v8 | 2055 } // namespace v8 |
| OLD | NEW |