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> | |
9 | |
10 #include "src/compiler/generic-node.h" | 8 #include "src/compiler/generic-node.h" |
11 #include "src/compiler/generic-node-inl.h" | 9 #include "src/compiler/generic-node-inl.h" |
12 #include "src/compiler/node.h" | 10 #include "src/compiler/node.h" |
13 #include "src/compiler/operator.h" | 11 #include "src/compiler/operator.h" |
14 #include "src/unique.h" | 12 #include "src/unique.h" |
15 | 13 |
16 namespace v8 { | 14 namespace v8 { |
17 namespace internal { | 15 namespace internal { |
18 namespace compiler { | 16 namespace compiler { |
19 | 17 |
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
99 typedef Int64Matcher IntPtrMatcher; | 97 typedef Int64Matcher IntPtrMatcher; |
100 typedef Uint64Matcher UintPtrMatcher; | 98 typedef Uint64Matcher UintPtrMatcher; |
101 #endif | 99 #endif |
102 | 100 |
103 | 101 |
104 // A pattern matcher for floating point constants. | 102 // A pattern matcher for floating point constants. |
105 template <typename T, IrOpcode::Value kOpcode> | 103 template <typename T, IrOpcode::Value kOpcode> |
106 struct FloatMatcher FINAL : public ValueMatcher<T, kOpcode> { | 104 struct FloatMatcher FINAL : public ValueMatcher<T, kOpcode> { |
107 explicit FloatMatcher(Node* node) : ValueMatcher<T, kOpcode>(node) {} | 105 explicit FloatMatcher(Node* node) : ValueMatcher<T, kOpcode>(node) {} |
108 | 106 |
109 bool IsMinusZero() const { return this->Is(0.0) && signbit(this->Value()); } | |
110 bool IsNaN() const { return this->HasValue() && std::isnan(this->Value()); } | 107 bool IsNaN() const { return this->HasValue() && std::isnan(this->Value()); } |
111 }; | 108 }; |
112 | 109 |
113 typedef FloatMatcher<float, IrOpcode::kFloat32Constant> Float32Matcher; | 110 typedef FloatMatcher<float, IrOpcode::kFloat32Constant> Float32Matcher; |
114 typedef FloatMatcher<double, IrOpcode::kFloat64Constant> Float64Matcher; | 111 typedef FloatMatcher<double, IrOpcode::kFloat64Constant> Float64Matcher; |
115 typedef FloatMatcher<double, IrOpcode::kNumberConstant> NumberMatcher; | 112 typedef FloatMatcher<double, IrOpcode::kNumberConstant> NumberMatcher; |
116 | 113 |
117 | 114 |
118 // A pattern matcher for heap object constants. | 115 // A pattern matcher for heap object constants. |
119 template <typename T> | 116 template <typename T> |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
163 | 160 |
164 typedef BinopMatcher<Int32Matcher, Int32Matcher> Int32BinopMatcher; | 161 typedef BinopMatcher<Int32Matcher, Int32Matcher> Int32BinopMatcher; |
165 typedef BinopMatcher<Uint32Matcher, Uint32Matcher> Uint32BinopMatcher; | 162 typedef BinopMatcher<Uint32Matcher, Uint32Matcher> Uint32BinopMatcher; |
166 typedef BinopMatcher<Int64Matcher, Int64Matcher> Int64BinopMatcher; | 163 typedef BinopMatcher<Int64Matcher, Int64Matcher> Int64BinopMatcher; |
167 typedef BinopMatcher<Uint64Matcher, Uint64Matcher> Uint64BinopMatcher; | 164 typedef BinopMatcher<Uint64Matcher, Uint64Matcher> Uint64BinopMatcher; |
168 typedef BinopMatcher<IntPtrMatcher, IntPtrMatcher> IntPtrBinopMatcher; | 165 typedef BinopMatcher<IntPtrMatcher, IntPtrMatcher> IntPtrBinopMatcher; |
169 typedef BinopMatcher<UintPtrMatcher, UintPtrMatcher> UintPtrBinopMatcher; | 166 typedef BinopMatcher<UintPtrMatcher, UintPtrMatcher> UintPtrBinopMatcher; |
170 typedef BinopMatcher<Float64Matcher, Float64Matcher> Float64BinopMatcher; | 167 typedef BinopMatcher<Float64Matcher, Float64Matcher> Float64BinopMatcher; |
171 typedef BinopMatcher<NumberMatcher, NumberMatcher> NumberBinopMatcher; | 168 typedef BinopMatcher<NumberMatcher, NumberMatcher> NumberBinopMatcher; |
172 | 169 |
173 | |
174 template <class BinopMatcher, IrOpcode::Value kAddOpcode, | 170 template <class BinopMatcher, IrOpcode::Value kAddOpcode, |
175 IrOpcode::Value kMulOpcode, IrOpcode::Value kShiftOpcode> | 171 IrOpcode::Value kMulOpcode, IrOpcode::Value kShiftOpcode> |
176 struct AddMatcher : public BinopMatcher { | 172 struct AddMatcher : public BinopMatcher { |
177 static const IrOpcode::Value kOpcode = kAddOpcode; | 173 static const IrOpcode::Value kOpcode = kAddOpcode; |
178 | 174 |
179 explicit AddMatcher(Node* node) : BinopMatcher(node), scale_exponent_(-1) { | 175 explicit AddMatcher(Node* node) : BinopMatcher(node), scale_exponent_(-1) { |
180 if (this->HasProperty(Operator::kCommutative)) PutScaledInputOnLeft(); | 176 if (this->HasProperty(Operator::kCommutative)) PutScaledInputOnLeft(); |
181 } | 177 } |
182 | 178 |
183 bool HasScaledInput() const { return scale_exponent_ != -1; } | 179 bool HasScaledInput() const { return scale_exponent_ != -1; } |
(...skipping 203 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
387 }; | 383 }; |
388 | 384 |
389 typedef ScaledWithOffsetMatcher<Int32AddMatcher> ScaledWithOffset32Matcher; | 385 typedef ScaledWithOffsetMatcher<Int32AddMatcher> ScaledWithOffset32Matcher; |
390 typedef ScaledWithOffsetMatcher<Int64AddMatcher> ScaledWithOffset64Matcher; | 386 typedef ScaledWithOffsetMatcher<Int64AddMatcher> ScaledWithOffset64Matcher; |
391 | 387 |
392 } // namespace compiler | 388 } // namespace compiler |
393 } // namespace internal | 389 } // namespace internal |
394 } // namespace v8 | 390 } // namespace v8 |
395 | 391 |
396 #endif // V8_COMPILER_NODE_MATCHERS_H_ | 392 #endif // V8_COMPILER_NODE_MATCHERS_H_ |
OLD | NEW |