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