Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(82)

Side by Side Diff: src/compiler/node-matchers.h

Issue 1314473007: [turbofan] Remove usage of Unique<T> from graph. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Rebased and fixed. Created 5 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « src/compiler/js-typed-lowering.cc ('k') | src/compiler/operator.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
55 value_ = OpParameter<T>(node); 55 value_ = OpParameter<T>(node);
56 } 56 }
57 } 57 }
58 58
59 bool HasValue() const { return has_value_; } 59 bool HasValue() const { return has_value_; }
60 const T& Value() const { 60 const T& Value() const {
61 DCHECK(HasValue()); 61 DCHECK(HasValue());
62 return value_; 62 return value_;
63 } 63 }
64 64
65 bool Is(const T& value) const {
66 return this->HasValue() && this->Value() == value;
67 }
68
69 bool IsInRange(const T& low, const T& high) const {
70 return this->HasValue() && low <= this->Value() && this->Value() <= high;
71 }
72
73 private: 65 private:
74 T value_; 66 T value_;
75 bool has_value_; 67 bool has_value_;
76 }; 68 };
77 69
78 70
79 template <> 71 template <>
80 inline ValueMatcher<int64_t, IrOpcode::kInt64Constant>::ValueMatcher(Node* node) 72 inline ValueMatcher<int64_t, IrOpcode::kInt64Constant>::ValueMatcher(Node* node)
81 : NodeMatcher(node), value_(), has_value_(false) { 73 : NodeMatcher(node), value_(), has_value_(false) {
82 if (opcode() == IrOpcode::kInt32Constant) { 74 if (opcode() == IrOpcode::kInt32Constant) {
(...skipping 18 matching lines...) Expand all
101 has_value_ = true; 93 has_value_ = true;
102 } 94 }
103 } 95 }
104 96
105 97
106 // A pattern matcher for integer constants. 98 // A pattern matcher for integer constants.
107 template <typename T, IrOpcode::Value kOpcode> 99 template <typename T, IrOpcode::Value kOpcode>
108 struct IntMatcher final : public ValueMatcher<T, kOpcode> { 100 struct IntMatcher final : public ValueMatcher<T, kOpcode> {
109 explicit IntMatcher(Node* node) : ValueMatcher<T, kOpcode>(node) {} 101 explicit IntMatcher(Node* node) : ValueMatcher<T, kOpcode>(node) {}
110 102
103 bool Is(const T& value) const {
104 return this->HasValue() && this->Value() == value;
105 }
106 bool IsInRange(const T& low, const T& high) const {
107 return this->HasValue() && low <= this->Value() && this->Value() <= high;
108 }
111 bool IsMultipleOf(T n) const { 109 bool IsMultipleOf(T n) const {
112 return this->HasValue() && (this->Value() % n) == 0; 110 return this->HasValue() && (this->Value() % n) == 0;
113 } 111 }
114 bool IsPowerOf2() const { 112 bool IsPowerOf2() const {
115 return this->HasValue() && this->Value() > 0 && 113 return this->HasValue() && this->Value() > 0 &&
116 (this->Value() & (this->Value() - 1)) == 0; 114 (this->Value() & (this->Value() - 1)) == 0;
117 } 115 }
118 bool IsNegativePowerOf2() const { 116 bool IsNegativePowerOf2() const {
119 return this->HasValue() && this->Value() < 0 && 117 return this->HasValue() && this->Value() < 0 &&
120 (-this->Value() & (-this->Value() - 1)) == 0; 118 (-this->Value() & (-this->Value() - 1)) == 0;
(...skipping 11 matching lines...) Expand all
132 typedef Int64Matcher IntPtrMatcher; 130 typedef Int64Matcher IntPtrMatcher;
133 typedef Uint64Matcher UintPtrMatcher; 131 typedef Uint64Matcher UintPtrMatcher;
134 #endif 132 #endif
135 133
136 134
137 // A pattern matcher for floating point constants. 135 // A pattern matcher for floating point constants.
138 template <typename T, IrOpcode::Value kOpcode> 136 template <typename T, IrOpcode::Value kOpcode>
139 struct FloatMatcher final : public ValueMatcher<T, kOpcode> { 137 struct FloatMatcher final : public ValueMatcher<T, kOpcode> {
140 explicit FloatMatcher(Node* node) : ValueMatcher<T, kOpcode>(node) {} 138 explicit FloatMatcher(Node* node) : ValueMatcher<T, kOpcode>(node) {}
141 139
140 bool Is(const T& value) const {
141 return this->HasValue() && this->Value() == value;
142 }
143 bool IsInRange(const T& low, const T& high) const {
144 return this->HasValue() && low <= this->Value() && this->Value() <= high;
145 }
142 bool IsMinusZero() const { 146 bool IsMinusZero() const {
143 return this->Is(0.0) && std::signbit(this->Value()); 147 return this->Is(0.0) && std::signbit(this->Value());
144 } 148 }
145 bool IsNaN() const { return this->HasValue() && std::isnan(this->Value()); } 149 bool IsNaN() const { return this->HasValue() && std::isnan(this->Value()); }
146 bool IsZero() const { return this->Is(0.0) && !std::signbit(this->Value()); } 150 bool IsZero() const { return this->Is(0.0) && !std::signbit(this->Value()); }
147 }; 151 };
148 152
149 typedef FloatMatcher<float, IrOpcode::kFloat32Constant> Float32Matcher; 153 typedef FloatMatcher<float, IrOpcode::kFloat32Constant> Float32Matcher;
150 typedef FloatMatcher<double, IrOpcode::kFloat64Constant> Float64Matcher; 154 typedef FloatMatcher<double, IrOpcode::kFloat64Constant> Float64Matcher;
151 typedef FloatMatcher<double, IrOpcode::kNumberConstant> NumberMatcher; 155 typedef FloatMatcher<double, IrOpcode::kNumberConstant> NumberMatcher;
152 156
153 157
154 // A pattern matcher for heap object constants. 158 // A pattern matcher for heap object constants.
155 struct HeapObjectMatcher final 159 struct HeapObjectMatcher final
156 : public ValueMatcher<Unique<HeapObject>, IrOpcode::kHeapConstant> { 160 : public ValueMatcher<Handle<HeapObject>, IrOpcode::kHeapConstant> {
157 explicit HeapObjectMatcher(Node* node) 161 explicit HeapObjectMatcher(Node* node)
158 : ValueMatcher<Unique<HeapObject>, IrOpcode::kHeapConstant>(node) {} 162 : ValueMatcher<Handle<HeapObject>, IrOpcode::kHeapConstant>(node) {}
159 }; 163 };
160 164
161 165
162 // A pattern matcher for external reference constants. 166 // A pattern matcher for external reference constants.
163 struct ExternalReferenceMatcher final 167 struct ExternalReferenceMatcher final
164 : public ValueMatcher<ExternalReference, IrOpcode::kExternalConstant> { 168 : public ValueMatcher<ExternalReference, IrOpcode::kExternalConstant> {
165 explicit ExternalReferenceMatcher(Node* node) 169 explicit ExternalReferenceMatcher(Node* node)
166 : ValueMatcher<ExternalReference, IrOpcode::kExternalConstant>(node) {} 170 : ValueMatcher<ExternalReference, IrOpcode::kExternalConstant>(node) {}
171 bool Is(const ExternalReference& value) const {
172 return this->HasValue() && this->Value() == value;
173 }
167 }; 174 };
168 175
169 176
170 // For shorter pattern matching code, this struct matches the inputs to 177 // For shorter pattern matching code, this struct matches the inputs to
171 // machine-level load operations. 178 // machine-level load operations.
172 template <typename Object> 179 template <typename Object>
173 struct LoadMatcher : public NodeMatcher { 180 struct LoadMatcher : public NodeMatcher {
174 explicit LoadMatcher(Node* node) 181 explicit LoadMatcher(Node* node)
175 : NodeMatcher(node), object_(InputAt(0)), index_(InputAt(1)) {} 182 : NodeMatcher(node), object_(InputAt(0)), index_(InputAt(1)) {}
176 183
(...skipping 413 matching lines...) Expand 10 before | Expand all | Expand 10 after
590 Node* branch_; 597 Node* branch_;
591 Node* if_true_; 598 Node* if_true_;
592 Node* if_false_; 599 Node* if_false_;
593 }; 600 };
594 601
595 } // namespace compiler 602 } // namespace compiler
596 } // namespace internal 603 } // namespace internal
597 } // namespace v8 604 } // namespace v8
598 605
599 #endif // V8_COMPILER_NODE_MATCHERS_H_ 606 #endif // V8_COMPILER_NODE_MATCHERS_H_
OLDNEW
« no previous file with comments | « src/compiler/js-typed-lowering.cc ('k') | src/compiler/operator.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698