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 123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
134 size_t value_out, size_t effect_out, size_t control_out, | 134 size_t value_out, size_t effect_out, size_t control_out, |
135 T parameter, Pred const& pred = Pred(), Hash const& hash = Hash()) | 135 T parameter, Pred const& pred = Pred(), Hash const& hash = Hash()) |
136 : Operator(opcode, properties, mnemonic, value_in, effect_in, control_in, | 136 : Operator(opcode, properties, mnemonic, value_in, effect_in, control_in, |
137 value_out, effect_out, control_out), | 137 value_out, effect_out, control_out), |
138 parameter_(parameter), | 138 parameter_(parameter), |
139 pred_(pred), | 139 pred_(pred), |
140 hash_(hash) {} | 140 hash_(hash) {} |
141 | 141 |
142 T const& parameter() const { return parameter_; } | 142 T const& parameter() const { return parameter_; } |
143 | 143 |
144 virtual bool Equals(const Operator* other) const FINAL { | 144 bool Equals(const Operator* other) const FINAL { |
145 if (opcode() != other->opcode()) return false; | 145 if (opcode() != other->opcode()) return false; |
146 const Operator1<T>* that = static_cast<const Operator1<T>*>(other); | 146 const Operator1<T>* that = static_cast<const Operator1<T>*>(other); |
147 return this->pred_(this->parameter(), that->parameter()); | 147 return this->pred_(this->parameter(), that->parameter()); |
148 } | 148 } |
149 virtual size_t HashCode() const FINAL { | 149 size_t HashCode() const FINAL { |
150 return base::hash_combine(this->opcode(), this->hash_(this->parameter())); | 150 return base::hash_combine(this->opcode(), this->hash_(this->parameter())); |
151 } | 151 } |
152 virtual void PrintParameter(std::ostream& os) const { | 152 virtual void PrintParameter(std::ostream& os) const { |
153 os << "[" << this->parameter() << "]"; | 153 os << "[" << this->parameter() << "]"; |
154 } | 154 } |
155 | 155 |
156 protected: | 156 protected: |
157 virtual void PrintTo(std::ostream& os) const FINAL { | 157 void PrintTo(std::ostream& os) const FINAL { |
158 os << mnemonic(); | 158 os << mnemonic(); |
159 PrintParameter(os); | 159 PrintParameter(os); |
160 } | 160 } |
161 | 161 |
162 private: | 162 private: |
163 T const parameter_; | 163 T const parameter_; |
164 Pred const pred_; | 164 Pred const pred_; |
165 Hash const hash_; | 165 Hash const hash_; |
166 }; | 166 }; |
167 | 167 |
168 | 168 |
169 // Helper to extract parameters from Operator1<*> operator. | 169 // Helper to extract parameters from Operator1<*> operator. |
170 template <typename T> | 170 template <typename T> |
171 inline T const& OpParameter(const Operator* op) { | 171 inline T const& OpParameter(const Operator* op) { |
172 return static_cast<const Operator1<T>*>(op)->parameter(); | 172 return static_cast<const Operator1<T>*>(op)->parameter(); |
173 } | 173 } |
174 | 174 |
175 } // namespace compiler | 175 } // namespace compiler |
176 } // namespace internal | 176 } // namespace internal |
177 } // namespace v8 | 177 } // namespace v8 |
178 | 178 |
179 #endif // V8_COMPILER_OPERATOR_H_ | 179 #endif // V8_COMPILER_OPERATOR_H_ |
OLD | NEW |