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 190 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
201 return (NodeMatcher::MatchAndExplain(node, listener) && | 201 return (NodeMatcher::MatchAndExplain(node, listener) && |
202 PrintMatchAndExplain(OpParameter<T>(node), "value", value_matcher_, | 202 PrintMatchAndExplain(OpParameter<T>(node), "value", value_matcher_, |
203 listener)); | 203 listener)); |
204 } | 204 } |
205 | 205 |
206 private: | 206 private: |
207 const Matcher<T> value_matcher_; | 207 const Matcher<T> value_matcher_; |
208 }; | 208 }; |
209 | 209 |
210 | 210 |
| 211 class IsSelectMatcher FINAL : public NodeMatcher { |
| 212 public: |
| 213 IsSelectMatcher(const Matcher<MachineType>& type_matcher, |
| 214 const Matcher<Node*>& value0_matcher, |
| 215 const Matcher<Node*>& value1_matcher, |
| 216 const Matcher<Node*>& value2_matcher) |
| 217 : NodeMatcher(IrOpcode::kSelect), |
| 218 type_matcher_(type_matcher), |
| 219 value0_matcher_(value0_matcher), |
| 220 value1_matcher_(value1_matcher), |
| 221 value2_matcher_(value2_matcher) {} |
| 222 |
| 223 virtual void DescribeTo(std::ostream* os) const OVERRIDE { |
| 224 NodeMatcher::DescribeTo(os); |
| 225 *os << " whose type ("; |
| 226 type_matcher_.DescribeTo(os); |
| 227 *os << "), value0 ("; |
| 228 value0_matcher_.DescribeTo(os); |
| 229 *os << "), value1 ("; |
| 230 value1_matcher_.DescribeTo(os); |
| 231 *os << ") and value2 ("; |
| 232 value2_matcher_.DescribeTo(os); |
| 233 *os << ")"; |
| 234 } |
| 235 |
| 236 virtual bool MatchAndExplain(Node* node, |
| 237 MatchResultListener* listener) const OVERRIDE { |
| 238 return (NodeMatcher::MatchAndExplain(node, listener) && |
| 239 PrintMatchAndExplain(OpParameter<MachineType>(node), "type", |
| 240 type_matcher_, listener) && |
| 241 PrintMatchAndExplain(NodeProperties::GetValueInput(node, 0), |
| 242 "value0", value0_matcher_, listener) && |
| 243 PrintMatchAndExplain(NodeProperties::GetValueInput(node, 1), |
| 244 "value1", value1_matcher_, listener) && |
| 245 PrintMatchAndExplain(NodeProperties::GetValueInput(node, 2), |
| 246 "value2", value2_matcher_, listener)); |
| 247 } |
| 248 |
| 249 private: |
| 250 const Matcher<MachineType> type_matcher_; |
| 251 const Matcher<Node*> value0_matcher_; |
| 252 const Matcher<Node*> value1_matcher_; |
| 253 const Matcher<Node*> value2_matcher_; |
| 254 }; |
| 255 |
| 256 |
211 class IsPhiMatcher FINAL : public NodeMatcher { | 257 class IsPhiMatcher FINAL : public NodeMatcher { |
212 public: | 258 public: |
213 IsPhiMatcher(const Matcher<MachineType>& type_matcher, | 259 IsPhiMatcher(const Matcher<MachineType>& type_matcher, |
214 const Matcher<Node*>& value0_matcher, | 260 const Matcher<Node*>& value0_matcher, |
215 const Matcher<Node*>& value1_matcher, | 261 const Matcher<Node*>& value1_matcher, |
216 const Matcher<Node*>& control_matcher) | 262 const Matcher<Node*>& control_matcher) |
217 : NodeMatcher(IrOpcode::kPhi), | 263 : NodeMatcher(IrOpcode::kPhi), |
218 type_matcher_(type_matcher), | 264 type_matcher_(type_matcher), |
219 value0_matcher_(value0_matcher), | 265 value0_matcher_(value0_matcher), |
220 value1_matcher_(value1_matcher), | 266 value1_matcher_(value1_matcher), |
(...skipping 537 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
758 new IsConstantMatcher<double>(IrOpcode::kFloat64Constant, value_matcher)); | 804 new IsConstantMatcher<double>(IrOpcode::kFloat64Constant, value_matcher)); |
759 } | 805 } |
760 | 806 |
761 | 807 |
762 Matcher<Node*> IsNumberConstant(const Matcher<double>& value_matcher) { | 808 Matcher<Node*> IsNumberConstant(const Matcher<double>& value_matcher) { |
763 return MakeMatcher( | 809 return MakeMatcher( |
764 new IsConstantMatcher<double>(IrOpcode::kNumberConstant, value_matcher)); | 810 new IsConstantMatcher<double>(IrOpcode::kNumberConstant, value_matcher)); |
765 } | 811 } |
766 | 812 |
767 | 813 |
| 814 Matcher<Node*> IsSelect(const Matcher<MachineType>& type_matcher, |
| 815 const Matcher<Node*>& value0_matcher, |
| 816 const Matcher<Node*>& value1_matcher, |
| 817 const Matcher<Node*>& value2_matcher) { |
| 818 return MakeMatcher(new IsSelectMatcher(type_matcher, value0_matcher, |
| 819 value1_matcher, value2_matcher)); |
| 820 } |
| 821 |
| 822 |
768 Matcher<Node*> IsPhi(const Matcher<MachineType>& type_matcher, | 823 Matcher<Node*> IsPhi(const Matcher<MachineType>& type_matcher, |
769 const Matcher<Node*>& value0_matcher, | 824 const Matcher<Node*>& value0_matcher, |
770 const Matcher<Node*>& value1_matcher, | 825 const Matcher<Node*>& value1_matcher, |
771 const Matcher<Node*>& merge_matcher) { | 826 const Matcher<Node*>& merge_matcher) { |
772 return MakeMatcher(new IsPhiMatcher(type_matcher, value0_matcher, | 827 return MakeMatcher(new IsPhiMatcher(type_matcher, value0_matcher, |
773 value1_matcher, merge_matcher)); | 828 value1_matcher, merge_matcher)); |
774 } | 829 } |
775 | 830 |
776 | 831 |
777 Matcher<Node*> IsProjection(const Matcher<size_t>& index_matcher, | 832 Matcher<Node*> IsProjection(const Matcher<size_t>& index_matcher, |
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
850 | 905 |
851 #define IS_BINOP_MATCHER(Name) \ | 906 #define IS_BINOP_MATCHER(Name) \ |
852 Matcher<Node*> Is##Name(const Matcher<Node*>& lhs_matcher, \ | 907 Matcher<Node*> Is##Name(const Matcher<Node*>& lhs_matcher, \ |
853 const Matcher<Node*>& rhs_matcher) { \ | 908 const Matcher<Node*>& rhs_matcher) { \ |
854 return MakeMatcher( \ | 909 return MakeMatcher( \ |
855 new IsBinopMatcher(IrOpcode::k##Name, lhs_matcher, rhs_matcher)); \ | 910 new IsBinopMatcher(IrOpcode::k##Name, lhs_matcher, rhs_matcher)); \ |
856 } | 911 } |
857 IS_BINOP_MATCHER(NumberEqual) | 912 IS_BINOP_MATCHER(NumberEqual) |
858 IS_BINOP_MATCHER(NumberLessThan) | 913 IS_BINOP_MATCHER(NumberLessThan) |
859 IS_BINOP_MATCHER(NumberSubtract) | 914 IS_BINOP_MATCHER(NumberSubtract) |
| 915 IS_BINOP_MATCHER(NumberMultiply) |
860 IS_BINOP_MATCHER(Word32And) | 916 IS_BINOP_MATCHER(Word32And) |
861 IS_BINOP_MATCHER(Word32Sar) | 917 IS_BINOP_MATCHER(Word32Sar) |
862 IS_BINOP_MATCHER(Word32Shl) | 918 IS_BINOP_MATCHER(Word32Shl) |
863 IS_BINOP_MATCHER(Word32Shr) | 919 IS_BINOP_MATCHER(Word32Shr) |
864 IS_BINOP_MATCHER(Word32Ror) | 920 IS_BINOP_MATCHER(Word32Ror) |
865 IS_BINOP_MATCHER(Word32Equal) | 921 IS_BINOP_MATCHER(Word32Equal) |
866 IS_BINOP_MATCHER(Word64And) | 922 IS_BINOP_MATCHER(Word64And) |
867 IS_BINOP_MATCHER(Word64Sar) | 923 IS_BINOP_MATCHER(Word64Sar) |
868 IS_BINOP_MATCHER(Word64Shl) | 924 IS_BINOP_MATCHER(Word64Shl) |
869 IS_BINOP_MATCHER(Word64Equal) | 925 IS_BINOP_MATCHER(Word64Equal) |
(...skipping 21 matching lines...) Expand all Loading... |
891 IS_UNOP_MATCHER(ChangeUint32ToUint64) | 947 IS_UNOP_MATCHER(ChangeUint32ToUint64) |
892 IS_UNOP_MATCHER(TruncateFloat64ToFloat32) | 948 IS_UNOP_MATCHER(TruncateFloat64ToFloat32) |
893 IS_UNOP_MATCHER(TruncateFloat64ToInt32) | 949 IS_UNOP_MATCHER(TruncateFloat64ToInt32) |
894 IS_UNOP_MATCHER(TruncateInt64ToInt32) | 950 IS_UNOP_MATCHER(TruncateInt64ToInt32) |
895 IS_UNOP_MATCHER(Float64Sqrt) | 951 IS_UNOP_MATCHER(Float64Sqrt) |
896 #undef IS_UNOP_MATCHER | 952 #undef IS_UNOP_MATCHER |
897 | 953 |
898 } // namespace compiler | 954 } // namespace compiler |
899 } // namespace internal | 955 } // namespace internal |
900 } // namespace v8 | 956 } // namespace v8 |
OLD | NEW |