| 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/common-operator.h" | 5 #include "src/compiler/common-operator.h" |
| 6 | 6 |
| 7 #include "src/assembler.h" | 7 #include "src/assembler.h" |
| 8 #include "src/base/lazy-instance.h" | 8 #include "src/base/lazy-instance.h" |
| 9 #include "src/compiler/linkage.h" | 9 #include "src/compiler/linkage.h" |
| 10 #include "src/unique.h" | 10 #include "src/unique.h" |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 43 return os; | 43 return os; |
| 44 } | 44 } |
| 45 | 45 |
| 46 | 46 |
| 47 BranchHint BranchHintOf(const Operator* const op) { | 47 BranchHint BranchHintOf(const Operator* const op) { |
| 48 DCHECK_EQ(IrOpcode::kBranch, op->opcode()); | 48 DCHECK_EQ(IrOpcode::kBranch, op->opcode()); |
| 49 return OpParameter<BranchHint>(op); | 49 return OpParameter<BranchHint>(op); |
| 50 } | 50 } |
| 51 | 51 |
| 52 | 52 |
| 53 bool operator==(SelectParameters const& lhs, SelectParameters const& rhs) { |
| 54 return lhs.type() == rhs.type() && lhs.hint() == rhs.hint(); |
| 55 } |
| 56 |
| 57 |
| 58 bool operator!=(SelectParameters const& lhs, SelectParameters const& rhs) { |
| 59 return !(lhs == rhs); |
| 60 } |
| 61 |
| 62 |
| 63 size_t hash_value(SelectParameters const& p) { |
| 64 return base::hash_combine(p.type(), p.hint()); |
| 65 } |
| 66 |
| 67 |
| 68 std::ostream& operator<<(std::ostream& os, SelectParameters const& p) { |
| 69 return os << p.type() << "|" << p.hint(); |
| 70 } |
| 71 |
| 72 |
| 73 SelectParameters const& SelectParametersOf(const Operator* const op) { |
| 74 DCHECK_EQ(IrOpcode::kSelect, op->opcode()); |
| 75 return OpParameter<SelectParameters>(op); |
| 76 } |
| 77 |
| 78 |
| 53 size_t hash_value(OutputFrameStateCombine const& sc) { | 79 size_t hash_value(OutputFrameStateCombine const& sc) { |
| 54 return base::hash_combine(sc.kind_, sc.parameter_); | 80 return base::hash_combine(sc.kind_, sc.parameter_); |
| 55 } | 81 } |
| 56 | 82 |
| 57 | 83 |
| 58 std::ostream& operator<<(std::ostream& os, OutputFrameStateCombine const& sc) { | 84 std::ostream& operator<<(std::ostream& os, OutputFrameStateCombine const& sc) { |
| 59 switch (sc.kind_) { | 85 switch (sc.kind_) { |
| 60 case OutputFrameStateCombine::kPushOutput: | 86 case OutputFrameStateCombine::kPushOutput: |
| 61 if (sc.parameter_ == 0) return os << "Ignore"; | 87 if (sc.parameter_ == 0) return os << "Ignore"; |
| 62 return os << "Push(" << sc.parameter_ << ")"; | 88 return os << "Push(" << sc.parameter_ << ")"; |
| (...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 212 } | 238 } |
| 213 | 239 |
| 214 | 240 |
| 215 const Operator* CommonOperatorBuilder::HeapConstant( | 241 const Operator* CommonOperatorBuilder::HeapConstant( |
| 216 const Unique<HeapObject>& value) { | 242 const Unique<HeapObject>& value) { |
| 217 return new (zone()) Operator1<Unique<HeapObject>>( | 243 return new (zone()) Operator1<Unique<HeapObject>>( |
| 218 IrOpcode::kHeapConstant, Operator::kPure, 0, 1, "HeapConstant", value); | 244 IrOpcode::kHeapConstant, Operator::kPure, 0, 1, "HeapConstant", value); |
| 219 } | 245 } |
| 220 | 246 |
| 221 | 247 |
| 248 const Operator* CommonOperatorBuilder::Select(MachineType type, |
| 249 BranchHint hint) { |
| 250 return new (zone()) |
| 251 Operator1<SelectParameters>(IrOpcode::kSelect, Operator::kPure, 3, 1, |
| 252 "Select", SelectParameters(type, hint)); |
| 253 } |
| 254 |
| 255 |
| 222 const Operator* CommonOperatorBuilder::Phi(MachineType type, int arguments) { | 256 const Operator* CommonOperatorBuilder::Phi(MachineType type, int arguments) { |
| 223 DCHECK(arguments > 0); // Disallow empty phis. | 257 DCHECK(arguments > 0); // Disallow empty phis. |
| 224 return new (zone()) Operator1<MachineType>(IrOpcode::kPhi, Operator::kPure, | 258 return new (zone()) Operator1<MachineType>(IrOpcode::kPhi, Operator::kPure, |
| 225 arguments, 1, "Phi", type); | 259 arguments, 1, "Phi", type); |
| 226 } | 260 } |
| 227 | 261 |
| 228 | 262 |
| 229 const Operator* CommonOperatorBuilder::EffectPhi(int arguments) { | 263 const Operator* CommonOperatorBuilder::EffectPhi(int arguments) { |
| 230 DCHECK(arguments > 0); // Disallow empty phis. | 264 DCHECK(arguments > 0); // Disallow empty phis. |
| 231 return new (zone()) Operator1<int>(IrOpcode::kEffectPhi, Operator::kPure, 0, | 265 return new (zone()) Operator1<int>(IrOpcode::kEffectPhi, Operator::kPure, 0, |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 284 | 318 |
| 285 | 319 |
| 286 const Operator* CommonOperatorBuilder::Projection(size_t index) { | 320 const Operator* CommonOperatorBuilder::Projection(size_t index) { |
| 287 return new (zone()) Operator1<size_t>(IrOpcode::kProjection, Operator::kPure, | 321 return new (zone()) Operator1<size_t>(IrOpcode::kProjection, Operator::kPure, |
| 288 1, 1, "Projection", index); | 322 1, 1, "Projection", index); |
| 289 } | 323 } |
| 290 | 324 |
| 291 } // namespace compiler | 325 } // namespace compiler |
| 292 } // namespace internal | 326 } // namespace internal |
| 293 } // namespace v8 | 327 } // namespace v8 |
| OLD | NEW |