Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 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 |
| 3 | // found in the LICENSE file. |
| 4 | |
| 5 | #ifndef V8_INTERPRETER_BYTECODE_TRAITS_H_ |
| 6 | #define V8_INTERPRETER_BYTECODE_TRAITS_H_ |
| 7 | |
| 8 | #include "src/interpreter/bytecodes.h" |
| 9 | |
| 10 | namespace v8 { |
| 11 | namespace internal { |
| 12 | namespace interpreter { |
| 13 | |
Ben Murdoch | da12d29 | 2016-06-02 14:46:10 +0100 | [diff] [blame] | 14 | template <OperandTypeInfo> |
| 15 | struct OperandTypeInfoTraits { |
| 16 | static const bool kIsScalable = false; |
| 17 | static const bool kIsUnsigned = false; |
| 18 | static const OperandSize kUnscaledSize = OperandSize::kNone; |
| 19 | }; |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 20 | |
Ben Murdoch | da12d29 | 2016-06-02 14:46:10 +0100 | [diff] [blame] | 21 | #define DECLARE_OPERAND_TYPE_INFO(Name, Scalable, Unsigned, BaseSize) \ |
| 22 | template <> \ |
| 23 | struct OperandTypeInfoTraits<OperandTypeInfo::k##Name> { \ |
| 24 | static const bool kIsScalable = Scalable; \ |
| 25 | static const bool kIsUnsigned = Unsigned; \ |
| 26 | static const OperandSize kUnscaledSize = BaseSize; \ |
| 27 | }; |
| 28 | OPERAND_TYPE_INFO_LIST(DECLARE_OPERAND_TYPE_INFO) |
| 29 | #undef DECLARE_OPERAND_TYPE_INFO |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 30 | |
| 31 | template <OperandType> |
Ben Murdoch | da12d29 | 2016-06-02 14:46:10 +0100 | [diff] [blame] | 32 | struct OperandTraits { |
Ben Murdoch | 61f157c | 2016-09-16 13:49:30 +0100 | [diff] [blame] | 33 | typedef OperandTypeInfoTraits<OperandTypeInfo::kNone> TypeInfoTraits; |
| 34 | static const OperandTypeInfo kOperandTypeInfo = OperandTypeInfo::kNone; |
Ben Murdoch | da12d29 | 2016-06-02 14:46:10 +0100 | [diff] [blame] | 35 | }; |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 36 | |
Ben Murdoch | 61f157c | 2016-09-16 13:49:30 +0100 | [diff] [blame] | 37 | #define DECLARE_OPERAND_TYPE_TRAITS(Name, InfoType) \ |
| 38 | template <> \ |
| 39 | struct OperandTraits<OperandType::k##Name> { \ |
| 40 | typedef OperandTypeInfoTraits<InfoType> TypeInfoTraits; \ |
| 41 | static const OperandTypeInfo kOperandTypeInfo = InfoType; \ |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 42 | }; |
Ben Murdoch | da12d29 | 2016-06-02 14:46:10 +0100 | [diff] [blame] | 43 | OPERAND_TYPE_LIST(DECLARE_OPERAND_TYPE_TRAITS) |
| 44 | #undef DECLARE_OPERAND_TYPE_TRAITS |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 45 | |
Ben Murdoch | c561043 | 2016-08-08 18:44:38 +0100 | [diff] [blame] | 46 | template <OperandType operand_type, OperandScale operand_scale> |
| 47 | struct OperandScaler { |
| 48 | template <bool, OperandSize, OperandScale> |
| 49 | struct Helper { |
| 50 | static const int kSize = 0; |
| 51 | }; |
| 52 | template <OperandSize size, OperandScale scale> |
| 53 | struct Helper<false, size, scale> { |
| 54 | static const int kSize = static_cast<int>(size); |
| 55 | }; |
| 56 | template <OperandSize size, OperandScale scale> |
| 57 | struct Helper<true, size, scale> { |
| 58 | static const int kSize = static_cast<int>(size) * static_cast<int>(scale); |
| 59 | }; |
| 60 | |
| 61 | static const int kSize = |
Ben Murdoch | 61f157c | 2016-09-16 13:49:30 +0100 | [diff] [blame] | 62 | Helper<OperandTraits<operand_type>::TypeInfoTraits::kIsScalable, |
| 63 | OperandTraits<operand_type>::TypeInfoTraits::kUnscaledSize, |
Ben Murdoch | c561043 | 2016-08-08 18:44:38 +0100 | [diff] [blame] | 64 | operand_scale>::kSize; |
| 65 | static const OperandSize kOperandSize = static_cast<OperandSize>(kSize); |
| 66 | }; |
| 67 | |
Ben Murdoch | 097c5b2 | 2016-05-18 11:27:45 +0100 | [diff] [blame] | 68 | template <OperandType> |
| 69 | struct RegisterOperandTraits { |
| 70 | static const int kIsRegisterOperand = 0; |
| 71 | }; |
| 72 | |
| 73 | #define DECLARE_REGISTER_OPERAND(Name, _) \ |
| 74 | template <> \ |
| 75 | struct RegisterOperandTraits<OperandType::k##Name> { \ |
| 76 | static const int kIsRegisterOperand = 1; \ |
| 77 | }; |
| 78 | REGISTER_OPERAND_TYPE_LIST(DECLARE_REGISTER_OPERAND) |
| 79 | #undef DECLARE_REGISTER_OPERAND |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 80 | |
Ben Murdoch | da12d29 | 2016-06-02 14:46:10 +0100 | [diff] [blame] | 81 | template <AccumulatorUse, OperandType...> |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 82 | struct BytecodeTraits {}; |
| 83 | |
Ben Murdoch | da12d29 | 2016-06-02 14:46:10 +0100 | [diff] [blame] | 84 | template <AccumulatorUse accumulator_use, OperandType operand_0, |
| 85 | OperandType operand_1, OperandType operand_2, OperandType operand_3> |
| 86 | struct BytecodeTraits<accumulator_use, operand_0, operand_1, operand_2, |
| 87 | operand_3> { |
Ben Murdoch | c561043 | 2016-08-08 18:44:38 +0100 | [diff] [blame] | 88 | static const OperandType* GetOperandTypes() { |
| 89 | static const OperandType operand_types[] = {operand_0, operand_1, operand_2, |
| 90 | operand_3, OperandType::kNone}; |
| 91 | return operand_types; |
| 92 | } |
| 93 | |
Ben Murdoch | 61f157c | 2016-09-16 13:49:30 +0100 | [diff] [blame] | 94 | static const OperandTypeInfo* GetOperandTypeInfos() { |
| 95 | static const OperandTypeInfo operand_type_infos[] = { |
| 96 | OperandTraits<operand_0>::kOperandTypeInfo, |
| 97 | OperandTraits<operand_1>::kOperandTypeInfo, |
| 98 | OperandTraits<operand_2>::kOperandTypeInfo, |
| 99 | OperandTraits<operand_3>::kOperandTypeInfo, OperandTypeInfo::kNone}; |
| 100 | return operand_type_infos; |
| 101 | } |
| 102 | |
| 103 | static const OperandSize* GetOperandSizes(OperandScale operand_scale) { |
Ben Murdoch | c561043 | 2016-08-08 18:44:38 +0100 | [diff] [blame] | 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 | }; \ |
Ben Murdoch | 61f157c | 2016-09-16 13:49:30 +0100 | [diff] [blame] | 113 | return kOperandSizes; \ |
Ben Murdoch | c561043 | 2016-08-08 18:44:38 +0100 | [diff] [blame] | 114 | } |
| 115 | OPERAND_SCALE_LIST(CASE) |
| 116 | #undef CASE |
| 117 | } |
| 118 | UNREACHABLE(); |
Ben Murdoch | 61f157c | 2016-09-16 13:49:30 +0100 | [diff] [blame] | 119 | return nullptr; |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 120 | } |
| 121 | |
Ben Murdoch | 097c5b2 | 2016-05-18 11:27:45 +0100 | [diff] [blame] | 122 | template <OperandType ot> |
| 123 | static inline bool HasAnyOperandsOfType() { |
| 124 | return operand_0 == ot || operand_1 == ot || operand_2 == ot || |
| 125 | operand_3 == ot; |
| 126 | } |
| 127 | |
Ben Murdoch | da12d29 | 2016-06-02 14:46:10 +0100 | [diff] [blame] | 128 | static inline bool IsScalable() { |
Ben Murdoch | 61f157c | 2016-09-16 13:49:30 +0100 | [diff] [blame] | 129 | return (OperandTraits<operand_0>::TypeInfoTraits::kIsScalable | |
| 130 | OperandTraits<operand_1>::TypeInfoTraits::kIsScalable | |
| 131 | OperandTraits<operand_2>::TypeInfoTraits::kIsScalable | |
| 132 | OperandTraits<operand_3>::TypeInfoTraits::kIsScalable); |
Ben Murdoch | da12d29 | 2016-06-02 14:46:10 +0100 | [diff] [blame] | 133 | } |
| 134 | |
| 135 | static const AccumulatorUse kAccumulatorUse = accumulator_use; |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 136 | static const int kOperandCount = 4; |
Ben Murdoch | 097c5b2 | 2016-05-18 11:27:45 +0100 | [diff] [blame] | 137 | static const int kRegisterOperandCount = |
| 138 | RegisterOperandTraits<operand_0>::kIsRegisterOperand + |
| 139 | RegisterOperandTraits<operand_1>::kIsRegisterOperand + |
| 140 | RegisterOperandTraits<operand_2>::kIsRegisterOperand + |
| 141 | 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); |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 147 | }; |
| 148 | |
Ben Murdoch | da12d29 | 2016-06-02 14:46:10 +0100 | [diff] [blame] | 149 | template <AccumulatorUse accumulator_use, OperandType operand_0, |
| 150 | OperandType operand_1, OperandType operand_2> |
| 151 | struct BytecodeTraits<accumulator_use, operand_0, operand_1, operand_2> { |
Ben Murdoch | c561043 | 2016-08-08 18:44:38 +0100 | [diff] [blame] | 152 | static const OperandType* GetOperandTypes() { |
| 153 | static const OperandType operand_types[] = {operand_0, operand_1, operand_2, |
| 154 | OperandType::kNone}; |
| 155 | return operand_types; |
| 156 | } |
| 157 | |
Ben Murdoch | 61f157c | 2016-09-16 13:49:30 +0100 | [diff] [blame] | 158 | static const OperandTypeInfo* GetOperandTypeInfos() { |
| 159 | static const OperandTypeInfo operand_type_infos[] = { |
| 160 | OperandTraits<operand_0>::kOperandTypeInfo, |
| 161 | OperandTraits<operand_1>::kOperandTypeInfo, |
| 162 | OperandTraits<operand_2>::kOperandTypeInfo, OperandTypeInfo::kNone}; |
| 163 | return operand_type_infos; |
| 164 | } |
| 165 | |
| 166 | static const OperandSize* GetOperandSizes(OperandScale operand_scale) { |
Ben Murdoch | c561043 | 2016-08-08 18:44:38 +0100 | [diff] [blame] | 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 | }; \ |
Ben Murdoch | 61f157c | 2016-09-16 13:49:30 +0100 | [diff] [blame] | 175 | return kOperandSizes; \ |
Ben Murdoch | c561043 | 2016-08-08 18:44:38 +0100 | [diff] [blame] | 176 | } |
| 177 | OPERAND_SCALE_LIST(CASE) |
| 178 | #undef CASE |
| 179 | } |
| 180 | UNREACHABLE(); |
Ben Murdoch | 61f157c | 2016-09-16 13:49:30 +0100 | [diff] [blame] | 181 | return nullptr; |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 182 | } |
| 183 | |
Ben Murdoch | 097c5b2 | 2016-05-18 11:27:45 +0100 | [diff] [blame] | 184 | template <OperandType ot> |
| 185 | static inline bool HasAnyOperandsOfType() { |
| 186 | return operand_0 == ot || operand_1 == ot || operand_2 == ot; |
| 187 | } |
| 188 | |
Ben Murdoch | da12d29 | 2016-06-02 14:46:10 +0100 | [diff] [blame] | 189 | static inline bool IsScalable() { |
Ben Murdoch | 61f157c | 2016-09-16 13:49:30 +0100 | [diff] [blame] | 190 | return (OperandTraits<operand_0>::TypeInfoTraits::kIsScalable | |
| 191 | OperandTraits<operand_1>::TypeInfoTraits::kIsScalable | |
| 192 | OperandTraits<operand_2>::TypeInfoTraits::kIsScalable); |
Ben Murdoch | da12d29 | 2016-06-02 14:46:10 +0100 | [diff] [blame] | 193 | } |
| 194 | |
| 195 | static const AccumulatorUse kAccumulatorUse = accumulator_use; |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 196 | static const int kOperandCount = 3; |
Ben Murdoch | 097c5b2 | 2016-05-18 11:27:45 +0100 | [diff] [blame] | 197 | static const int kRegisterOperandCount = |
| 198 | RegisterOperandTraits<operand_0>::kIsRegisterOperand + |
| 199 | RegisterOperandTraits<operand_1>::kIsRegisterOperand + |
| 200 | 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); |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 205 | }; |
| 206 | |
Ben Murdoch | da12d29 | 2016-06-02 14:46:10 +0100 | [diff] [blame] | 207 | template <AccumulatorUse accumulator_use, OperandType operand_0, |
| 208 | OperandType operand_1> |
| 209 | struct BytecodeTraits<accumulator_use, operand_0, operand_1> { |
Ben Murdoch | c561043 | 2016-08-08 18:44:38 +0100 | [diff] [blame] | 210 | static const OperandType* GetOperandTypes() { |
| 211 | static const OperandType operand_types[] = {operand_0, operand_1, |
| 212 | OperandType::kNone}; |
| 213 | return operand_types; |
| 214 | } |
| 215 | |
Ben Murdoch | 61f157c | 2016-09-16 13:49:30 +0100 | [diff] [blame] | 216 | static const OperandTypeInfo* GetOperandTypeInfos() { |
| 217 | static const OperandTypeInfo operand_type_infos[] = { |
| 218 | OperandTraits<operand_0>::kOperandTypeInfo, |
| 219 | OperandTraits<operand_1>::kOperandTypeInfo, OperandTypeInfo::kNone}; |
| 220 | return operand_type_infos; |
| 221 | } |
| 222 | |
| 223 | static const OperandSize* GetOperandSizes(OperandScale operand_scale) { |
Ben Murdoch | c561043 | 2016-08-08 18:44:38 +0100 | [diff] [blame] | 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 | }; \ |
Ben Murdoch | 61f157c | 2016-09-16 13:49:30 +0100 | [diff] [blame] | 231 | return kOperandSizes; \ |
Ben Murdoch | c561043 | 2016-08-08 18:44:38 +0100 | [diff] [blame] | 232 | } |
| 233 | OPERAND_SCALE_LIST(CASE) |
| 234 | #undef CASE |
| 235 | } |
| 236 | UNREACHABLE(); |
Ben Murdoch | 61f157c | 2016-09-16 13:49:30 +0100 | [diff] [blame] | 237 | return nullptr; |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 238 | } |
| 239 | |
Ben Murdoch | 097c5b2 | 2016-05-18 11:27:45 +0100 | [diff] [blame] | 240 | template <OperandType ot> |
| 241 | static inline bool HasAnyOperandsOfType() { |
| 242 | return operand_0 == ot || operand_1 == ot; |
| 243 | } |
| 244 | |
Ben Murdoch | da12d29 | 2016-06-02 14:46:10 +0100 | [diff] [blame] | 245 | static inline bool IsScalable() { |
Ben Murdoch | 61f157c | 2016-09-16 13:49:30 +0100 | [diff] [blame] | 246 | return (OperandTraits<operand_0>::TypeInfoTraits::kIsScalable | |
| 247 | OperandTraits<operand_1>::TypeInfoTraits::kIsScalable); |
Ben Murdoch | da12d29 | 2016-06-02 14:46:10 +0100 | [diff] [blame] | 248 | } |
| 249 | |
| 250 | static const AccumulatorUse kAccumulatorUse = accumulator_use; |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 251 | static const int kOperandCount = 2; |
Ben Murdoch | 097c5b2 | 2016-05-18 11:27:45 +0100 | [diff] [blame] | 252 | static const int kRegisterOperandCount = |
| 253 | RegisterOperandTraits<operand_0>::kIsRegisterOperand + |
| 254 | RegisterOperandTraits<operand_1>::kIsRegisterOperand; |
| 255 | static const int kRegisterOperandBitmap = |
| 256 | RegisterOperandTraits<operand_0>::kIsRegisterOperand + |
| 257 | (RegisterOperandTraits<operand_1>::kIsRegisterOperand << 1); |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 258 | }; |
| 259 | |
Ben Murdoch | da12d29 | 2016-06-02 14:46:10 +0100 | [diff] [blame] | 260 | template <AccumulatorUse accumulator_use, OperandType operand_0> |
| 261 | struct BytecodeTraits<accumulator_use, operand_0> { |
Ben Murdoch | c561043 | 2016-08-08 18:44:38 +0100 | [diff] [blame] | 262 | static const OperandType* GetOperandTypes() { |
| 263 | static const OperandType operand_types[] = {operand_0, OperandType::kNone}; |
| 264 | return operand_types; |
| 265 | } |
| 266 | |
Ben Murdoch | 61f157c | 2016-09-16 13:49:30 +0100 | [diff] [blame] | 267 | static const OperandTypeInfo* GetOperandTypeInfos() { |
| 268 | static const OperandTypeInfo operand_type_infos[] = { |
| 269 | OperandTraits<operand_0>::kOperandTypeInfo, OperandTypeInfo::kNone}; |
| 270 | return operand_type_infos; |
| 271 | } |
| 272 | |
| 273 | static const OperandSize* GetOperandSizes(OperandScale operand_scale) { |
Ben Murdoch | c561043 | 2016-08-08 18:44:38 +0100 | [diff] [blame] | 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 | }; \ |
Ben Murdoch | 61f157c | 2016-09-16 13:49:30 +0100 | [diff] [blame] | 280 | return kOperandSizes; \ |
Ben Murdoch | c561043 | 2016-08-08 18:44:38 +0100 | [diff] [blame] | 281 | } |
| 282 | OPERAND_SCALE_LIST(CASE) |
| 283 | #undef CASE |
| 284 | } |
| 285 | UNREACHABLE(); |
Ben Murdoch | 61f157c | 2016-09-16 13:49:30 +0100 | [diff] [blame] | 286 | return nullptr; |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 287 | } |
| 288 | |
Ben Murdoch | 097c5b2 | 2016-05-18 11:27:45 +0100 | [diff] [blame] | 289 | template <OperandType ot> |
| 290 | static inline bool HasAnyOperandsOfType() { |
| 291 | return operand_0 == ot; |
| 292 | } |
| 293 | |
Ben Murdoch | da12d29 | 2016-06-02 14:46:10 +0100 | [diff] [blame] | 294 | static inline bool IsScalable() { |
Ben Murdoch | 61f157c | 2016-09-16 13:49:30 +0100 | [diff] [blame] | 295 | return OperandTraits<operand_0>::TypeInfoTraits::kIsScalable; |
Ben Murdoch | da12d29 | 2016-06-02 14:46:10 +0100 | [diff] [blame] | 296 | } |
| 297 | |
| 298 | static const AccumulatorUse kAccumulatorUse = accumulator_use; |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 299 | static const int kOperandCount = 1; |
Ben Murdoch | 097c5b2 | 2016-05-18 11:27:45 +0100 | [diff] [blame] | 300 | static const int kRegisterOperandCount = |
| 301 | RegisterOperandTraits<operand_0>::kIsRegisterOperand; |
| 302 | static const int kRegisterOperandBitmap = |
| 303 | RegisterOperandTraits<operand_0>::kIsRegisterOperand; |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 304 | }; |
| 305 | |
Ben Murdoch | da12d29 | 2016-06-02 14:46:10 +0100 | [diff] [blame] | 306 | template <AccumulatorUse accumulator_use> |
| 307 | struct BytecodeTraits<accumulator_use> { |
Ben Murdoch | c561043 | 2016-08-08 18:44:38 +0100 | [diff] [blame] | 308 | static const OperandType* GetOperandTypes() { |
| 309 | static const OperandType operand_types[] = {OperandType::kNone}; |
| 310 | return operand_types; |
| 311 | } |
| 312 | |
Ben Murdoch | 61f157c | 2016-09-16 13:49:30 +0100 | [diff] [blame] | 313 | static const OperandTypeInfo* GetOperandTypeInfos() { |
| 314 | static const OperandTypeInfo operand_type_infos[] = { |
| 315 | OperandTypeInfo::kNone}; |
| 316 | return operand_type_infos; |
| 317 | } |
| 318 | |
| 319 | static const OperandSize* GetOperandSizes(OperandScale operand_scale) { |
| 320 | return nullptr; |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 321 | } |
| 322 | |
Ben Murdoch | 097c5b2 | 2016-05-18 11:27:45 +0100 | [diff] [blame] | 323 | template <OperandType ot> |
| 324 | static inline bool HasAnyOperandsOfType() { |
| 325 | return false; |
| 326 | } |
| 327 | |
Ben Murdoch | da12d29 | 2016-06-02 14:46:10 +0100 | [diff] [blame] | 328 | static inline bool IsScalable() { return false; } |
| 329 | |
| 330 | static const AccumulatorUse kAccumulatorUse = accumulator_use; |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 331 | static const int kOperandCount = 0; |
Ben Murdoch | 097c5b2 | 2016-05-18 11:27:45 +0100 | [diff] [blame] | 332 | static const int kRegisterOperandCount = 0; |
| 333 | static const int kRegisterOperandBitmap = 0; |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 334 | }; |
| 335 | |
Ben Murdoch | da12d29 | 2016-06-02 14:46:10 +0100 | [diff] [blame] | 336 | static OperandSize ScaledOperandSize(OperandType operand_type, |
| 337 | OperandScale operand_scale) { |
Ben Murdoch | c561043 | 2016-08-08 18:44:38 +0100 | [diff] [blame] | 338 | STATIC_ASSERT(static_cast<int>(OperandScale::kQuadruple) == 4 && |
| 339 | OperandScale::kLast == OperandScale::kQuadruple); |
| 340 | int index = static_cast<int>(operand_scale) >> 1; |
Ben Murdoch | da12d29 | 2016-06-02 14:46:10 +0100 | [diff] [blame] | 341 | switch (operand_type) { |
Ben Murdoch | c561043 | 2016-08-08 18:44:38 +0100 | [diff] [blame] | 342 | #define CASE(Name, TypeInfo) \ |
| 343 | case OperandType::k##Name: { \ |
| 344 | static const OperandSize kOperandSizes[] = { \ |
| 345 | OperandScaler<OperandType::k##Name, \ |
| 346 | OperandScale::kSingle>::kOperandSize, \ |
| 347 | OperandScaler<OperandType::k##Name, \ |
| 348 | OperandScale::kDouble>::kOperandSize, \ |
| 349 | OperandScaler<OperandType::k##Name, \ |
| 350 | OperandScale::kQuadruple>::kOperandSize}; \ |
| 351 | return kOperandSizes[index]; \ |
Ben Murdoch | da12d29 | 2016-06-02 14:46:10 +0100 | [diff] [blame] | 352 | } |
| 353 | OPERAND_TYPE_LIST(CASE) |
| 354 | #undef CASE |
| 355 | } |
| 356 | UNREACHABLE(); |
| 357 | return OperandSize::kNone; |
| 358 | } |
| 359 | |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 360 | } // namespace interpreter |
| 361 | } // namespace internal |
| 362 | } // namespace v8 |
| 363 | |
| 364 | #endif // V8_INTERPRETER_BYTECODE_TRAITS_H_ |