Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(286)

Side by Side Diff: src/arm64/lithium-arm64.h

Issue 257203002: ARM64: Use the shifter operand to merge in previous shift instructions. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 6 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 541 matching lines...) Expand 10 before | Expand all | Expand 10 after
552 } 552 }
553 553
554 LOperand* left() { return inputs_[0]; } 554 LOperand* left() { return inputs_[0]; }
555 LOperand* right() { return inputs_[1]; } 555 LOperand* right() { return inputs_[1]; }
556 556
557 DECLARE_CONCRETE_INSTRUCTION(AddE, "add-e") 557 DECLARE_CONCRETE_INSTRUCTION(AddE, "add-e")
558 DECLARE_HYDROGEN_ACCESSOR(Add) 558 DECLARE_HYDROGEN_ACCESSOR(Add)
559 }; 559 };
560 560
561 561
562 class LAddI V8_FINAL : public LTemplateInstruction<1, 2, 0> { 562 class LShiftedRightOpInterface {
563 public:
ulan 2014/05/02 10:01:18 Google style guide doesn't allow non-pure multiple
Alexandre Rames 2014/05/02 13:51:44 Done.
564 LShiftedRightOpInterface()
565 : shift_(NO_SHIFT), shift_amount_(0) {}
566 LShiftedRightOpInterface(Shift shift, LOperand* shift_amount)
567 : shift_(shift), shift_amount_(shift_amount) {}
568
569 virtual ~LShiftedRightOpInterface() {}
570
571 Shift shift() const { return shift_; }
572 LOperand* shift_amount() const { return shift_amount_; }
573
574 protected:
575 Shift shift_;
576 LOperand* shift_amount_;
577 };
578
579
580 class LAddI V8_FINAL : public LTemplateInstruction<1, 2, 0>,
581 public LShiftedRightOpInterface {
563 public: 582 public:
564 LAddI(LOperand* left, LOperand* right) { 583 LAddI(LOperand* left, LOperand* right) {
565 inputs_[0] = left; 584 inputs_[0] = left;
566 inputs_[1] = right; 585 inputs_[1] = right;
567 } 586 }
587 LAddI(LOperand* left, LOperand* right, Shift shift, LOperand* shift_amount)
588 : LShiftedRightOpInterface(shift, shift_amount) {
589 inputs_[0] = left;
590 inputs_[1] = right;
591 }
568 592
569 LOperand* left() { return inputs_[0]; } 593 LOperand* left() { return inputs_[0]; }
570 LOperand* right() { return inputs_[1]; } 594 LOperand* right() { return inputs_[1]; }
571 595
572 DECLARE_CONCRETE_INSTRUCTION(AddI, "add-i") 596 DECLARE_CONCRETE_INSTRUCTION(AddI, "add-i")
573 DECLARE_HYDROGEN_ACCESSOR(Add) 597 DECLARE_HYDROGEN_ACCESSOR(Add)
574 }; 598 };
575 599
576 600
577 class LAddS V8_FINAL : public LTemplateInstruction<1, 2, 0> { 601 class LAddS V8_FINAL : public LTemplateInstruction<1, 2, 0> {
(...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after
721 } 745 }
722 746
723 LOperand* index() { return inputs_[0]; } 747 LOperand* index() { return inputs_[0]; }
724 LOperand* length() { return inputs_[1]; } 748 LOperand* length() { return inputs_[1]; }
725 749
726 DECLARE_CONCRETE_INSTRUCTION(BoundsCheck, "bounds-check") 750 DECLARE_CONCRETE_INSTRUCTION(BoundsCheck, "bounds-check")
727 DECLARE_HYDROGEN_ACCESSOR(BoundsCheck) 751 DECLARE_HYDROGEN_ACCESSOR(BoundsCheck)
728 }; 752 };
729 753
730 754
731 class LBitI V8_FINAL : public LTemplateInstruction<1, 2, 0> { 755 class LBitI V8_FINAL : public LTemplateInstruction<1, 2, 0>,
756 public LShiftedRightOpInterface {
732 public: 757 public:
733 LBitI(LOperand* left, LOperand* right) { 758 LBitI(LOperand* left, LOperand* right) {
734 inputs_[0] = left; 759 inputs_[0] = left;
735 inputs_[1] = right; 760 inputs_[1] = right;
736 } 761 }
737 762
763 LBitI(LOperand* left, LOperand* right, Shift shift, LOperand* shift_amount)
764 : LShiftedRightOpInterface(shift, shift_amount) {
765 inputs_[0] = left;
766 inputs_[1] = right;
767 }
768
738 LOperand* left() { return inputs_[0]; } 769 LOperand* left() { return inputs_[0]; }
739 LOperand* right() { return inputs_[1]; } 770 LOperand* right() { return inputs_[1]; }
740 771
741 Token::Value op() const { return hydrogen()->op(); } 772 Token::Value op() const { return hydrogen()->op(); }
742 773
743 DECLARE_CONCRETE_INSTRUCTION(BitI, "bit-i") 774 DECLARE_CONCRETE_INSTRUCTION(BitI, "bit-i")
744 DECLARE_HYDROGEN_ACCESSOR(Bitwise) 775 DECLARE_HYDROGEN_ACCESSOR(Bitwise)
745 }; 776 };
746 777
747 778
(...skipping 1945 matching lines...) Expand 10 before | Expand all | Expand 10 after
2693 2724
2694 LOperand* value() { return inputs_[0]; } 2725 LOperand* value() { return inputs_[0]; }
2695 LOperand* temp1() { return temps_[0]; } 2726 LOperand* temp1() { return temps_[0]; }
2696 LOperand* temp2() { return temps_[1]; } 2727 LOperand* temp2() { return temps_[1]; }
2697 2728
2698 DECLARE_CONCRETE_INSTRUCTION(StoreGlobalCell, "store-global-cell") 2729 DECLARE_CONCRETE_INSTRUCTION(StoreGlobalCell, "store-global-cell")
2699 DECLARE_HYDROGEN_ACCESSOR(StoreGlobalCell) 2730 DECLARE_HYDROGEN_ACCESSOR(StoreGlobalCell)
2700 }; 2731 };
2701 2732
2702 2733
2703 class LSubI V8_FINAL : public LTemplateInstruction<1, 2, 0> { 2734 class LSubI V8_FINAL : public LTemplateInstruction<1, 2, 0>,
2735 public LShiftedRightOpInterface {
2704 public: 2736 public:
2705 LSubI(LOperand* left, LOperand* right) { 2737 LSubI(LOperand* left, LOperand* right) {
2706 inputs_[0] = left; 2738 inputs_[0] = left;
2707 inputs_[1] = right; 2739 inputs_[1] = right;
2708 } 2740 }
2709 2741
2742 LSubI(LOperand* left, LOperand* right, Shift shift, LOperand* shift_amount)
2743 : LShiftedRightOpInterface(shift, shift_amount) {
2744 inputs_[0] = left;
2745 inputs_[1] = right;
2746 }
2747
2710 LOperand* left() { return inputs_[0]; } 2748 LOperand* left() { return inputs_[0]; }
2711 LOperand* right() { return inputs_[1]; } 2749 LOperand* right() { return inputs_[1]; }
2712 2750
2713 DECLARE_CONCRETE_INSTRUCTION(SubI, "sub-i") 2751 DECLARE_CONCRETE_INSTRUCTION(SubI, "sub-i")
2714 DECLARE_HYDROGEN_ACCESSOR(Sub) 2752 DECLARE_HYDROGEN_ACCESSOR(Sub)
2715 }; 2753 };
2716 2754
2717 2755
2718 class LSubS: public LTemplateInstruction<1, 2, 0> { 2756 class LSubS: public LTemplateInstruction<1, 2, 0> {
2719 public: 2757 public:
(...skipping 325 matching lines...) Expand 10 before | Expand all | Expand 10 after
3045 LInstruction* instr, 3083 LInstruction* instr,
3046 HInstruction* hinstr, 3084 HInstruction* hinstr,
3047 CanDeoptimize can_deoptimize = CANNOT_DEOPTIMIZE_EAGERLY); 3085 CanDeoptimize can_deoptimize = CANNOT_DEOPTIMIZE_EAGERLY);
3048 3086
3049 LInstruction* AssignPointerMap(LInstruction* instr); 3087 LInstruction* AssignPointerMap(LInstruction* instr);
3050 LInstruction* AssignEnvironment(LInstruction* instr); 3088 LInstruction* AssignEnvironment(LInstruction* instr);
3051 3089
3052 void VisitInstruction(HInstruction* current); 3090 void VisitInstruction(HInstruction* current);
3053 void DoBasicBlock(HBasicBlock* block); 3091 void DoBasicBlock(HBasicBlock* block);
3054 3092
3093 int ShiftAmountFromHConstant(HValue* constant) {
3094 return HConstant::cast(constant)->Integer32Value() & 0x1f;
3095 }
3096 bool LikelyFitsImmField(HInstruction* instr, int imm) {
3097 if (instr->IsAdd() || instr->IsSub()) {
3098 return Assembler::IsImmAddSub(imm) || Assembler::IsImmAddSub(-imm);
ulan 2014/05/02 10:01:18 Did you mean && instead of ||?
Alexandre Rames 2014/05/02 13:51:44 '||' was intended. IsImmAddSub() works with unsign
3099 } else if (instr->IsBitwise()) {
3100 unsigned unused_n, unused_imm_s, unused_imm_r;
3101 return Assembler::IsImmLogical(imm, kWRegSizeInBits,
3102 &unused_n, &unused_imm_s, &unused_imm_r);
3103 } else {
3104 UNREACHABLE();
ulan 2014/05/02 10:01:18 nit: I'd slightly prefer a more compact ASSERT(ins
Alexandre Rames 2014/05/02 13:51:44 Done.
3105 return false;
3106 }
3107 }
3108
3109 // Indicates if a sequence of the form
3110 // lsl x8, x9, #imm
3111 // add x0, x1, x8
3112 // can be replaced with:
3113 // add x0, x1, x9 LSL #imm
3114 // If this is not possible, the function returns NULL. Otherwise it returns a
3115 // pointer to the shift instruction that would be optimized away.
3116 HBitwiseBinaryOperation* CanTransformToShiftedOp(HValue* val,
3117 HValue** left = NULL);
3118 // Checks if all uses of the shift operation can optimize it away.
3119 bool ShiftCanBeOptimizedAway(HBitwiseBinaryOperation* shift);
3120 // Attempts to merge the binary operation and an eventual previous shift
3121 // operation into a single operation. Returns the merged instruction on
3122 // success, and NULL otherwise.
3123 LInstruction* TryDoOpWithShiftedRightOperand(HBinaryOperation* op);
3124 LInstruction* DoShiftedBinaryOp(HBinaryOperation* instr,
3125 HValue* left,
3126 HBitwiseBinaryOperation* shift);
3127
3055 LInstruction* DoShift(Token::Value op, HBitwiseBinaryOperation* instr); 3128 LInstruction* DoShift(Token::Value op, HBitwiseBinaryOperation* instr);
3056 LInstruction* DoArithmeticD(Token::Value op, 3129 LInstruction* DoArithmeticD(Token::Value op,
3057 HArithmeticBinaryOperation* instr); 3130 HArithmeticBinaryOperation* instr);
3058 LInstruction* DoArithmeticT(Token::Value op, 3131 LInstruction* DoArithmeticT(Token::Value op,
3059 HBinaryOperation* instr); 3132 HBinaryOperation* instr);
3060 3133
3061 LPlatformChunk* chunk_; 3134 LPlatformChunk* chunk_;
3062 CompilationInfo* info_; 3135 CompilationInfo* info_;
3063 HGraph* const graph_; 3136 HGraph* const graph_;
3064 Status status_; 3137 Status status_;
3065 HInstruction* current_instruction_; 3138 HInstruction* current_instruction_;
3066 HBasicBlock* current_block_; 3139 HBasicBlock* current_block_;
3067 LAllocator* allocator_; 3140 LAllocator* allocator_;
3068 3141
3069 DISALLOW_COPY_AND_ASSIGN(LChunkBuilder); 3142 DISALLOW_COPY_AND_ASSIGN(LChunkBuilder);
3070 }; 3143 };
3071 3144
3072 #undef DECLARE_HYDROGEN_ACCESSOR 3145 #undef DECLARE_HYDROGEN_ACCESSOR
3073 #undef DECLARE_CONCRETE_INSTRUCTION 3146 #undef DECLARE_CONCRETE_INSTRUCTION
3074 3147
3075 } } // namespace v8::internal 3148 } } // namespace v8::internal
3076 3149
3077 #endif // V8_ARM64_LITHIUM_ARM64_H_ 3150 #endif // V8_ARM64_LITHIUM_ARM64_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698