| OLD | NEW |
| 1 // Copyright 2016 the V8 project authors. All rights reserved. | 1 // Copyright 2016 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_OPERANDS_H_ | 5 #ifndef V8_INTERPRETER_BYTECODE_OPERANDS_H_ |
| 6 #define V8_INTERPRETER_BYTECODE_OPERANDS_H_ | 6 #define V8_INTERPRETER_BYTECODE_OPERANDS_H_ |
| 7 | 7 |
| 8 #include "src/globals.h" | 8 #include "src/globals.h" |
| 9 | 9 |
| 10 namespace v8 { | 10 namespace v8 { |
| 11 namespace internal { | 11 namespace internal { |
| 12 namespace interpreter { | 12 namespace interpreter { |
| 13 | 13 |
| 14 #define INVALID_OPERAND_TYPE_LIST(V) V(None, OperandTypeInfo::kNone) | 14 #define INVALID_OPERAND_TYPE_LIST(V) V(None, OperandTypeInfo::kNone) |
| 15 | 15 |
| 16 #define REGISTER_INPUT_OPERAND_TYPE_LIST(V) \ | 16 #define REGISTER_INPUT_OPERAND_TYPE_LIST(V) \ |
| 17 V(Reg, OperandTypeInfo::kScalableSignedByte) \ | 17 V(Reg, OperandTypeInfo::kScalableSignedByte) \ |
| 18 V(RegList, OperandTypeInfo::kScalableSignedByte) \ | 18 V(RegList, OperandTypeInfo::kScalableSignedByte) \ |
| 19 V(RegPair, OperandTypeInfo::kScalableSignedByte) | 19 V(RegPair, OperandTypeInfo::kScalableSignedByte) |
| 20 | 20 |
| 21 #define REGISTER_OUTPUT_OPERAND_TYPE_LIST(V) \ | 21 #define REGISTER_OUTPUT_OPERAND_TYPE_LIST(V) \ |
| 22 V(RegOut, OperandTypeInfo::kScalableSignedByte) \ | 22 V(RegOut, OperandTypeInfo::kScalableSignedByte) \ |
| 23 V(RegOutPair, OperandTypeInfo::kScalableSignedByte) \ | 23 V(RegOutPair, OperandTypeInfo::kScalableSignedByte) \ |
| 24 V(RegOutTriple, OperandTypeInfo::kScalableSignedByte) | 24 V(RegOutTriple, OperandTypeInfo::kScalableSignedByte) |
| 25 | 25 |
| 26 #define UNSIGNED_SCALAR_OPERAND_TYPE_LIST(V) \ | 26 #define SIGNED_SCALABLE_SCALAR_OPERAND_TYPE_LIST(V) \ |
| 27 V(Imm, OperandTypeInfo::kScalableSignedByte) |
| 28 |
| 29 #define UNSIGNED_SCALABLE_SCALAR_OPERAND_TYPE_LIST(V) \ |
| 30 V(Idx, OperandTypeInfo::kScalableUnsignedByte) \ |
| 31 V(UImm, OperandTypeInfo::kScalableUnsignedByte) \ |
| 32 V(RegCount, OperandTypeInfo::kScalableUnsignedByte) |
| 33 |
| 34 #define UNSIGNED_FIXED_SCALAR_OPERAND_TYPE_LIST(V) \ |
| 27 V(Flag8, OperandTypeInfo::kFixedUnsignedByte) \ | 35 V(Flag8, OperandTypeInfo::kFixedUnsignedByte) \ |
| 28 V(IntrinsicId, OperandTypeInfo::kFixedUnsignedByte) \ | 36 V(IntrinsicId, OperandTypeInfo::kFixedUnsignedByte) \ |
| 29 V(Idx, OperandTypeInfo::kScalableUnsignedByte) \ | |
| 30 V(UImm, OperandTypeInfo::kScalableUnsignedByte) \ | |
| 31 V(RegCount, OperandTypeInfo::kScalableUnsignedByte) \ | |
| 32 V(RuntimeId, OperandTypeInfo::kFixedUnsignedShort) | 37 V(RuntimeId, OperandTypeInfo::kFixedUnsignedShort) |
| 33 | 38 |
| 34 #define SIGNED_SCALAR_OPERAND_TYPE_LIST(V) \ | 39 // Carefully ordered for operand type range checks below. |
| 35 V(Imm, OperandTypeInfo::kScalableSignedByte) | 40 #define NON_REGISTER_OPERAND_TYPE_LIST(V) \ |
| 41 INVALID_OPERAND_TYPE_LIST(V) \ |
| 42 UNSIGNED_FIXED_SCALAR_OPERAND_TYPE_LIST(V) \ |
| 43 UNSIGNED_SCALABLE_SCALAR_OPERAND_TYPE_LIST(V) \ |
| 44 SIGNED_SCALABLE_SCALAR_OPERAND_TYPE_LIST(V) |
| 36 | 45 |
| 46 // Carefully ordered for operand type range checks below. |
| 37 #define REGISTER_OPERAND_TYPE_LIST(V) \ | 47 #define REGISTER_OPERAND_TYPE_LIST(V) \ |
| 38 REGISTER_INPUT_OPERAND_TYPE_LIST(V) \ | 48 REGISTER_INPUT_OPERAND_TYPE_LIST(V) \ |
| 39 REGISTER_OUTPUT_OPERAND_TYPE_LIST(V) | 49 REGISTER_OUTPUT_OPERAND_TYPE_LIST(V) |
| 40 | 50 |
| 41 #define NON_REGISTER_OPERAND_TYPE_LIST(V) \ | |
| 42 INVALID_OPERAND_TYPE_LIST(V) \ | |
| 43 UNSIGNED_SCALAR_OPERAND_TYPE_LIST(V) \ | |
| 44 SIGNED_SCALAR_OPERAND_TYPE_LIST(V) | |
| 45 | |
| 46 // The list of operand types used by bytecodes. | 51 // The list of operand types used by bytecodes. |
| 52 // Carefully ordered for operand type range checks below. |
| 47 #define OPERAND_TYPE_LIST(V) \ | 53 #define OPERAND_TYPE_LIST(V) \ |
| 48 NON_REGISTER_OPERAND_TYPE_LIST(V) \ | 54 NON_REGISTER_OPERAND_TYPE_LIST(V) \ |
| 49 REGISTER_OPERAND_TYPE_LIST(V) | 55 REGISTER_OPERAND_TYPE_LIST(V) |
| 50 | 56 |
| 51 // Enumeration of scaling factors applicable to scalable operands. Code | 57 // Enumeration of scaling factors applicable to scalable operands. Code |
| 52 // relies on being able to cast values to integer scaling values. | 58 // relies on being able to cast values to integer scaling values. |
| 53 #define OPERAND_SCALE_LIST(V) \ | 59 #define OPERAND_SCALE_LIST(V) \ |
| 54 V(Single, 1) \ | 60 V(Single, 1) \ |
| 55 V(Double, 2) \ | 61 V(Double, 2) \ |
| 56 V(Quadruple, 4) | 62 V(Quadruple, 4) |
| (...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 118 } | 124 } |
| 119 | 125 |
| 120 V8_EXPORT_PRIVATE std::ostream& operator<<(std::ostream& os, | 126 V8_EXPORT_PRIVATE std::ostream& operator<<(std::ostream& os, |
| 121 const AccumulatorUse& use); | 127 const AccumulatorUse& use); |
| 122 V8_EXPORT_PRIVATE std::ostream& operator<<(std::ostream& os, | 128 V8_EXPORT_PRIVATE std::ostream& operator<<(std::ostream& os, |
| 123 const OperandScale& operand_scale); | 129 const OperandScale& operand_scale); |
| 124 V8_EXPORT_PRIVATE std::ostream& operator<<(std::ostream& os, | 130 V8_EXPORT_PRIVATE std::ostream& operator<<(std::ostream& os, |
| 125 const OperandSize& operand_size); | 131 const OperandSize& operand_size); |
| 126 std::ostream& operator<<(std::ostream& os, const OperandType& operand_type); | 132 std::ostream& operator<<(std::ostream& os, const OperandType& operand_type); |
| 127 | 133 |
| 134 class BytecodeOperands { |
| 135 public: |
| 136 // Returns true if |accumulator_use| reads the accumulator. |
| 137 static constexpr bool ReadsAccumulator(AccumulatorUse accumulator_use) { |
| 138 return accumulator_use == AccumulatorUse::kRead || |
| 139 accumulator_use == AccumulatorUse::kReadWrite; |
| 140 } |
| 141 |
| 142 // Returns true if |accumulator_use| writes the accumulator. |
| 143 static constexpr bool WritesAccumulator(AccumulatorUse accumulator_use) { |
| 144 return accumulator_use == AccumulatorUse::kWrite || |
| 145 accumulator_use == AccumulatorUse::kReadWrite; |
| 146 } |
| 147 |
| 148 // Returns true if |operand_type| is a scalable signed byte. |
| 149 static constexpr bool IsScalableSignedByte(OperandType operand_type) { |
| 150 return operand_type >= OperandType::kImm && |
| 151 operand_type <= OperandType::kRegOutTriple; |
| 152 } |
| 153 |
| 154 // Returns true if |operand_type| is a scalable unsigned byte. |
| 155 static constexpr bool IsScalableUnsignedByte(OperandType operand_type) { |
| 156 return operand_type >= OperandType::kIdx && |
| 157 operand_type <= OperandType::kRegCount; |
| 158 } |
| 159 }; |
| 160 |
| 128 } // namespace interpreter | 161 } // namespace interpreter |
| 129 } // namespace internal | 162 } // namespace internal |
| 130 } // namespace v8 | 163 } // namespace v8 |
| 131 | 164 |
| 132 #endif // V8_INTERPRETER_BYTECODE_OPERANDS_H_ | 165 #endif // V8_INTERPRETER_BYTECODE_OPERANDS_H_ |
| OLD | NEW |