| 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 "src/compiler/node-properties-inl.h" | 7 #include "src/compiler/node-properties-inl.h" |
| 8 #include "src/compiler/simplified-operator.h" | 8 #include "src/compiler/simplified-operator.h" |
| 9 | 9 |
| 10 using testing::_; | 10 using testing::_; |
| (...skipping 520 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 531 const Matcher<Node*> effect_matcher_; | 531 const Matcher<Node*> effect_matcher_; |
| 532 const Matcher<Node*> control_matcher_; | 532 const Matcher<Node*> control_matcher_; |
| 533 }; | 533 }; |
| 534 | 534 |
| 535 | 535 |
| 536 class IsLoadElementMatcher FINAL : public NodeMatcher { | 536 class IsLoadElementMatcher FINAL : public NodeMatcher { |
| 537 public: | 537 public: |
| 538 IsLoadElementMatcher(const Matcher<ElementAccess>& access_matcher, | 538 IsLoadElementMatcher(const Matcher<ElementAccess>& access_matcher, |
| 539 const Matcher<Node*>& base_matcher, | 539 const Matcher<Node*>& base_matcher, |
| 540 const Matcher<Node*>& index_matcher, | 540 const Matcher<Node*>& index_matcher, |
| 541 const Matcher<Node*>& length_matcher, | 541 const Matcher<Node*>& effect_matcher, |
| 542 const Matcher<Node*>& effect_matcher) | 542 const Matcher<Node*>& control_matcher) |
| 543 : NodeMatcher(IrOpcode::kLoadElement), | 543 : NodeMatcher(IrOpcode::kLoadElement), |
| 544 access_matcher_(access_matcher), | 544 access_matcher_(access_matcher), |
| 545 base_matcher_(base_matcher), | 545 base_matcher_(base_matcher), |
| 546 index_matcher_(index_matcher), | 546 index_matcher_(index_matcher), |
| 547 length_matcher_(length_matcher), | 547 effect_matcher_(effect_matcher), |
| 548 effect_matcher_(effect_matcher) {} | 548 control_matcher_(control_matcher) {} |
| 549 | 549 |
| 550 virtual void DescribeTo(std::ostream* os) const OVERRIDE { | 550 virtual void DescribeTo(std::ostream* os) const OVERRIDE { |
| 551 NodeMatcher::DescribeTo(os); | 551 NodeMatcher::DescribeTo(os); |
| 552 *os << " whose access ("; | 552 *os << " whose access ("; |
| 553 access_matcher_.DescribeTo(os); | 553 access_matcher_.DescribeTo(os); |
| 554 *os << "), base ("; | 554 *os << "), base ("; |
| 555 base_matcher_.DescribeTo(os); | 555 base_matcher_.DescribeTo(os); |
| 556 *os << "), index ("; | 556 *os << "), index ("; |
| 557 index_matcher_.DescribeTo(os); | 557 index_matcher_.DescribeTo(os); |
| 558 *os << "), length ("; | 558 *os << "), effect ("; |
| 559 length_matcher_.DescribeTo(os); | |
| 560 *os << ") and effect ("; | |
| 561 effect_matcher_.DescribeTo(os); | 559 effect_matcher_.DescribeTo(os); |
| 560 *os << ") and control ("; |
| 561 control_matcher_.DescribeTo(os); |
| 562 *os << ")"; | 562 *os << ")"; |
| 563 } | 563 } |
| 564 | 564 |
| 565 virtual bool MatchAndExplain(Node* node, | 565 virtual bool MatchAndExplain(Node* node, |
| 566 MatchResultListener* listener) const OVERRIDE { | 566 MatchResultListener* listener) const OVERRIDE { |
| 567 return (NodeMatcher::MatchAndExplain(node, listener) && | 567 return (NodeMatcher::MatchAndExplain(node, listener) && |
| 568 PrintMatchAndExplain(OpParameter<ElementAccess>(node), "access", | 568 PrintMatchAndExplain(OpParameter<ElementAccess>(node), "access", |
| 569 access_matcher_, listener) && | 569 access_matcher_, listener) && |
| 570 PrintMatchAndExplain(NodeProperties::GetValueInput(node, 0), "base", | 570 PrintMatchAndExplain(NodeProperties::GetValueInput(node, 0), "base", |
| 571 base_matcher_, listener) && | 571 base_matcher_, listener) && |
| 572 PrintMatchAndExplain(NodeProperties::GetValueInput(node, 1), | 572 PrintMatchAndExplain(NodeProperties::GetValueInput(node, 1), |
| 573 "index", index_matcher_, listener) && | 573 "index", index_matcher_, listener) && |
| 574 PrintMatchAndExplain(NodeProperties::GetValueInput(node, 2), | |
| 575 "length", length_matcher_, listener) && | |
| 576 PrintMatchAndExplain(NodeProperties::GetEffectInput(node), "effect", | 574 PrintMatchAndExplain(NodeProperties::GetEffectInput(node), "effect", |
| 577 effect_matcher_, listener)); | 575 effect_matcher_, listener) && |
| 576 PrintMatchAndExplain(NodeProperties::GetControlInput(node), |
| 577 "control", control_matcher_, listener)); |
| 578 } | 578 } |
| 579 | 579 |
| 580 private: | 580 private: |
| 581 const Matcher<ElementAccess> access_matcher_; | 581 const Matcher<ElementAccess> access_matcher_; |
| 582 const Matcher<Node*> base_matcher_; | 582 const Matcher<Node*> base_matcher_; |
| 583 const Matcher<Node*> index_matcher_; | 583 const Matcher<Node*> index_matcher_; |
| 584 const Matcher<Node*> length_matcher_; | |
| 585 const Matcher<Node*> effect_matcher_; | 584 const Matcher<Node*> effect_matcher_; |
| 585 const Matcher<Node*> control_matcher_; |
| 586 }; | 586 }; |
| 587 | 587 |
| 588 | 588 |
| 589 class IsStoreElementMatcher FINAL : public NodeMatcher { | 589 class IsStoreElementMatcher FINAL : public NodeMatcher { |
| 590 public: | 590 public: |
| 591 IsStoreElementMatcher(const Matcher<ElementAccess>& access_matcher, | 591 IsStoreElementMatcher(const Matcher<ElementAccess>& access_matcher, |
| 592 const Matcher<Node*>& base_matcher, | 592 const Matcher<Node*>& base_matcher, |
| 593 const Matcher<Node*>& index_matcher, | 593 const Matcher<Node*>& index_matcher, |
| 594 const Matcher<Node*>& length_matcher, | |
| 595 const Matcher<Node*>& value_matcher, | 594 const Matcher<Node*>& value_matcher, |
| 596 const Matcher<Node*>& effect_matcher, | 595 const Matcher<Node*>& effect_matcher, |
| 597 const Matcher<Node*>& control_matcher) | 596 const Matcher<Node*>& control_matcher) |
| 598 : NodeMatcher(IrOpcode::kStoreElement), | 597 : NodeMatcher(IrOpcode::kStoreElement), |
| 599 access_matcher_(access_matcher), | 598 access_matcher_(access_matcher), |
| 600 base_matcher_(base_matcher), | 599 base_matcher_(base_matcher), |
| 601 index_matcher_(index_matcher), | 600 index_matcher_(index_matcher), |
| 602 length_matcher_(length_matcher), | |
| 603 value_matcher_(value_matcher), | 601 value_matcher_(value_matcher), |
| 604 effect_matcher_(effect_matcher), | 602 effect_matcher_(effect_matcher), |
| 605 control_matcher_(control_matcher) {} | 603 control_matcher_(control_matcher) {} |
| 606 | 604 |
| 607 virtual void DescribeTo(std::ostream* os) const OVERRIDE { | 605 virtual void DescribeTo(std::ostream* os) const OVERRIDE { |
| 608 NodeMatcher::DescribeTo(os); | 606 NodeMatcher::DescribeTo(os); |
| 609 *os << " whose access ("; | 607 *os << " whose access ("; |
| 610 access_matcher_.DescribeTo(os); | 608 access_matcher_.DescribeTo(os); |
| 611 *os << "), base ("; | 609 *os << "), base ("; |
| 612 base_matcher_.DescribeTo(os); | 610 base_matcher_.DescribeTo(os); |
| 613 *os << "), index ("; | 611 *os << "), index ("; |
| 614 index_matcher_.DescribeTo(os); | 612 index_matcher_.DescribeTo(os); |
| 615 *os << "), length ("; | |
| 616 length_matcher_.DescribeTo(os); | |
| 617 *os << "), value ("; | 613 *os << "), value ("; |
| 618 value_matcher_.DescribeTo(os); | 614 value_matcher_.DescribeTo(os); |
| 619 *os << "), effect ("; | 615 *os << "), effect ("; |
| 620 effect_matcher_.DescribeTo(os); | 616 effect_matcher_.DescribeTo(os); |
| 621 *os << ") and control ("; | 617 *os << ") and control ("; |
| 622 control_matcher_.DescribeTo(os); | 618 control_matcher_.DescribeTo(os); |
| 623 *os << ")"; | 619 *os << ")"; |
| 624 } | 620 } |
| 625 | 621 |
| 626 virtual bool MatchAndExplain(Node* node, | 622 virtual bool MatchAndExplain(Node* node, |
| 627 MatchResultListener* listener) const OVERRIDE { | 623 MatchResultListener* listener) const OVERRIDE { |
| 628 return (NodeMatcher::MatchAndExplain(node, listener) && | 624 return (NodeMatcher::MatchAndExplain(node, listener) && |
| 629 PrintMatchAndExplain(OpParameter<ElementAccess>(node), "access", | 625 PrintMatchAndExplain(OpParameter<ElementAccess>(node), "access", |
| 630 access_matcher_, listener) && | 626 access_matcher_, listener) && |
| 631 PrintMatchAndExplain(NodeProperties::GetValueInput(node, 0), "base", | 627 PrintMatchAndExplain(NodeProperties::GetValueInput(node, 0), "base", |
| 632 base_matcher_, listener) && | 628 base_matcher_, listener) && |
| 633 PrintMatchAndExplain(NodeProperties::GetValueInput(node, 1), | 629 PrintMatchAndExplain(NodeProperties::GetValueInput(node, 1), |
| 634 "index", index_matcher_, listener) && | 630 "index", index_matcher_, listener) && |
| 635 PrintMatchAndExplain(NodeProperties::GetValueInput(node, 2), | |
| 636 "length", length_matcher_, listener) && | |
| 637 PrintMatchAndExplain(NodeProperties::GetValueInput(node, 3), | 631 PrintMatchAndExplain(NodeProperties::GetValueInput(node, 3), |
| 638 "value", value_matcher_, listener) && | 632 "value", value_matcher_, listener) && |
| 639 PrintMatchAndExplain(NodeProperties::GetEffectInput(node), "effect", | 633 PrintMatchAndExplain(NodeProperties::GetEffectInput(node), "effect", |
| 640 effect_matcher_, listener) && | 634 effect_matcher_, listener) && |
| 641 PrintMatchAndExplain(NodeProperties::GetControlInput(node), | 635 PrintMatchAndExplain(NodeProperties::GetControlInput(node), |
| 642 "control", control_matcher_, listener)); | 636 "control", control_matcher_, listener)); |
| 643 } | 637 } |
| 644 | 638 |
| 645 private: | 639 private: |
| 646 const Matcher<ElementAccess> access_matcher_; | 640 const Matcher<ElementAccess> access_matcher_; |
| 647 const Matcher<Node*> base_matcher_; | 641 const Matcher<Node*> base_matcher_; |
| 648 const Matcher<Node*> index_matcher_; | 642 const Matcher<Node*> index_matcher_; |
| 649 const Matcher<Node*> length_matcher_; | |
| 650 const Matcher<Node*> value_matcher_; | 643 const Matcher<Node*> value_matcher_; |
| 651 const Matcher<Node*> effect_matcher_; | 644 const Matcher<Node*> effect_matcher_; |
| 652 const Matcher<Node*> control_matcher_; | 645 const Matcher<Node*> control_matcher_; |
| 653 }; | 646 }; |
| 654 | 647 |
| 655 | 648 |
| 656 class IsLoadMatcher FINAL : public NodeMatcher { | 649 class IsLoadMatcher FINAL : public NodeMatcher { |
| 657 public: | 650 public: |
| 658 IsLoadMatcher(const Matcher<LoadRepresentation>& rep_matcher, | 651 IsLoadMatcher(const Matcher<LoadRepresentation>& rep_matcher, |
| 659 const Matcher<Node*>& base_matcher, | 652 const Matcher<Node*>& base_matcher, |
| (...skipping 348 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1008 const Matcher<Node*>& effect_matcher, | 1001 const Matcher<Node*>& effect_matcher, |
| 1009 const Matcher<Node*>& control_matcher) { | 1002 const Matcher<Node*>& control_matcher) { |
| 1010 return MakeMatcher(new IsLoadFieldMatcher(access_matcher, base_matcher, | 1003 return MakeMatcher(new IsLoadFieldMatcher(access_matcher, base_matcher, |
| 1011 effect_matcher, control_matcher)); | 1004 effect_matcher, control_matcher)); |
| 1012 } | 1005 } |
| 1013 | 1006 |
| 1014 | 1007 |
| 1015 Matcher<Node*> IsLoadElement(const Matcher<ElementAccess>& access_matcher, | 1008 Matcher<Node*> IsLoadElement(const Matcher<ElementAccess>& access_matcher, |
| 1016 const Matcher<Node*>& base_matcher, | 1009 const Matcher<Node*>& base_matcher, |
| 1017 const Matcher<Node*>& index_matcher, | 1010 const Matcher<Node*>& index_matcher, |
| 1018 const Matcher<Node*>& length_matcher, | 1011 const Matcher<Node*>& effect_matcher, |
| 1019 const Matcher<Node*>& effect_matcher) { | 1012 const Matcher<Node*>& control_matcher) { |
| 1020 return MakeMatcher(new IsLoadElementMatcher(access_matcher, base_matcher, | 1013 return MakeMatcher(new IsLoadElementMatcher(access_matcher, base_matcher, |
| 1021 index_matcher, length_matcher, | 1014 index_matcher, effect_matcher, |
| 1022 effect_matcher)); | 1015 control_matcher)); |
| 1023 } | 1016 } |
| 1024 | 1017 |
| 1025 | 1018 |
| 1026 Matcher<Node*> IsStoreElement(const Matcher<ElementAccess>& access_matcher, | 1019 Matcher<Node*> IsStoreElement(const Matcher<ElementAccess>& access_matcher, |
| 1027 const Matcher<Node*>& base_matcher, | 1020 const Matcher<Node*>& base_matcher, |
| 1028 const Matcher<Node*>& index_matcher, | 1021 const Matcher<Node*>& index_matcher, |
| 1029 const Matcher<Node*>& length_matcher, | |
| 1030 const Matcher<Node*>& value_matcher, | 1022 const Matcher<Node*>& value_matcher, |
| 1031 const Matcher<Node*>& effect_matcher, | 1023 const Matcher<Node*>& effect_matcher, |
| 1032 const Matcher<Node*>& control_matcher) { | 1024 const Matcher<Node*>& control_matcher) { |
| 1033 return MakeMatcher(new IsStoreElementMatcher( | 1025 return MakeMatcher(new IsStoreElementMatcher( |
| 1034 access_matcher, base_matcher, index_matcher, length_matcher, | 1026 access_matcher, base_matcher, index_matcher, value_matcher, |
| 1035 value_matcher, effect_matcher, control_matcher)); | 1027 effect_matcher, control_matcher)); |
| 1036 } | 1028 } |
| 1037 | 1029 |
| 1038 | 1030 |
| 1039 Matcher<Node*> IsLoad(const Matcher<LoadRepresentation>& rep_matcher, | 1031 Matcher<Node*> IsLoad(const Matcher<LoadRepresentation>& rep_matcher, |
| 1040 const Matcher<Node*>& base_matcher, | 1032 const Matcher<Node*>& base_matcher, |
| 1041 const Matcher<Node*>& index_matcher, | 1033 const Matcher<Node*>& index_matcher, |
| 1042 const Matcher<Node*>& effect_matcher, | 1034 const Matcher<Node*>& effect_matcher, |
| 1043 const Matcher<Node*>& control_matcher) { | 1035 const Matcher<Node*>& control_matcher) { |
| 1044 return MakeMatcher(new IsLoadMatcher(rep_matcher, base_matcher, index_matcher, | 1036 return MakeMatcher(new IsLoadMatcher(rep_matcher, base_matcher, index_matcher, |
| 1045 effect_matcher, control_matcher)); | 1037 effect_matcher, control_matcher)); |
| (...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1118 IS_UNOP_MATCHER(Float64Ceil) | 1110 IS_UNOP_MATCHER(Float64Ceil) |
| 1119 IS_UNOP_MATCHER(Float64RoundTruncate) | 1111 IS_UNOP_MATCHER(Float64RoundTruncate) |
| 1120 IS_UNOP_MATCHER(Float64RoundTiesAway) | 1112 IS_UNOP_MATCHER(Float64RoundTiesAway) |
| 1121 IS_UNOP_MATCHER(NumberToInt32) | 1113 IS_UNOP_MATCHER(NumberToInt32) |
| 1122 IS_UNOP_MATCHER(NumberToUint32) | 1114 IS_UNOP_MATCHER(NumberToUint32) |
| 1123 #undef IS_UNOP_MATCHER | 1115 #undef IS_UNOP_MATCHER |
| 1124 | 1116 |
| 1125 } // namespace compiler | 1117 } // namespace compiler |
| 1126 } // namespace internal | 1118 } // namespace internal |
| 1127 } // namespace v8 | 1119 } // namespace v8 |
| OLD | NEW |