| 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/graph-unittest.h" | 5 #include "test/unittests/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 #include "src/compiler/simplified-operator.h" | 10 #include "src/compiler/simplified-operator.h" |
| (...skipping 636 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 647 const Matcher<LoadRepresentation> rep_matcher_; | 647 const Matcher<LoadRepresentation> rep_matcher_; |
| 648 const Matcher<Node*> base_matcher_; | 648 const Matcher<Node*> base_matcher_; |
| 649 const Matcher<Node*> index_matcher_; | 649 const Matcher<Node*> index_matcher_; |
| 650 const Matcher<Node*> effect_matcher_; | 650 const Matcher<Node*> effect_matcher_; |
| 651 const Matcher<Node*> control_matcher_; | 651 const Matcher<Node*> control_matcher_; |
| 652 }; | 652 }; |
| 653 | 653 |
| 654 | 654 |
| 655 class IsStoreMatcher FINAL : public NodeMatcher { | 655 class IsStoreMatcher FINAL : public NodeMatcher { |
| 656 public: | 656 public: |
| 657 IsStoreMatcher(const Matcher<MachineType>& type_matcher, | 657 IsStoreMatcher(const Matcher<StoreRepresentation>& rep_matcher, |
| 658 const Matcher<WriteBarrierKind> write_barrier_matcher, | |
| 659 const Matcher<Node*>& base_matcher, | 658 const Matcher<Node*>& base_matcher, |
| 660 const Matcher<Node*>& index_matcher, | 659 const Matcher<Node*>& index_matcher, |
| 661 const Matcher<Node*>& value_matcher, | 660 const Matcher<Node*>& value_matcher, |
| 662 const Matcher<Node*>& effect_matcher, | 661 const Matcher<Node*>& effect_matcher, |
| 663 const Matcher<Node*>& control_matcher) | 662 const Matcher<Node*>& control_matcher) |
| 664 : NodeMatcher(IrOpcode::kStore), | 663 : NodeMatcher(IrOpcode::kStore), |
| 665 type_matcher_(type_matcher), | 664 rep_matcher_(rep_matcher), |
| 666 write_barrier_matcher_(write_barrier_matcher), | |
| 667 base_matcher_(base_matcher), | 665 base_matcher_(base_matcher), |
| 668 index_matcher_(index_matcher), | 666 index_matcher_(index_matcher), |
| 669 value_matcher_(value_matcher), | 667 value_matcher_(value_matcher), |
| 670 effect_matcher_(effect_matcher), | 668 effect_matcher_(effect_matcher), |
| 671 control_matcher_(control_matcher) {} | 669 control_matcher_(control_matcher) {} |
| 672 | 670 |
| 673 virtual void DescribeTo(std::ostream* os) const OVERRIDE { | 671 virtual void DescribeTo(std::ostream* os) const OVERRIDE { |
| 674 NodeMatcher::DescribeTo(os); | 672 NodeMatcher::DescribeTo(os); |
| 675 *os << " whose type ("; | 673 *os << " whose rep ("; |
| 676 type_matcher_.DescribeTo(os); | 674 rep_matcher_.DescribeTo(os); |
| 677 *os << "), write barrier ("; | |
| 678 write_barrier_matcher_.DescribeTo(os); | |
| 679 *os << "), base ("; | 675 *os << "), base ("; |
| 680 base_matcher_.DescribeTo(os); | 676 base_matcher_.DescribeTo(os); |
| 681 *os << "), index ("; | 677 *os << "), index ("; |
| 682 index_matcher_.DescribeTo(os); | 678 index_matcher_.DescribeTo(os); |
| 683 *os << "), value ("; | 679 *os << "), value ("; |
| 684 value_matcher_.DescribeTo(os); | 680 value_matcher_.DescribeTo(os); |
| 685 *os << "), effect ("; | 681 *os << "), effect ("; |
| 686 effect_matcher_.DescribeTo(os); | 682 effect_matcher_.DescribeTo(os); |
| 687 *os << ") and control ("; | 683 *os << ") and control ("; |
| 688 control_matcher_.DescribeTo(os); | 684 control_matcher_.DescribeTo(os); |
| 689 *os << ")"; | 685 *os << ")"; |
| 690 } | 686 } |
| 691 | 687 |
| 692 virtual bool MatchAndExplain(Node* node, | 688 virtual bool MatchAndExplain(Node* node, |
| 693 MatchResultListener* listener) const OVERRIDE { | 689 MatchResultListener* listener) const OVERRIDE { |
| 694 return (NodeMatcher::MatchAndExplain(node, listener) && | 690 return (NodeMatcher::MatchAndExplain(node, listener) && |
| 695 PrintMatchAndExplain( | 691 PrintMatchAndExplain(OpParameter<StoreRepresentation>(node), "rep", |
| 696 OpParameter<StoreRepresentation>(node).machine_type(), "type", | 692 rep_matcher_, listener) && |
| 697 type_matcher_, listener) && | |
| 698 PrintMatchAndExplain( | |
| 699 OpParameter<StoreRepresentation>(node).write_barrier_kind(), | |
| 700 "write barrier", write_barrier_matcher_, listener) && | |
| 701 PrintMatchAndExplain(NodeProperties::GetValueInput(node, 0), "base", | 693 PrintMatchAndExplain(NodeProperties::GetValueInput(node, 0), "base", |
| 702 base_matcher_, listener) && | 694 base_matcher_, listener) && |
| 703 PrintMatchAndExplain(NodeProperties::GetValueInput(node, 1), | 695 PrintMatchAndExplain(NodeProperties::GetValueInput(node, 1), |
| 704 "index", index_matcher_, listener) && | 696 "index", index_matcher_, listener) && |
| 705 PrintMatchAndExplain(NodeProperties::GetValueInput(node, 2), | 697 PrintMatchAndExplain(NodeProperties::GetValueInput(node, 2), |
| 706 "value", value_matcher_, listener) && | 698 "value", value_matcher_, listener) && |
| 707 PrintMatchAndExplain(NodeProperties::GetEffectInput(node), "effect", | 699 PrintMatchAndExplain(NodeProperties::GetEffectInput(node), "effect", |
| 708 effect_matcher_, listener) && | 700 effect_matcher_, listener) && |
| 709 PrintMatchAndExplain(NodeProperties::GetControlInput(node), | 701 PrintMatchAndExplain(NodeProperties::GetControlInput(node), |
| 710 "control", control_matcher_, listener)); | 702 "control", control_matcher_, listener)); |
| 711 } | 703 } |
| 712 | 704 |
| 713 private: | 705 private: |
| 714 const Matcher<MachineType> type_matcher_; | 706 const Matcher<StoreRepresentation> rep_matcher_; |
| 715 const Matcher<WriteBarrierKind> write_barrier_matcher_; | |
| 716 const Matcher<Node*> base_matcher_; | 707 const Matcher<Node*> base_matcher_; |
| 717 const Matcher<Node*> index_matcher_; | 708 const Matcher<Node*> index_matcher_; |
| 718 const Matcher<Node*> value_matcher_; | 709 const Matcher<Node*> value_matcher_; |
| 719 const Matcher<Node*> effect_matcher_; | 710 const Matcher<Node*> effect_matcher_; |
| 720 const Matcher<Node*> control_matcher_; | 711 const Matcher<Node*> control_matcher_; |
| 721 }; | 712 }; |
| 722 | 713 |
| 723 | 714 |
| 724 class IsBinopMatcher FINAL : public NodeMatcher { | 715 class IsBinopMatcher FINAL : public NodeMatcher { |
| 725 public: | 716 public: |
| (...skipping 194 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 920 Matcher<Node*> IsLoad(const Matcher<LoadRepresentation>& rep_matcher, | 911 Matcher<Node*> IsLoad(const Matcher<LoadRepresentation>& rep_matcher, |
| 921 const Matcher<Node*>& base_matcher, | 912 const Matcher<Node*>& base_matcher, |
| 922 const Matcher<Node*>& index_matcher, | 913 const Matcher<Node*>& index_matcher, |
| 923 const Matcher<Node*>& effect_matcher, | 914 const Matcher<Node*>& effect_matcher, |
| 924 const Matcher<Node*>& control_matcher) { | 915 const Matcher<Node*>& control_matcher) { |
| 925 return MakeMatcher(new IsLoadMatcher(rep_matcher, base_matcher, index_matcher, | 916 return MakeMatcher(new IsLoadMatcher(rep_matcher, base_matcher, index_matcher, |
| 926 effect_matcher, control_matcher)); | 917 effect_matcher, control_matcher)); |
| 927 } | 918 } |
| 928 | 919 |
| 929 | 920 |
| 930 Matcher<Node*> IsStore(const Matcher<MachineType>& type_matcher, | 921 Matcher<Node*> IsStore(const Matcher<StoreRepresentation>& rep_matcher, |
| 931 const Matcher<WriteBarrierKind>& write_barrier_matcher, | |
| 932 const Matcher<Node*>& base_matcher, | 922 const Matcher<Node*>& base_matcher, |
| 933 const Matcher<Node*>& index_matcher, | 923 const Matcher<Node*>& index_matcher, |
| 934 const Matcher<Node*>& value_matcher, | 924 const Matcher<Node*>& value_matcher, |
| 935 const Matcher<Node*>& effect_matcher, | 925 const Matcher<Node*>& effect_matcher, |
| 936 const Matcher<Node*>& control_matcher) { | 926 const Matcher<Node*>& control_matcher) { |
| 937 return MakeMatcher(new IsStoreMatcher( | 927 return MakeMatcher(new IsStoreMatcher(rep_matcher, base_matcher, |
| 938 type_matcher, write_barrier_matcher, base_matcher, index_matcher, | 928 index_matcher, value_matcher, |
| 939 value_matcher, effect_matcher, control_matcher)); | 929 effect_matcher, control_matcher)); |
| 940 } | 930 } |
| 941 | 931 |
| 942 | 932 |
| 943 #define IS_BINOP_MATCHER(Name) \ | 933 #define IS_BINOP_MATCHER(Name) \ |
| 944 Matcher<Node*> Is##Name(const Matcher<Node*>& lhs_matcher, \ | 934 Matcher<Node*> Is##Name(const Matcher<Node*>& lhs_matcher, \ |
| 945 const Matcher<Node*>& rhs_matcher) { \ | 935 const Matcher<Node*>& rhs_matcher) { \ |
| 946 return MakeMatcher( \ | 936 return MakeMatcher( \ |
| 947 new IsBinopMatcher(IrOpcode::k##Name, lhs_matcher, rhs_matcher)); \ | 937 new IsBinopMatcher(IrOpcode::k##Name, lhs_matcher, rhs_matcher)); \ |
| 948 } | 938 } |
| 949 IS_BINOP_MATCHER(NumberLessThan) | 939 IS_BINOP_MATCHER(NumberLessThan) |
| (...skipping 25 matching lines...) Expand all Loading... |
| 975 IS_UNOP_MATCHER(ChangeUint32ToUint64) | 965 IS_UNOP_MATCHER(ChangeUint32ToUint64) |
| 976 IS_UNOP_MATCHER(TruncateFloat64ToFloat32) | 966 IS_UNOP_MATCHER(TruncateFloat64ToFloat32) |
| 977 IS_UNOP_MATCHER(TruncateFloat64ToInt32) | 967 IS_UNOP_MATCHER(TruncateFloat64ToInt32) |
| 978 IS_UNOP_MATCHER(TruncateInt64ToInt32) | 968 IS_UNOP_MATCHER(TruncateInt64ToInt32) |
| 979 IS_UNOP_MATCHER(Float64Sqrt) | 969 IS_UNOP_MATCHER(Float64Sqrt) |
| 980 #undef IS_UNOP_MATCHER | 970 #undef IS_UNOP_MATCHER |
| 981 | 971 |
| 982 } // namespace compiler | 972 } // namespace compiler |
| 983 } // namespace internal | 973 } // namespace internal |
| 984 } // namespace v8 | 974 } // namespace v8 |
| OLD | NEW |