5 #ifndef V8_INTERPRETER_BYTECODE_OPERANDS_H_ 6 #define V8_INTERPRETER_BYTECODE_OPERANDS_H_ 8 #include "src/globals.h" 12 namespace interpreter {
14 #define INVALID_OPERAND_TYPE_LIST(V) V(None, OperandTypeInfo::kNone) 16 #define REGISTER_INPUT_OPERAND_TYPE_LIST(V) \ 17 V(Reg, OperandTypeInfo::kScalableSignedByte) \ 18 V(RegList, OperandTypeInfo::kScalableSignedByte) \ 19 V(RegPair, OperandTypeInfo::kScalableSignedByte) 21 #define REGISTER_OUTPUT_OPERAND_TYPE_LIST(V) \ 22 V(RegOut, OperandTypeInfo::kScalableSignedByte) \ 23 V(RegOutList, OperandTypeInfo::kScalableSignedByte) \ 24 V(RegOutPair, OperandTypeInfo::kScalableSignedByte) \ 25 V(RegOutTriple, OperandTypeInfo::kScalableSignedByte) 27 #define SIGNED_SCALABLE_SCALAR_OPERAND_TYPE_LIST(V) \ 28 V(Imm, OperandTypeInfo::kScalableSignedByte) 30 #define UNSIGNED_SCALABLE_SCALAR_OPERAND_TYPE_LIST(V) \ 31 V(Idx, OperandTypeInfo::kScalableUnsignedByte) \ 32 V(UImm, OperandTypeInfo::kScalableUnsignedByte) \ 33 V(RegCount, OperandTypeInfo::kScalableUnsignedByte) 35 #define UNSIGNED_FIXED_SCALAR_OPERAND_TYPE_LIST(V) \ 36 V(Flag8, OperandTypeInfo::kFixedUnsignedByte) \ 37 V(IntrinsicId, OperandTypeInfo::kFixedUnsignedByte) \ 38 V(RuntimeId, OperandTypeInfo::kFixedUnsignedShort) \ 39 V(NativeContextIndex, OperandTypeInfo::kScalableUnsignedByte) 42 #define NON_REGISTER_OPERAND_TYPE_LIST(V) \ 43 INVALID_OPERAND_TYPE_LIST(V) \ 44 UNSIGNED_FIXED_SCALAR_OPERAND_TYPE_LIST(V) \ 45 UNSIGNED_SCALABLE_SCALAR_OPERAND_TYPE_LIST(V) \ 46 SIGNED_SCALABLE_SCALAR_OPERAND_TYPE_LIST(V) 49 #define REGISTER_OPERAND_TYPE_LIST(V) \ 50 REGISTER_INPUT_OPERAND_TYPE_LIST(V) \ 51 REGISTER_OUTPUT_OPERAND_TYPE_LIST(V) 55 #define OPERAND_TYPE_LIST(V) \ 56 NON_REGISTER_OPERAND_TYPE_LIST(V) \ 57 REGISTER_OPERAND_TYPE_LIST(V) 61 #define OPERAND_SCALE_LIST(V) \ 66 enum class OperandScale : uint8_t {
67 #define DECLARE_OPERAND_SCALE(Name, Scale) k##Name = Scale, 68 OPERAND_SCALE_LIST(DECLARE_OPERAND_SCALE)
69 #undef DECLARE_OPERAND_SCALE 76 enum class OperandSize : uint8_t {
86 #define OPERAND_TYPE_INFO_LIST(V) \ 87 V(None, false, false, OperandSize::kNone) \ 88 V(ScalableSignedByte, true, false, OperandSize::kByte) \ 89 V(ScalableUnsignedByte, true, true, OperandSize::kByte) \ 90 V(FixedUnsignedByte, false, true, OperandSize::kByte) \ 91 V(FixedUnsignedShort, false, true, OperandSize::kShort) 93 enum class OperandTypeInfo : uint8_t {
94 #define DECLARE_OPERAND_TYPE_INFO(Name, ...) k##Name, 95 OPERAND_TYPE_INFO_LIST(DECLARE_OPERAND_TYPE_INFO)
96 #undef DECLARE_OPERAND_TYPE_INFO 100 enum class OperandType : uint8_t {
101 #define DECLARE_OPERAND_TYPE(Name, _) k##Name, 102 OPERAND_TYPE_LIST(DECLARE_OPERAND_TYPE)
103 #undef DECLARE_OPERAND_TYPE 104 #define COUNT_OPERAND_TYPES(x, _) +1 107 kLast = -1 OPERAND_TYPE_LIST(COUNT_OPERAND_TYPES)
108 #undef COUNT_OPERAND_TYPES 111 enum class AccumulatorUse : uint8_t {
115 kReadWrite = kRead | kWrite
118 inline AccumulatorUse operator&(AccumulatorUse lhs, AccumulatorUse rhs) {
119 int result =
static_cast<int>(lhs) & static_cast<int>(rhs);
120 return static_cast<AccumulatorUse
>(result);
123 inline AccumulatorUse operator|(AccumulatorUse lhs, AccumulatorUse rhs) {
124 int result =
static_cast<int>(lhs) | static_cast<int>(rhs);
125 return static_cast<AccumulatorUse
>(result);
128 V8_EXPORT_PRIVATE std::ostream& operator<<(std::ostream& os,
129 const AccumulatorUse& use);
130 V8_EXPORT_PRIVATE std::ostream& operator<<(std::ostream& os,
131 const OperandScale& operand_scale);
132 V8_EXPORT_PRIVATE std::ostream& operator<<(std::ostream& os,
133 const OperandSize& operand_size);
134 V8_EXPORT_PRIVATE std::ostream& operator<<(std::ostream& os,
135 const OperandType& operand_type);
140 static const int kOperandTypeCount =
static_cast<int>(OperandType::kLast) + 1;
143 #define OPERAND_SCALE_COUNT(...) +1 144 static const int kOperandScaleCount =
145 0 OPERAND_SCALE_LIST(OPERAND_SCALE_COUNT);
146 #undef OPERAND_SCALE_COUNT 148 static int OperandScaleAsIndex(OperandScale operand_scale) {
149 switch (operand_scale) {
150 case OperandScale::kSingle:
152 case OperandScale::kDouble:
154 case OperandScale::kQuadruple:
162 static constexpr
bool ReadsAccumulator(AccumulatorUse accumulator_use) {
163 return accumulator_use == AccumulatorUse::kRead ||
164 accumulator_use == AccumulatorUse::kReadWrite;
168 static constexpr
bool WritesAccumulator(AccumulatorUse accumulator_use) {
169 return accumulator_use == AccumulatorUse::kWrite ||
170 accumulator_use == AccumulatorUse::kReadWrite;
174 static constexpr
bool IsScalableSignedByte(OperandType operand_type) {
175 return operand_type >= OperandType::kImm &&
176 operand_type <= OperandType::kRegOutTriple;
180 static constexpr
bool IsScalableUnsignedByte(OperandType operand_type) {
181 return operand_type >= OperandType::kIdx &&
182 operand_type <= OperandType::kRegCount;
190 #endif // V8_INTERPRETER_BYTECODE_OPERANDS_H_