Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(165)

Side by Side Diff: test/unittests/compiler/node-test-utils.cc

Issue 763963002: [turbofan] Add checked load/store operators. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Reapply fix. Created 6 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 515 matching lines...) Expand 10 before | Expand all | Expand 10 after
526 } 526 }
527 527
528 private: 528 private:
529 const Matcher<FieldAccess> access_matcher_; 529 const Matcher<FieldAccess> access_matcher_;
530 const Matcher<Node*> base_matcher_; 530 const Matcher<Node*> base_matcher_;
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 IsLoadBufferMatcher FINAL : public NodeMatcher {
537 public:
538 IsLoadBufferMatcher(const Matcher<BufferAccess>& access_matcher,
539 const Matcher<Node*>& buffer_matcher,
540 const Matcher<Node*>& offset_matcher,
541 const Matcher<Node*>& length_matcher,
542 const Matcher<Node*>& effect_matcher,
543 const Matcher<Node*>& control_matcher)
544 : NodeMatcher(IrOpcode::kLoadBuffer),
545 access_matcher_(access_matcher),
546 buffer_matcher_(buffer_matcher),
547 offset_matcher_(offset_matcher),
548 length_matcher_(length_matcher),
549 effect_matcher_(effect_matcher),
550 control_matcher_(control_matcher) {}
551
552 virtual void DescribeTo(std::ostream* os) const OVERRIDE {
553 NodeMatcher::DescribeTo(os);
554 *os << " whose access (";
555 access_matcher_.DescribeTo(os);
556 *os << "), buffer (";
557 buffer_matcher_.DescribeTo(os);
558 *os << "), offset (";
559 offset_matcher_.DescribeTo(os);
560 *os << "), length (";
561 length_matcher_.DescribeTo(os);
562 *os << "), effect (";
563 effect_matcher_.DescribeTo(os);
564 *os << ") and control (";
565 control_matcher_.DescribeTo(os);
566 *os << ")";
567 }
568
569 virtual bool MatchAndExplain(Node* node,
570 MatchResultListener* listener) const OVERRIDE {
571 return (NodeMatcher::MatchAndExplain(node, listener) &&
572 PrintMatchAndExplain(BufferAccessOf(node->op()), "access",
573 access_matcher_, listener) &&
574 PrintMatchAndExplain(NodeProperties::GetValueInput(node, 0),
575 "buffer", buffer_matcher_, listener) &&
576 PrintMatchAndExplain(NodeProperties::GetValueInput(node, 1),
577 "offset", offset_matcher_, listener) &&
578 PrintMatchAndExplain(NodeProperties::GetValueInput(node, 2),
579 "length", length_matcher_, listener) &&
580 PrintMatchAndExplain(NodeProperties::GetEffectInput(node), "effect",
581 effect_matcher_, listener) &&
582 PrintMatchAndExplain(NodeProperties::GetControlInput(node),
583 "control", control_matcher_, listener));
584 }
585
586 private:
587 const Matcher<BufferAccess> access_matcher_;
588 const Matcher<Node*> buffer_matcher_;
589 const Matcher<Node*> offset_matcher_;
590 const Matcher<Node*> length_matcher_;
591 const Matcher<Node*> effect_matcher_;
592 const Matcher<Node*> control_matcher_;
593 };
594
595
596 class IsStoreBufferMatcher FINAL : public NodeMatcher {
597 public:
598 IsStoreBufferMatcher(const Matcher<BufferAccess>& access_matcher,
599 const Matcher<Node*>& buffer_matcher,
600 const Matcher<Node*>& offset_matcher,
601 const Matcher<Node*>& length_matcher,
602 const Matcher<Node*>& value_matcher,
603 const Matcher<Node*>& effect_matcher,
604 const Matcher<Node*>& control_matcher)
605 : NodeMatcher(IrOpcode::kStoreBuffer),
606 access_matcher_(access_matcher),
607 buffer_matcher_(buffer_matcher),
608 offset_matcher_(offset_matcher),
609 length_matcher_(length_matcher),
610 value_matcher_(value_matcher),
611 effect_matcher_(effect_matcher),
612 control_matcher_(control_matcher) {}
613
614 virtual void DescribeTo(std::ostream* os) const OVERRIDE {
615 NodeMatcher::DescribeTo(os);
616 *os << " whose access (";
617 access_matcher_.DescribeTo(os);
618 *os << "), buffer (";
619 buffer_matcher_.DescribeTo(os);
620 *os << "), offset (";
621 offset_matcher_.DescribeTo(os);
622 *os << "), length (";
623 length_matcher_.DescribeTo(os);
624 *os << "), value (";
625 value_matcher_.DescribeTo(os);
626 *os << "), effect (";
627 effect_matcher_.DescribeTo(os);
628 *os << ") and control (";
629 control_matcher_.DescribeTo(os);
630 *os << ")";
631 }
632
633 virtual bool MatchAndExplain(Node* node,
634 MatchResultListener* listener) const OVERRIDE {
635 return (NodeMatcher::MatchAndExplain(node, listener) &&
636 PrintMatchAndExplain(BufferAccessOf(node->op()), "access",
637 access_matcher_, listener) &&
638 PrintMatchAndExplain(NodeProperties::GetValueInput(node, 0),
639 "buffer", buffer_matcher_, listener) &&
640 PrintMatchAndExplain(NodeProperties::GetValueInput(node, 1),
641 "offset", offset_matcher_, listener) &&
642 PrintMatchAndExplain(NodeProperties::GetValueInput(node, 2),
643 "length", length_matcher_, listener) &&
644 PrintMatchAndExplain(NodeProperties::GetValueInput(node, 3),
645 "value", value_matcher_, listener) &&
646 PrintMatchAndExplain(NodeProperties::GetEffectInput(node), "effect",
647 effect_matcher_, listener) &&
648 PrintMatchAndExplain(NodeProperties::GetControlInput(node),
649 "control", control_matcher_, listener));
650 }
651
652 private:
653 const Matcher<BufferAccess> access_matcher_;
654 const Matcher<Node*> buffer_matcher_;
655 const Matcher<Node*> offset_matcher_;
656 const Matcher<Node*> length_matcher_;
657 const Matcher<Node*> value_matcher_;
658 const Matcher<Node*> effect_matcher_;
659 const Matcher<Node*> control_matcher_;
660 };
661
662
536 class IsLoadElementMatcher FINAL : public NodeMatcher { 663 class IsLoadElementMatcher FINAL : public NodeMatcher {
537 public: 664 public:
538 IsLoadElementMatcher(const Matcher<ElementAccess>& access_matcher, 665 IsLoadElementMatcher(const Matcher<ElementAccess>& access_matcher,
539 const Matcher<Node*>& base_matcher, 666 const Matcher<Node*>& base_matcher,
540 const Matcher<Node*>& index_matcher, 667 const Matcher<Node*>& index_matcher,
541 const Matcher<Node*>& length_matcher, 668 const Matcher<Node*>& effect_matcher,
542 const Matcher<Node*>& effect_matcher) 669 const Matcher<Node*>& control_matcher)
543 : NodeMatcher(IrOpcode::kLoadElement), 670 : NodeMatcher(IrOpcode::kLoadElement),
544 access_matcher_(access_matcher), 671 access_matcher_(access_matcher),
545 base_matcher_(base_matcher), 672 base_matcher_(base_matcher),
546 index_matcher_(index_matcher), 673 index_matcher_(index_matcher),
547 length_matcher_(length_matcher), 674 effect_matcher_(effect_matcher),
548 effect_matcher_(effect_matcher) {} 675 control_matcher_(control_matcher) {}
549 676
550 virtual void DescribeTo(std::ostream* os) const OVERRIDE { 677 virtual void DescribeTo(std::ostream* os) const OVERRIDE {
551 NodeMatcher::DescribeTo(os); 678 NodeMatcher::DescribeTo(os);
552 *os << " whose access ("; 679 *os << " whose access (";
553 access_matcher_.DescribeTo(os); 680 access_matcher_.DescribeTo(os);
554 *os << "), base ("; 681 *os << "), base (";
555 base_matcher_.DescribeTo(os); 682 base_matcher_.DescribeTo(os);
556 *os << "), index ("; 683 *os << "), index (";
557 index_matcher_.DescribeTo(os); 684 index_matcher_.DescribeTo(os);
558 *os << "), length ("; 685 *os << "), effect (";
559 length_matcher_.DescribeTo(os);
560 *os << ") and effect (";
561 effect_matcher_.DescribeTo(os); 686 effect_matcher_.DescribeTo(os);
687 *os << ") and control (";
688 control_matcher_.DescribeTo(os);
562 *os << ")"; 689 *os << ")";
563 } 690 }
564 691
565 virtual bool MatchAndExplain(Node* node, 692 virtual bool MatchAndExplain(Node* node,
566 MatchResultListener* listener) const OVERRIDE { 693 MatchResultListener* listener) const OVERRIDE {
567 return (NodeMatcher::MatchAndExplain(node, listener) && 694 return (NodeMatcher::MatchAndExplain(node, listener) &&
568 PrintMatchAndExplain(OpParameter<ElementAccess>(node), "access", 695 PrintMatchAndExplain(OpParameter<ElementAccess>(node), "access",
569 access_matcher_, listener) && 696 access_matcher_, listener) &&
570 PrintMatchAndExplain(NodeProperties::GetValueInput(node, 0), "base", 697 PrintMatchAndExplain(NodeProperties::GetValueInput(node, 0), "base",
571 base_matcher_, listener) && 698 base_matcher_, listener) &&
572 PrintMatchAndExplain(NodeProperties::GetValueInput(node, 1), 699 PrintMatchAndExplain(NodeProperties::GetValueInput(node, 1),
573 "index", index_matcher_, listener) && 700 "index", index_matcher_, listener) &&
574 PrintMatchAndExplain(NodeProperties::GetValueInput(node, 2),
575 "length", length_matcher_, listener) &&
576 PrintMatchAndExplain(NodeProperties::GetEffectInput(node), "effect", 701 PrintMatchAndExplain(NodeProperties::GetEffectInput(node), "effect",
577 effect_matcher_, listener)); 702 effect_matcher_, listener) &&
703 PrintMatchAndExplain(NodeProperties::GetControlInput(node),
704 "control", control_matcher_, listener));
578 } 705 }
579 706
580 private: 707 private:
581 const Matcher<ElementAccess> access_matcher_; 708 const Matcher<ElementAccess> access_matcher_;
582 const Matcher<Node*> base_matcher_; 709 const Matcher<Node*> base_matcher_;
583 const Matcher<Node*> index_matcher_; 710 const Matcher<Node*> index_matcher_;
584 const Matcher<Node*> length_matcher_;
585 const Matcher<Node*> effect_matcher_; 711 const Matcher<Node*> effect_matcher_;
712 const Matcher<Node*> control_matcher_;
586 }; 713 };
587 714
588 715
589 class IsStoreElementMatcher FINAL : public NodeMatcher { 716 class IsStoreElementMatcher FINAL : public NodeMatcher {
590 public: 717 public:
591 IsStoreElementMatcher(const Matcher<ElementAccess>& access_matcher, 718 IsStoreElementMatcher(const Matcher<ElementAccess>& access_matcher,
592 const Matcher<Node*>& base_matcher, 719 const Matcher<Node*>& base_matcher,
593 const Matcher<Node*>& index_matcher, 720 const Matcher<Node*>& index_matcher,
594 const Matcher<Node*>& length_matcher,
595 const Matcher<Node*>& value_matcher, 721 const Matcher<Node*>& value_matcher,
596 const Matcher<Node*>& effect_matcher, 722 const Matcher<Node*>& effect_matcher,
597 const Matcher<Node*>& control_matcher) 723 const Matcher<Node*>& control_matcher)
598 : NodeMatcher(IrOpcode::kStoreElement), 724 : NodeMatcher(IrOpcode::kStoreElement),
599 access_matcher_(access_matcher), 725 access_matcher_(access_matcher),
600 base_matcher_(base_matcher), 726 base_matcher_(base_matcher),
601 index_matcher_(index_matcher), 727 index_matcher_(index_matcher),
602 length_matcher_(length_matcher),
603 value_matcher_(value_matcher), 728 value_matcher_(value_matcher),
604 effect_matcher_(effect_matcher), 729 effect_matcher_(effect_matcher),
605 control_matcher_(control_matcher) {} 730 control_matcher_(control_matcher) {}
606 731
607 virtual void DescribeTo(std::ostream* os) const OVERRIDE { 732 virtual void DescribeTo(std::ostream* os) const OVERRIDE {
608 NodeMatcher::DescribeTo(os); 733 NodeMatcher::DescribeTo(os);
609 *os << " whose access ("; 734 *os << " whose access (";
610 access_matcher_.DescribeTo(os); 735 access_matcher_.DescribeTo(os);
611 *os << "), base ("; 736 *os << "), base (";
612 base_matcher_.DescribeTo(os); 737 base_matcher_.DescribeTo(os);
613 *os << "), index ("; 738 *os << "), index (";
614 index_matcher_.DescribeTo(os); 739 index_matcher_.DescribeTo(os);
615 *os << "), length (";
616 length_matcher_.DescribeTo(os);
617 *os << "), value ("; 740 *os << "), value (";
618 value_matcher_.DescribeTo(os); 741 value_matcher_.DescribeTo(os);
619 *os << "), effect ("; 742 *os << "), effect (";
620 effect_matcher_.DescribeTo(os); 743 effect_matcher_.DescribeTo(os);
621 *os << ") and control ("; 744 *os << ") and control (";
622 control_matcher_.DescribeTo(os); 745 control_matcher_.DescribeTo(os);
623 *os << ")"; 746 *os << ")";
624 } 747 }
625 748
626 virtual bool MatchAndExplain(Node* node, 749 virtual bool MatchAndExplain(Node* node,
627 MatchResultListener* listener) const OVERRIDE { 750 MatchResultListener* listener) const OVERRIDE {
628 return (NodeMatcher::MatchAndExplain(node, listener) && 751 return (NodeMatcher::MatchAndExplain(node, listener) &&
629 PrintMatchAndExplain(OpParameter<ElementAccess>(node), "access", 752 PrintMatchAndExplain(OpParameter<ElementAccess>(node), "access",
630 access_matcher_, listener) && 753 access_matcher_, listener) &&
631 PrintMatchAndExplain(NodeProperties::GetValueInput(node, 0), "base", 754 PrintMatchAndExplain(NodeProperties::GetValueInput(node, 0), "base",
632 base_matcher_, listener) && 755 base_matcher_, listener) &&
633 PrintMatchAndExplain(NodeProperties::GetValueInput(node, 1), 756 PrintMatchAndExplain(NodeProperties::GetValueInput(node, 1),
634 "index", index_matcher_, listener) && 757 "index", index_matcher_, listener) &&
635 PrintMatchAndExplain(NodeProperties::GetValueInput(node, 2), 758 PrintMatchAndExplain(NodeProperties::GetValueInput(node, 2),
636 "length", length_matcher_, listener) &&
637 PrintMatchAndExplain(NodeProperties::GetValueInput(node, 3),
638 "value", value_matcher_, listener) && 759 "value", value_matcher_, listener) &&
639 PrintMatchAndExplain(NodeProperties::GetEffectInput(node), "effect", 760 PrintMatchAndExplain(NodeProperties::GetEffectInput(node), "effect",
640 effect_matcher_, listener) && 761 effect_matcher_, listener) &&
641 PrintMatchAndExplain(NodeProperties::GetControlInput(node), 762 PrintMatchAndExplain(NodeProperties::GetControlInput(node),
642 "control", control_matcher_, listener)); 763 "control", control_matcher_, listener));
643 } 764 }
644 765
645 private: 766 private:
646 const Matcher<ElementAccess> access_matcher_; 767 const Matcher<ElementAccess> access_matcher_;
647 const Matcher<Node*> base_matcher_; 768 const Matcher<Node*> base_matcher_;
648 const Matcher<Node*> index_matcher_; 769 const Matcher<Node*> index_matcher_;
649 const Matcher<Node*> length_matcher_;
650 const Matcher<Node*> value_matcher_; 770 const Matcher<Node*> value_matcher_;
651 const Matcher<Node*> effect_matcher_; 771 const Matcher<Node*> effect_matcher_;
652 const Matcher<Node*> control_matcher_; 772 const Matcher<Node*> control_matcher_;
653 }; 773 };
654 774
655 775
656 class IsLoadMatcher FINAL : public NodeMatcher { 776 class IsLoadMatcher FINAL : public NodeMatcher {
657 public: 777 public:
658 IsLoadMatcher(const Matcher<LoadRepresentation>& rep_matcher, 778 IsLoadMatcher(const Matcher<LoadRepresentation>& rep_matcher,
659 const Matcher<Node*>& base_matcher, 779 const Matcher<Node*>& base_matcher,
(...skipping 345 matching lines...) Expand 10 before | Expand all | Expand 10 after
1005 1125
1006 Matcher<Node*> IsLoadField(const Matcher<FieldAccess>& access_matcher, 1126 Matcher<Node*> IsLoadField(const Matcher<FieldAccess>& access_matcher,
1007 const Matcher<Node*>& base_matcher, 1127 const Matcher<Node*>& base_matcher,
1008 const Matcher<Node*>& effect_matcher, 1128 const Matcher<Node*>& effect_matcher,
1009 const Matcher<Node*>& control_matcher) { 1129 const Matcher<Node*>& control_matcher) {
1010 return MakeMatcher(new IsLoadFieldMatcher(access_matcher, base_matcher, 1130 return MakeMatcher(new IsLoadFieldMatcher(access_matcher, base_matcher,
1011 effect_matcher, control_matcher)); 1131 effect_matcher, control_matcher));
1012 } 1132 }
1013 1133
1014 1134
1135 Matcher<Node*> IsLoadBuffer(const Matcher<BufferAccess>& access_matcher,
1136 const Matcher<Node*>& buffer_matcher,
1137 const Matcher<Node*>& offset_matcher,
1138 const Matcher<Node*>& length_matcher,
1139 const Matcher<Node*>& effect_matcher,
1140 const Matcher<Node*>& control_matcher) {
1141 return MakeMatcher(new IsLoadBufferMatcher(access_matcher, buffer_matcher,
1142 offset_matcher, length_matcher,
1143 effect_matcher, control_matcher));
1144 }
1145
1146
1147 Matcher<Node*> IsStoreBuffer(const Matcher<BufferAccess>& access_matcher,
1148 const Matcher<Node*>& buffer_matcher,
1149 const Matcher<Node*>& offset_matcher,
1150 const Matcher<Node*>& length_matcher,
1151 const Matcher<Node*>& value_matcher,
1152 const Matcher<Node*>& effect_matcher,
1153 const Matcher<Node*>& control_matcher) {
1154 return MakeMatcher(new IsStoreBufferMatcher(
1155 access_matcher, buffer_matcher, offset_matcher, length_matcher,
1156 value_matcher, effect_matcher, control_matcher));
1157 }
1158
1159
1015 Matcher<Node*> IsLoadElement(const Matcher<ElementAccess>& access_matcher, 1160 Matcher<Node*> IsLoadElement(const Matcher<ElementAccess>& access_matcher,
1016 const Matcher<Node*>& base_matcher, 1161 const Matcher<Node*>& base_matcher,
1017 const Matcher<Node*>& index_matcher, 1162 const Matcher<Node*>& index_matcher,
1018 const Matcher<Node*>& length_matcher, 1163 const Matcher<Node*>& effect_matcher,
1019 const Matcher<Node*>& effect_matcher) { 1164 const Matcher<Node*>& control_matcher) {
1020 return MakeMatcher(new IsLoadElementMatcher(access_matcher, base_matcher, 1165 return MakeMatcher(new IsLoadElementMatcher(access_matcher, base_matcher,
1021 index_matcher, length_matcher, 1166 index_matcher, effect_matcher,
1022 effect_matcher)); 1167 control_matcher));
1023 } 1168 }
1024 1169
1025 1170
1026 Matcher<Node*> IsStoreElement(const Matcher<ElementAccess>& access_matcher, 1171 Matcher<Node*> IsStoreElement(const Matcher<ElementAccess>& access_matcher,
1027 const Matcher<Node*>& base_matcher, 1172 const Matcher<Node*>& base_matcher,
1028 const Matcher<Node*>& index_matcher, 1173 const Matcher<Node*>& index_matcher,
1029 const Matcher<Node*>& length_matcher,
1030 const Matcher<Node*>& value_matcher, 1174 const Matcher<Node*>& value_matcher,
1031 const Matcher<Node*>& effect_matcher, 1175 const Matcher<Node*>& effect_matcher,
1032 const Matcher<Node*>& control_matcher) { 1176 const Matcher<Node*>& control_matcher) {
1033 return MakeMatcher(new IsStoreElementMatcher( 1177 return MakeMatcher(new IsStoreElementMatcher(
1034 access_matcher, base_matcher, index_matcher, length_matcher, 1178 access_matcher, base_matcher, index_matcher, value_matcher,
1035 value_matcher, effect_matcher, control_matcher)); 1179 effect_matcher, control_matcher));
1036 } 1180 }
1037 1181
1038 1182
1039 Matcher<Node*> IsLoad(const Matcher<LoadRepresentation>& rep_matcher, 1183 Matcher<Node*> IsLoad(const Matcher<LoadRepresentation>& rep_matcher,
1040 const Matcher<Node*>& base_matcher, 1184 const Matcher<Node*>& base_matcher,
1041 const Matcher<Node*>& index_matcher, 1185 const Matcher<Node*>& index_matcher,
1042 const Matcher<Node*>& effect_matcher, 1186 const Matcher<Node*>& effect_matcher,
1043 const Matcher<Node*>& control_matcher) { 1187 const Matcher<Node*>& control_matcher) {
1044 return MakeMatcher(new IsLoadMatcher(rep_matcher, base_matcher, index_matcher, 1188 return MakeMatcher(new IsLoadMatcher(rep_matcher, base_matcher, index_matcher,
1045 effect_matcher, control_matcher)); 1189 effect_matcher, control_matcher));
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
1118 IS_UNOP_MATCHER(Float64Ceil) 1262 IS_UNOP_MATCHER(Float64Ceil)
1119 IS_UNOP_MATCHER(Float64RoundTruncate) 1263 IS_UNOP_MATCHER(Float64RoundTruncate)
1120 IS_UNOP_MATCHER(Float64RoundTiesAway) 1264 IS_UNOP_MATCHER(Float64RoundTiesAway)
1121 IS_UNOP_MATCHER(NumberToInt32) 1265 IS_UNOP_MATCHER(NumberToInt32)
1122 IS_UNOP_MATCHER(NumberToUint32) 1266 IS_UNOP_MATCHER(NumberToUint32)
1123 #undef IS_UNOP_MATCHER 1267 #undef IS_UNOP_MATCHER
1124 1268
1125 } // namespace compiler 1269 } // namespace compiler
1126 } // namespace internal 1270 } // namespace internal
1127 } // namespace v8 1271 } // namespace v8
OLDNEW
« no previous file with comments | « test/unittests/compiler/node-test-utils.h ('k') | test/unittests/compiler/simplified-operator-reducer-unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698