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 "src/compiler/generic-node.h" | 8 #include "src/compiler/generic-node.h" |
9 #include "src/compiler/generic-node-inl.h" | 9 #include "src/compiler/generic-node-inl.h" |
10 #include "src/compiler/node.h" | 10 #include "src/compiler/node.h" |
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
73 | 73 |
74 // A pattern matcher for integer constants. | 74 // A pattern matcher for integer constants. |
75 template <typename T, IrOpcode::Value kOpcode> | 75 template <typename T, IrOpcode::Value kOpcode> |
76 struct IntMatcher FINAL : public ValueMatcher<T, kOpcode> { | 76 struct IntMatcher FINAL : public ValueMatcher<T, kOpcode> { |
77 explicit IntMatcher(Node* node) : ValueMatcher<T, kOpcode>(node) {} | 77 explicit IntMatcher(Node* node) : ValueMatcher<T, kOpcode>(node) {} |
78 | 78 |
79 bool IsPowerOf2() const { | 79 bool IsPowerOf2() const { |
80 return this->HasValue() && this->Value() > 0 && | 80 return this->HasValue() && this->Value() > 0 && |
81 (this->Value() & (this->Value() - 1)) == 0; | 81 (this->Value() & (this->Value() - 1)) == 0; |
82 } | 82 } |
| 83 bool IsNegativePowerOf2() const { |
| 84 return this->HasValue() && this->Value() < 0 && |
| 85 (-this->Value() & (-this->Value() - 1)) == 0; |
| 86 } |
83 }; | 87 }; |
84 | 88 |
85 typedef IntMatcher<int32_t, IrOpcode::kInt32Constant> Int32Matcher; | 89 typedef IntMatcher<int32_t, IrOpcode::kInt32Constant> Int32Matcher; |
86 typedef IntMatcher<uint32_t, IrOpcode::kInt32Constant> Uint32Matcher; | 90 typedef IntMatcher<uint32_t, IrOpcode::kInt32Constant> Uint32Matcher; |
87 typedef IntMatcher<int64_t, IrOpcode::kInt64Constant> Int64Matcher; | 91 typedef IntMatcher<int64_t, IrOpcode::kInt64Constant> Int64Matcher; |
88 typedef IntMatcher<uint64_t, IrOpcode::kInt64Constant> Uint64Matcher; | 92 typedef IntMatcher<uint64_t, IrOpcode::kInt64Constant> Uint64Matcher; |
89 #if V8_HOST_ARCH_32_BIT | 93 #if V8_HOST_ARCH_32_BIT |
90 typedef Int32Matcher IntPtrMatcher; | 94 typedef Int32Matcher IntPtrMatcher; |
91 typedef Uint32Matcher UintPtrMatcher; | 95 typedef Uint32Matcher UintPtrMatcher; |
92 #else | 96 #else |
(...skipping 284 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
377 }; | 381 }; |
378 | 382 |
379 typedef ScaledWithOffsetMatcher<Int32AddMatcher> ScaledWithOffset32Matcher; | 383 typedef ScaledWithOffsetMatcher<Int32AddMatcher> ScaledWithOffset32Matcher; |
380 typedef ScaledWithOffsetMatcher<Int64AddMatcher> ScaledWithOffset64Matcher; | 384 typedef ScaledWithOffsetMatcher<Int64AddMatcher> ScaledWithOffset64Matcher; |
381 | 385 |
382 } // namespace compiler | 386 } // namespace compiler |
383 } // namespace internal | 387 } // namespace internal |
384 } // namespace v8 | 388 } // namespace v8 |
385 | 389 |
386 #endif // V8_COMPILER_NODE_MATCHERS_H_ | 390 #endif // V8_COMPILER_NODE_MATCHERS_H_ |
OLD | NEW |