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
AccumulatorUseToString(AccumulatorUse accumulator_use)15 const char* AccumulatorUseToString(AccumulatorUse accumulator_use) {
16 switch (accumulator_use) {
17 case AccumulatorUse::kNone:
18 return "None";
19 case AccumulatorUse::kRead:
20 return "Read";
21 case AccumulatorUse::kWrite:
22 return "Write";
23 case AccumulatorUse::kReadWrite:
24 return "ReadWrite";
25 }
26 UNREACHABLE();
27 return "";
28 }
29
OperandTypeToString(OperandType operand_type)30 const char* OperandTypeToString(OperandType operand_type) {
31 switch (operand_type) {
32 #define CASE(Name, _) \
33 case OperandType::k##Name: \
34 return #Name;
35 OPERAND_TYPE_LIST(CASE)
36 #undef CASE
37 }
38 UNREACHABLE();
39 return "";
40 }
41
OperandScaleToString(OperandScale operand_scale)42 const char* OperandScaleToString(OperandScale operand_scale) {
43 switch (operand_scale) {
44 #define CASE(Name, _) \
45 case OperandScale::k##Name: \
46 return #Name;
47 OPERAND_SCALE_LIST(CASE)
48 #undef CASE
49 }
50 UNREACHABLE();
51 return "";
52 }
53
OperandSizeToString(OperandSize operand_size)54 const char* OperandSizeToString(OperandSize operand_size) {
55 switch (operand_size) {
56 case OperandSize::kNone:
57 return "None";
58 case OperandSize::kByte:
59 return "Byte";
60 case OperandSize::kShort:
61 return "Short";
62 case OperandSize::kQuad:
63 return "Quad";
64 }
65 UNREACHABLE();
66 return "";
67 }
68
69 } // namespace
70
operator <<(std::ostream & os,const AccumulatorUse & use)71 std::ostream& operator<<(std::ostream& os, const AccumulatorUse& use) {
72 return os << AccumulatorUseToString(use);
73 }
74
operator <<(std::ostream & os,const OperandSize & operand_size)75 std::ostream& operator<<(std::ostream& os, const OperandSize& operand_size) {
76 return os << OperandSizeToString(operand_size);
77 }
78
operator <<(std::ostream & os,const OperandScale & operand_scale)79 std::ostream& operator<<(std::ostream& os, const OperandScale& operand_scale) {
80 return os << OperandScaleToString(operand_scale);
81 }
82
operator <<(std::ostream & os,const OperandType & operand_type)83 std::ostream& operator<<(std::ostream& os, const OperandType& operand_type) {
84 return os << OperandTypeToString(operand_type);
85 }
86
87 } // namespace interpreter
88 } // namespace internal
89 } // namespace v8
90