11cb0ef41Sopenharmony_ci// Copyright 2014 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/compiler/opcodes.h" 61cb0ef41Sopenharmony_ci 71cb0ef41Sopenharmony_ci#include <algorithm> 81cb0ef41Sopenharmony_ci#include <ostream> 91cb0ef41Sopenharmony_ci 101cb0ef41Sopenharmony_ci#include "src/base/macros.h" 111cb0ef41Sopenharmony_ci 121cb0ef41Sopenharmony_cinamespace v8 { 131cb0ef41Sopenharmony_cinamespace internal { 141cb0ef41Sopenharmony_cinamespace compiler { 151cb0ef41Sopenharmony_ci 161cb0ef41Sopenharmony_cinamespace { 171cb0ef41Sopenharmony_ci 181cb0ef41Sopenharmony_cichar const* const kMnemonics[] = { 191cb0ef41Sopenharmony_ci#define DECLARE_MNEMONIC(x, ...) #x, 201cb0ef41Sopenharmony_ci ALL_OP_LIST(DECLARE_MNEMONIC) 211cb0ef41Sopenharmony_ci#undef DECLARE_MNEMONIC 221cb0ef41Sopenharmony_ci "UnknownOpcode"}; 231cb0ef41Sopenharmony_ci 241cb0ef41Sopenharmony_ci} // namespace 251cb0ef41Sopenharmony_ci 261cb0ef41Sopenharmony_ci 271cb0ef41Sopenharmony_ci// static 281cb0ef41Sopenharmony_cichar const* IrOpcode::Mnemonic(Value value) { 291cb0ef41Sopenharmony_ci DCHECK_LE(0, static_cast<int>(value)); 301cb0ef41Sopenharmony_ci DCHECK_LE(static_cast<int>(value), IrOpcode::Value::kLast); 311cb0ef41Sopenharmony_ci size_t const n = std::min<size_t>(value, arraysize(kMnemonics) - 1); 321cb0ef41Sopenharmony_ci return kMnemonics[n]; 331cb0ef41Sopenharmony_ci} 341cb0ef41Sopenharmony_ci 351cb0ef41Sopenharmony_ci 361cb0ef41Sopenharmony_cistd::ostream& operator<<(std::ostream& os, IrOpcode::Value opcode) { 371cb0ef41Sopenharmony_ci return os << IrOpcode::Mnemonic(opcode); 381cb0ef41Sopenharmony_ci} 391cb0ef41Sopenharmony_ci 401cb0ef41Sopenharmony_ci} // namespace compiler 411cb0ef41Sopenharmony_ci} // namespace internal 421cb0ef41Sopenharmony_ci} // namespace v8 43