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(IrOpcode::kLoad == op->opcode() || | 72 DCHECK_EQ(IrOpcode::kLoad, op->opcode()); |
73 IrOpcode::kAtomicLoad == op->opcode()); | |
74 return OpParameter<LoadRepresentation>(op); | 73 return OpParameter<LoadRepresentation>(op); |
75 } | 74 } |
76 | 75 |
77 | 76 |
78 StoreRepresentation const& StoreRepresentationOf(Operator const* op) { | 77 StoreRepresentation const& StoreRepresentationOf(Operator const* op) { |
79 DCHECK_EQ(IrOpcode::kStore, op->opcode()); | 78 DCHECK_EQ(IrOpcode::kStore, op->opcode()); |
80 return OpParameter<StoreRepresentation>(op); | 79 return OpParameter<StoreRepresentation>(op); |
81 } | 80 } |
82 | 81 |
83 | 82 |
(...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
244 #define MACHINE_REPRESENTATION_LIST(V) \ | 243 #define MACHINE_REPRESENTATION_LIST(V) \ |
245 V(kFloat32) \ | 244 V(kFloat32) \ |
246 V(kFloat64) \ | 245 V(kFloat64) \ |
247 V(kSimd128) \ | 246 V(kSimd128) \ |
248 V(kWord8) \ | 247 V(kWord8) \ |
249 V(kWord16) \ | 248 V(kWord16) \ |
250 V(kWord32) \ | 249 V(kWord32) \ |
251 V(kWord64) \ | 250 V(kWord64) \ |
252 V(kTagged) | 251 V(kTagged) |
253 | 252 |
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 | |
262 struct MachineOperatorGlobalCache { | 253 struct MachineOperatorGlobalCache { |
263 #define PURE(Name, properties, value_input_count, control_input_count, \ | 254 #define PURE(Name, properties, value_input_count, control_input_count, \ |
264 output_count) \ | 255 output_count) \ |
265 struct Name##Operator final : public Operator { \ | 256 struct Name##Operator final : public Operator { \ |
266 Name##Operator() \ | 257 Name##Operator() \ |
267 : Operator(IrOpcode::k##Name, Operator::kPure | properties, #Name, \ | 258 : Operator(IrOpcode::k##Name, Operator::kPure | properties, #Name, \ |
268 value_input_count, 0, control_input_count, output_count, 0, \ | 259 value_input_count, 0, control_input_count, output_count, 0, \ |
269 0) {} \ | 260 0) {} \ |
270 }; \ | 261 }; \ |
271 Name##Operator k##Name; | 262 Name##Operator k##Name; |
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
355 } \ | 346 } \ |
356 }; \ | 347 }; \ |
357 Store##Type##NoWriteBarrier##Operator kStore##Type##NoWriteBarrier; \ | 348 Store##Type##NoWriteBarrier##Operator kStore##Type##NoWriteBarrier; \ |
358 Store##Type##MapWriteBarrier##Operator kStore##Type##MapWriteBarrier; \ | 349 Store##Type##MapWriteBarrier##Operator kStore##Type##MapWriteBarrier; \ |
359 Store##Type##PointerWriteBarrier##Operator \ | 350 Store##Type##PointerWriteBarrier##Operator \ |
360 kStore##Type##PointerWriteBarrier; \ | 351 kStore##Type##PointerWriteBarrier; \ |
361 Store##Type##FullWriteBarrier##Operator kStore##Type##FullWriteBarrier; \ | 352 Store##Type##FullWriteBarrier##Operator kStore##Type##FullWriteBarrier; \ |
362 CheckedStore##Type##Operator kCheckedStore##Type; | 353 CheckedStore##Type##Operator kCheckedStore##Type; |
363 MACHINE_REPRESENTATION_LIST(STORE) | 354 MACHINE_REPRESENTATION_LIST(STORE) |
364 #undef STORE | 355 #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 | |
377 }; | 356 }; |
378 | 357 |
379 | 358 |
380 static base::LazyInstance<MachineOperatorGlobalCache>::type kCache = | 359 static base::LazyInstance<MachineOperatorGlobalCache>::type kCache = |
381 LAZY_INSTANCE_INITIALIZER; | 360 LAZY_INSTANCE_INITIALIZER; |
382 | 361 |
383 | 362 |
384 MachineOperatorBuilder::MachineOperatorBuilder(Zone* zone, | 363 MachineOperatorBuilder::MachineOperatorBuilder(Zone* zone, |
385 MachineRepresentation word, | 364 MachineRepresentation word, |
386 Flags flags) | 365 Flags flags) |
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
501 const Operator* MachineOperatorBuilder::Word64PopcntPlaceholder() { | 480 const Operator* MachineOperatorBuilder::Word64PopcntPlaceholder() { |
502 return &cache_.kWord64Popcnt; | 481 return &cache_.kWord64Popcnt; |
503 } | 482 } |
504 | 483 |
505 // On 32 bit platforms we need to get a reference to optional operators of | 484 // On 32 bit platforms we need to get a reference to optional operators of |
506 // 64-bit instructions for later Int64Lowering, even though 32 bit platforms | 485 // 64-bit instructions for later Int64Lowering, even though 32 bit platforms |
507 // don't support the original 64-bit instruction. | 486 // don't support the original 64-bit instruction. |
508 const Operator* MachineOperatorBuilder::Word64CtzPlaceholder() { | 487 const Operator* MachineOperatorBuilder::Word64CtzPlaceholder() { |
509 return &cache_.kWord64Ctz; | 488 return &cache_.kWord64Ctz; |
510 } | 489 } |
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 | |
523 } // namespace compiler | 490 } // namespace compiler |
524 } // namespace internal | 491 } // namespace internal |
525 } // namespace v8 | 492 } // namespace v8 |
OLD | NEW |