Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 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 | |
Emily Bernier | d0a1eb7 | 2015-03-24 16:35:39 -0400 | [diff] [blame] | 7 | #include <limits> |
| 8 | |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 9 | namespace v8 { |
| 10 | namespace internal { |
| 11 | namespace compiler { |
| 12 | |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 13 | namespace { |
Emily Bernier | d0a1eb7 | 2015-03-24 16:35:39 -0400 | [diff] [blame] | 14 | |
| 15 | template <typename N> |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 16 | V8_INLINE N CheckRange(size_t val) { |
| 17 | CHECK_LE(val, std::numeric_limits<N>::max()); |
Emily Bernier | d0a1eb7 | 2015-03-24 16:35:39 -0400 | [diff] [blame] | 18 | return static_cast<N>(val); |
| 19 | } |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 20 | |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 21 | } // namespace |
| 22 | |
| 23 | |
| 24 | // static |
| 25 | STATIC_CONST_MEMBER_DEFINITION const size_t Operator::kMaxControlOutputCount; |
| 26 | |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 27 | |
Emily Bernier | d0a1eb7 | 2015-03-24 16:35:39 -0400 | [diff] [blame] | 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)), |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 39 | control_out_(CheckRange<uint16_t>(control_out)) {} |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 40 | |
| 41 | |
Emily Bernier | d0a1eb7 | 2015-03-24 16:35:39 -0400 | [diff] [blame] | 42 | std::ostream& operator<<(std::ostream& os, const Operator& op) { |
| 43 | op.PrintTo(os); |
| 44 | return os; |
| 45 | } |
| 46 | |
| 47 | |
| 48 | void Operator::PrintTo(std::ostream& os) const { os << mnemonic(); } |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 49 | |
| 50 | } // namespace compiler |
| 51 | } // namespace internal |
| 52 | } // namespace v8 |