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 28 matching lines...) Expand all Loading... |
39 IrOpcode::kAtomicLoad == op->opcode()); | 39 IrOpcode::kAtomicLoad == op->opcode()); |
40 return OpParameter<LoadRepresentation>(op); | 40 return OpParameter<LoadRepresentation>(op); |
41 } | 41 } |
42 | 42 |
43 | 43 |
44 StoreRepresentation const& StoreRepresentationOf(Operator const* op) { | 44 StoreRepresentation const& StoreRepresentationOf(Operator const* op) { |
45 DCHECK_EQ(IrOpcode::kStore, op->opcode()); | 45 DCHECK_EQ(IrOpcode::kStore, op->opcode()); |
46 return OpParameter<StoreRepresentation>(op); | 46 return OpParameter<StoreRepresentation>(op); |
47 } | 47 } |
48 | 48 |
| 49 UnalignedLoadRepresentation UnalignedLoadRepresentationOf(Operator const* op) { |
| 50 DCHECK_EQ(IrOpcode::kUnalignedLoad, op->opcode()); |
| 51 return OpParameter<UnalignedLoadRepresentation>(op); |
| 52 } |
| 53 |
| 54 UnalignedStoreRepresentation const& UnalignedStoreRepresentationOf( |
| 55 Operator const* op) { |
| 56 DCHECK_EQ(IrOpcode::kUnalignedStore, op->opcode()); |
| 57 return OpParameter<UnalignedStoreRepresentation>(op); |
| 58 } |
49 | 59 |
50 CheckedLoadRepresentation CheckedLoadRepresentationOf(Operator const* op) { | 60 CheckedLoadRepresentation CheckedLoadRepresentationOf(Operator const* op) { |
51 DCHECK_EQ(IrOpcode::kCheckedLoad, op->opcode()); | 61 DCHECK_EQ(IrOpcode::kCheckedLoad, op->opcode()); |
52 return OpParameter<CheckedLoadRepresentation>(op); | 62 return OpParameter<CheckedLoadRepresentation>(op); |
53 } | 63 } |
54 | 64 |
55 | 65 |
56 CheckedStoreRepresentation CheckedStoreRepresentationOf(Operator const* op) { | 66 CheckedStoreRepresentation CheckedStoreRepresentationOf(Operator const* op) { |
57 DCHECK_EQ(IrOpcode::kCheckedStore, op->opcode()); | 67 DCHECK_EQ(IrOpcode::kCheckedStore, op->opcode()); |
58 return OpParameter<CheckedStoreRepresentation>(op); | 68 return OpParameter<CheckedStoreRepresentation>(op); |
(...skipping 403 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
462 #undef OVERFLOW_OP | 472 #undef OVERFLOW_OP |
463 | 473 |
464 #define LOAD(Type) \ | 474 #define LOAD(Type) \ |
465 struct Load##Type##Operator final : public Operator1<LoadRepresentation> { \ | 475 struct Load##Type##Operator final : public Operator1<LoadRepresentation> { \ |
466 Load##Type##Operator() \ | 476 Load##Type##Operator() \ |
467 : Operator1<LoadRepresentation>( \ | 477 : Operator1<LoadRepresentation>( \ |
468 IrOpcode::kLoad, \ | 478 IrOpcode::kLoad, \ |
469 Operator::kNoDeopt | Operator::kNoThrow | Operator::kNoWrite, \ | 479 Operator::kNoDeopt | Operator::kNoThrow | Operator::kNoWrite, \ |
470 "Load", 2, 1, 1, 1, 1, 0, MachineType::Type()) {} \ | 480 "Load", 2, 1, 1, 1, 1, 0, MachineType::Type()) {} \ |
471 }; \ | 481 }; \ |
| 482 struct UnalignedLoad##Type##Operator final \ |
| 483 : public Operator1<UnalignedLoadRepresentation> { \ |
| 484 UnalignedLoad##Type##Operator() \ |
| 485 : Operator1<UnalignedLoadRepresentation>( \ |
| 486 IrOpcode::kUnalignedLoad, \ |
| 487 Operator::kNoDeopt | Operator::kNoThrow | Operator::kNoWrite, \ |
| 488 "UnalignedLoad", 2, 1, 1, 1, 1, 0, MachineType::Type()) {} \ |
| 489 }; \ |
472 struct CheckedLoad##Type##Operator final \ | 490 struct CheckedLoad##Type##Operator final \ |
473 : public Operator1<CheckedLoadRepresentation> { \ | 491 : public Operator1<CheckedLoadRepresentation> { \ |
474 CheckedLoad##Type##Operator() \ | 492 CheckedLoad##Type##Operator() \ |
475 : Operator1<CheckedLoadRepresentation>( \ | 493 : Operator1<CheckedLoadRepresentation>( \ |
476 IrOpcode::kCheckedLoad, \ | 494 IrOpcode::kCheckedLoad, \ |
477 Operator::kNoDeopt | Operator::kNoThrow | Operator::kNoWrite, \ | 495 Operator::kNoDeopt | Operator::kNoThrow | Operator::kNoWrite, \ |
478 "CheckedLoad", 3, 1, 1, 1, 1, 0, MachineType::Type()) {} \ | 496 "CheckedLoad", 3, 1, 1, 1, 1, 0, MachineType::Type()) {} \ |
479 }; \ | 497 }; \ |
480 Load##Type##Operator kLoad##Type; \ | 498 Load##Type##Operator kLoad##Type; \ |
| 499 UnalignedLoad##Type##Operator kUnalignedLoad##Type; \ |
481 CheckedLoad##Type##Operator kCheckedLoad##Type; | 500 CheckedLoad##Type##Operator kCheckedLoad##Type; |
482 MACHINE_TYPE_LIST(LOAD) | 501 MACHINE_TYPE_LIST(LOAD) |
483 #undef LOAD | 502 #undef LOAD |
484 | 503 |
485 #define STACKSLOT(Type) \ | 504 #define STACKSLOT(Type) \ |
486 struct StackSlot##Type##Operator final \ | 505 struct StackSlot##Type##Operator final \ |
487 : public Operator1<MachineRepresentation> { \ | 506 : public Operator1<MachineRepresentation> { \ |
488 StackSlot##Type##Operator() \ | 507 StackSlot##Type##Operator() \ |
489 : Operator1<MachineRepresentation>( \ | 508 : Operator1<MachineRepresentation>( \ |
490 IrOpcode::kStackSlot, Operator::kNoDeopt | Operator::kNoThrow, \ | 509 IrOpcode::kStackSlot, Operator::kNoDeopt | Operator::kNoThrow, \ |
(...skipping 27 matching lines...) Expand all Loading... |
518 struct Store##Type##PointerWriteBarrier##Operator final \ | 537 struct Store##Type##PointerWriteBarrier##Operator final \ |
519 : public Store##Type##Operator { \ | 538 : public Store##Type##Operator { \ |
520 Store##Type##PointerWriteBarrier##Operator() \ | 539 Store##Type##PointerWriteBarrier##Operator() \ |
521 : Store##Type##Operator(kPointerWriteBarrier) {} \ | 540 : Store##Type##Operator(kPointerWriteBarrier) {} \ |
522 }; \ | 541 }; \ |
523 struct Store##Type##FullWriteBarrier##Operator final \ | 542 struct Store##Type##FullWriteBarrier##Operator final \ |
524 : public Store##Type##Operator { \ | 543 : public Store##Type##Operator { \ |
525 Store##Type##FullWriteBarrier##Operator() \ | 544 Store##Type##FullWriteBarrier##Operator() \ |
526 : Store##Type##Operator(kFullWriteBarrier) {} \ | 545 : Store##Type##Operator(kFullWriteBarrier) {} \ |
527 }; \ | 546 }; \ |
| 547 struct UnalignedStore##Type##Operator final \ |
| 548 : public Operator1<UnalignedStoreRepresentation> { \ |
| 549 UnalignedStore##Type##Operator() \ |
| 550 : Operator1<UnalignedStoreRepresentation>( \ |
| 551 IrOpcode::kUnalignedStore, \ |
| 552 Operator::kNoDeopt | Operator::kNoRead | Operator::kNoThrow, \ |
| 553 "UnalignedStore", 3, 1, 1, 0, 1, 0, \ |
| 554 MachineRepresentation::Type) {} \ |
| 555 }; \ |
528 struct CheckedStore##Type##Operator final \ | 556 struct CheckedStore##Type##Operator final \ |
529 : public Operator1<CheckedStoreRepresentation> { \ | 557 : public Operator1<CheckedStoreRepresentation> { \ |
530 CheckedStore##Type##Operator() \ | 558 CheckedStore##Type##Operator() \ |
531 : Operator1<CheckedStoreRepresentation>( \ | 559 : Operator1<CheckedStoreRepresentation>( \ |
532 IrOpcode::kCheckedStore, \ | 560 IrOpcode::kCheckedStore, \ |
533 Operator::kNoDeopt | Operator::kNoRead | Operator::kNoThrow, \ | 561 Operator::kNoDeopt | Operator::kNoRead | Operator::kNoThrow, \ |
534 "CheckedStore", 4, 1, 1, 0, 1, 0, MachineRepresentation::Type) { \ | 562 "CheckedStore", 4, 1, 1, 0, 1, 0, MachineRepresentation::Type) { \ |
535 } \ | 563 } \ |
536 }; \ | 564 }; \ |
537 Store##Type##NoWriteBarrier##Operator kStore##Type##NoWriteBarrier; \ | 565 Store##Type##NoWriteBarrier##Operator kStore##Type##NoWriteBarrier; \ |
538 Store##Type##MapWriteBarrier##Operator kStore##Type##MapWriteBarrier; \ | 566 Store##Type##MapWriteBarrier##Operator kStore##Type##MapWriteBarrier; \ |
539 Store##Type##PointerWriteBarrier##Operator \ | 567 Store##Type##PointerWriteBarrier##Operator \ |
540 kStore##Type##PointerWriteBarrier; \ | 568 kStore##Type##PointerWriteBarrier; \ |
541 Store##Type##FullWriteBarrier##Operator kStore##Type##FullWriteBarrier; \ | 569 Store##Type##FullWriteBarrier##Operator kStore##Type##FullWriteBarrier; \ |
| 570 UnalignedStore##Type##Operator kUnalignedStore##Type; \ |
542 CheckedStore##Type##Operator kCheckedStore##Type; | 571 CheckedStore##Type##Operator kCheckedStore##Type; |
543 MACHINE_REPRESENTATION_LIST(STORE) | 572 MACHINE_REPRESENTATION_LIST(STORE) |
544 #undef STORE | 573 #undef STORE |
545 | 574 |
546 #define ATOMIC_LOAD(Type) \ | 575 #define ATOMIC_LOAD(Type) \ |
547 struct AtomicLoad##Type##Operator final \ | 576 struct AtomicLoad##Type##Operator final \ |
548 : public Operator1<LoadRepresentation> { \ | 577 : public Operator1<LoadRepresentation> { \ |
549 AtomicLoad##Type##Operator() \ | 578 AtomicLoad##Type##Operator() \ |
550 : Operator1<LoadRepresentation>( \ | 579 : Operator1<LoadRepresentation>( \ |
551 IrOpcode::kAtomicLoad, \ | 580 IrOpcode::kAtomicLoad, \ |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
591 AlignmentRequirements alignmentRequirements) | 620 AlignmentRequirements alignmentRequirements) |
592 : zone_(zone), | 621 : zone_(zone), |
593 cache_(kCache.Get()), | 622 cache_(kCache.Get()), |
594 word_(word), | 623 word_(word), |
595 flags_(flags), | 624 flags_(flags), |
596 alignment_requirements_(alignmentRequirements) { | 625 alignment_requirements_(alignmentRequirements) { |
597 DCHECK(word == MachineRepresentation::kWord32 || | 626 DCHECK(word == MachineRepresentation::kWord32 || |
598 word == MachineRepresentation::kWord64); | 627 word == MachineRepresentation::kWord64); |
599 } | 628 } |
600 | 629 |
| 630 const OptionalOperator MachineOperatorBuilder::UnalignedLoad( |
| 631 UnalignedLoadRepresentation rep) { |
| 632 #define LOAD(Type) \ |
| 633 if (rep == MachineType::Type()) { \ |
| 634 return OptionalOperator(flags_ & kUnalignedLoad, \ |
| 635 &cache_.kUnalignedLoad##Type); \ |
| 636 } |
| 637 MACHINE_TYPE_LIST(LOAD) |
| 638 #undef LOAD |
| 639 UNREACHABLE(); |
| 640 return OptionalOperator(false, nullptr); |
| 641 } |
| 642 |
| 643 const OptionalOperator MachineOperatorBuilder::UnalignedStore( |
| 644 UnalignedStoreRepresentation rep) { |
| 645 switch (rep) { |
| 646 #define STORE(kRep) \ |
| 647 case MachineRepresentation::kRep: \ |
| 648 return OptionalOperator(flags_ & kUnalignedStore, \ |
| 649 &cache_.kUnalignedStore##kRep); |
| 650 MACHINE_REPRESENTATION_LIST(STORE) |
| 651 #undef STORE |
| 652 case MachineRepresentation::kBit: |
| 653 case MachineRepresentation::kNone: |
| 654 break; |
| 655 } |
| 656 UNREACHABLE(); |
| 657 return OptionalOperator(false, nullptr); |
| 658 } |
601 | 659 |
602 #define PURE(Name, properties, value_input_count, control_input_count, \ | 660 #define PURE(Name, properties, value_input_count, control_input_count, \ |
603 output_count) \ | 661 output_count) \ |
604 const Operator* MachineOperatorBuilder::Name() { return &cache_.k##Name; } | 662 const Operator* MachineOperatorBuilder::Name() { return &cache_.k##Name; } |
605 PURE_OP_LIST(PURE) | 663 PURE_OP_LIST(PURE) |
606 #undef PURE | 664 #undef PURE |
607 | 665 |
608 #define PURE(Name, properties, value_input_count, control_input_count, \ | 666 #define PURE(Name, properties, value_input_count, control_input_count, \ |
609 output_count) \ | 667 output_count) \ |
610 const OptionalOperator MachineOperatorBuilder::Name() { \ | 668 const OptionalOperator MachineOperatorBuilder::Name() { \ |
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
720 } | 778 } |
721 ATOMIC_REPRESENTATION_LIST(STORE) | 779 ATOMIC_REPRESENTATION_LIST(STORE) |
722 #undef STORE | 780 #undef STORE |
723 UNREACHABLE(); | 781 UNREACHABLE(); |
724 return nullptr; | 782 return nullptr; |
725 } | 783 } |
726 | 784 |
727 } // namespace compiler | 785 } // namespace compiler |
728 } // namespace internal | 786 } // namespace internal |
729 } // namespace v8 | 787 } // namespace v8 |
OLD | NEW |