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

Side by Side Diff: src/ppc/simulator-ppc.cc

Issue 2625013002: PPC: Enable P9 and implement mod[s|u][d|w] instr (Closed)
Patch Set: rebased Created 3 years, 11 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
« no previous file with comments | « src/ppc/disasm-ppc.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 <stdarg.h> 5 #include <stdarg.h>
6 #include <stdlib.h> 6 #include <stdlib.h>
7 #include <cmath> 7 #include <cmath>
8 8
9 #if V8_TARGET_ARCH_PPC 9 #if V8_TARGET_ARCH_PPC
10 10
(...skipping 1690 matching lines...) Expand 10 before | Expand all | Expand 10 after
1701 uintptr_t rs_val = get_register(rs); 1701 uintptr_t rs_val = get_register(rs);
1702 uintptr_t rb_val = get_register(rb) & 0x7f; 1702 uintptr_t rb_val = get_register(rb) & 0x7f;
1703 intptr_t result = (rb_val > 63) ? 0 : rs_val >> rb_val; 1703 intptr_t result = (rb_val > 63) ? 0 : rs_val >> rb_val;
1704 set_register(ra, result); 1704 set_register(ra, result);
1705 if (instr->Bit(0)) { // RC bit set 1705 if (instr->Bit(0)) { // RC bit set
1706 SetCR0(result); 1706 SetCR0(result);
1707 } 1707 }
1708 break; 1708 break;
1709 } 1709 }
1710 #endif 1710 #endif
1711 case MODUW: {
1712 int rt = instr->RTValue();
1713 int ra = instr->RAValue();
1714 int rb = instr->RBValue();
1715 uint32_t ra_val = get_register(ra);
1716 uint32_t rb_val = get_register(rb);
1717 uint32_t alu_out = (rb_val == 0) ? -1 : ra_val % rb_val;
1718 set_register(rt, alu_out);
1719 break;
1720 }
1721 #if V8_TARGET_ARCH_PPC64
1722 case MODUD: {
1723 int rt = instr->RTValue();
1724 int ra = instr->RAValue();
1725 int rb = instr->RBValue();
1726 uint64_t ra_val = get_register(ra);
1727 uint64_t rb_val = get_register(rb);
1728 uint64_t alu_out = (rb_val == 0) ? -1 : ra_val % rb_val;
1729 set_register(rt, alu_out);
1730 break;
1731 }
1732 #endif
1733 case MODSW: {
1734 int rt = instr->RTValue();
1735 int ra = instr->RAValue();
1736 int rb = instr->RBValue();
1737 int32_t ra_val = get_register(ra);
1738 int32_t rb_val = get_register(rb);
1739 bool overflow = (ra_val == kMinInt && rb_val == -1);
1740 // result is undefined if divisor is zero or if operation
1741 // is 0x80000000 / -1.
1742 int32_t alu_out = (rb_val == 0 || overflow) ? -1 : ra_val % rb_val;
1743 set_register(rt, alu_out);
1744 break;
1745 }
1746 #if V8_TARGET_ARCH_PPC64
1747 case MODSD: {
1748 int rt = instr->RTValue();
1749 int ra = instr->RAValue();
1750 int rb = instr->RBValue();
1751 int64_t ra_val = get_register(ra);
1752 int64_t rb_val = get_register(rb);
1753 int64_t one = 1; // work-around gcc
1754 int64_t kMinLongLong = (one << 63);
1755 // result is undefined if divisor is zero or if operation
1756 // is 0x80000000_00000000 / -1.
1757 int64_t alu_out =
1758 (rb_val == 0 || (ra_val == kMinLongLong && rb_val == -1))
1759 ? -1
1760 : ra_val % rb_val;
1761 set_register(rt, alu_out);
1762 break;
1763 }
1764 #endif
1711 case SRAW: { 1765 case SRAW: {
1712 int rs = instr->RSValue(); 1766 int rs = instr->RSValue();
1713 int ra = instr->RAValue(); 1767 int ra = instr->RAValue();
1714 int rb = instr->RBValue(); 1768 int rb = instr->RBValue();
1715 int32_t rs_val = get_register(rs); 1769 int32_t rs_val = get_register(rs);
1716 intptr_t rb_val = get_register(rb) & 0x3f; 1770 intptr_t rb_val = get_register(rb) & 0x3f;
1717 intptr_t result = (rb_val > 31) ? rs_val >> 31 : rs_val >> rb_val; 1771 intptr_t result = (rb_val > 31) ? rs_val >> 31 : rs_val >> rb_val;
1718 set_register(ra, result); 1772 set_register(ra, result);
1719 if (instr->Bit(0)) { // RC bit set 1773 if (instr->Bit(0)) { // RC bit set
1720 SetCR0(result); 1774 SetCR0(result);
(...skipping 2409 matching lines...) Expand 10 before | Expand all | Expand 10 after
4130 uintptr_t* stack_slot = reinterpret_cast<uintptr_t*>(current_sp); 4184 uintptr_t* stack_slot = reinterpret_cast<uintptr_t*>(current_sp);
4131 uintptr_t address = *stack_slot; 4185 uintptr_t address = *stack_slot;
4132 set_register(sp, current_sp + sizeof(uintptr_t)); 4186 set_register(sp, current_sp + sizeof(uintptr_t));
4133 return address; 4187 return address;
4134 } 4188 }
4135 } // namespace internal 4189 } // namespace internal
4136 } // namespace v8 4190 } // namespace v8
4137 4191
4138 #endif // USE_SIMULATOR 4192 #endif // USE_SIMULATOR
4139 #endif // V8_TARGET_ARCH_PPC 4193 #endif // V8_TARGET_ARCH_PPC
OLDNEW
« no previous file with comments | « src/ppc/disasm-ppc.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698