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 IsTernopMatcher final : public NodeMatcher { |
| 1410 public: |
| 1411 IsTernopMatcher(IrOpcode::Value opcode, const Matcher<Node*>& lhs_matcher, |
| 1412 const Matcher<Node*>& mid_matcher, |
| 1413 const Matcher<Node*>& rhs_matcher) |
| 1414 : NodeMatcher(opcode), |
| 1415 lhs_matcher_(lhs_matcher), |
| 1416 mid_matcher_(mid_matcher), |
| 1417 rhs_matcher_(rhs_matcher) {} |
| 1418 |
| 1419 void DescribeTo(std::ostream* os) const final { |
| 1420 NodeMatcher::DescribeTo(os); |
| 1421 *os << " whose lhs ("; |
| 1422 lhs_matcher_.DescribeTo(os); |
| 1423 *os << ") and mid ("; |
| 1424 mid_matcher_.DescribeTo(os); |
| 1425 *os << ") and rhs ("; |
| 1426 rhs_matcher_.DescribeTo(os); |
| 1427 *os << ")"; |
| 1428 } |
| 1429 |
| 1430 bool MatchAndExplain(Node* node, MatchResultListener* listener) const final { |
| 1431 return (NodeMatcher::MatchAndExplain(node, listener) && |
| 1432 PrintMatchAndExplain(NodeProperties::GetValueInput(node, 0), "lhs", |
| 1433 lhs_matcher_, listener) && |
| 1434 PrintMatchAndExplain(NodeProperties::GetValueInput(node, 1), "mid", |
| 1435 mid_matcher_, listener) && |
| 1436 PrintMatchAndExplain(NodeProperties::GetValueInput(node, 2), "rhs", |
| 1437 rhs_matcher_, listener)); |
| 1438 } |
| 1439 |
| 1440 private: |
| 1441 const Matcher<Node*> lhs_matcher_; |
| 1442 const Matcher<Node*> mid_matcher_; |
| 1443 const Matcher<Node*> rhs_matcher_; |
| 1444 }; |
1409 | 1445 |
1410 class IsBinopMatcher final : public NodeMatcher { | 1446 class IsBinopMatcher final : public NodeMatcher { |
1411 public: | 1447 public: |
1412 IsBinopMatcher(IrOpcode::Value opcode, const Matcher<Node*>& lhs_matcher, | 1448 IsBinopMatcher(IrOpcode::Value opcode, const Matcher<Node*>& lhs_matcher, |
1413 const Matcher<Node*>& rhs_matcher) | 1449 const Matcher<Node*>& rhs_matcher) |
1414 : NodeMatcher(opcode), | 1450 : NodeMatcher(opcode), |
1415 lhs_matcher_(lhs_matcher), | 1451 lhs_matcher_(lhs_matcher), |
1416 rhs_matcher_(rhs_matcher) {} | 1452 rhs_matcher_(rhs_matcher) {} |
1417 | 1453 |
1418 void DescribeTo(std::ostream* os) const final { | 1454 void DescribeTo(std::ostream* os) const final { |
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1477 PrintMatchAndExplain(ParameterIndexOf(node->op()), "index", | 1513 PrintMatchAndExplain(ParameterIndexOf(node->op()), "index", |
1478 index_matcher_, listener)); | 1514 index_matcher_, listener)); |
1479 } | 1515 } |
1480 | 1516 |
1481 private: | 1517 private: |
1482 const Matcher<int> index_matcher_; | 1518 const Matcher<int> index_matcher_; |
1483 }; | 1519 }; |
1484 | 1520 |
1485 } // namespace | 1521 } // namespace |
1486 | 1522 |
1487 | |
1488 Matcher<Node*> IsDead() { | 1523 Matcher<Node*> IsDead() { |
1489 return MakeMatcher(new NodeMatcher(IrOpcode::kDead)); | 1524 return MakeMatcher(new NodeMatcher(IrOpcode::kDead)); |
1490 } | 1525 } |
1491 | 1526 |
1492 Matcher<Node*> IsEnd(const Matcher<Node*>& control0_matcher) { | 1527 Matcher<Node*> IsEnd(const Matcher<Node*>& control0_matcher) { |
1493 return MakeMatcher(new IsControl1Matcher(IrOpcode::kEnd, control0_matcher)); | 1528 return MakeMatcher(new IsControl1Matcher(IrOpcode::kEnd, control0_matcher)); |
1494 } | 1529 } |
1495 | 1530 |
1496 | 1531 |
1497 Matcher<Node*> IsEnd(const Matcher<Node*>& control0_matcher, | 1532 Matcher<Node*> IsEnd(const Matcher<Node*>& control0_matcher, |
(...skipping 564 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2062 | 2097 |
2063 Matcher<Node*> IsParameter(const Matcher<int> index_matcher) { | 2098 Matcher<Node*> IsParameter(const Matcher<int> index_matcher) { |
2064 return MakeMatcher(new IsParameterMatcher(index_matcher)); | 2099 return MakeMatcher(new IsParameterMatcher(index_matcher)); |
2065 } | 2100 } |
2066 | 2101 |
2067 | 2102 |
2068 Matcher<Node*> IsLoadFramePointer() { | 2103 Matcher<Node*> IsLoadFramePointer() { |
2069 return MakeMatcher(new NodeMatcher(IrOpcode::kLoadFramePointer)); | 2104 return MakeMatcher(new NodeMatcher(IrOpcode::kLoadFramePointer)); |
2070 } | 2105 } |
2071 | 2106 |
| 2107 #define IS_TERNOP_MATCHER(Name) \ |
| 2108 Matcher<Node*> Is##Name(const Matcher<Node*>& lhs_matcher, \ |
| 2109 const Matcher<Node*>& mid_matcher, \ |
| 2110 const Matcher<Node*>& rhs_matcher) { \ |
| 2111 return MakeMatcher(new IsTernopMatcher(IrOpcode::k##Name, lhs_matcher, \ |
| 2112 mid_matcher, rhs_matcher)); \ |
| 2113 } |
| 2114 |
| 2115 IS_TERNOP_MATCHER(WasmWord64Shl) |
2072 | 2116 |
2073 #define IS_BINOP_MATCHER(Name) \ | 2117 #define IS_BINOP_MATCHER(Name) \ |
2074 Matcher<Node*> Is##Name(const Matcher<Node*>& lhs_matcher, \ | 2118 Matcher<Node*> Is##Name(const Matcher<Node*>& lhs_matcher, \ |
2075 const Matcher<Node*>& rhs_matcher) { \ | 2119 const Matcher<Node*>& rhs_matcher) { \ |
2076 return MakeMatcher( \ | 2120 return MakeMatcher( \ |
2077 new IsBinopMatcher(IrOpcode::k##Name, lhs_matcher, rhs_matcher)); \ | 2121 new IsBinopMatcher(IrOpcode::k##Name, lhs_matcher, rhs_matcher)); \ |
2078 } | 2122 } |
2079 IS_BINOP_MATCHER(NumberEqual) | 2123 IS_BINOP_MATCHER(NumberEqual) |
2080 IS_BINOP_MATCHER(NumberLessThan) | 2124 IS_BINOP_MATCHER(NumberLessThan) |
2081 IS_BINOP_MATCHER(NumberSubtract) | 2125 IS_BINOP_MATCHER(NumberSubtract) |
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2145 IS_UNOP_MATCHER(NumberToInt32) | 2189 IS_UNOP_MATCHER(NumberToInt32) |
2146 IS_UNOP_MATCHER(NumberToUint32) | 2190 IS_UNOP_MATCHER(NumberToUint32) |
2147 IS_UNOP_MATCHER(ObjectIsReceiver) | 2191 IS_UNOP_MATCHER(ObjectIsReceiver) |
2148 IS_UNOP_MATCHER(ObjectIsSmi) | 2192 IS_UNOP_MATCHER(ObjectIsSmi) |
2149 IS_UNOP_MATCHER(Word32Clz) | 2193 IS_UNOP_MATCHER(Word32Clz) |
2150 #undef IS_UNOP_MATCHER | 2194 #undef IS_UNOP_MATCHER |
2151 | 2195 |
2152 } // namespace compiler | 2196 } // namespace compiler |
2153 } // namespace internal | 2197 } // namespace internal |
2154 } // namespace v8 | 2198 } // namespace v8 |
OLD | NEW |