• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // 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/operator.h"
6 
7 #include <limits>
8 
9 namespace v8 {
10 namespace internal {
11 namespace compiler {
12 
13 namespace {
14 
15 template <typename N>
CheckRange(size_t val)16 V8_INLINE N CheckRange(size_t val) {
17   CHECK_LE(val, std::numeric_limits<N>::max());
18   return static_cast<N>(val);
19 }
20 
21 }  // namespace
22 
23 
24 // static
25 STATIC_CONST_MEMBER_DEFINITION const size_t Operator::kMaxControlOutputCount;
26 
27 
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)28 Operator::Operator(Opcode opcode, Properties properties, const char* mnemonic,
29                    size_t value_in, size_t effect_in, size_t control_in,
30                    size_t value_out, size_t effect_out, size_t control_out)
31     : opcode_(opcode),
32       properties_(properties),
33       mnemonic_(mnemonic),
34       value_in_(CheckRange<uint32_t>(value_in)),
35       effect_in_(CheckRange<uint16_t>(effect_in)),
36       control_in_(CheckRange<uint16_t>(control_in)),
37       value_out_(CheckRange<uint16_t>(value_out)),
38       effect_out_(CheckRange<uint8_t>(effect_out)),
39       control_out_(CheckRange<uint16_t>(control_out)) {}
40 
41 
operator <<(std::ostream & os,const Operator & op)42 std::ostream& operator<<(std::ostream& os, const Operator& op) {
43   op.PrintTo(os);
44   return os;
45 }
46 
47 
PrintTo(std::ostream & os) const48 void Operator::PrintTo(std::ostream& os) const { os << mnemonic(); }
49 
50 }  // namespace compiler
51 }  // namespace internal
52 }  // namespace v8
53