OLD | NEW |
1 // Copyright 2014 the V8 project authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "src/compiler/operator.h" | 5 #include "src/compiler/operator.h" |
6 | 6 |
| 7 #include <limits> |
| 8 |
7 namespace v8 { | 9 namespace v8 { |
8 namespace internal { | 10 namespace internal { |
9 namespace compiler { | 11 namespace compiler { |
10 | 12 |
11 Operator::~Operator() {} | 13 Operator::~Operator() {} |
12 | 14 |
13 | 15 |
| 16 std::ostream& operator<<(std::ostream& os, const Operator& op) { |
| 17 op.PrintTo(os); |
| 18 return os; |
| 19 } |
| 20 |
| 21 |
14 SimpleOperator::SimpleOperator(Opcode opcode, Properties properties, | 22 SimpleOperator::SimpleOperator(Opcode opcode, Properties properties, |
15 int input_count, int output_count, | 23 size_t input_count, size_t output_count, |
16 const char* mnemonic) | 24 const char* mnemonic) |
17 : Operator(opcode, properties, mnemonic), | 25 : Operator(opcode, properties, mnemonic), |
18 input_count_(input_count), | 26 input_count_(static_cast<uint8_t>(input_count)), |
19 output_count_(output_count) {} | 27 output_count_(static_cast<uint8_t>(output_count)) { |
| 28 DCHECK(input_count <= std::numeric_limits<uint8_t>::max()); |
| 29 DCHECK(output_count <= std::numeric_limits<uint8_t>::max()); |
| 30 } |
20 | 31 |
21 | 32 |
22 SimpleOperator::~SimpleOperator() {} | 33 SimpleOperator::~SimpleOperator() {} |
23 | 34 |
| 35 |
| 36 bool SimpleOperator::Equals(const Operator* that) const { |
| 37 return opcode() == that->opcode(); |
| 38 } |
| 39 |
| 40 |
| 41 size_t SimpleOperator::HashCode() const { |
| 42 return base::hash<Opcode>()(opcode()); |
| 43 } |
| 44 |
| 45 |
| 46 int SimpleOperator::InputCount() const { return input_count_; } |
| 47 |
| 48 |
| 49 int SimpleOperator::OutputCount() const { return output_count_; } |
| 50 |
| 51 |
| 52 void SimpleOperator::PrintTo(std::ostream& os) const { os << mnemonic(); } |
| 53 |
24 } // namespace compiler | 54 } // namespace compiler |
25 } // namespace internal | 55 } // namespace internal |
26 } // namespace v8 | 56 } // namespace v8 |
OLD | NEW |