blob: 2a8e01a26d90e9bfbe4460f015358e13eb2f8be8 [file] [log] [blame]
Emily Bernierd0a1eb72015-03-24 16:35:39 -04001// Copyright 2014 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/compiler/opcodes.h"
6
7#include <algorithm>
Ben Murdoch4a90d5f2016-03-22 12:00:34 +00008#include <ostream>
Emily Bernierd0a1eb72015-03-24 16:35:39 -04009
10#include "src/base/macros.h"
11
12namespace v8 {
13namespace internal {
14namespace compiler {
15
16namespace {
17
18char const* const kMnemonics[] = {
19#define DECLARE_MNEMONIC(x) #x,
20 ALL_OP_LIST(DECLARE_MNEMONIC)
21#undef DECLARE_MNEMONIC
22 "UnknownOpcode"};
23
24} // namespace
25
26
27// static
28char const* IrOpcode::Mnemonic(Value value) {
Ben Murdoch4a90d5f2016-03-22 12:00:34 +000029 size_t const n = std::min<size_t>(value, arraysize(kMnemonics) - 1);
Emily Bernierd0a1eb72015-03-24 16:35:39 -040030 return kMnemonics[n];
31}
32
Ben Murdoch4a90d5f2016-03-22 12:00:34 +000033
34std::ostream& operator<<(std::ostream& os, IrOpcode::Value opcode) {
35 return os << IrOpcode::Mnemonic(opcode);
36}
37
Emily Bernierd0a1eb72015-03-24 16:35:39 -040038} // namespace compiler
39} // namespace internal
40} // namespace v8