| 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 #ifndef V8_COMPILER_NODE_MATCHERS_H_ | 5 #ifndef V8_COMPILER_NODE_MATCHERS_H_ |
| 6 #define V8_COMPILER_NODE_MATCHERS_H_ | 6 #define V8_COMPILER_NODE_MATCHERS_H_ |
| 7 | 7 |
| 8 #include <cmath> | 8 #include <cmath> |
| 9 | 9 |
| 10 // TODO(turbofan): Move ExternalReference out of assembler.h | 10 // TODO(turbofan): Move ExternalReference out of assembler.h |
| 11 #include "src/assembler.h" | 11 #include "src/assembler.h" |
| 12 #include "src/base/compiler-specific.h" |
| 12 #include "src/compiler/node.h" | 13 #include "src/compiler/node.h" |
| 13 #include "src/compiler/operator.h" | 14 #include "src/compiler/operator.h" |
| 14 #include "src/double.h" | 15 #include "src/double.h" |
| 16 #include "src/globals.h" |
| 15 | 17 |
| 16 namespace v8 { | 18 namespace v8 { |
| 17 namespace internal { | 19 namespace internal { |
| 18 namespace compiler { | 20 namespace compiler { |
| 19 | 21 |
| 20 // A pattern matcher for nodes. | 22 // A pattern matcher for nodes. |
| 21 struct NodeMatcher { | 23 struct NodeMatcher { |
| 22 explicit NodeMatcher(Node* node) : node_(node) {} | 24 explicit NodeMatcher(Node* node) : node_(node) {} |
| 23 | 25 |
| 24 Node* node() const { return node_; } | 26 Node* node() const { return node_; } |
| (...skipping 619 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 644 scale_ = scale; | 646 scale_ = scale; |
| 645 matches_ = true; | 647 matches_ = true; |
| 646 } | 648 } |
| 647 }; | 649 }; |
| 648 | 650 |
| 649 typedef BaseWithIndexAndDisplacementMatcher<Int32AddMatcher> | 651 typedef BaseWithIndexAndDisplacementMatcher<Int32AddMatcher> |
| 650 BaseWithIndexAndDisplacement32Matcher; | 652 BaseWithIndexAndDisplacement32Matcher; |
| 651 typedef BaseWithIndexAndDisplacementMatcher<Int64AddMatcher> | 653 typedef BaseWithIndexAndDisplacementMatcher<Int64AddMatcher> |
| 652 BaseWithIndexAndDisplacement64Matcher; | 654 BaseWithIndexAndDisplacement64Matcher; |
| 653 | 655 |
| 654 struct BranchMatcher : public NodeMatcher { | 656 struct V8_EXPORT_PRIVATE BranchMatcher : public NON_EXPORTED_BASE(NodeMatcher) { |
| 655 explicit BranchMatcher(Node* branch); | 657 explicit BranchMatcher(Node* branch); |
| 656 | 658 |
| 657 bool Matched() const { return if_true_ && if_false_; } | 659 bool Matched() const { return if_true_ && if_false_; } |
| 658 | 660 |
| 659 Node* Branch() const { return node(); } | 661 Node* Branch() const { return node(); } |
| 660 Node* IfTrue() const { return if_true_; } | 662 Node* IfTrue() const { return if_true_; } |
| 661 Node* IfFalse() const { return if_false_; } | 663 Node* IfFalse() const { return if_false_; } |
| 662 | 664 |
| 663 private: | 665 private: |
| 664 Node* if_true_; | 666 Node* if_true_; |
| 665 Node* if_false_; | 667 Node* if_false_; |
| 666 }; | 668 }; |
| 667 | 669 |
| 668 | 670 struct V8_EXPORT_PRIVATE DiamondMatcher |
| 669 struct DiamondMatcher : public NodeMatcher { | 671 : public NON_EXPORTED_BASE(NodeMatcher) { |
| 670 explicit DiamondMatcher(Node* merge); | 672 explicit DiamondMatcher(Node* merge); |
| 671 | 673 |
| 672 bool Matched() const { return branch_; } | 674 bool Matched() const { return branch_; } |
| 673 bool IfProjectionsAreOwned() const { | 675 bool IfProjectionsAreOwned() const { |
| 674 return if_true_->OwnedBy(node()) && if_false_->OwnedBy(node()); | 676 return if_true_->OwnedBy(node()) && if_false_->OwnedBy(node()); |
| 675 } | 677 } |
| 676 | 678 |
| 677 Node* Branch() const { return branch_; } | 679 Node* Branch() const { return branch_; } |
| 678 Node* IfTrue() const { return if_true_; } | 680 Node* IfTrue() const { return if_true_; } |
| 679 Node* IfFalse() const { return if_false_; } | 681 Node* IfFalse() const { return if_false_; } |
| (...skipping 17 matching lines...) Expand all Loading... |
| 697 Node* branch_; | 699 Node* branch_; |
| 698 Node* if_true_; | 700 Node* if_true_; |
| 699 Node* if_false_; | 701 Node* if_false_; |
| 700 }; | 702 }; |
| 701 | 703 |
| 702 } // namespace compiler | 704 } // namespace compiler |
| 703 } // namespace internal | 705 } // namespace internal |
| 704 } // namespace v8 | 706 } // namespace v8 |
| 705 | 707 |
| 706 #endif // V8_COMPILER_NODE_MATCHERS_H_ | 708 #endif // V8_COMPILER_NODE_MATCHERS_H_ |
| OLD | NEW |