| 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 "src/base/flags.h" | 8 #include "src/base/flags.h" |
| 9 #include "src/ostreams.h" | 9 #include "src/ostreams.h" |
| 10 #include "src/unique.h" | 10 #include "src/unique.h" |
| (...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 103 DISALLOW_COPY_AND_ASSIGN(Operator); | 103 DISALLOW_COPY_AND_ASSIGN(Operator); |
| 104 }; | 104 }; |
| 105 | 105 |
| 106 DEFINE_OPERATORS_FOR_FLAGS(Operator::Properties) | 106 DEFINE_OPERATORS_FOR_FLAGS(Operator::Properties) |
| 107 | 107 |
| 108 OStream& operator<<(OStream& os, const Operator& op); | 108 OStream& operator<<(OStream& os, const Operator& op); |
| 109 | 109 |
| 110 // An implementation of Operator that has no static parameters. Such operators | 110 // An implementation of Operator that has no static parameters. Such operators |
| 111 // have just a name, an opcode, and a fixed number of inputs and outputs. | 111 // have just a name, an opcode, and a fixed number of inputs and outputs. |
| 112 // They can represented by singletons and shared globally. | 112 // They can represented by singletons and shared globally. |
| 113 class SimpleOperator FINAL : public Operator { | 113 class SimpleOperator : public Operator { |
| 114 public: | 114 public: |
| 115 SimpleOperator(Opcode opcode, Properties properties, int input_count, | 115 SimpleOperator(Opcode opcode, Properties properties, int input_count, |
| 116 int output_count, const char* mnemonic); | 116 int output_count, const char* mnemonic); |
| 117 ~SimpleOperator(); | 117 ~SimpleOperator(); |
| 118 | 118 |
| 119 virtual bool Equals(const Operator* that) const OVERRIDE { | 119 virtual bool Equals(const Operator* that) const FINAL { |
| 120 return opcode() == that->opcode(); | 120 return opcode() == that->opcode(); |
| 121 } | 121 } |
| 122 virtual int HashCode() const OVERRIDE { return opcode(); } | 122 virtual int HashCode() const FINAL { return opcode(); } |
| 123 virtual int InputCount() const OVERRIDE { return input_count_; } | 123 virtual int InputCount() const FINAL { return input_count_; } |
| 124 virtual int OutputCount() const OVERRIDE { return output_count_; } | 124 virtual int OutputCount() const FINAL { return output_count_; } |
| 125 | 125 |
| 126 private: | 126 private: |
| 127 virtual OStream& PrintTo(OStream& os) const OVERRIDE { // NOLINT | 127 virtual OStream& PrintTo(OStream& os) const FINAL { // NOLINT |
| 128 return os << mnemonic(); | 128 return os << mnemonic(); |
| 129 } | 129 } |
| 130 | 130 |
| 131 int input_count_; | 131 int input_count_; |
| 132 int output_count_; | 132 int output_count_; |
| 133 | 133 |
| 134 DISALLOW_COPY_AND_ASSIGN(SimpleOperator); | 134 DISALLOW_COPY_AND_ASSIGN(SimpleOperator); |
| 135 }; | 135 }; |
| 136 | 136 |
| 137 // Template specialization implements a kind of type class for dealing with the | 137 // Template specialization implements a kind of type class for dealing with the |
| (...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 253 virtual OStream& PrintTo(OStream& os) const FINAL { // NOLINT | 253 virtual OStream& PrintTo(OStream& os) const FINAL { // NOLINT |
| 254 return PrintParameter(os << mnemonic()); | 254 return PrintParameter(os << mnemonic()); |
| 255 } | 255 } |
| 256 | 256 |
| 257 private: | 257 private: |
| 258 int input_count_; | 258 int input_count_; |
| 259 int output_count_; | 259 int output_count_; |
| 260 T parameter_; | 260 T parameter_; |
| 261 }; | 261 }; |
| 262 | 262 |
| 263 // Type definitions for operators with specific types of parameters. | |
| 264 typedef Operator1<Unique<Name> > NameOperator; | |
| 265 | |
| 266 | 263 |
| 267 // Helper to extract parameters from Operator1<*> operator. | 264 // Helper to extract parameters from Operator1<*> operator. |
| 268 template <typename T> | 265 template <typename T> |
| 269 static inline const T& OpParameter(const Operator* op) { | 266 static inline const T& OpParameter(const Operator* op) { |
| 270 return reinterpret_cast<const Operator1<T>*>(op)->parameter(); | 267 return reinterpret_cast<const Operator1<T>*>(op)->parameter(); |
| 271 } | 268 } |
| 272 | 269 |
| 273 } // namespace compiler | 270 } // namespace compiler |
| 274 } // namespace internal | 271 } // namespace internal |
| 275 } // namespace v8 | 272 } // namespace v8 |
| 276 | 273 |
| 277 #endif // V8_COMPILER_OPERATOR_H_ | 274 #endif // V8_COMPILER_OPERATOR_H_ |
| OLD | NEW |