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 |
(...skipping 12 matching lines...) Expand all Loading... |
23 | 23 |
24 Node* node() const { return node_; } | 24 Node* node() const { return node_; } |
25 const Operator* op() const { return node()->op(); } | 25 const Operator* op() const { return node()->op(); } |
26 IrOpcode::Value opcode() const { return node()->opcode(); } | 26 IrOpcode::Value opcode() const { return node()->opcode(); } |
27 | 27 |
28 bool HasProperty(Operator::Property property) const { | 28 bool HasProperty(Operator::Property property) const { |
29 return op()->HasProperty(property); | 29 return op()->HasProperty(property); |
30 } | 30 } |
31 Node* InputAt(int index) const { return node()->InputAt(index); } | 31 Node* InputAt(int index) const { return node()->InputAt(index); } |
32 | 32 |
| 33 bool Equals(const Node* node) const { return node_ == node; } |
| 34 |
33 bool IsComparison() const; | 35 bool IsComparison() const; |
34 | 36 |
35 #define DEFINE_IS_OPCODE(Opcode) \ | 37 #define DEFINE_IS_OPCODE(Opcode) \ |
36 bool Is##Opcode() const { return opcode() == IrOpcode::k##Opcode; } | 38 bool Is##Opcode() const { return opcode() == IrOpcode::k##Opcode; } |
37 ALL_OP_LIST(DEFINE_IS_OPCODE) | 39 ALL_OP_LIST(DEFINE_IS_OPCODE) |
38 #undef DEFINE_IS_OPCODE | 40 #undef DEFINE_IS_OPCODE |
39 | 41 |
40 private: | 42 private: |
41 Node* node_; | 43 Node* node_; |
42 }; | 44 }; |
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
134 | 136 |
135 // A pattern matcher for floating point constants. | 137 // A pattern matcher for floating point constants. |
136 template <typename T, IrOpcode::Value kOpcode> | 138 template <typename T, IrOpcode::Value kOpcode> |
137 struct FloatMatcher FINAL : public ValueMatcher<T, kOpcode> { | 139 struct FloatMatcher FINAL : public ValueMatcher<T, kOpcode> { |
138 explicit FloatMatcher(Node* node) : ValueMatcher<T, kOpcode>(node) {} | 140 explicit FloatMatcher(Node* node) : ValueMatcher<T, kOpcode>(node) {} |
139 | 141 |
140 bool IsMinusZero() const { | 142 bool IsMinusZero() const { |
141 return this->Is(0.0) && std::signbit(this->Value()); | 143 return this->Is(0.0) && std::signbit(this->Value()); |
142 } | 144 } |
143 bool IsNaN() const { return this->HasValue() && std::isnan(this->Value()); } | 145 bool IsNaN() const { return this->HasValue() && std::isnan(this->Value()); } |
| 146 bool IsZero() const { return this->Is(0.0) && !std::signbit(this->Value()); } |
144 }; | 147 }; |
145 | 148 |
146 typedef FloatMatcher<float, IrOpcode::kFloat32Constant> Float32Matcher; | 149 typedef FloatMatcher<float, IrOpcode::kFloat32Constant> Float32Matcher; |
147 typedef FloatMatcher<double, IrOpcode::kFloat64Constant> Float64Matcher; | 150 typedef FloatMatcher<double, IrOpcode::kFloat64Constant> Float64Matcher; |
148 typedef FloatMatcher<double, IrOpcode::kNumberConstant> NumberMatcher; | 151 typedef FloatMatcher<double, IrOpcode::kNumberConstant> NumberMatcher; |
149 | 152 |
150 | 153 |
151 // A pattern matcher for heap object constants. | 154 // A pattern matcher for heap object constants. |
152 template <typename T> | 155 template <typename T> |
153 struct HeapObjectMatcher FINAL | 156 struct HeapObjectMatcher FINAL |
(...skipping 420 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
574 Node* branch_; | 577 Node* branch_; |
575 Node* if_true_; | 578 Node* if_true_; |
576 Node* if_false_; | 579 Node* if_false_; |
577 }; | 580 }; |
578 | 581 |
579 } // namespace compiler | 582 } // namespace compiler |
580 } // namespace internal | 583 } // namespace internal |
581 } // namespace v8 | 584 } // namespace v8 |
582 | 585 |
583 #endif // V8_COMPILER_NODE_MATCHERS_H_ | 586 #endif // V8_COMPILER_NODE_MATCHERS_H_ |
OLD | NEW |