OLD | NEW |
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 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_HYDROGEN_INSTRUCTIONS_H_ | 5 #ifndef V8_HYDROGEN_INSTRUCTIONS_H_ |
6 #define V8_HYDROGEN_INSTRUCTIONS_H_ | 6 #define V8_HYDROGEN_INSTRUCTIONS_H_ |
7 | 7 |
8 #include "src/v8.h" | 8 #include "src/v8.h" |
9 | 9 |
10 #include "src/allocation.h" | 10 #include "src/allocation.h" |
(...skipping 645 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
656 bool IsDefinedAfter(HBasicBlock* other) const; | 656 bool IsDefinedAfter(HBasicBlock* other) const; |
657 | 657 |
658 // Operands. | 658 // Operands. |
659 virtual int OperandCount() = 0; | 659 virtual int OperandCount() = 0; |
660 virtual HValue* OperandAt(int index) const = 0; | 660 virtual HValue* OperandAt(int index) const = 0; |
661 void SetOperandAt(int index, HValue* value); | 661 void SetOperandAt(int index, HValue* value); |
662 | 662 |
663 void DeleteAndReplaceWith(HValue* other); | 663 void DeleteAndReplaceWith(HValue* other); |
664 void ReplaceAllUsesWith(HValue* other); | 664 void ReplaceAllUsesWith(HValue* other); |
665 bool HasNoUses() const { return use_list_ == NULL; } | 665 bool HasNoUses() const { return use_list_ == NULL; } |
| 666 bool HasOneUse() const { |
| 667 return use_list_ != NULL && use_list_->tail() == NULL; |
| 668 } |
666 bool HasMultipleUses() const { | 669 bool HasMultipleUses() const { |
667 return use_list_ != NULL && use_list_->tail() != NULL; | 670 return use_list_ != NULL && use_list_->tail() != NULL; |
668 } | 671 } |
669 int UseCount() const; | 672 int UseCount() const; |
670 | 673 |
671 // Mark this HValue as dead and to be removed from other HValues' use lists. | 674 // Mark this HValue as dead and to be removed from other HValues' use lists. |
672 void Kill(); | 675 void Kill(); |
673 | 676 |
674 int flags() const { return flags_; } | 677 int flags() const { return flags_; } |
675 void SetFlag(Flag f) { flags_ |= (1 << f); } | 678 void SetFlag(Flag f) { flags_ |= (1 << f); } |
(...skipping 3077 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3753 if (!IsCommutative()) return false; | 3756 if (!IsCommutative()) return false; |
3754 | 3757 |
3755 // Constant operands are better off on the right, they can be inlined in | 3758 // Constant operands are better off on the right, they can be inlined in |
3756 // many situations on most platforms. | 3759 // many situations on most platforms. |
3757 if (left()->IsConstant()) return true; | 3760 if (left()->IsConstant()) return true; |
3758 if (right()->IsConstant()) return false; | 3761 if (right()->IsConstant()) return false; |
3759 | 3762 |
3760 // Otherwise, if there is only one use of the right operand, it would be | 3763 // Otherwise, if there is only one use of the right operand, it would be |
3761 // better off on the left for platforms that only have 2-arg arithmetic | 3764 // better off on the left for platforms that only have 2-arg arithmetic |
3762 // ops (e.g ia32, x64) that clobber the left operand. | 3765 // ops (e.g ia32, x64) that clobber the left operand. |
3763 return right()->UseCount() == 1; | 3766 return right()->HasOneUse(); |
3764 } | 3767 } |
3765 | 3768 |
3766 HValue* BetterLeftOperand() { | 3769 HValue* BetterLeftOperand() { |
3767 return AreOperandsBetterSwitched() ? right() : left(); | 3770 return AreOperandsBetterSwitched() ? right() : left(); |
3768 } | 3771 } |
3769 | 3772 |
3770 HValue* BetterRightOperand() { | 3773 HValue* BetterRightOperand() { |
3771 return AreOperandsBetterSwitched() ? left() : right(); | 3774 return AreOperandsBetterSwitched() ? left() : right(); |
3772 } | 3775 } |
3773 | 3776 |
(...skipping 4028 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7802 }; | 7805 }; |
7803 | 7806 |
7804 | 7807 |
7805 | 7808 |
7806 #undef DECLARE_INSTRUCTION | 7809 #undef DECLARE_INSTRUCTION |
7807 #undef DECLARE_CONCRETE_INSTRUCTION | 7810 #undef DECLARE_CONCRETE_INSTRUCTION |
7808 | 7811 |
7809 } } // namespace v8::internal | 7812 } } // namespace v8::internal |
7810 | 7813 |
7811 #endif // V8_HYDROGEN_INSTRUCTIONS_H_ | 7814 #endif // V8_HYDROGEN_INSTRUCTIONS_H_ |
OLD | NEW |