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/node.h" | 8 #include "src/compiler/node.h" |
9 #include "src/compiler/operator.h" | 9 #include "src/compiler/operator.h" |
10 #include "src/unique.h" | 10 #include "src/unique.h" |
(...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
143 | 143 |
144 typedef BinopMatcher<Int32Matcher, Int32Matcher> Int32BinopMatcher; | 144 typedef BinopMatcher<Int32Matcher, Int32Matcher> Int32BinopMatcher; |
145 typedef BinopMatcher<Uint32Matcher, Uint32Matcher> Uint32BinopMatcher; | 145 typedef BinopMatcher<Uint32Matcher, Uint32Matcher> Uint32BinopMatcher; |
146 typedef BinopMatcher<Int64Matcher, Int64Matcher> Int64BinopMatcher; | 146 typedef BinopMatcher<Int64Matcher, Int64Matcher> Int64BinopMatcher; |
147 typedef BinopMatcher<Uint64Matcher, Uint64Matcher> Uint64BinopMatcher; | 147 typedef BinopMatcher<Uint64Matcher, Uint64Matcher> Uint64BinopMatcher; |
148 typedef BinopMatcher<IntPtrMatcher, IntPtrMatcher> IntPtrBinopMatcher; | 148 typedef BinopMatcher<IntPtrMatcher, IntPtrMatcher> IntPtrBinopMatcher; |
149 typedef BinopMatcher<UintPtrMatcher, UintPtrMatcher> UintPtrBinopMatcher; | 149 typedef BinopMatcher<UintPtrMatcher, UintPtrMatcher> UintPtrBinopMatcher; |
150 typedef BinopMatcher<Float64Matcher, Float64Matcher> Float64BinopMatcher; | 150 typedef BinopMatcher<Float64Matcher, Float64Matcher> Float64BinopMatcher; |
151 typedef BinopMatcher<NumberMatcher, NumberMatcher> NumberBinopMatcher; | 151 typedef BinopMatcher<NumberMatcher, NumberMatcher> NumberBinopMatcher; |
152 | 152 |
153 | |
154 // Fairly intel-specify node matcher used for matching scale factors in | |
155 // addressing modes. | |
156 // Matches nodes of form [x * N] for N in {1,2,4,8} | |
157 class ScaleFactorMatcher : public NodeMatcher { | |
158 public: | |
159 static const int kMatchedFactors[4]; | |
160 | |
161 explicit ScaleFactorMatcher(Node* node); | |
162 | |
163 bool Matches() const { return left_ != NULL; } | |
164 int Power() const { | |
165 DCHECK(Matches()); | |
166 return power_; | |
167 } | |
168 Node* Left() const { | |
169 DCHECK(Matches()); | |
170 return left_; | |
171 } | |
172 | |
173 private: | |
174 Node* left_; | |
175 int power_; | |
176 }; | |
177 | |
178 | |
179 // Fairly intel-specify node matcher used for matching index and displacement | |
180 // operands in addressing modes. | |
181 // Matches nodes of form: | |
182 // [x * N] | |
183 // [x * N + K] | |
184 // [x + K] | |
185 // [x] -- fallback case | |
186 // for N in {1,2,4,8} and K int32_t | |
187 class IndexAndDisplacementMatcher : public NodeMatcher { | |
188 public: | |
189 explicit IndexAndDisplacementMatcher(Node* node); | |
190 | |
191 Node* index_node() const { return index_node_; } | |
192 int displacement() const { return displacement_; } | |
193 int power() const { return power_; } | |
194 | |
195 private: | |
196 Node* index_node_; | |
197 int displacement_; | |
198 int power_; | |
199 }; | |
200 | |
201 | |
202 // Fairly intel-specify node matcher used for matching multiplies that can be | |
203 // transformed to lea instructions. | |
204 // Matches nodes of form: | |
205 // [x * N] | |
206 // for N in {1,2,3,4,5,8,9} | |
207 class LeaMultiplyMatcher : public NodeMatcher { | |
208 public: | |
209 static const int kMatchedFactors[7]; | |
210 | |
211 explicit LeaMultiplyMatcher(Node* node); | |
212 | |
213 bool Matches() const { return left_ != NULL; } | |
214 int Power() const { | |
215 DCHECK(Matches()); | |
216 return power_; | |
217 } | |
218 Node* Left() const { | |
219 DCHECK(Matches()); | |
220 return left_; | |
221 } | |
222 // Displacement will be either 0 or 1. | |
223 int32_t Displacement() const { | |
224 DCHECK(Matches()); | |
225 return displacement_; | |
226 } | |
227 | |
228 private: | |
229 Node* left_; | |
230 int power_; | |
231 int displacement_; | |
232 }; | |
233 | |
234 | |
235 } // namespace compiler | 153 } // namespace compiler |
236 } // namespace internal | 154 } // namespace internal |
237 } // namespace v8 | 155 } // namespace v8 |
238 | 156 |
239 #endif // V8_COMPILER_NODE_MATCHERS_H_ | 157 #endif // V8_COMPILER_NODE_MATCHERS_H_ |
OLD | NEW |