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/machine-operator.h" | 5 #include "src/compiler/machine-operator.h" |
6 | 6 |
7 #include "src/base/lazy-instance.h" | 7 #include "src/base/lazy-instance.h" |
8 #include "src/compiler/opcodes.h" | 8 #include "src/compiler/opcodes.h" |
9 #include "src/compiler/operator.h" | 9 #include "src/compiler/operator.h" |
10 | 10 |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
62 } | 62 } |
63 | 63 |
64 | 64 |
65 std::ostream& operator<<(std::ostream& os, StoreRepresentation rep) { | 65 std::ostream& operator<<(std::ostream& os, StoreRepresentation rep) { |
66 return os << "(" << rep.representation() << " : " << rep.write_barrier_kind() | 66 return os << "(" << rep.representation() << " : " << rep.write_barrier_kind() |
67 << ")"; | 67 << ")"; |
68 } | 68 } |
69 | 69 |
70 | 70 |
71 LoadRepresentation LoadRepresentationOf(Operator const* op) { | 71 LoadRepresentation LoadRepresentationOf(Operator const* op) { |
72 DCHECK_EQ(IrOpcode::kLoad, op->opcode()); | 72 DCHECK(IrOpcode::kLoad == op->opcode() || |
| 73 IrOpcode::kAtomicLoad == op->opcode()); |
73 return OpParameter<LoadRepresentation>(op); | 74 return OpParameter<LoadRepresentation>(op); |
74 } | 75 } |
75 | 76 |
76 | 77 |
77 StoreRepresentation const& StoreRepresentationOf(Operator const* op) { | 78 StoreRepresentation const& StoreRepresentationOf(Operator const* op) { |
78 DCHECK_EQ(IrOpcode::kStore, op->opcode()); | 79 DCHECK_EQ(IrOpcode::kStore, op->opcode()); |
79 return OpParameter<StoreRepresentation>(op); | 80 return OpParameter<StoreRepresentation>(op); |
80 } | 81 } |
81 | 82 |
82 | 83 |
(...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
243 #define MACHINE_REPRESENTATION_LIST(V) \ | 244 #define MACHINE_REPRESENTATION_LIST(V) \ |
244 V(kFloat32) \ | 245 V(kFloat32) \ |
245 V(kFloat64) \ | 246 V(kFloat64) \ |
246 V(kSimd128) \ | 247 V(kSimd128) \ |
247 V(kWord8) \ | 248 V(kWord8) \ |
248 V(kWord16) \ | 249 V(kWord16) \ |
249 V(kWord32) \ | 250 V(kWord32) \ |
250 V(kWord64) \ | 251 V(kWord64) \ |
251 V(kTagged) | 252 V(kTagged) |
252 | 253 |
| 254 #define ATOMIC_TYPE_LIST(V) \ |
| 255 V(Int8) \ |
| 256 V(Uint8) \ |
| 257 V(Int16) \ |
| 258 V(Uint16) \ |
| 259 V(Int32) \ |
| 260 V(Uint32) |
| 261 |
253 struct MachineOperatorGlobalCache { | 262 struct MachineOperatorGlobalCache { |
254 #define PURE(Name, properties, value_input_count, control_input_count, \ | 263 #define PURE(Name, properties, value_input_count, control_input_count, \ |
255 output_count) \ | 264 output_count) \ |
256 struct Name##Operator final : public Operator { \ | 265 struct Name##Operator final : public Operator { \ |
257 Name##Operator() \ | 266 Name##Operator() \ |
258 : Operator(IrOpcode::k##Name, Operator::kPure | properties, #Name, \ | 267 : Operator(IrOpcode::k##Name, Operator::kPure | properties, #Name, \ |
259 value_input_count, 0, control_input_count, output_count, 0, \ | 268 value_input_count, 0, control_input_count, output_count, 0, \ |
260 0) {} \ | 269 0) {} \ |
261 }; \ | 270 }; \ |
262 Name##Operator k##Name; | 271 Name##Operator k##Name; |
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
346 } \ | 355 } \ |
347 }; \ | 356 }; \ |
348 Store##Type##NoWriteBarrier##Operator kStore##Type##NoWriteBarrier; \ | 357 Store##Type##NoWriteBarrier##Operator kStore##Type##NoWriteBarrier; \ |
349 Store##Type##MapWriteBarrier##Operator kStore##Type##MapWriteBarrier; \ | 358 Store##Type##MapWriteBarrier##Operator kStore##Type##MapWriteBarrier; \ |
350 Store##Type##PointerWriteBarrier##Operator \ | 359 Store##Type##PointerWriteBarrier##Operator \ |
351 kStore##Type##PointerWriteBarrier; \ | 360 kStore##Type##PointerWriteBarrier; \ |
352 Store##Type##FullWriteBarrier##Operator kStore##Type##FullWriteBarrier; \ | 361 Store##Type##FullWriteBarrier##Operator kStore##Type##FullWriteBarrier; \ |
353 CheckedStore##Type##Operator kCheckedStore##Type; | 362 CheckedStore##Type##Operator kCheckedStore##Type; |
354 MACHINE_REPRESENTATION_LIST(STORE) | 363 MACHINE_REPRESENTATION_LIST(STORE) |
355 #undef STORE | 364 #undef STORE |
| 365 |
| 366 #define ATOMIC(Type) \ |
| 367 struct AtomicLoad##Type##Operator final \ |
| 368 : public Operator1<LoadRepresentation> { \ |
| 369 AtomicLoad##Type##Operator() \ |
| 370 : Operator1<LoadRepresentation>( \ |
| 371 IrOpcode::kAtomicLoad, Operator::kNoThrow | Operator::kNoWrite, \ |
| 372 "AtomicLoad", 2, 1, 1, 1, 1, 0, MachineType::Type()) {} \ |
| 373 }; \ |
| 374 AtomicLoad##Type##Operator kAtomicLoad##Type; |
| 375 ATOMIC_TYPE_LIST(ATOMIC) |
| 376 #undef ATOMIC |
356 }; | 377 }; |
357 | 378 |
358 | 379 |
359 static base::LazyInstance<MachineOperatorGlobalCache>::type kCache = | 380 static base::LazyInstance<MachineOperatorGlobalCache>::type kCache = |
360 LAZY_INSTANCE_INITIALIZER; | 381 LAZY_INSTANCE_INITIALIZER; |
361 | 382 |
362 | 383 |
363 MachineOperatorBuilder::MachineOperatorBuilder(Zone* zone, | 384 MachineOperatorBuilder::MachineOperatorBuilder(Zone* zone, |
364 MachineRepresentation word, | 385 MachineRepresentation word, |
365 Flags flags) | 386 Flags flags) |
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
480 const Operator* MachineOperatorBuilder::Word64PopcntPlaceholder() { | 501 const Operator* MachineOperatorBuilder::Word64PopcntPlaceholder() { |
481 return &cache_.kWord64Popcnt; | 502 return &cache_.kWord64Popcnt; |
482 } | 503 } |
483 | 504 |
484 // On 32 bit platforms we need to get a reference to optional operators of | 505 // On 32 bit platforms we need to get a reference to optional operators of |
485 // 64-bit instructions for later Int64Lowering, even though 32 bit platforms | 506 // 64-bit instructions for later Int64Lowering, even though 32 bit platforms |
486 // don't support the original 64-bit instruction. | 507 // don't support the original 64-bit instruction. |
487 const Operator* MachineOperatorBuilder::Word64CtzPlaceholder() { | 508 const Operator* MachineOperatorBuilder::Word64CtzPlaceholder() { |
488 return &cache_.kWord64Ctz; | 509 return &cache_.kWord64Ctz; |
489 } | 510 } |
| 511 |
| 512 const Operator* MachineOperatorBuilder::AtomicLoad(LoadRepresentation rep) { |
| 513 #define LOAD(Type) \ |
| 514 if (rep == MachineType::Type()) { \ |
| 515 return &cache_.kAtomicLoad##Type; \ |
| 516 } |
| 517 ATOMIC_TYPE_LIST(LOAD) |
| 518 #undef LOAD |
| 519 UNREACHABLE(); |
| 520 return nullptr; |
| 521 } |
| 522 |
490 } // namespace compiler | 523 } // namespace compiler |
491 } // namespace internal | 524 } // namespace internal |
492 } // namespace v8 | 525 } // namespace v8 |
OLD | NEW |