summaryrefslogtreecommitdiff
path: root/deps/v8/src/compiler/operator.cc
blob: ae10348422cf3eeb71525c0e637225864e9fa52e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
// Copyright 2014 the V8 project authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#include "src/compiler/operator.h"

#include <limits>

namespace v8 {
namespace internal {
namespace compiler {

namespace {

template <typename N>
V8_INLINE N CheckRange(size_t val) {
  CHECK_LE(val, std::numeric_limits<N>::max());
  return static_cast<N>(val);
}

}  // namespace


// static
STATIC_CONST_MEMBER_DEFINITION const size_t Operator::kMaxControlOutputCount;


Operator::Operator(Opcode opcode, Properties properties, const char* mnemonic,
                   size_t value_in, size_t effect_in, size_t control_in,
                   size_t value_out, size_t effect_out, size_t control_out)
    : opcode_(opcode),
      properties_(properties),
      mnemonic_(mnemonic),
      value_in_(CheckRange<uint32_t>(value_in)),
      effect_in_(CheckRange<uint16_t>(effect_in)),
      control_in_(CheckRange<uint16_t>(control_in)),
      value_out_(CheckRange<uint16_t>(value_out)),
      effect_out_(CheckRange<uint8_t>(effect_out)),
      control_out_(CheckRange<uint16_t>(control_out)) {}


std::ostream& operator<<(std::ostream& os, const Operator& op) {
  op.PrintTo(os);
  return os;
}


void Operator::PrintTo(std::ostream& os) const { os << mnemonic(); }

}  // namespace compiler
}  // namespace internal
}  // namespace v8