11cb0ef41Sopenharmony_ci// Copyright 2016 the V8 project authors. All rights reserved.
21cb0ef41Sopenharmony_ci// Use of this source code is governed by a BSD-style license that can be
31cb0ef41Sopenharmony_ci// found in the LICENSE file.
41cb0ef41Sopenharmony_ci
51cb0ef41Sopenharmony_ci#include "src/interpreter/bytecode-operands.h"
61cb0ef41Sopenharmony_ci
71cb0ef41Sopenharmony_ci#include <iomanip>
81cb0ef41Sopenharmony_ci
91cb0ef41Sopenharmony_cinamespace v8 {
101cb0ef41Sopenharmony_cinamespace internal {
111cb0ef41Sopenharmony_cinamespace interpreter {
121cb0ef41Sopenharmony_ci
131cb0ef41Sopenharmony_cinamespace {
141cb0ef41Sopenharmony_ci
151cb0ef41Sopenharmony_ciconst char* ImplicitRegisterUseToString(
161cb0ef41Sopenharmony_ci    ImplicitRegisterUse implicit_register_use) {
171cb0ef41Sopenharmony_ci  switch (implicit_register_use) {
181cb0ef41Sopenharmony_ci    case ImplicitRegisterUse::kNone:
191cb0ef41Sopenharmony_ci      return "None";
201cb0ef41Sopenharmony_ci    case ImplicitRegisterUse::kReadAccumulator:
211cb0ef41Sopenharmony_ci      return "ReadAccumulator";
221cb0ef41Sopenharmony_ci    case ImplicitRegisterUse::kWriteAccumulator:
231cb0ef41Sopenharmony_ci      return "WriteAccumulator";
241cb0ef41Sopenharmony_ci    case ImplicitRegisterUse::kWriteShortStar:
251cb0ef41Sopenharmony_ci      return "WriteShortStar";
261cb0ef41Sopenharmony_ci    case ImplicitRegisterUse::kReadWriteAccumulator:
271cb0ef41Sopenharmony_ci      return "ReadWriteAccumulator";
281cb0ef41Sopenharmony_ci    case ImplicitRegisterUse::kReadAccumulatorWriteShortStar:
291cb0ef41Sopenharmony_ci      return "ReadAccumulatorWriteShortStar";
301cb0ef41Sopenharmony_ci  }
311cb0ef41Sopenharmony_ci  UNREACHABLE();
321cb0ef41Sopenharmony_ci}
331cb0ef41Sopenharmony_ci
341cb0ef41Sopenharmony_ciconst char* OperandTypeToString(OperandType operand_type) {
351cb0ef41Sopenharmony_ci  switch (operand_type) {
361cb0ef41Sopenharmony_ci#define CASE(Name, _)        \
371cb0ef41Sopenharmony_ci  case OperandType::k##Name: \
381cb0ef41Sopenharmony_ci    return #Name;
391cb0ef41Sopenharmony_ci    OPERAND_TYPE_LIST(CASE)
401cb0ef41Sopenharmony_ci#undef CASE
411cb0ef41Sopenharmony_ci  }
421cb0ef41Sopenharmony_ci  UNREACHABLE();
431cb0ef41Sopenharmony_ci}
441cb0ef41Sopenharmony_ci
451cb0ef41Sopenharmony_ciconst char* OperandScaleToString(OperandScale operand_scale) {
461cb0ef41Sopenharmony_ci  switch (operand_scale) {
471cb0ef41Sopenharmony_ci#define CASE(Name, _)         \
481cb0ef41Sopenharmony_ci  case OperandScale::k##Name: \
491cb0ef41Sopenharmony_ci    return #Name;
501cb0ef41Sopenharmony_ci    OPERAND_SCALE_LIST(CASE)
511cb0ef41Sopenharmony_ci#undef CASE
521cb0ef41Sopenharmony_ci  }
531cb0ef41Sopenharmony_ci  UNREACHABLE();
541cb0ef41Sopenharmony_ci}
551cb0ef41Sopenharmony_ci
561cb0ef41Sopenharmony_ciconst char* OperandSizeToString(OperandSize operand_size) {
571cb0ef41Sopenharmony_ci  switch (operand_size) {
581cb0ef41Sopenharmony_ci    case OperandSize::kNone:
591cb0ef41Sopenharmony_ci      return "None";
601cb0ef41Sopenharmony_ci    case OperandSize::kByte:
611cb0ef41Sopenharmony_ci      return "Byte";
621cb0ef41Sopenharmony_ci    case OperandSize::kShort:
631cb0ef41Sopenharmony_ci      return "Short";
641cb0ef41Sopenharmony_ci    case OperandSize::kQuad:
651cb0ef41Sopenharmony_ci      return "Quad";
661cb0ef41Sopenharmony_ci  }
671cb0ef41Sopenharmony_ci  UNREACHABLE();
681cb0ef41Sopenharmony_ci}
691cb0ef41Sopenharmony_ci
701cb0ef41Sopenharmony_ci}  // namespace
711cb0ef41Sopenharmony_ci
721cb0ef41Sopenharmony_cistd::ostream& operator<<(std::ostream& os, const ImplicitRegisterUse& use) {
731cb0ef41Sopenharmony_ci  return os << ImplicitRegisterUseToString(use);
741cb0ef41Sopenharmony_ci}
751cb0ef41Sopenharmony_ci
761cb0ef41Sopenharmony_cistd::ostream& operator<<(std::ostream& os, const OperandSize& operand_size) {
771cb0ef41Sopenharmony_ci  return os << OperandSizeToString(operand_size);
781cb0ef41Sopenharmony_ci}
791cb0ef41Sopenharmony_ci
801cb0ef41Sopenharmony_cistd::ostream& operator<<(std::ostream& os, const OperandScale& operand_scale) {
811cb0ef41Sopenharmony_ci  return os << OperandScaleToString(operand_scale);
821cb0ef41Sopenharmony_ci}
831cb0ef41Sopenharmony_ci
841cb0ef41Sopenharmony_cistd::ostream& operator<<(std::ostream& os, const OperandType& operand_type) {
851cb0ef41Sopenharmony_ci  return os << OperandTypeToString(operand_type);
861cb0ef41Sopenharmony_ci}
871cb0ef41Sopenharmony_ci
881cb0ef41Sopenharmony_ci}  // namespace interpreter
891cb0ef41Sopenharmony_ci}  // namespace internal
901cb0ef41Sopenharmony_ci}  // namespace v8
91