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
3 // found in the LICENSE file.
4 
5 #include "src/interpreter/bytecode-operands.h"
6 
7 #include <iomanip>
8 
9 namespace v8 {
10 namespace internal {
11 namespace interpreter {
12 
13 namespace {
14 
ImplicitRegisterUseToString( ImplicitRegisterUse implicit_register_use)15 const char* ImplicitRegisterUseToString(
16     ImplicitRegisterUse implicit_register_use) {
17   switch (implicit_register_use) {
18     case ImplicitRegisterUse::kNone:
19       return "None";
20     case ImplicitRegisterUse::kReadAccumulator:
21       return "ReadAccumulator";
22     case ImplicitRegisterUse::kWriteAccumulator:
23       return "WriteAccumulator";
24     case ImplicitRegisterUse::kWriteShortStar:
25       return "WriteShortStar";
26     case ImplicitRegisterUse::kReadWriteAccumulator:
27       return "ReadWriteAccumulator";
28     case ImplicitRegisterUse::kReadAccumulatorWriteShortStar:
29       return "ReadAccumulatorWriteShortStar";
30   }
31   UNREACHABLE();
32 }
33 
OperandTypeToString(OperandType operand_type)34 const char* OperandTypeToString(OperandType operand_type) {
35   switch (operand_type) {
36 #define CASE(Name, _)        \
37   case OperandType::k##Name: \
38     return #Name;
39     OPERAND_TYPE_LIST(CASE)
40 #undef CASE
41   }
42   UNREACHABLE();
43 }
44 
OperandScaleToString(OperandScale operand_scale)45 const char* OperandScaleToString(OperandScale operand_scale) {
46   switch (operand_scale) {
47 #define CASE(Name, _)         \
48   case OperandScale::k##Name: \
49     return #Name;
50     OPERAND_SCALE_LIST(CASE)
51 #undef CASE
52   }
53   UNREACHABLE();
54 }
55 
OperandSizeToString(OperandSize operand_size)56 const char* OperandSizeToString(OperandSize operand_size) {
57   switch (operand_size) {
58     case OperandSize::kNone:
59       return "None";
60     case OperandSize::kByte:
61       return "Byte";
62     case OperandSize::kShort:
63       return "Short";
64     case OperandSize::kQuad:
65       return "Quad";
66   }
67   UNREACHABLE();
68 }
69 
70 }  // namespace
71 
operator <<(std::ostream& os, const ImplicitRegisterUse& use)72 std::ostream& operator<<(std::ostream& os, const ImplicitRegisterUse& use) {
73   return os << ImplicitRegisterUseToString(use);
74 }
75 
operator <<(std::ostream& os, const OperandSize& operand_size)76 std::ostream& operator<<(std::ostream& os, const OperandSize& operand_size) {
77   return os << OperandSizeToString(operand_size);
78 }
79 
operator <<(std::ostream& os, const OperandScale& operand_scale)80 std::ostream& operator<<(std::ostream& os, const OperandScale& operand_scale) {
81   return os << OperandScaleToString(operand_scale);
82 }
83 
operator <<(std::ostream& os, const OperandType& operand_type)84 std::ostream& operator<<(std::ostream& os, const OperandType& operand_type) {
85   return os << OperandTypeToString(operand_type);
86 }
87 
88 }  // namespace interpreter
89 }  // namespace internal
90 }  // namespace v8
91