OLD | NEW |
1 // Copyright (c) 1994-2006 Sun Microsystems Inc. | 1 // Copyright (c) 1994-2006 Sun Microsystems Inc. |
2 // All Rights Reserved. | 2 // All Rights Reserved. |
3 // | 3 // |
4 // Redistribution and use in source and binary forms, with or without | 4 // Redistribution and use in source and binary forms, with or without |
5 // modification, are permitted provided that the following conditions | 5 // modification, are permitted provided that the following conditions |
6 // are met: | 6 // are met: |
7 // | 7 // |
8 // - Redistributions of source code must retain the above copyright notice, | 8 // - Redistributions of source code must retain the above copyright notice, |
9 // this list of conditions and the following disclaimer. | 9 // this list of conditions and the following disclaimer. |
10 // | 10 // |
(...skipping 737 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
748 void bc(int branch_offset, BOfield bo, int condition_bit, LKBit lk = LeaveLK); | 748 void bc(int branch_offset, BOfield bo, int condition_bit, LKBit lk = LeaveLK); |
749 void b(int branch_offset, LKBit lk); | 749 void b(int branch_offset, LKBit lk); |
750 | 750 |
751 void bcctr(BOfield bo, LKBit lk); | 751 void bcctr(BOfield bo, LKBit lk); |
752 void bctr(); | 752 void bctr(); |
753 void bctrl(); | 753 void bctrl(); |
754 | 754 |
755 // Convenience branch instructions using labels | 755 // Convenience branch instructions using labels |
756 void b(Label* L, LKBit lk = LeaveLK) { b(branch_offset(L, false), lk); } | 756 void b(Label* L, LKBit lk = LeaveLK) { b(branch_offset(L, false), lk); } |
757 | 757 |
| 758 inline CRegister cmpi_optimization(CRegister cr) { |
| 759 // Check whether the branch is preceeded by an optimizable cmpi against 0. |
| 760 // The cmpi can be deleted if it is also preceeded by an instruction that |
| 761 // sets the register used by the compare and supports a dot form. |
| 762 unsigned int sradi_mask = kOpcodeMask | kExt2OpcodeVariant2Mask; |
| 763 unsigned int srawi_mask = kOpcodeMask | kExt2OpcodeMask; |
| 764 int pos = pc_offset(); |
| 765 int cmpi_pos = pc_offset() - kInstrSize; |
| 766 |
| 767 if (cmpi_pos > 0 && optimizable_cmpi_pos_ == cmpi_pos && |
| 768 cmpi_cr_.code() == cr.code() && last_bound_pos_ != pos) { |
| 769 int xpos = cmpi_pos - kInstrSize; |
| 770 int xinstr = instr_at(xpos); |
| 771 int cmpi_ra = (instr_at(cmpi_pos) & 0x1f0000) >> 16; |
| 772 // ra is at the same bit position for the three cases below. |
| 773 int ra = (xinstr & 0x1f0000) >> 16; |
| 774 if (cmpi_ra == ra) { |
| 775 if ((xinstr & sradi_mask) == (EXT2 | SRADIX)) { |
| 776 cr = cr0; |
| 777 instr_at_put(xpos, xinstr | SetRC); |
| 778 pc_ -= kInstrSize; |
| 779 } else if ((xinstr & srawi_mask) == (EXT2 | SRAWIX)) { |
| 780 cr = cr0; |
| 781 instr_at_put(xpos, xinstr | SetRC); |
| 782 pc_ -= kInstrSize; |
| 783 } else if ((xinstr & kOpcodeMask) == ANDIx) { |
| 784 cr = cr0; |
| 785 pc_ -= kInstrSize; |
| 786 // nothing to do here since andi. records. |
| 787 } |
| 788 // didn't match one of the above, must keep cmpwi. |
| 789 } |
| 790 } |
| 791 return cr; |
| 792 } |
| 793 |
758 void bc_short(Condition cond, Label* L, CRegister cr = cr7, | 794 void bc_short(Condition cond, Label* L, CRegister cr = cr7, |
759 LKBit lk = LeaveLK) { | 795 LKBit lk = LeaveLK) { |
760 DCHECK(cond != al); | 796 DCHECK(cond != al); |
761 DCHECK(cr.code() >= 0 && cr.code() <= 7); | 797 DCHECK(cr.code() >= 0 && cr.code() <= 7); |
762 | 798 |
| 799 cr = cmpi_optimization(cr); |
| 800 |
763 int b_offset = branch_offset(L, false); | 801 int b_offset = branch_offset(L, false); |
764 | 802 |
765 switch (cond) { | 803 switch (cond) { |
766 case eq: | 804 case eq: |
767 bc(b_offset, BT, encode_crbit(cr, CR_EQ), lk); | 805 bc(b_offset, BT, encode_crbit(cr, CR_EQ), lk); |
768 break; | 806 break; |
769 case ne: | 807 case ne: |
770 bc(b_offset, BF, encode_crbit(cr, CR_EQ), lk); | 808 bc(b_offset, BF, encode_crbit(cr, CR_EQ), lk); |
771 break; | 809 break; |
772 case gt: | 810 case gt: |
(...skipping 24 matching lines...) Expand all Loading... |
797 UNIMPLEMENTED(); | 835 UNIMPLEMENTED(); |
798 } | 836 } |
799 } | 837 } |
800 | 838 |
801 void isel(Register rt, Register ra, Register rb, int cb); | 839 void isel(Register rt, Register ra, Register rb, int cb); |
802 void isel(Condition cond, Register rt, Register ra, Register rb, | 840 void isel(Condition cond, Register rt, Register ra, Register rb, |
803 CRegister cr = cr7) { | 841 CRegister cr = cr7) { |
804 DCHECK(cond != al); | 842 DCHECK(cond != al); |
805 DCHECK(cr.code() >= 0 && cr.code() <= 7); | 843 DCHECK(cr.code() >= 0 && cr.code() <= 7); |
806 | 844 |
| 845 cr = cmpi_optimization(cr); |
| 846 |
807 switch (cond) { | 847 switch (cond) { |
808 case eq: | 848 case eq: |
809 isel(rt, ra, rb, encode_crbit(cr, CR_EQ)); | 849 isel(rt, ra, rb, encode_crbit(cr, CR_EQ)); |
810 break; | 850 break; |
811 case ne: | 851 case ne: |
812 isel(rt, rb, ra, encode_crbit(cr, CR_EQ)); | 852 isel(rt, rb, ra, encode_crbit(cr, CR_EQ)); |
813 break; | 853 break; |
814 case gt: | 854 case gt: |
815 isel(rt, ra, rb, encode_crbit(cr, CR_GT)); | 855 isel(rt, ra, rb, encode_crbit(cr, CR_GT)); |
816 break; | 856 break; |
(...skipping 628 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1445 int constant_pool_entry_sharing_blocked_nesting_; | 1485 int constant_pool_entry_sharing_blocked_nesting_; |
1446 | 1486 |
1447 // Relocation info generation | 1487 // Relocation info generation |
1448 // Each relocation is encoded as a variable size value | 1488 // Each relocation is encoded as a variable size value |
1449 static const int kMaxRelocSize = RelocInfoWriter::kMaxSize; | 1489 static const int kMaxRelocSize = RelocInfoWriter::kMaxSize; |
1450 RelocInfoWriter reloc_info_writer; | 1490 RelocInfoWriter reloc_info_writer; |
1451 std::vector<DeferredRelocInfo> relocations_; | 1491 std::vector<DeferredRelocInfo> relocations_; |
1452 | 1492 |
1453 // The bound position, before this we cannot do instruction elimination. | 1493 // The bound position, before this we cannot do instruction elimination. |
1454 int last_bound_pos_; | 1494 int last_bound_pos_; |
| 1495 // Optimizable cmpi information. |
| 1496 int optimizable_cmpi_pos_; |
| 1497 CRegister cmpi_cr_; |
1455 | 1498 |
1456 ConstantPoolBuilder constant_pool_builder_; | 1499 ConstantPoolBuilder constant_pool_builder_; |
1457 | 1500 |
1458 // Code emission | 1501 // Code emission |
1459 inline void CheckBuffer(); | 1502 inline void CheckBuffer(); |
1460 void GrowBuffer(int needed = 0); | 1503 void GrowBuffer(int needed = 0); |
1461 inline void emit(Instr x); | 1504 inline void emit(Instr x); |
1462 inline void CheckTrampolinePoolQuick(); | 1505 inline void CheckTrampolinePoolQuick(); |
1463 | 1506 |
1464 // Instruction generation | 1507 // Instruction generation |
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1538 | 1581 |
1539 | 1582 |
1540 class EnsureSpace BASE_EMBEDDED { | 1583 class EnsureSpace BASE_EMBEDDED { |
1541 public: | 1584 public: |
1542 explicit EnsureSpace(Assembler* assembler) { assembler->CheckBuffer(); } | 1585 explicit EnsureSpace(Assembler* assembler) { assembler->CheckBuffer(); } |
1543 }; | 1586 }; |
1544 } | 1587 } |
1545 } // namespace v8::internal | 1588 } // namespace v8::internal |
1546 | 1589 |
1547 #endif // V8_PPC_ASSEMBLER_PPC_H_ | 1590 #endif // V8_PPC_ASSEMBLER_PPC_H_ |
OLD | NEW |