Index: src/compiler/node-matchers.h |
diff --git a/src/compiler/node-matchers.h b/src/compiler/node-matchers.h |
index 718803f314243bec661bccf0dbf99e495f16d724..3e64ddd4f7b337202cd93ceac55a1911f3a26181 100644 |
--- a/src/compiler/node-matchers.h |
+++ b/src/compiler/node-matchers.h |
@@ -96,6 +96,41 @@ typedef FloatMatcher<double, IrOpcode::kFloat64Constant> Float64Matcher; |
typedef FloatMatcher<double, IrOpcode::kNumberConstant> NumberMatcher; |
+// A pattern matcher for any numberic constant. |
+struct NumericValueMatcher : public NodeMatcher { |
+ explicit NumericValueMatcher(Node* const node) : NodeMatcher(node) { |
+ switch (opcode()) { |
+ case IrOpcode::kInt32Constant: |
+ has_value_ = true; |
+ value_ = OpParameter<int32_t>(node); |
+ break; |
+ case IrOpcode::kFloat32Constant: |
+ has_value_ = true; |
+ value_ = OpParameter<float>(node); |
+ break; |
+ case IrOpcode::kFloat64Constant: |
+ case IrOpcode::kNumberConstant: |
+ has_value_ = true; |
+ value_ = OpParameter<double>(node); |
+ break; |
+ default: |
+ has_value_ = false; |
+ break; |
+ } |
+ } |
+ |
+ bool HasValue() const { return has_value_; } |
+ double Value() const { |
+ DCHECK(HasValue()); |
+ return value_; |
+ } |
+ |
+ private: |
+ double value_; |
+ bool has_value_; |
+}; |
+ |
+ |
// A pattern matcher for heap object constants. |
template <typename T> |
struct HeapObjectMatcher FINAL |