OLD | NEW |
1 // Copyright 2013 the V8 project authors. All rights reserved. | 1 // Copyright 2013 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 #ifndef V8_COMPILER_OPERATOR_H_ | 5 #ifndef V8_COMPILER_OPERATOR_H_ |
6 #define V8_COMPILER_OPERATOR_H_ | 6 #define V8_COMPILER_OPERATOR_H_ |
7 | 7 |
8 #include <ostream> // NOLINT(readability/streams) | 8 #include <ostream> // NOLINT(readability/streams) |
9 | 9 |
10 #include "src/base/flags.h" | 10 #include "src/base/flags.h" |
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
78 // should have unequal hashcodes with high probability. | 78 // should have unequal hashcodes with high probability. |
79 virtual size_t HashCode() const { return base::hash<Opcode>()(opcode()); } | 79 virtual size_t HashCode() const { return base::hash<Opcode>()(opcode()); } |
80 | 80 |
81 // Check whether this operator has the given property. | 81 // Check whether this operator has the given property. |
82 bool HasProperty(Property property) const { | 82 bool HasProperty(Property property) const { |
83 return (properties() & property) == property; | 83 return (properties() & property) == property; |
84 } | 84 } |
85 | 85 |
86 Properties properties() const { return properties_; } | 86 Properties properties() const { return properties_; } |
87 | 87 |
| 88 // TODO(bmeurer): Use bit fields below? |
| 89 static const size_t kMaxControlOutputCount = (1u << 16) - 1; |
| 90 |
88 // TODO(titzer): convert return values here to size_t. | 91 // TODO(titzer): convert return values here to size_t. |
89 int ValueInputCount() const { return value_in_; } | 92 int ValueInputCount() const { return value_in_; } |
90 int EffectInputCount() const { return effect_in_; } | 93 int EffectInputCount() const { return effect_in_; } |
91 int ControlInputCount() const { return control_in_; } | 94 int ControlInputCount() const { return control_in_; } |
92 | 95 |
93 int ValueOutputCount() const { return value_out_; } | 96 int ValueOutputCount() const { return value_out_; } |
94 int EffectOutputCount() const { return effect_out_; } | 97 int EffectOutputCount() const { return effect_out_; } |
95 int ControlOutputCount() const { return control_out_; } | 98 int ControlOutputCount() const { return control_out_; } |
96 | 99 |
97 static size_t ZeroIfPure(Properties properties) { | 100 static size_t ZeroIfPure(Properties properties) { |
98 return (properties & kPure) == kPure ? 0 : 1; | 101 return (properties & kPure) == kPure ? 0 : 1; |
99 } | 102 } |
100 | 103 |
101 // TODO(titzer): API for input and output types, for typechecking graph. | 104 // TODO(titzer): API for input and output types, for typechecking graph. |
102 protected: | 105 protected: |
103 // Print the full operator into the given stream, including any | 106 // Print the full operator into the given stream, including any |
104 // static parameters. Useful for debugging and visualizing the IR. | 107 // static parameters. Useful for debugging and visualizing the IR. |
105 virtual void PrintTo(std::ostream& os) const; | 108 virtual void PrintTo(std::ostream& os) const; |
106 friend std::ostream& operator<<(std::ostream& os, const Operator& op); | 109 friend std::ostream& operator<<(std::ostream& os, const Operator& op); |
107 | 110 |
108 private: | 111 private: |
109 Opcode opcode_; | 112 Opcode opcode_; |
110 Properties properties_; | 113 Properties properties_; |
111 const char* mnemonic_; | 114 const char* mnemonic_; |
112 uint32_t value_in_; | 115 uint32_t value_in_; |
113 uint16_t effect_in_; | 116 uint16_t effect_in_; |
114 uint16_t control_in_; | 117 uint16_t control_in_; |
115 uint16_t value_out_; | 118 uint16_t value_out_; |
116 uint8_t effect_out_; | 119 uint8_t effect_out_; |
117 uint8_t control_out_; | 120 uint16_t control_out_; |
118 | 121 |
119 DISALLOW_COPY_AND_ASSIGN(Operator); | 122 DISALLOW_COPY_AND_ASSIGN(Operator); |
120 }; | 123 }; |
121 | 124 |
122 DEFINE_OPERATORS_FOR_FLAGS(Operator::Properties) | 125 DEFINE_OPERATORS_FOR_FLAGS(Operator::Properties) |
123 | 126 |
124 std::ostream& operator<<(std::ostream& os, const Operator& op); | 127 std::ostream& operator<<(std::ostream& os, const Operator& op); |
125 | 128 |
126 | 129 |
127 // A templatized implementation of Operator that has one static parameter of | 130 // A templatized implementation of Operator that has one static parameter of |
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
187 return reinterpret_cast<const Operator1<double, base::bit_equal_to<double>, | 190 return reinterpret_cast<const Operator1<double, base::bit_equal_to<double>, |
188 base::bit_hash<double>>*>(op) | 191 base::bit_hash<double>>*>(op) |
189 ->parameter(); | 192 ->parameter(); |
190 } | 193 } |
191 | 194 |
192 } // namespace compiler | 195 } // namespace compiler |
193 } // namespace internal | 196 } // namespace internal |
194 } // namespace v8 | 197 } // namespace v8 |
195 | 198 |
196 #endif // V8_COMPILER_OPERATOR_H_ | 199 #endif // V8_COMPILER_OPERATOR_H_ |
OLD | NEW |