OLD | NEW |
1 // Copyright 2013 the V8 project authors. All rights reserved. | 1 // Copyright 2013 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 #ifndef V8_ARM64_LITHIUM_ARM64_H_ | 5 #ifndef V8_ARM64_LITHIUM_ARM64_H_ |
6 #define V8_ARM64_LITHIUM_ARM64_H_ | 6 #define V8_ARM64_LITHIUM_ARM64_H_ |
7 | 7 |
8 #include "hydrogen.h" | 8 #include "hydrogen.h" |
9 #include "lithium-allocator.h" | 9 #include "lithium-allocator.h" |
10 #include "lithium.h" | 10 #include "lithium.h" |
(...skipping 547 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
558 LOperand* left() { return inputs_[0]; } | 558 LOperand* left() { return inputs_[0]; } |
559 LOperand* right() { return inputs_[1]; } | 559 LOperand* right() { return inputs_[1]; } |
560 | 560 |
561 DECLARE_CONCRETE_INSTRUCTION(AddE, "add-e") | 561 DECLARE_CONCRETE_INSTRUCTION(AddE, "add-e") |
562 DECLARE_HYDROGEN_ACCESSOR(Add) | 562 DECLARE_HYDROGEN_ACCESSOR(Add) |
563 }; | 563 }; |
564 | 564 |
565 | 565 |
566 class LAddI V8_FINAL : public LTemplateInstruction<1, 2, 0> { | 566 class LAddI V8_FINAL : public LTemplateInstruction<1, 2, 0> { |
567 public: | 567 public: |
568 LAddI(LOperand* left, LOperand* right) { | 568 LAddI(LOperand* left, LOperand* right) |
| 569 : shift_(NO_SHIFT), shift_amount_(0) { |
569 inputs_[0] = left; | 570 inputs_[0] = left; |
570 inputs_[1] = right; | 571 inputs_[1] = right; |
571 } | 572 } |
| 573 |
| 574 LAddI(LOperand* left, LOperand* right, Shift shift, LOperand* shift_amount) |
| 575 : shift_(shift), shift_amount_(shift_amount) { |
| 576 inputs_[0] = left; |
| 577 inputs_[1] = right; |
| 578 } |
572 | 579 |
573 LOperand* left() { return inputs_[0]; } | 580 LOperand* left() { return inputs_[0]; } |
574 LOperand* right() { return inputs_[1]; } | 581 LOperand* right() { return inputs_[1]; } |
575 | 582 |
| 583 Shift shift() const { return shift_; } |
| 584 LOperand* shift_amount() const { return shift_amount_; } |
| 585 |
576 DECLARE_CONCRETE_INSTRUCTION(AddI, "add-i") | 586 DECLARE_CONCRETE_INSTRUCTION(AddI, "add-i") |
577 DECLARE_HYDROGEN_ACCESSOR(Add) | 587 DECLARE_HYDROGEN_ACCESSOR(Add) |
| 588 |
| 589 protected: |
| 590 Shift shift_; |
| 591 LOperand* shift_amount_; |
578 }; | 592 }; |
579 | 593 |
580 | 594 |
581 class LAddS V8_FINAL : public LTemplateInstruction<1, 2, 0> { | 595 class LAddS V8_FINAL : public LTemplateInstruction<1, 2, 0> { |
582 public: | 596 public: |
583 LAddS(LOperand* left, LOperand* right) { | 597 LAddS(LOperand* left, LOperand* right) { |
584 inputs_[0] = left; | 598 inputs_[0] = left; |
585 inputs_[1] = right; | 599 inputs_[1] = right; |
586 } | 600 } |
587 | 601 |
(...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
727 LOperand* index() { return inputs_[0]; } | 741 LOperand* index() { return inputs_[0]; } |
728 LOperand* length() { return inputs_[1]; } | 742 LOperand* length() { return inputs_[1]; } |
729 | 743 |
730 DECLARE_CONCRETE_INSTRUCTION(BoundsCheck, "bounds-check") | 744 DECLARE_CONCRETE_INSTRUCTION(BoundsCheck, "bounds-check") |
731 DECLARE_HYDROGEN_ACCESSOR(BoundsCheck) | 745 DECLARE_HYDROGEN_ACCESSOR(BoundsCheck) |
732 }; | 746 }; |
733 | 747 |
734 | 748 |
735 class LBitI V8_FINAL : public LTemplateInstruction<1, 2, 0> { | 749 class LBitI V8_FINAL : public LTemplateInstruction<1, 2, 0> { |
736 public: | 750 public: |
737 LBitI(LOperand* left, LOperand* right) { | 751 LBitI(LOperand* left, LOperand* right) |
| 752 : shift_(NO_SHIFT), shift_amount_(0) { |
738 inputs_[0] = left; | 753 inputs_[0] = left; |
739 inputs_[1] = right; | 754 inputs_[1] = right; |
740 } | 755 } |
| 756 |
| 757 LBitI(LOperand* left, LOperand* right, Shift shift, LOperand* shift_amount) |
| 758 : shift_(shift), shift_amount_(shift_amount) { |
| 759 inputs_[0] = left; |
| 760 inputs_[1] = right; |
| 761 } |
741 | 762 |
742 LOperand* left() { return inputs_[0]; } | 763 LOperand* left() { return inputs_[0]; } |
743 LOperand* right() { return inputs_[1]; } | 764 LOperand* right() { return inputs_[1]; } |
744 | 765 |
| 766 Shift shift() const { return shift_; } |
| 767 LOperand* shift_amount() const { return shift_amount_; } |
| 768 |
745 Token::Value op() const { return hydrogen()->op(); } | 769 Token::Value op() const { return hydrogen()->op(); } |
746 | 770 |
747 DECLARE_CONCRETE_INSTRUCTION(BitI, "bit-i") | 771 DECLARE_CONCRETE_INSTRUCTION(BitI, "bit-i") |
748 DECLARE_HYDROGEN_ACCESSOR(Bitwise) | 772 DECLARE_HYDROGEN_ACCESSOR(Bitwise) |
| 773 |
| 774 protected: |
| 775 Shift shift_; |
| 776 LOperand* shift_amount_; |
749 }; | 777 }; |
750 | 778 |
751 | 779 |
752 class LBitS V8_FINAL : public LTemplateInstruction<1, 2, 0> { | 780 class LBitS V8_FINAL : public LTemplateInstruction<1, 2, 0> { |
753 public: | 781 public: |
754 LBitS(LOperand* left, LOperand* right) { | 782 LBitS(LOperand* left, LOperand* right) { |
755 inputs_[0] = left; | 783 inputs_[0] = left; |
756 inputs_[1] = right; | 784 inputs_[1] = right; |
757 } | 785 } |
758 | 786 |
(...skipping 1960 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2719 LOperand* temp1() { return temps_[0]; } | 2747 LOperand* temp1() { return temps_[0]; } |
2720 LOperand* temp2() { return temps_[1]; } | 2748 LOperand* temp2() { return temps_[1]; } |
2721 | 2749 |
2722 DECLARE_CONCRETE_INSTRUCTION(StoreGlobalCell, "store-global-cell") | 2750 DECLARE_CONCRETE_INSTRUCTION(StoreGlobalCell, "store-global-cell") |
2723 DECLARE_HYDROGEN_ACCESSOR(StoreGlobalCell) | 2751 DECLARE_HYDROGEN_ACCESSOR(StoreGlobalCell) |
2724 }; | 2752 }; |
2725 | 2753 |
2726 | 2754 |
2727 class LSubI V8_FINAL : public LTemplateInstruction<1, 2, 0> { | 2755 class LSubI V8_FINAL : public LTemplateInstruction<1, 2, 0> { |
2728 public: | 2756 public: |
2729 LSubI(LOperand* left, LOperand* right) { | 2757 LSubI(LOperand* left, LOperand* right) |
| 2758 : shift_(NO_SHIFT), shift_amount_(0) { |
2730 inputs_[0] = left; | 2759 inputs_[0] = left; |
2731 inputs_[1] = right; | 2760 inputs_[1] = right; |
2732 } | 2761 } |
| 2762 |
| 2763 LSubI(LOperand* left, LOperand* right, Shift shift, LOperand* shift_amount) |
| 2764 : shift_(shift), shift_amount_(shift_amount) { |
| 2765 inputs_[0] = left; |
| 2766 inputs_[1] = right; |
| 2767 } |
2733 | 2768 |
2734 LOperand* left() { return inputs_[0]; } | 2769 LOperand* left() { return inputs_[0]; } |
2735 LOperand* right() { return inputs_[1]; } | 2770 LOperand* right() { return inputs_[1]; } |
2736 | 2771 |
| 2772 Shift shift() const { return shift_; } |
| 2773 LOperand* shift_amount() const { return shift_amount_; } |
| 2774 |
2737 DECLARE_CONCRETE_INSTRUCTION(SubI, "sub-i") | 2775 DECLARE_CONCRETE_INSTRUCTION(SubI, "sub-i") |
2738 DECLARE_HYDROGEN_ACCESSOR(Sub) | 2776 DECLARE_HYDROGEN_ACCESSOR(Sub) |
| 2777 |
| 2778 protected: |
| 2779 Shift shift_; |
| 2780 LOperand* shift_amount_; |
2739 }; | 2781 }; |
2740 | 2782 |
2741 | 2783 |
2742 class LSubS: public LTemplateInstruction<1, 2, 0> { | 2784 class LSubS: public LTemplateInstruction<1, 2, 0> { |
2743 public: | 2785 public: |
2744 LSubS(LOperand* left, LOperand* right) { | 2786 LSubS(LOperand* left, LOperand* right) { |
2745 inputs_[0] = left; | 2787 inputs_[0] = left; |
2746 inputs_[1] = right; | 2788 inputs_[1] = right; |
2747 } | 2789 } |
2748 | 2790 |
(...skipping 320 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3069 LInstruction* instr, | 3111 LInstruction* instr, |
3070 HInstruction* hinstr, | 3112 HInstruction* hinstr, |
3071 CanDeoptimize can_deoptimize = CANNOT_DEOPTIMIZE_EAGERLY); | 3113 CanDeoptimize can_deoptimize = CANNOT_DEOPTIMIZE_EAGERLY); |
3072 | 3114 |
3073 LInstruction* AssignPointerMap(LInstruction* instr); | 3115 LInstruction* AssignPointerMap(LInstruction* instr); |
3074 LInstruction* AssignEnvironment(LInstruction* instr); | 3116 LInstruction* AssignEnvironment(LInstruction* instr); |
3075 | 3117 |
3076 void VisitInstruction(HInstruction* current); | 3118 void VisitInstruction(HInstruction* current); |
3077 void DoBasicBlock(HBasicBlock* block); | 3119 void DoBasicBlock(HBasicBlock* block); |
3078 | 3120 |
| 3121 int JSShiftAmountFromHConstant(HValue* constant) { |
| 3122 return HConstant::cast(constant)->Integer32Value() & 0x1f; |
| 3123 } |
| 3124 bool LikelyFitsImmField(HInstruction* instr, int imm) { |
| 3125 if (instr->IsAdd() || instr->IsSub()) { |
| 3126 return Assembler::IsImmAddSub(imm) || Assembler::IsImmAddSub(-imm); |
| 3127 } else { |
| 3128 ASSERT(instr->IsBitwise()); |
| 3129 unsigned unused_n, unused_imm_s, unused_imm_r; |
| 3130 return Assembler::IsImmLogical(imm, kWRegSizeInBits, |
| 3131 &unused_n, &unused_imm_s, &unused_imm_r); |
| 3132 } |
| 3133 } |
| 3134 |
| 3135 // Indicates if a sequence of the form |
| 3136 // lsl x8, x9, #imm |
| 3137 // add x0, x1, x8 |
| 3138 // can be replaced with: |
| 3139 // add x0, x1, x9 LSL #imm |
| 3140 // If this is not possible, the function returns NULL. Otherwise it returns a |
| 3141 // pointer to the shift instruction that would be optimized away. |
| 3142 HBitwiseBinaryOperation* CanTransformToShiftedOp(HValue* val, |
| 3143 HValue** left = NULL); |
| 3144 // Checks if all uses of the shift operation can optimize it away. |
| 3145 bool ShiftCanBeOptimizedAway(HBitwiseBinaryOperation* shift); |
| 3146 // Attempts to merge the binary operation and an eventual previous shift |
| 3147 // operation into a single operation. Returns the merged instruction on |
| 3148 // success, and NULL otherwise. |
| 3149 LInstruction* TryDoOpWithShiftedRightOperand(HBinaryOperation* op); |
| 3150 LInstruction* DoShiftedBinaryOp(HBinaryOperation* instr, |
| 3151 HValue* left, |
| 3152 HBitwiseBinaryOperation* shift); |
| 3153 |
3079 LInstruction* DoShift(Token::Value op, HBitwiseBinaryOperation* instr); | 3154 LInstruction* DoShift(Token::Value op, HBitwiseBinaryOperation* instr); |
3080 LInstruction* DoArithmeticD(Token::Value op, | 3155 LInstruction* DoArithmeticD(Token::Value op, |
3081 HArithmeticBinaryOperation* instr); | 3156 HArithmeticBinaryOperation* instr); |
3082 LInstruction* DoArithmeticT(Token::Value op, | 3157 LInstruction* DoArithmeticT(Token::Value op, |
3083 HBinaryOperation* instr); | 3158 HBinaryOperation* instr); |
3084 | 3159 |
3085 LPlatformChunk* chunk_; | 3160 LPlatformChunk* chunk_; |
3086 CompilationInfo* info_; | 3161 CompilationInfo* info_; |
3087 HGraph* const graph_; | 3162 HGraph* const graph_; |
3088 Status status_; | 3163 Status status_; |
3089 HInstruction* current_instruction_; | 3164 HInstruction* current_instruction_; |
3090 HBasicBlock* current_block_; | 3165 HBasicBlock* current_block_; |
3091 LAllocator* allocator_; | 3166 LAllocator* allocator_; |
3092 | 3167 |
3093 DISALLOW_COPY_AND_ASSIGN(LChunkBuilder); | 3168 DISALLOW_COPY_AND_ASSIGN(LChunkBuilder); |
3094 }; | 3169 }; |
3095 | 3170 |
3096 #undef DECLARE_HYDROGEN_ACCESSOR | 3171 #undef DECLARE_HYDROGEN_ACCESSOR |
3097 #undef DECLARE_CONCRETE_INSTRUCTION | 3172 #undef DECLARE_CONCRETE_INSTRUCTION |
3098 | 3173 |
3099 } } // namespace v8::internal | 3174 } } // namespace v8::internal |
3100 | 3175 |
3101 #endif // V8_ARM64_LITHIUM_ARM64_H_ | 3176 #endif // V8_ARM64_LITHIUM_ARM64_H_ |
OLD | NEW |