OLD | NEW |
1 // Copyright 2015 the V8 project authors. All rights reserved. | 1 // Copyright 2015 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_INTERPRETER_BYTECODE_TRAITS_H_ | 5 #ifndef V8_INTERPRETER_BYTECODE_TRAITS_H_ |
6 #define V8_INTERPRETER_BYTECODE_TRAITS_H_ | 6 #define V8_INTERPRETER_BYTECODE_TRAITS_H_ |
7 | 7 |
8 #include "src/interpreter/bytecodes.h" | 8 #include "src/interpreter/bytecodes.h" |
9 | 9 |
10 namespace v8 { | 10 namespace v8 { |
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
93 | 93 |
94 static const OperandTypeInfo* GetOperandTypeInfos() { | 94 static const OperandTypeInfo* GetOperandTypeInfos() { |
95 static const OperandTypeInfo operand_type_infos[] = { | 95 static const OperandTypeInfo operand_type_infos[] = { |
96 OperandTraits<operand_0>::kOperandTypeInfo, | 96 OperandTraits<operand_0>::kOperandTypeInfo, |
97 OperandTraits<operand_1>::kOperandTypeInfo, | 97 OperandTraits<operand_1>::kOperandTypeInfo, |
98 OperandTraits<operand_2>::kOperandTypeInfo, | 98 OperandTraits<operand_2>::kOperandTypeInfo, |
99 OperandTraits<operand_3>::kOperandTypeInfo, OperandTypeInfo::kNone}; | 99 OperandTraits<operand_3>::kOperandTypeInfo, OperandTypeInfo::kNone}; |
100 return operand_type_infos; | 100 return operand_type_infos; |
101 } | 101 } |
102 | 102 |
103 static const OperandSize* GetOperandSizes(OperandScale operand_scale) { | |
104 switch (operand_scale) { | |
105 #define CASE(Name, _) \ | |
106 case OperandScale::k##Name: { \ | |
107 static const OperandSize kOperandSizes[] = { \ | |
108 OperandScaler<operand_0, OperandScale::k##Name>::kOperandSize, \ | |
109 OperandScaler<operand_1, OperandScale::k##Name>::kOperandSize, \ | |
110 OperandScaler<operand_2, OperandScale::k##Name>::kOperandSize, \ | |
111 OperandScaler<operand_3, OperandScale::k##Name>::kOperandSize, \ | |
112 }; \ | |
113 return kOperandSizes; \ | |
114 } | |
115 OPERAND_SCALE_LIST(CASE) | |
116 #undef CASE | |
117 } | |
118 UNREACHABLE(); | |
119 return nullptr; | |
120 } | |
121 | |
122 template <OperandType ot> | 103 template <OperandType ot> |
123 static inline bool HasAnyOperandsOfType() { | 104 static inline bool HasAnyOperandsOfType() { |
124 return operand_0 == ot || operand_1 == ot || operand_2 == ot || | 105 return operand_0 == ot || operand_1 == ot || operand_2 == ot || |
125 operand_3 == ot; | 106 operand_3 == ot; |
126 } | 107 } |
127 | 108 |
128 static inline bool IsScalable() { | 109 static inline bool IsScalable() { |
129 return (OperandTraits<operand_0>::TypeInfoTraits::kIsScalable | | 110 return (OperandTraits<operand_0>::TypeInfoTraits::kIsScalable | |
130 OperandTraits<operand_1>::TypeInfoTraits::kIsScalable | | 111 OperandTraits<operand_1>::TypeInfoTraits::kIsScalable | |
131 OperandTraits<operand_2>::TypeInfoTraits::kIsScalable | | 112 OperandTraits<operand_2>::TypeInfoTraits::kIsScalable | |
132 OperandTraits<operand_3>::TypeInfoTraits::kIsScalable); | 113 OperandTraits<operand_3>::TypeInfoTraits::kIsScalable); |
133 } | 114 } |
134 | 115 |
135 static const AccumulatorUse kAccumulatorUse = accumulator_use; | 116 static const AccumulatorUse kAccumulatorUse = accumulator_use; |
136 static const int kOperandCount = 4; | 117 static const int kOperandCount = 4; |
137 static const int kRegisterOperandCount = | 118 static const int kRegisterOperandCount = |
138 RegisterOperandTraits<operand_0>::kIsRegisterOperand + | 119 RegisterOperandTraits<operand_0>::kIsRegisterOperand + |
139 RegisterOperandTraits<operand_1>::kIsRegisterOperand + | 120 RegisterOperandTraits<operand_1>::kIsRegisterOperand + |
140 RegisterOperandTraits<operand_2>::kIsRegisterOperand + | 121 RegisterOperandTraits<operand_2>::kIsRegisterOperand + |
141 RegisterOperandTraits<operand_3>::kIsRegisterOperand; | 122 RegisterOperandTraits<operand_3>::kIsRegisterOperand; |
142 static const int kRegisterOperandBitmap = | |
143 RegisterOperandTraits<operand_0>::kIsRegisterOperand + | |
144 (RegisterOperandTraits<operand_1>::kIsRegisterOperand << 1) + | |
145 (RegisterOperandTraits<operand_2>::kIsRegisterOperand << 2) + | |
146 (RegisterOperandTraits<operand_3>::kIsRegisterOperand << 3); | |
147 }; | 123 }; |
148 | 124 |
149 template <AccumulatorUse accumulator_use, OperandType operand_0, | 125 template <AccumulatorUse accumulator_use, OperandType operand_0, |
150 OperandType operand_1, OperandType operand_2> | 126 OperandType operand_1, OperandType operand_2> |
151 struct BytecodeTraits<accumulator_use, operand_0, operand_1, operand_2> { | 127 struct BytecodeTraits<accumulator_use, operand_0, operand_1, operand_2> { |
152 static const OperandType* GetOperandTypes() { | 128 static const OperandType* GetOperandTypes() { |
153 static const OperandType operand_types[] = {operand_0, operand_1, operand_2, | 129 static const OperandType operand_types[] = {operand_0, operand_1, operand_2, |
154 OperandType::kNone}; | 130 OperandType::kNone}; |
155 return operand_types; | 131 return operand_types; |
156 } | 132 } |
157 | 133 |
158 static const OperandTypeInfo* GetOperandTypeInfos() { | 134 static const OperandTypeInfo* GetOperandTypeInfos() { |
159 static const OperandTypeInfo operand_type_infos[] = { | 135 static const OperandTypeInfo operand_type_infos[] = { |
160 OperandTraits<operand_0>::kOperandTypeInfo, | 136 OperandTraits<operand_0>::kOperandTypeInfo, |
161 OperandTraits<operand_1>::kOperandTypeInfo, | 137 OperandTraits<operand_1>::kOperandTypeInfo, |
162 OperandTraits<operand_2>::kOperandTypeInfo, OperandTypeInfo::kNone}; | 138 OperandTraits<operand_2>::kOperandTypeInfo, OperandTypeInfo::kNone}; |
163 return operand_type_infos; | 139 return operand_type_infos; |
164 } | 140 } |
165 | 141 |
166 static const OperandSize* GetOperandSizes(OperandScale operand_scale) { | |
167 switch (operand_scale) { | |
168 #define CASE(Name, _) \ | |
169 case OperandScale::k##Name: { \ | |
170 static const OperandSize kOperandSizes[] = { \ | |
171 OperandScaler<operand_0, OperandScale::k##Name>::kOperandSize, \ | |
172 OperandScaler<operand_1, OperandScale::k##Name>::kOperandSize, \ | |
173 OperandScaler<operand_2, OperandScale::k##Name>::kOperandSize, \ | |
174 }; \ | |
175 return kOperandSizes; \ | |
176 } | |
177 OPERAND_SCALE_LIST(CASE) | |
178 #undef CASE | |
179 } | |
180 UNREACHABLE(); | |
181 return nullptr; | |
182 } | |
183 | |
184 template <OperandType ot> | 142 template <OperandType ot> |
185 static inline bool HasAnyOperandsOfType() { | 143 static inline bool HasAnyOperandsOfType() { |
186 return operand_0 == ot || operand_1 == ot || operand_2 == ot; | 144 return operand_0 == ot || operand_1 == ot || operand_2 == ot; |
187 } | 145 } |
188 | 146 |
189 static inline bool IsScalable() { | 147 static inline bool IsScalable() { |
190 return (OperandTraits<operand_0>::TypeInfoTraits::kIsScalable | | 148 return (OperandTraits<operand_0>::TypeInfoTraits::kIsScalable | |
191 OperandTraits<operand_1>::TypeInfoTraits::kIsScalable | | 149 OperandTraits<operand_1>::TypeInfoTraits::kIsScalable | |
192 OperandTraits<operand_2>::TypeInfoTraits::kIsScalable); | 150 OperandTraits<operand_2>::TypeInfoTraits::kIsScalable); |
193 } | 151 } |
194 | 152 |
195 static const AccumulatorUse kAccumulatorUse = accumulator_use; | 153 static const AccumulatorUse kAccumulatorUse = accumulator_use; |
196 static const int kOperandCount = 3; | 154 static const int kOperandCount = 3; |
197 static const int kRegisterOperandCount = | 155 static const int kRegisterOperandCount = |
198 RegisterOperandTraits<operand_0>::kIsRegisterOperand + | 156 RegisterOperandTraits<operand_0>::kIsRegisterOperand + |
199 RegisterOperandTraits<operand_1>::kIsRegisterOperand + | 157 RegisterOperandTraits<operand_1>::kIsRegisterOperand + |
200 RegisterOperandTraits<operand_2>::kIsRegisterOperand; | 158 RegisterOperandTraits<operand_2>::kIsRegisterOperand; |
201 static const int kRegisterOperandBitmap = | |
202 RegisterOperandTraits<operand_0>::kIsRegisterOperand + | |
203 (RegisterOperandTraits<operand_1>::kIsRegisterOperand << 1) + | |
204 (RegisterOperandTraits<operand_2>::kIsRegisterOperand << 2); | |
205 }; | 159 }; |
206 | 160 |
207 template <AccumulatorUse accumulator_use, OperandType operand_0, | 161 template <AccumulatorUse accumulator_use, OperandType operand_0, |
208 OperandType operand_1> | 162 OperandType operand_1> |
209 struct BytecodeTraits<accumulator_use, operand_0, operand_1> { | 163 struct BytecodeTraits<accumulator_use, operand_0, operand_1> { |
210 static const OperandType* GetOperandTypes() { | 164 static const OperandType* GetOperandTypes() { |
211 static const OperandType operand_types[] = {operand_0, operand_1, | 165 static const OperandType operand_types[] = {operand_0, operand_1, |
212 OperandType::kNone}; | 166 OperandType::kNone}; |
213 return operand_types; | 167 return operand_types; |
214 } | 168 } |
215 | 169 |
216 static const OperandTypeInfo* GetOperandTypeInfos() { | 170 static const OperandTypeInfo* GetOperandTypeInfos() { |
217 static const OperandTypeInfo operand_type_infos[] = { | 171 static const OperandTypeInfo operand_type_infos[] = { |
218 OperandTraits<operand_0>::kOperandTypeInfo, | 172 OperandTraits<operand_0>::kOperandTypeInfo, |
219 OperandTraits<operand_1>::kOperandTypeInfo, OperandTypeInfo::kNone}; | 173 OperandTraits<operand_1>::kOperandTypeInfo, OperandTypeInfo::kNone}; |
220 return operand_type_infos; | 174 return operand_type_infos; |
221 } | 175 } |
222 | 176 |
223 static const OperandSize* GetOperandSizes(OperandScale operand_scale) { | |
224 switch (operand_scale) { | |
225 #define CASE(Name, _) \ | |
226 case OperandScale::k##Name: { \ | |
227 static const OperandSize kOperandSizes[] = { \ | |
228 OperandScaler<operand_0, OperandScale::k##Name>::kOperandSize, \ | |
229 OperandScaler<operand_1, OperandScale::k##Name>::kOperandSize, \ | |
230 }; \ | |
231 return kOperandSizes; \ | |
232 } | |
233 OPERAND_SCALE_LIST(CASE) | |
234 #undef CASE | |
235 } | |
236 UNREACHABLE(); | |
237 return nullptr; | |
238 } | |
239 | |
240 template <OperandType ot> | 177 template <OperandType ot> |
241 static inline bool HasAnyOperandsOfType() { | 178 static inline bool HasAnyOperandsOfType() { |
242 return operand_0 == ot || operand_1 == ot; | 179 return operand_0 == ot || operand_1 == ot; |
243 } | 180 } |
244 | 181 |
245 static inline bool IsScalable() { | 182 static inline bool IsScalable() { |
246 return (OperandTraits<operand_0>::TypeInfoTraits::kIsScalable | | 183 return (OperandTraits<operand_0>::TypeInfoTraits::kIsScalable | |
247 OperandTraits<operand_1>::TypeInfoTraits::kIsScalable); | 184 OperandTraits<operand_1>::TypeInfoTraits::kIsScalable); |
248 } | 185 } |
249 | 186 |
250 static const AccumulatorUse kAccumulatorUse = accumulator_use; | 187 static const AccumulatorUse kAccumulatorUse = accumulator_use; |
251 static const int kOperandCount = 2; | 188 static const int kOperandCount = 2; |
252 static const int kRegisterOperandCount = | 189 static const int kRegisterOperandCount = |
253 RegisterOperandTraits<operand_0>::kIsRegisterOperand + | 190 RegisterOperandTraits<operand_0>::kIsRegisterOperand + |
254 RegisterOperandTraits<operand_1>::kIsRegisterOperand; | 191 RegisterOperandTraits<operand_1>::kIsRegisterOperand; |
255 static const int kRegisterOperandBitmap = | |
256 RegisterOperandTraits<operand_0>::kIsRegisterOperand + | |
257 (RegisterOperandTraits<operand_1>::kIsRegisterOperand << 1); | |
258 }; | 192 }; |
259 | 193 |
260 template <AccumulatorUse accumulator_use, OperandType operand_0> | 194 template <AccumulatorUse accumulator_use, OperandType operand_0> |
261 struct BytecodeTraits<accumulator_use, operand_0> { | 195 struct BytecodeTraits<accumulator_use, operand_0> { |
262 static const OperandType* GetOperandTypes() { | 196 static const OperandType* GetOperandTypes() { |
263 static const OperandType operand_types[] = {operand_0, OperandType::kNone}; | 197 static const OperandType operand_types[] = {operand_0, OperandType::kNone}; |
264 return operand_types; | 198 return operand_types; |
265 } | 199 } |
266 | 200 |
267 static const OperandTypeInfo* GetOperandTypeInfos() { | 201 static const OperandTypeInfo* GetOperandTypeInfos() { |
268 static const OperandTypeInfo operand_type_infos[] = { | 202 static const OperandTypeInfo operand_type_infos[] = { |
269 OperandTraits<operand_0>::kOperandTypeInfo, OperandTypeInfo::kNone}; | 203 OperandTraits<operand_0>::kOperandTypeInfo, OperandTypeInfo::kNone}; |
270 return operand_type_infos; | 204 return operand_type_infos; |
271 } | 205 } |
272 | 206 |
273 static const OperandSize* GetOperandSizes(OperandScale operand_scale) { | |
274 switch (operand_scale) { | |
275 #define CASE(Name, _) \ | |
276 case OperandScale::k##Name: { \ | |
277 static const OperandSize kOperandSizes[] = { \ | |
278 OperandScaler<operand_0, OperandScale::k##Name>::kOperandSize, \ | |
279 }; \ | |
280 return kOperandSizes; \ | |
281 } | |
282 OPERAND_SCALE_LIST(CASE) | |
283 #undef CASE | |
284 } | |
285 UNREACHABLE(); | |
286 return nullptr; | |
287 } | |
288 | |
289 template <OperandType ot> | 207 template <OperandType ot> |
290 static inline bool HasAnyOperandsOfType() { | 208 static inline bool HasAnyOperandsOfType() { |
291 return operand_0 == ot; | 209 return operand_0 == ot; |
292 } | 210 } |
293 | 211 |
294 static inline bool IsScalable() { | 212 static inline bool IsScalable() { |
295 return OperandTraits<operand_0>::TypeInfoTraits::kIsScalable; | 213 return OperandTraits<operand_0>::TypeInfoTraits::kIsScalable; |
296 } | 214 } |
297 | 215 |
298 static const AccumulatorUse kAccumulatorUse = accumulator_use; | 216 static const AccumulatorUse kAccumulatorUse = accumulator_use; |
299 static const int kOperandCount = 1; | 217 static const int kOperandCount = 1; |
300 static const int kRegisterOperandCount = | 218 static const int kRegisterOperandCount = |
301 RegisterOperandTraits<operand_0>::kIsRegisterOperand; | 219 RegisterOperandTraits<operand_0>::kIsRegisterOperand; |
302 static const int kRegisterOperandBitmap = | |
303 RegisterOperandTraits<operand_0>::kIsRegisterOperand; | |
304 }; | 220 }; |
305 | 221 |
306 template <AccumulatorUse accumulator_use> | 222 template <AccumulatorUse accumulator_use> |
307 struct BytecodeTraits<accumulator_use> { | 223 struct BytecodeTraits<accumulator_use> { |
308 static const OperandType* GetOperandTypes() { | 224 static const OperandType* GetOperandTypes() { |
309 static const OperandType operand_types[] = {OperandType::kNone}; | 225 static const OperandType operand_types[] = {OperandType::kNone}; |
310 return operand_types; | 226 return operand_types; |
311 } | 227 } |
312 | 228 |
313 static const OperandTypeInfo* GetOperandTypeInfos() { | 229 static const OperandTypeInfo* GetOperandTypeInfos() { |
314 static const OperandTypeInfo operand_type_infos[] = { | 230 static const OperandTypeInfo operand_type_infos[] = { |
315 OperandTypeInfo::kNone}; | 231 OperandTypeInfo::kNone}; |
316 return operand_type_infos; | 232 return operand_type_infos; |
317 } | 233 } |
318 | 234 |
319 static const OperandSize* GetOperandSizes(OperandScale operand_scale) { | |
320 return nullptr; | |
321 } | |
322 | |
323 template <OperandType ot> | 235 template <OperandType ot> |
324 static inline bool HasAnyOperandsOfType() { | 236 static inline bool HasAnyOperandsOfType() { |
325 return false; | 237 return false; |
326 } | 238 } |
327 | 239 |
328 static inline bool IsScalable() { return false; } | 240 static inline bool IsScalable() { return false; } |
329 | 241 |
330 static const AccumulatorUse kAccumulatorUse = accumulator_use; | 242 static const AccumulatorUse kAccumulatorUse = accumulator_use; |
331 static const int kOperandCount = 0; | 243 static const int kOperandCount = 0; |
332 static const int kRegisterOperandCount = 0; | 244 static const int kRegisterOperandCount = 0; |
333 static const int kRegisterOperandBitmap = 0; | |
334 }; | 245 }; |
335 | 246 |
336 static OperandSize ScaledOperandSize(OperandType operand_type, | 247 static OperandSize ScaledOperandSize(OperandType operand_type, |
337 OperandScale operand_scale) { | 248 OperandScale operand_scale) { |
338 STATIC_ASSERT(static_cast<int>(OperandScale::kQuadruple) == 4 && | 249 STATIC_ASSERT(static_cast<int>(OperandScale::kQuadruple) == 4 && |
339 OperandScale::kLast == OperandScale::kQuadruple); | 250 OperandScale::kLast == OperandScale::kQuadruple); |
340 int index = static_cast<int>(operand_scale) >> 1; | 251 int index = static_cast<int>(operand_scale) >> 1; |
341 switch (operand_type) { | 252 switch (operand_type) { |
342 #define CASE(Name, TypeInfo) \ | 253 #define CASE(Name, TypeInfo) \ |
343 case OperandType::k##Name: { \ | 254 case OperandType::k##Name: { \ |
(...skipping 11 matching lines...) Expand all Loading... |
355 } | 266 } |
356 UNREACHABLE(); | 267 UNREACHABLE(); |
357 return OperandSize::kNone; | 268 return OperandSize::kNone; |
358 } | 269 } |
359 | 270 |
360 } // namespace interpreter | 271 } // namespace interpreter |
361 } // namespace internal | 272 } // namespace internal |
362 } // namespace v8 | 273 } // namespace v8 |
363 | 274 |
364 #endif // V8_INTERPRETER_BYTECODE_TRAITS_H_ | 275 #endif // V8_INTERPRETER_BYTECODE_TRAITS_H_ |
OLD | NEW |