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 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
72 CheckedStoreRepresentation CheckedStoreRepresentationOf(Operator const* op) { | 72 CheckedStoreRepresentation CheckedStoreRepresentationOf(Operator const* op) { |
73 DCHECK_EQ(IrOpcode::kCheckedStore, op->opcode()); | 73 DCHECK_EQ(IrOpcode::kCheckedStore, op->opcode()); |
74 return OpParameter<CheckedStoreRepresentation>(op); | 74 return OpParameter<CheckedStoreRepresentation>(op); |
75 } | 75 } |
76 | 76 |
77 MachineRepresentation StackSlotRepresentationOf(Operator const* op) { | 77 MachineRepresentation StackSlotRepresentationOf(Operator const* op) { |
78 DCHECK_EQ(IrOpcode::kStackSlot, op->opcode()); | 78 DCHECK_EQ(IrOpcode::kStackSlot, op->opcode()); |
79 return OpParameter<MachineRepresentation>(op); | 79 return OpParameter<MachineRepresentation>(op); |
80 } | 80 } |
81 | 81 |
| 82 MachineRepresentation AtomicStoreRepresentationOf(Operator const* op) { |
| 83 DCHECK_EQ(IrOpcode::kAtomicStore, op->opcode()); |
| 84 return OpParameter<MachineRepresentation>(op); |
| 85 } |
| 86 |
82 #define PURE_OP_LIST(V) \ | 87 #define PURE_OP_LIST(V) \ |
83 V(Word32And, Operator::kAssociative | Operator::kCommutative, 2, 0, 1) \ | 88 V(Word32And, Operator::kAssociative | Operator::kCommutative, 2, 0, 1) \ |
84 V(Word32Or, Operator::kAssociative | Operator::kCommutative, 2, 0, 1) \ | 89 V(Word32Or, Operator::kAssociative | Operator::kCommutative, 2, 0, 1) \ |
85 V(Word32Xor, Operator::kAssociative | Operator::kCommutative, 2, 0, 1) \ | 90 V(Word32Xor, Operator::kAssociative | Operator::kCommutative, 2, 0, 1) \ |
86 V(Word32Shl, Operator::kNoProperties, 2, 0, 1) \ | 91 V(Word32Shl, Operator::kNoProperties, 2, 0, 1) \ |
87 V(Word32Shr, Operator::kNoProperties, 2, 0, 1) \ | 92 V(Word32Shr, Operator::kNoProperties, 2, 0, 1) \ |
88 V(Word32Sar, Operator::kNoProperties, 2, 0, 1) \ | 93 V(Word32Sar, Operator::kNoProperties, 2, 0, 1) \ |
89 V(Word32Ror, Operator::kNoProperties, 2, 0, 1) \ | 94 V(Word32Ror, Operator::kNoProperties, 2, 0, 1) \ |
90 V(Word32Equal, Operator::kCommutative, 2, 0, 1) \ | 95 V(Word32Equal, Operator::kCommutative, 2, 0, 1) \ |
91 V(Word32Clz, Operator::kNoProperties, 1, 0, 1) \ | 96 V(Word32Clz, Operator::kNoProperties, 1, 0, 1) \ |
(...skipping 317 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
409 V(kTagged) | 414 V(kTagged) |
410 | 415 |
411 #define ATOMIC_TYPE_LIST(V) \ | 416 #define ATOMIC_TYPE_LIST(V) \ |
412 V(Int8) \ | 417 V(Int8) \ |
413 V(Uint8) \ | 418 V(Uint8) \ |
414 V(Int16) \ | 419 V(Int16) \ |
415 V(Uint16) \ | 420 V(Uint16) \ |
416 V(Int32) \ | 421 V(Int32) \ |
417 V(Uint32) | 422 V(Uint32) |
418 | 423 |
| 424 #define ATOMIC_REPRESENTATION_LIST(V) \ |
| 425 V(kWord8) \ |
| 426 V(kWord16) \ |
| 427 V(kWord32) |
| 428 |
419 struct MachineOperatorGlobalCache { | 429 struct MachineOperatorGlobalCache { |
420 #define PURE(Name, properties, value_input_count, control_input_count, \ | 430 #define PURE(Name, properties, value_input_count, control_input_count, \ |
421 output_count) \ | 431 output_count) \ |
422 struct Name##Operator final : public Operator { \ | 432 struct Name##Operator final : public Operator { \ |
423 Name##Operator() \ | 433 Name##Operator() \ |
424 : Operator(IrOpcode::k##Name, Operator::kPure | properties, #Name, \ | 434 : Operator(IrOpcode::k##Name, Operator::kPure | properties, #Name, \ |
425 value_input_count, 0, control_input_count, output_count, 0, \ | 435 value_input_count, 0, control_input_count, output_count, 0, \ |
426 0) {} \ | 436 0) {} \ |
427 }; \ | 437 }; \ |
428 Name##Operator k##Name; | 438 Name##Operator k##Name; |
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
500 }; \ | 510 }; \ |
501 Store##Type##NoWriteBarrier##Operator kStore##Type##NoWriteBarrier; \ | 511 Store##Type##NoWriteBarrier##Operator kStore##Type##NoWriteBarrier; \ |
502 Store##Type##MapWriteBarrier##Operator kStore##Type##MapWriteBarrier; \ | 512 Store##Type##MapWriteBarrier##Operator kStore##Type##MapWriteBarrier; \ |
503 Store##Type##PointerWriteBarrier##Operator \ | 513 Store##Type##PointerWriteBarrier##Operator \ |
504 kStore##Type##PointerWriteBarrier; \ | 514 kStore##Type##PointerWriteBarrier; \ |
505 Store##Type##FullWriteBarrier##Operator kStore##Type##FullWriteBarrier; \ | 515 Store##Type##FullWriteBarrier##Operator kStore##Type##FullWriteBarrier; \ |
506 CheckedStore##Type##Operator kCheckedStore##Type; | 516 CheckedStore##Type##Operator kCheckedStore##Type; |
507 MACHINE_REPRESENTATION_LIST(STORE) | 517 MACHINE_REPRESENTATION_LIST(STORE) |
508 #undef STORE | 518 #undef STORE |
509 | 519 |
510 #define ATOMIC(Type) \ | 520 #define ATOMIC_LOAD(Type) \ |
511 struct AtomicLoad##Type##Operator final \ | 521 struct AtomicLoad##Type##Operator final \ |
512 : public Operator1<LoadRepresentation> { \ | 522 : public Operator1<LoadRepresentation> { \ |
513 AtomicLoad##Type##Operator() \ | 523 AtomicLoad##Type##Operator() \ |
514 : Operator1<LoadRepresentation>( \ | 524 : Operator1<LoadRepresentation>( \ |
515 IrOpcode::kAtomicLoad, Operator::kNoThrow | Operator::kNoWrite, \ | 525 IrOpcode::kAtomicLoad, Operator::kNoThrow | Operator::kNoWrite, \ |
516 "AtomicLoad", 2, 1, 1, 1, 1, 0, MachineType::Type()) {} \ | 526 "AtomicLoad", 2, 1, 1, 1, 1, 0, MachineType::Type()) {} \ |
517 }; \ | 527 }; \ |
518 AtomicLoad##Type##Operator kAtomicLoad##Type; | 528 AtomicLoad##Type##Operator kAtomicLoad##Type; |
519 ATOMIC_TYPE_LIST(ATOMIC) | 529 ATOMIC_TYPE_LIST(ATOMIC_LOAD) |
520 #undef ATOMIC | 530 #undef ATOMIC_LOAD |
| 531 |
| 532 #define ATOMIC_STORE(Type) \ |
| 533 struct AtomicStore##Type##Operator \ |
| 534 : public Operator1<MachineRepresentation> { \ |
| 535 AtomicStore##Type##Operator() \ |
| 536 : Operator1<MachineRepresentation>( \ |
| 537 IrOpcode::kAtomicStore, Operator::kNoRead | Operator::kNoThrow, \ |
| 538 "AtomicStore", 3, 1, 1, 0, 1, 0, MachineRepresentation::Type) {} \ |
| 539 }; \ |
| 540 AtomicStore##Type##Operator kAtomicStore##Type; |
| 541 ATOMIC_REPRESENTATION_LIST(ATOMIC_STORE) |
| 542 #undef STORE |
521 }; | 543 }; |
522 | 544 |
523 | 545 |
524 static base::LazyInstance<MachineOperatorGlobalCache>::type kCache = | 546 static base::LazyInstance<MachineOperatorGlobalCache>::type kCache = |
525 LAZY_INSTANCE_INITIALIZER; | 547 LAZY_INSTANCE_INITIALIZER; |
526 | 548 |
527 | 549 |
528 MachineOperatorBuilder::MachineOperatorBuilder(Zone* zone, | 550 MachineOperatorBuilder::MachineOperatorBuilder(Zone* zone, |
529 MachineRepresentation word, | 551 MachineRepresentation word, |
530 Flags flags) | 552 Flags flags) |
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
644 #define LOAD(Type) \ | 666 #define LOAD(Type) \ |
645 if (rep == MachineType::Type()) { \ | 667 if (rep == MachineType::Type()) { \ |
646 return &cache_.kAtomicLoad##Type; \ | 668 return &cache_.kAtomicLoad##Type; \ |
647 } | 669 } |
648 ATOMIC_TYPE_LIST(LOAD) | 670 ATOMIC_TYPE_LIST(LOAD) |
649 #undef LOAD | 671 #undef LOAD |
650 UNREACHABLE(); | 672 UNREACHABLE(); |
651 return nullptr; | 673 return nullptr; |
652 } | 674 } |
653 | 675 |
| 676 const Operator* MachineOperatorBuilder::AtomicStore(MachineRepresentation rep) { |
| 677 #define STORE(kRep) \ |
| 678 if (rep == MachineRepresentation::kRep) { \ |
| 679 return &cache_.kAtomicStore##kRep; \ |
| 680 } |
| 681 ATOMIC_REPRESENTATION_LIST(STORE) |
| 682 #undef STORE |
| 683 UNREACHABLE(); |
| 684 return nullptr; |
| 685 } |
| 686 |
654 } // namespace compiler | 687 } // namespace compiler |
655 } // namespace internal | 688 } // namespace internal |
656 } // namespace v8 | 689 } // namespace v8 |
OLD | NEW |