| 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 393 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 404 listener)); | 404 listener)); |
| 405 } | 405 } |
| 406 | 406 |
| 407 private: | 407 private: |
| 408 const Matcher<T> value_matcher_; | 408 const Matcher<T> value_matcher_; |
| 409 }; | 409 }; |
| 410 | 410 |
| 411 | 411 |
| 412 class IsSelectMatcher final : public NodeMatcher { | 412 class IsSelectMatcher final : public NodeMatcher { |
| 413 public: | 413 public: |
| 414 IsSelectMatcher(const Matcher<MachineType>& type_matcher, | 414 IsSelectMatcher(const Matcher<MachineRepresentation>& type_matcher, |
| 415 const Matcher<Node*>& value0_matcher, | 415 const Matcher<Node*>& value0_matcher, |
| 416 const Matcher<Node*>& value1_matcher, | 416 const Matcher<Node*>& value1_matcher, |
| 417 const Matcher<Node*>& value2_matcher) | 417 const Matcher<Node*>& value2_matcher) |
| 418 : NodeMatcher(IrOpcode::kSelect), | 418 : NodeMatcher(IrOpcode::kSelect), |
| 419 type_matcher_(type_matcher), | 419 type_matcher_(type_matcher), |
| 420 value0_matcher_(value0_matcher), | 420 value0_matcher_(value0_matcher), |
| 421 value1_matcher_(value1_matcher), | 421 value1_matcher_(value1_matcher), |
| 422 value2_matcher_(value2_matcher) {} | 422 value2_matcher_(value2_matcher) {} |
| 423 | 423 |
| 424 void DescribeTo(std::ostream* os) const final { | 424 void DescribeTo(std::ostream* os) const final { |
| 425 NodeMatcher::DescribeTo(os); | 425 NodeMatcher::DescribeTo(os); |
| 426 *os << " whose type ("; | 426 *os << " whose representation ("; |
| 427 type_matcher_.DescribeTo(os); | 427 type_matcher_.DescribeTo(os); |
| 428 *os << "), value0 ("; | 428 *os << "), value0 ("; |
| 429 value0_matcher_.DescribeTo(os); | 429 value0_matcher_.DescribeTo(os); |
| 430 *os << "), value1 ("; | 430 *os << "), value1 ("; |
| 431 value1_matcher_.DescribeTo(os); | 431 value1_matcher_.DescribeTo(os); |
| 432 *os << ") and value2 ("; | 432 *os << ") and value2 ("; |
| 433 value2_matcher_.DescribeTo(os); | 433 value2_matcher_.DescribeTo(os); |
| 434 *os << ")"; | 434 *os << ")"; |
| 435 } | 435 } |
| 436 | 436 |
| 437 bool MatchAndExplain(Node* node, MatchResultListener* listener) const final { | 437 bool MatchAndExplain(Node* node, MatchResultListener* listener) const final { |
| 438 return (NodeMatcher::MatchAndExplain(node, listener) && | 438 return ( |
| 439 PrintMatchAndExplain(OpParameter<SelectParameters>(node).type(), | 439 NodeMatcher::MatchAndExplain(node, listener) && |
| 440 "type", type_matcher_, listener) && | 440 PrintMatchAndExplain(SelectParametersOf(node->op()).representation(), |
| 441 PrintMatchAndExplain(NodeProperties::GetValueInput(node, 0), | 441 "representation", type_matcher_, listener) && |
| 442 "value0", value0_matcher_, listener) && | 442 PrintMatchAndExplain(NodeProperties::GetValueInput(node, 0), "value0", |
| 443 PrintMatchAndExplain(NodeProperties::GetValueInput(node, 1), | 443 value0_matcher_, listener) && |
| 444 "value1", value1_matcher_, listener) && | 444 PrintMatchAndExplain(NodeProperties::GetValueInput(node, 1), "value1", |
| 445 PrintMatchAndExplain(NodeProperties::GetValueInput(node, 2), | 445 value1_matcher_, listener) && |
| 446 "value2", value2_matcher_, listener)); | 446 PrintMatchAndExplain(NodeProperties::GetValueInput(node, 2), "value2", |
| 447 value2_matcher_, listener)); |
| 447 } | 448 } |
| 448 | 449 |
| 449 private: | 450 private: |
| 450 const Matcher<MachineType> type_matcher_; | 451 const Matcher<MachineRepresentation> type_matcher_; |
| 451 const Matcher<Node*> value0_matcher_; | 452 const Matcher<Node*> value0_matcher_; |
| 452 const Matcher<Node*> value1_matcher_; | 453 const Matcher<Node*> value1_matcher_; |
| 453 const Matcher<Node*> value2_matcher_; | 454 const Matcher<Node*> value2_matcher_; |
| 454 }; | 455 }; |
| 455 | 456 |
| 456 | 457 |
| 457 class IsPhiMatcher final : public NodeMatcher { | 458 class IsPhiMatcher final : public NodeMatcher { |
| 458 public: | 459 public: |
| 459 IsPhiMatcher(const Matcher<MachineType>& type_matcher, | 460 IsPhiMatcher(const Matcher<MachineRepresentation>& type_matcher, |
| 460 const Matcher<Node*>& value0_matcher, | 461 const Matcher<Node*>& value0_matcher, |
| 461 const Matcher<Node*>& value1_matcher, | 462 const Matcher<Node*>& value1_matcher, |
| 462 const Matcher<Node*>& control_matcher) | 463 const Matcher<Node*>& control_matcher) |
| 463 : NodeMatcher(IrOpcode::kPhi), | 464 : NodeMatcher(IrOpcode::kPhi), |
| 464 type_matcher_(type_matcher), | 465 type_matcher_(type_matcher), |
| 465 value0_matcher_(value0_matcher), | 466 value0_matcher_(value0_matcher), |
| 466 value1_matcher_(value1_matcher), | 467 value1_matcher_(value1_matcher), |
| 467 control_matcher_(control_matcher) {} | 468 control_matcher_(control_matcher) {} |
| 468 | 469 |
| 469 void DescribeTo(std::ostream* os) const final { | 470 void DescribeTo(std::ostream* os) const final { |
| 470 NodeMatcher::DescribeTo(os); | 471 NodeMatcher::DescribeTo(os); |
| 471 *os << " whose type ("; | 472 *os << " whose representation ("; |
| 472 type_matcher_.DescribeTo(os); | 473 type_matcher_.DescribeTo(os); |
| 473 *os << "), value0 ("; | 474 *os << "), value0 ("; |
| 474 value0_matcher_.DescribeTo(os); | 475 value0_matcher_.DescribeTo(os); |
| 475 *os << "), value1 ("; | 476 *os << "), value1 ("; |
| 476 value1_matcher_.DescribeTo(os); | 477 value1_matcher_.DescribeTo(os); |
| 477 *os << ") and control ("; | 478 *os << ") and control ("; |
| 478 control_matcher_.DescribeTo(os); | 479 control_matcher_.DescribeTo(os); |
| 479 *os << ")"; | 480 *os << ")"; |
| 480 } | 481 } |
| 481 | 482 |
| 482 bool MatchAndExplain(Node* node, MatchResultListener* listener) const final { | 483 bool MatchAndExplain(Node* node, MatchResultListener* listener) const final { |
| 483 return (NodeMatcher::MatchAndExplain(node, listener) && | 484 return (NodeMatcher::MatchAndExplain(node, listener) && |
| 484 PrintMatchAndExplain(OpParameter<MachineType>(node), "type", | 485 PrintMatchAndExplain(PhiRepresentationOf(node->op()), |
| 485 type_matcher_, listener) && | 486 "representation", type_matcher_, listener) && |
| 486 PrintMatchAndExplain(NodeProperties::GetValueInput(node, 0), | 487 PrintMatchAndExplain(NodeProperties::GetValueInput(node, 0), |
| 487 "value0", value0_matcher_, listener) && | 488 "value0", value0_matcher_, listener) && |
| 488 PrintMatchAndExplain(NodeProperties::GetValueInput(node, 1), | 489 PrintMatchAndExplain(NodeProperties::GetValueInput(node, 1), |
| 489 "value1", value1_matcher_, listener) && | 490 "value1", value1_matcher_, listener) && |
| 490 PrintMatchAndExplain(NodeProperties::GetControlInput(node), | 491 PrintMatchAndExplain(NodeProperties::GetControlInput(node), |
| 491 "control", control_matcher_, listener)); | 492 "control", control_matcher_, listener)); |
| 492 } | 493 } |
| 493 | 494 |
| 494 private: | 495 private: |
| 495 const Matcher<MachineType> type_matcher_; | 496 const Matcher<MachineRepresentation> type_matcher_; |
| 496 const Matcher<Node*> value0_matcher_; | 497 const Matcher<Node*> value0_matcher_; |
| 497 const Matcher<Node*> value1_matcher_; | 498 const Matcher<Node*> value1_matcher_; |
| 498 const Matcher<Node*> control_matcher_; | 499 const Matcher<Node*> control_matcher_; |
| 499 }; | 500 }; |
| 500 | 501 |
| 501 | 502 |
| 502 class IsPhi2Matcher final : public NodeMatcher { | 503 class IsPhi2Matcher final : public NodeMatcher { |
| 503 public: | 504 public: |
| 504 IsPhi2Matcher(const Matcher<MachineType>& type_matcher, | 505 IsPhi2Matcher(const Matcher<MachineRepresentation>& type_matcher, |
| 505 const Matcher<Node*>& value0_matcher, | 506 const Matcher<Node*>& value0_matcher, |
| 506 const Matcher<Node*>& value1_matcher, | 507 const Matcher<Node*>& value1_matcher, |
| 507 const Matcher<Node*>& value2_matcher, | 508 const Matcher<Node*>& value2_matcher, |
| 508 const Matcher<Node*>& control_matcher) | 509 const Matcher<Node*>& control_matcher) |
| 509 : NodeMatcher(IrOpcode::kPhi), | 510 : NodeMatcher(IrOpcode::kPhi), |
| 510 type_matcher_(type_matcher), | 511 type_matcher_(type_matcher), |
| 511 value0_matcher_(value0_matcher), | 512 value0_matcher_(value0_matcher), |
| 512 value1_matcher_(value1_matcher), | 513 value1_matcher_(value1_matcher), |
| 513 value2_matcher_(value2_matcher), | 514 value2_matcher_(value2_matcher), |
| 514 control_matcher_(control_matcher) {} | 515 control_matcher_(control_matcher) {} |
| 515 | 516 |
| 516 void DescribeTo(std::ostream* os) const final { | 517 void DescribeTo(std::ostream* os) const final { |
| 517 NodeMatcher::DescribeTo(os); | 518 NodeMatcher::DescribeTo(os); |
| 518 *os << " whose type ("; | 519 *os << " whose representation ("; |
| 519 type_matcher_.DescribeTo(os); | 520 type_matcher_.DescribeTo(os); |
| 520 *os << "), value0 ("; | 521 *os << "), value0 ("; |
| 521 value0_matcher_.DescribeTo(os); | 522 value0_matcher_.DescribeTo(os); |
| 522 *os << "), value1 ("; | 523 *os << "), value1 ("; |
| 523 value1_matcher_.DescribeTo(os); | 524 value1_matcher_.DescribeTo(os); |
| 524 *os << "), value2 ("; | 525 *os << "), value2 ("; |
| 525 value2_matcher_.DescribeTo(os); | 526 value2_matcher_.DescribeTo(os); |
| 526 *os << ") and control ("; | 527 *os << ") and control ("; |
| 527 control_matcher_.DescribeTo(os); | 528 control_matcher_.DescribeTo(os); |
| 528 *os << ")"; | 529 *os << ")"; |
| 529 } | 530 } |
| 530 | 531 |
| 531 bool MatchAndExplain(Node* node, MatchResultListener* listener) const final { | 532 bool MatchAndExplain(Node* node, MatchResultListener* listener) const final { |
| 532 return (NodeMatcher::MatchAndExplain(node, listener) && | 533 return (NodeMatcher::MatchAndExplain(node, listener) && |
| 533 PrintMatchAndExplain(OpParameter<MachineType>(node), "type", | 534 PrintMatchAndExplain(PhiRepresentationOf(node->op()), |
| 534 type_matcher_, listener) && | 535 "representation", type_matcher_, listener) && |
| 535 PrintMatchAndExplain(NodeProperties::GetValueInput(node, 0), | 536 PrintMatchAndExplain(NodeProperties::GetValueInput(node, 0), |
| 536 "value0", value0_matcher_, listener) && | 537 "value0", value0_matcher_, listener) && |
| 537 PrintMatchAndExplain(NodeProperties::GetValueInput(node, 1), | 538 PrintMatchAndExplain(NodeProperties::GetValueInput(node, 1), |
| 538 "value1", value1_matcher_, listener) && | 539 "value1", value1_matcher_, listener) && |
| 539 PrintMatchAndExplain(NodeProperties::GetValueInput(node, 2), | 540 PrintMatchAndExplain(NodeProperties::GetValueInput(node, 2), |
| 540 "value2", value2_matcher_, listener) && | 541 "value2", value2_matcher_, listener) && |
| 541 PrintMatchAndExplain(NodeProperties::GetControlInput(node), | 542 PrintMatchAndExplain(NodeProperties::GetControlInput(node), |
| 542 "control", control_matcher_, listener)); | 543 "control", control_matcher_, listener)); |
| 543 } | 544 } |
| 544 | 545 |
| 545 private: | 546 private: |
| 546 const Matcher<MachineType> type_matcher_; | 547 const Matcher<MachineRepresentation> type_matcher_; |
| 547 const Matcher<Node*> value0_matcher_; | 548 const Matcher<Node*> value0_matcher_; |
| 548 const Matcher<Node*> value1_matcher_; | 549 const Matcher<Node*> value1_matcher_; |
| 549 const Matcher<Node*> value2_matcher_; | 550 const Matcher<Node*> value2_matcher_; |
| 550 const Matcher<Node*> control_matcher_; | 551 const Matcher<Node*> control_matcher_; |
| 551 }; | 552 }; |
| 552 | 553 |
| 553 | 554 |
| 554 class IsEffectPhiMatcher final : public NodeMatcher { | 555 class IsEffectPhiMatcher final : public NodeMatcher { |
| 555 public: | 556 public: |
| 556 IsEffectPhiMatcher(const Matcher<Node*>& effect0_matcher, | 557 IsEffectPhiMatcher(const Matcher<Node*>& effect0_matcher, |
| (...skipping 1030 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1587 new IsConstantMatcher<double>(IrOpcode::kFloat64Constant, value_matcher)); | 1588 new IsConstantMatcher<double>(IrOpcode::kFloat64Constant, value_matcher)); |
| 1588 } | 1589 } |
| 1589 | 1590 |
| 1590 | 1591 |
| 1591 Matcher<Node*> IsNumberConstant(const Matcher<double>& value_matcher) { | 1592 Matcher<Node*> IsNumberConstant(const Matcher<double>& value_matcher) { |
| 1592 return MakeMatcher( | 1593 return MakeMatcher( |
| 1593 new IsConstantMatcher<double>(IrOpcode::kNumberConstant, value_matcher)); | 1594 new IsConstantMatcher<double>(IrOpcode::kNumberConstant, value_matcher)); |
| 1594 } | 1595 } |
| 1595 | 1596 |
| 1596 | 1597 |
| 1597 Matcher<Node*> IsSelect(const Matcher<MachineType>& type_matcher, | 1598 Matcher<Node*> IsSelect(const Matcher<MachineRepresentation>& type_matcher, |
| 1598 const Matcher<Node*>& value0_matcher, | 1599 const Matcher<Node*>& value0_matcher, |
| 1599 const Matcher<Node*>& value1_matcher, | 1600 const Matcher<Node*>& value1_matcher, |
| 1600 const Matcher<Node*>& value2_matcher) { | 1601 const Matcher<Node*>& value2_matcher) { |
| 1601 return MakeMatcher(new IsSelectMatcher(type_matcher, value0_matcher, | 1602 return MakeMatcher(new IsSelectMatcher(type_matcher, value0_matcher, |
| 1602 value1_matcher, value2_matcher)); | 1603 value1_matcher, value2_matcher)); |
| 1603 } | 1604 } |
| 1604 | 1605 |
| 1605 | 1606 |
| 1606 Matcher<Node*> IsPhi(const Matcher<MachineType>& type_matcher, | 1607 Matcher<Node*> IsPhi(const Matcher<MachineRepresentation>& type_matcher, |
| 1607 const Matcher<Node*>& value0_matcher, | 1608 const Matcher<Node*>& value0_matcher, |
| 1608 const Matcher<Node*>& value1_matcher, | 1609 const Matcher<Node*>& value1_matcher, |
| 1609 const Matcher<Node*>& merge_matcher) { | 1610 const Matcher<Node*>& merge_matcher) { |
| 1610 return MakeMatcher(new IsPhiMatcher(type_matcher, value0_matcher, | 1611 return MakeMatcher(new IsPhiMatcher(type_matcher, value0_matcher, |
| 1611 value1_matcher, merge_matcher)); | 1612 value1_matcher, merge_matcher)); |
| 1612 } | 1613 } |
| 1613 | 1614 |
| 1614 | 1615 |
| 1615 Matcher<Node*> IsPhi(const Matcher<MachineType>& type_matcher, | 1616 Matcher<Node*> IsPhi(const Matcher<MachineRepresentation>& type_matcher, |
| 1616 const Matcher<Node*>& value0_matcher, | 1617 const Matcher<Node*>& value0_matcher, |
| 1617 const Matcher<Node*>& value1_matcher, | 1618 const Matcher<Node*>& value1_matcher, |
| 1618 const Matcher<Node*>& value2_matcher, | 1619 const Matcher<Node*>& value2_matcher, |
| 1619 const Matcher<Node*>& merge_matcher) { | 1620 const Matcher<Node*>& merge_matcher) { |
| 1620 return MakeMatcher(new IsPhi2Matcher(type_matcher, value0_matcher, | 1621 return MakeMatcher(new IsPhi2Matcher(type_matcher, value0_matcher, |
| 1621 value1_matcher, value2_matcher, | 1622 value1_matcher, value2_matcher, |
| 1622 merge_matcher)); | 1623 merge_matcher)); |
| 1623 } | 1624 } |
| 1624 | 1625 |
| 1625 | 1626 |
| (...skipping 447 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2073 IS_UNOP_MATCHER(Float64ExtractHighWord32) | 2074 IS_UNOP_MATCHER(Float64ExtractHighWord32) |
| 2074 IS_UNOP_MATCHER(NumberToInt32) | 2075 IS_UNOP_MATCHER(NumberToInt32) |
| 2075 IS_UNOP_MATCHER(NumberToUint32) | 2076 IS_UNOP_MATCHER(NumberToUint32) |
| 2076 IS_UNOP_MATCHER(ObjectIsSmi) | 2077 IS_UNOP_MATCHER(ObjectIsSmi) |
| 2077 IS_UNOP_MATCHER(Word32Clz) | 2078 IS_UNOP_MATCHER(Word32Clz) |
| 2078 #undef IS_UNOP_MATCHER | 2079 #undef IS_UNOP_MATCHER |
| 2079 | 2080 |
| 2080 } // namespace compiler | 2081 } // namespace compiler |
| 2081 } // namespace internal | 2082 } // namespace internal |
| 2082 } // namespace v8 | 2083 } // namespace v8 |
| OLD | NEW |