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 9namespace v8 { 10namespace internal { 11namespace interpreter { 12 13namespace { 14 15const 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 34const 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 45const 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 56const 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 72std::ostream& operator<<(std::ostream& os, const ImplicitRegisterUse& use) { 73 return os << ImplicitRegisterUseToString(use); 74} 75 76std::ostream& operator<<(std::ostream& os, const OperandSize& operand_size) { 77 return os << OperandSizeToString(operand_size); 78} 79 80std::ostream& operator<<(std::ostream& os, const OperandScale& operand_scale) { 81 return os << OperandScaleToString(operand_scale); 82} 83 84std::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