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 1388 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1399 access_matcher_, listener) && | 1399 access_matcher_, listener) && |
1400 PrintMatchAndExplain(NodeProperties::GetContextInput(node), | 1400 PrintMatchAndExplain(NodeProperties::GetContextInput(node), |
1401 "context", context_matcher_, listener)); | 1401 "context", context_matcher_, listener)); |
1402 } | 1402 } |
1403 | 1403 |
1404 private: | 1404 private: |
1405 const Matcher<ContextAccess> access_matcher_; | 1405 const Matcher<ContextAccess> access_matcher_; |
1406 const Matcher<Node*> context_matcher_; | 1406 const Matcher<Node*> context_matcher_; |
1407 }; | 1407 }; |
1408 | 1408 |
| 1409 class IsQuadopMatcher final : public NodeMatcher { |
| 1410 public: |
| 1411 IsQuadopMatcher(IrOpcode::Value opcode, const Matcher<Node*>& a_matcher, |
| 1412 const Matcher<Node*>& b_matcher, |
| 1413 const Matcher<Node*>& c_matcher, |
| 1414 const Matcher<Node*>& d_matcher) |
| 1415 : NodeMatcher(opcode), |
| 1416 a_matcher_(a_matcher), |
| 1417 b_matcher_(b_matcher), |
| 1418 c_matcher_(c_matcher), |
| 1419 d_matcher_(d_matcher) {} |
| 1420 |
| 1421 void DescribeTo(std::ostream* os) const final { |
| 1422 NodeMatcher::DescribeTo(os); |
| 1423 *os << " whose a ("; |
| 1424 a_matcher_.DescribeTo(os); |
| 1425 *os << ") and b ("; |
| 1426 b_matcher_.DescribeTo(os); |
| 1427 *os << ") and c ("; |
| 1428 c_matcher_.DescribeTo(os); |
| 1429 *os << ") and d ("; |
| 1430 d_matcher_.DescribeTo(os); |
| 1431 *os << ")"; |
| 1432 } |
| 1433 |
| 1434 bool MatchAndExplain(Node* node, MatchResultListener* listener) const final { |
| 1435 return (NodeMatcher::MatchAndExplain(node, listener) && |
| 1436 PrintMatchAndExplain(NodeProperties::GetValueInput(node, 0), "a", |
| 1437 a_matcher_, listener) && |
| 1438 PrintMatchAndExplain(NodeProperties::GetValueInput(node, 1), "b", |
| 1439 b_matcher_, listener) && |
| 1440 PrintMatchAndExplain(NodeProperties::GetValueInput(node, 2), "c", |
| 1441 c_matcher_, listener) && |
| 1442 PrintMatchAndExplain(NodeProperties::GetValueInput(node, 3), "d", |
| 1443 d_matcher_, listener)); |
| 1444 } |
| 1445 |
| 1446 private: |
| 1447 const Matcher<Node*> a_matcher_; |
| 1448 const Matcher<Node*> b_matcher_; |
| 1449 const Matcher<Node*> c_matcher_; |
| 1450 const Matcher<Node*> d_matcher_; |
| 1451 }; |
| 1452 |
1409 class IsTernopMatcher final : public NodeMatcher { | 1453 class IsTernopMatcher final : public NodeMatcher { |
1410 public: | 1454 public: |
1411 IsTernopMatcher(IrOpcode::Value opcode, const Matcher<Node*>& lhs_matcher, | 1455 IsTernopMatcher(IrOpcode::Value opcode, const Matcher<Node*>& lhs_matcher, |
1412 const Matcher<Node*>& mid_matcher, | 1456 const Matcher<Node*>& mid_matcher, |
1413 const Matcher<Node*>& rhs_matcher) | 1457 const Matcher<Node*>& rhs_matcher) |
1414 : NodeMatcher(opcode), | 1458 : NodeMatcher(opcode), |
1415 lhs_matcher_(lhs_matcher), | 1459 lhs_matcher_(lhs_matcher), |
1416 mid_matcher_(mid_matcher), | 1460 mid_matcher_(mid_matcher), |
1417 rhs_matcher_(rhs_matcher) {} | 1461 rhs_matcher_(rhs_matcher) {} |
1418 | 1462 |
(...skipping 678 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2097 | 2141 |
2098 Matcher<Node*> IsParameter(const Matcher<int> index_matcher) { | 2142 Matcher<Node*> IsParameter(const Matcher<int> index_matcher) { |
2099 return MakeMatcher(new IsParameterMatcher(index_matcher)); | 2143 return MakeMatcher(new IsParameterMatcher(index_matcher)); |
2100 } | 2144 } |
2101 | 2145 |
2102 | 2146 |
2103 Matcher<Node*> IsLoadFramePointer() { | 2147 Matcher<Node*> IsLoadFramePointer() { |
2104 return MakeMatcher(new NodeMatcher(IrOpcode::kLoadFramePointer)); | 2148 return MakeMatcher(new NodeMatcher(IrOpcode::kLoadFramePointer)); |
2105 } | 2149 } |
2106 | 2150 |
| 2151 #define IS_QUADOP_MATCHER(Name) \ |
| 2152 Matcher<Node*> Is##Name( \ |
| 2153 const Matcher<Node*>& a_matcher, const Matcher<Node*>& b_matcher, \ |
| 2154 const Matcher<Node*>& c_matcher, const Matcher<Node*>& d_matcher) { \ |
| 2155 return MakeMatcher(new IsQuadopMatcher(IrOpcode::k##Name, a_matcher, \ |
| 2156 b_matcher, c_matcher, d_matcher)); \ |
| 2157 } |
| 2158 |
| 2159 IS_QUADOP_MATCHER(Int32AddPair) |
| 2160 |
2107 #define IS_TERNOP_MATCHER(Name) \ | 2161 #define IS_TERNOP_MATCHER(Name) \ |
2108 Matcher<Node*> Is##Name(const Matcher<Node*>& lhs_matcher, \ | 2162 Matcher<Node*> Is##Name(const Matcher<Node*>& lhs_matcher, \ |
2109 const Matcher<Node*>& mid_matcher, \ | 2163 const Matcher<Node*>& mid_matcher, \ |
2110 const Matcher<Node*>& rhs_matcher) { \ | 2164 const Matcher<Node*>& rhs_matcher) { \ |
2111 return MakeMatcher(new IsTernopMatcher(IrOpcode::k##Name, lhs_matcher, \ | 2165 return MakeMatcher(new IsTernopMatcher(IrOpcode::k##Name, lhs_matcher, \ |
2112 mid_matcher, rhs_matcher)); \ | 2166 mid_matcher, rhs_matcher)); \ |
2113 } | 2167 } |
2114 | 2168 |
2115 IS_TERNOP_MATCHER(Word32PairShl) | 2169 IS_TERNOP_MATCHER(Word32PairShl) |
2116 | 2170 |
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2189 IS_UNOP_MATCHER(NumberToInt32) | 2243 IS_UNOP_MATCHER(NumberToInt32) |
2190 IS_UNOP_MATCHER(NumberToUint32) | 2244 IS_UNOP_MATCHER(NumberToUint32) |
2191 IS_UNOP_MATCHER(ObjectIsReceiver) | 2245 IS_UNOP_MATCHER(ObjectIsReceiver) |
2192 IS_UNOP_MATCHER(ObjectIsSmi) | 2246 IS_UNOP_MATCHER(ObjectIsSmi) |
2193 IS_UNOP_MATCHER(Word32Clz) | 2247 IS_UNOP_MATCHER(Word32Clz) |
2194 #undef IS_UNOP_MATCHER | 2248 #undef IS_UNOP_MATCHER |
2195 | 2249 |
2196 } // namespace compiler | 2250 } // namespace compiler |
2197 } // namespace internal | 2251 } // namespace internal |
2198 } // namespace v8 | 2252 } // namespace v8 |
OLD | NEW |