Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(373)

Side by Side Diff: src/compiler/operator.cc

Issue 680313003: Move input/output counts directly into Operators, simplying OperatorProperties. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: yes Created 6 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « src/compiler/operator.h ('k') | src/compiler/operator-properties-inl.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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> 7 #include <limits>
8 8
9 namespace v8 { 9 namespace v8 {
10 namespace internal { 10 namespace internal {
11 namespace compiler { 11 namespace compiler {
12 12
13 Operator::~Operator() {} 13
14 template <typename N>
15 static inline N CheckRange(size_t val) {
16 CHECK(val <= std::numeric_limits<N>::max());
17 return static_cast<N>(val);
18 }
19
20
21 Operator::Operator(Opcode opcode, Properties properties, const char* mnemonic,
22 size_t value_in, size_t effect_in, size_t control_in,
23 size_t value_out, size_t effect_out, size_t control_out)
24 : opcode_(opcode),
25 properties_(properties),
26 mnemonic_(mnemonic),
27 value_in_(CheckRange<uint32_t>(value_in)),
28 effect_in_(CheckRange<uint16_t>(effect_in)),
29 control_in_(CheckRange<uint16_t>(control_in)),
30 value_out_(CheckRange<uint16_t>(value_out)),
31 effect_out_(CheckRange<uint8_t>(effect_out)),
32 control_out_(CheckRange<uint8_t>(control_out)) {}
14 33
15 34
16 std::ostream& operator<<(std::ostream& os, const Operator& op) { 35 std::ostream& operator<<(std::ostream& os, const Operator& op) {
17 op.PrintTo(os); 36 op.PrintTo(os);
18 return os; 37 return os;
19 } 38 }
20 39
21 40
22 SimpleOperator::SimpleOperator(Opcode opcode, Properties properties, 41 void Operator::PrintTo(std::ostream& os) const { os << mnemonic(); }
23 size_t input_count, size_t output_count,
24 const char* mnemonic)
25 : Operator(opcode, properties, mnemonic),
26 input_count_(static_cast<uint8_t>(input_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 }
31
32
33 SimpleOperator::~SimpleOperator() {}
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 42
54 } // namespace compiler 43 } // namespace compiler
55 } // namespace internal 44 } // namespace internal
56 } // namespace v8 45 } // namespace v8
OLDNEW
« no previous file with comments | « src/compiler/operator.h ('k') | src/compiler/operator-properties-inl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698