OLD | NEW |
1 // Copyright 2011 the V8 project authors. All rights reserved. | 1 // Copyright 2011 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 <limits.h> | 5 #include <limits.h> |
6 #include <stdarg.h> | 6 #include <stdarg.h> |
7 #include <stdlib.h> | 7 #include <stdlib.h> |
8 #include <cmath> | 8 #include <cmath> |
9 | 9 |
10 #if V8_TARGET_ARCH_MIPS64 | 10 #if V8_TARGET_ARCH_MIPS64 |
(...skipping 1725 matching lines...) Loading... |
1736 // TODO(plind): sign-extend and zero-extend not implmented properly | 1736 // TODO(plind): sign-extend and zero-extend not implmented properly |
1737 // on all the ReadXX functions, I don't think re-interpret cast does it. | 1737 // on all the ReadXX functions, I don't think re-interpret cast does it. |
1738 int32_t Simulator::ReadW(int64_t addr, Instruction* instr) { | 1738 int32_t Simulator::ReadW(int64_t addr, Instruction* instr) { |
1739 if (addr >=0 && addr < 0x400) { | 1739 if (addr >=0 && addr < 0x400) { |
1740 // This has to be a NULL-dereference, drop into debugger. | 1740 // This has to be a NULL-dereference, drop into debugger. |
1741 PrintF("Memory read from bad address: 0x%08" PRIx64 " , pc=0x%08" PRIxPTR | 1741 PrintF("Memory read from bad address: 0x%08" PRIx64 " , pc=0x%08" PRIxPTR |
1742 " \n", | 1742 " \n", |
1743 addr, reinterpret_cast<intptr_t>(instr)); | 1743 addr, reinterpret_cast<intptr_t>(instr)); |
1744 DieOrDebug(); | 1744 DieOrDebug(); |
1745 } | 1745 } |
1746 if ((addr & 0x3) == 0) { | 1746 if ((addr & 0x3) == 0 || kArchVariant == kMips64r6) { |
1747 int32_t* ptr = reinterpret_cast<int32_t*>(addr); | 1747 int32_t* ptr = reinterpret_cast<int32_t*>(addr); |
1748 TraceMemRd(addr, static_cast<int64_t>(*ptr)); | 1748 TraceMemRd(addr, static_cast<int64_t>(*ptr)); |
1749 return *ptr; | 1749 return *ptr; |
1750 } | 1750 } |
1751 PrintF("Unaligned read at 0x%08" PRIx64 " , pc=0x%08" V8PRIxPTR "\n", addr, | 1751 PrintF("Unaligned read at 0x%08" PRIx64 " , pc=0x%08" V8PRIxPTR "\n", addr, |
1752 reinterpret_cast<intptr_t>(instr)); | 1752 reinterpret_cast<intptr_t>(instr)); |
1753 DieOrDebug(); | 1753 DieOrDebug(); |
1754 return 0; | 1754 return 0; |
1755 } | 1755 } |
1756 | 1756 |
1757 | 1757 |
1758 uint32_t Simulator::ReadWU(int64_t addr, Instruction* instr) { | 1758 uint32_t Simulator::ReadWU(int64_t addr, Instruction* instr) { |
1759 if (addr >=0 && addr < 0x400) { | 1759 if (addr >=0 && addr < 0x400) { |
1760 // This has to be a NULL-dereference, drop into debugger. | 1760 // This has to be a NULL-dereference, drop into debugger. |
1761 PrintF("Memory read from bad address: 0x%08" PRIx64 " , pc=0x%08" PRIxPTR | 1761 PrintF("Memory read from bad address: 0x%08" PRIx64 " , pc=0x%08" PRIxPTR |
1762 " \n", | 1762 " \n", |
1763 addr, reinterpret_cast<intptr_t>(instr)); | 1763 addr, reinterpret_cast<intptr_t>(instr)); |
1764 DieOrDebug(); | 1764 DieOrDebug(); |
1765 } | 1765 } |
1766 if ((addr & 0x3) == 0) { | 1766 if ((addr & 0x3) == 0 || kArchVariant == kMips64r6) { |
1767 uint32_t* ptr = reinterpret_cast<uint32_t*>(addr); | 1767 uint32_t* ptr = reinterpret_cast<uint32_t*>(addr); |
1768 TraceMemRd(addr, static_cast<int64_t>(*ptr)); | 1768 TraceMemRd(addr, static_cast<int64_t>(*ptr)); |
1769 return *ptr; | 1769 return *ptr; |
1770 } | 1770 } |
1771 PrintF("Unaligned read at 0x%08" PRIx64 " , pc=0x%08" V8PRIxPTR "\n", addr, | 1771 PrintF("Unaligned read at 0x%08" PRIx64 " , pc=0x%08" V8PRIxPTR "\n", addr, |
1772 reinterpret_cast<intptr_t>(instr)); | 1772 reinterpret_cast<intptr_t>(instr)); |
1773 DieOrDebug(); | 1773 DieOrDebug(); |
1774 return 0; | 1774 return 0; |
1775 } | 1775 } |
1776 | 1776 |
1777 | 1777 |
1778 void Simulator::WriteW(int64_t addr, int32_t value, Instruction* instr) { | 1778 void Simulator::WriteW(int64_t addr, int32_t value, Instruction* instr) { |
1779 if (addr >= 0 && addr < 0x400) { | 1779 if (addr >= 0 && addr < 0x400) { |
1780 // This has to be a NULL-dereference, drop into debugger. | 1780 // This has to be a NULL-dereference, drop into debugger. |
1781 PrintF("Memory write to bad address: 0x%08" PRIx64 " , pc=0x%08" PRIxPTR | 1781 PrintF("Memory write to bad address: 0x%08" PRIx64 " , pc=0x%08" PRIxPTR |
1782 " \n", | 1782 " \n", |
1783 addr, reinterpret_cast<intptr_t>(instr)); | 1783 addr, reinterpret_cast<intptr_t>(instr)); |
1784 DieOrDebug(); | 1784 DieOrDebug(); |
1785 } | 1785 } |
1786 if ((addr & 0x3) == 0) { | 1786 if ((addr & 0x3) == 0 || kArchVariant == kMips64r6) { |
1787 TraceMemWr(addr, value, WORD); | 1787 TraceMemWr(addr, value, WORD); |
1788 int* ptr = reinterpret_cast<int*>(addr); | 1788 int* ptr = reinterpret_cast<int*>(addr); |
1789 *ptr = value; | 1789 *ptr = value; |
1790 return; | 1790 return; |
1791 } | 1791 } |
1792 PrintF("Unaligned write at 0x%08" PRIx64 " , pc=0x%08" V8PRIxPTR "\n", addr, | 1792 PrintF("Unaligned write at 0x%08" PRIx64 " , pc=0x%08" V8PRIxPTR "\n", addr, |
1793 reinterpret_cast<intptr_t>(instr)); | 1793 reinterpret_cast<intptr_t>(instr)); |
1794 DieOrDebug(); | 1794 DieOrDebug(); |
1795 } | 1795 } |
1796 | 1796 |
1797 | 1797 |
1798 int64_t Simulator::Read2W(int64_t addr, Instruction* instr) { | 1798 int64_t Simulator::Read2W(int64_t addr, Instruction* instr) { |
1799 if (addr >=0 && addr < 0x400) { | 1799 if (addr >=0 && addr < 0x400) { |
1800 // This has to be a NULL-dereference, drop into debugger. | 1800 // This has to be a NULL-dereference, drop into debugger. |
1801 PrintF("Memory read from bad address: 0x%08" PRIx64 " , pc=0x%08" PRIxPTR | 1801 PrintF("Memory read from bad address: 0x%08" PRIx64 " , pc=0x%08" PRIxPTR |
1802 " \n", | 1802 " \n", |
1803 addr, reinterpret_cast<intptr_t>(instr)); | 1803 addr, reinterpret_cast<intptr_t>(instr)); |
1804 DieOrDebug(); | 1804 DieOrDebug(); |
1805 } | 1805 } |
1806 if ((addr & kPointerAlignmentMask) == 0) { | 1806 if ((addr & kPointerAlignmentMask) == 0 || kArchVariant == kMips64r6) { |
1807 int64_t* ptr = reinterpret_cast<int64_t*>(addr); | 1807 int64_t* ptr = reinterpret_cast<int64_t*>(addr); |
1808 TraceMemRd(addr, *ptr); | 1808 TraceMemRd(addr, *ptr); |
1809 return *ptr; | 1809 return *ptr; |
1810 } | 1810 } |
1811 PrintF("Unaligned read at 0x%08" PRIx64 " , pc=0x%08" V8PRIxPTR "\n", addr, | 1811 PrintF("Unaligned read at 0x%08" PRIx64 " , pc=0x%08" V8PRIxPTR "\n", addr, |
1812 reinterpret_cast<intptr_t>(instr)); | 1812 reinterpret_cast<intptr_t>(instr)); |
1813 DieOrDebug(); | 1813 DieOrDebug(); |
1814 return 0; | 1814 return 0; |
1815 } | 1815 } |
1816 | 1816 |
1817 | 1817 |
1818 void Simulator::Write2W(int64_t addr, int64_t value, Instruction* instr) { | 1818 void Simulator::Write2W(int64_t addr, int64_t value, Instruction* instr) { |
1819 if (addr >= 0 && addr < 0x400) { | 1819 if (addr >= 0 && addr < 0x400) { |
1820 // This has to be a NULL-dereference, drop into debugger. | 1820 // This has to be a NULL-dereference, drop into debugger. |
1821 PrintF("Memory write to bad address: 0x%08" PRIx64 " , pc=0x%08" PRIxPTR | 1821 PrintF("Memory write to bad address: 0x%08" PRIx64 " , pc=0x%08" PRIxPTR |
1822 "\n", | 1822 "\n", |
1823 addr, reinterpret_cast<intptr_t>(instr)); | 1823 addr, reinterpret_cast<intptr_t>(instr)); |
1824 DieOrDebug(); | 1824 DieOrDebug(); |
1825 } | 1825 } |
1826 if ((addr & kPointerAlignmentMask) == 0) { | 1826 if ((addr & kPointerAlignmentMask) == 0 || kArchVariant == kMips64r6) { |
1827 TraceMemWr(addr, value, DWORD); | 1827 TraceMemWr(addr, value, DWORD); |
1828 int64_t* ptr = reinterpret_cast<int64_t*>(addr); | 1828 int64_t* ptr = reinterpret_cast<int64_t*>(addr); |
1829 *ptr = value; | 1829 *ptr = value; |
1830 return; | 1830 return; |
1831 } | 1831 } |
1832 PrintF("Unaligned write at 0x%08" PRIx64 " , pc=0x%08" V8PRIxPTR "\n", addr, | 1832 PrintF("Unaligned write at 0x%08" PRIx64 " , pc=0x%08" V8PRIxPTR "\n", addr, |
1833 reinterpret_cast<intptr_t>(instr)); | 1833 reinterpret_cast<intptr_t>(instr)); |
1834 DieOrDebug(); | 1834 DieOrDebug(); |
1835 } | 1835 } |
1836 | 1836 |
1837 | 1837 |
1838 double Simulator::ReadD(int64_t addr, Instruction* instr) { | 1838 double Simulator::ReadD(int64_t addr, Instruction* instr) { |
1839 if ((addr & kDoubleAlignmentMask) == 0) { | 1839 if ((addr & kDoubleAlignmentMask) == 0 || kArchVariant == kMips64r6) { |
1840 double* ptr = reinterpret_cast<double*>(addr); | 1840 double* ptr = reinterpret_cast<double*>(addr); |
1841 return *ptr; | 1841 return *ptr; |
1842 } | 1842 } |
1843 PrintF("Unaligned (double) read at 0x%08" PRIx64 " , pc=0x%08" V8PRIxPTR "\n", | 1843 PrintF("Unaligned (double) read at 0x%08" PRIx64 " , pc=0x%08" V8PRIxPTR "\n", |
1844 addr, reinterpret_cast<intptr_t>(instr)); | 1844 addr, reinterpret_cast<intptr_t>(instr)); |
1845 base::OS::Abort(); | 1845 base::OS::Abort(); |
1846 return 0; | 1846 return 0; |
1847 } | 1847 } |
1848 | 1848 |
1849 | 1849 |
1850 void Simulator::WriteD(int64_t addr, double value, Instruction* instr) { | 1850 void Simulator::WriteD(int64_t addr, double value, Instruction* instr) { |
1851 if ((addr & kDoubleAlignmentMask) == 0) { | 1851 if ((addr & kDoubleAlignmentMask) == 0 || kArchVariant == kMips64r6) { |
1852 double* ptr = reinterpret_cast<double*>(addr); | 1852 double* ptr = reinterpret_cast<double*>(addr); |
1853 *ptr = value; | 1853 *ptr = value; |
1854 return; | 1854 return; |
1855 } | 1855 } |
1856 PrintF("Unaligned (double) write at 0x%08" PRIx64 " , pc=0x%08" V8PRIxPTR | 1856 PrintF("Unaligned (double) write at 0x%08" PRIx64 " , pc=0x%08" V8PRIxPTR |
1857 "\n", | 1857 "\n", |
1858 addr, reinterpret_cast<intptr_t>(instr)); | 1858 addr, reinterpret_cast<intptr_t>(instr)); |
1859 DieOrDebug(); | 1859 DieOrDebug(); |
1860 } | 1860 } |
1861 | 1861 |
1862 | 1862 |
1863 uint16_t Simulator::ReadHU(int64_t addr, Instruction* instr) { | 1863 uint16_t Simulator::ReadHU(int64_t addr, Instruction* instr) { |
1864 if ((addr & 1) == 0) { | 1864 if ((addr & 1) == 0 || kArchVariant == kMips64r6) { |
1865 uint16_t* ptr = reinterpret_cast<uint16_t*>(addr); | 1865 uint16_t* ptr = reinterpret_cast<uint16_t*>(addr); |
1866 TraceMemRd(addr, static_cast<int64_t>(*ptr)); | 1866 TraceMemRd(addr, static_cast<int64_t>(*ptr)); |
1867 return *ptr; | 1867 return *ptr; |
1868 } | 1868 } |
1869 PrintF("Unaligned unsigned halfword read at 0x%08" PRIx64 | 1869 PrintF("Unaligned unsigned halfword read at 0x%08" PRIx64 |
1870 " , pc=0x%08" V8PRIxPTR "\n", | 1870 " , pc=0x%08" V8PRIxPTR "\n", |
1871 addr, reinterpret_cast<intptr_t>(instr)); | 1871 addr, reinterpret_cast<intptr_t>(instr)); |
1872 DieOrDebug(); | 1872 DieOrDebug(); |
1873 return 0; | 1873 return 0; |
1874 } | 1874 } |
1875 | 1875 |
1876 | 1876 |
1877 int16_t Simulator::ReadH(int64_t addr, Instruction* instr) { | 1877 int16_t Simulator::ReadH(int64_t addr, Instruction* instr) { |
1878 if ((addr & 1) == 0) { | 1878 if ((addr & 1) == 0 || kArchVariant == kMips64r6) { |
1879 int16_t* ptr = reinterpret_cast<int16_t*>(addr); | 1879 int16_t* ptr = reinterpret_cast<int16_t*>(addr); |
1880 TraceMemRd(addr, static_cast<int64_t>(*ptr)); | 1880 TraceMemRd(addr, static_cast<int64_t>(*ptr)); |
1881 return *ptr; | 1881 return *ptr; |
1882 } | 1882 } |
1883 PrintF("Unaligned signed halfword read at 0x%08" PRIx64 | 1883 PrintF("Unaligned signed halfword read at 0x%08" PRIx64 |
1884 " , pc=0x%08" V8PRIxPTR "\n", | 1884 " , pc=0x%08" V8PRIxPTR "\n", |
1885 addr, reinterpret_cast<intptr_t>(instr)); | 1885 addr, reinterpret_cast<intptr_t>(instr)); |
1886 DieOrDebug(); | 1886 DieOrDebug(); |
1887 return 0; | 1887 return 0; |
1888 } | 1888 } |
1889 | 1889 |
1890 | 1890 |
1891 void Simulator::WriteH(int64_t addr, uint16_t value, Instruction* instr) { | 1891 void Simulator::WriteH(int64_t addr, uint16_t value, Instruction* instr) { |
1892 if ((addr & 1) == 0) { | 1892 if ((addr & 1) == 0 || kArchVariant == kMips64r6) { |
1893 TraceMemWr(addr, value, HALF); | 1893 TraceMemWr(addr, value, HALF); |
1894 uint16_t* ptr = reinterpret_cast<uint16_t*>(addr); | 1894 uint16_t* ptr = reinterpret_cast<uint16_t*>(addr); |
1895 *ptr = value; | 1895 *ptr = value; |
1896 return; | 1896 return; |
1897 } | 1897 } |
1898 PrintF("Unaligned unsigned halfword write at 0x%08" PRIx64 | 1898 PrintF("Unaligned unsigned halfword write at 0x%08" PRIx64 |
1899 " , pc=0x%08" V8PRIxPTR "\n", | 1899 " , pc=0x%08" V8PRIxPTR "\n", |
1900 addr, reinterpret_cast<intptr_t>(instr)); | 1900 addr, reinterpret_cast<intptr_t>(instr)); |
1901 DieOrDebug(); | 1901 DieOrDebug(); |
1902 } | 1902 } |
1903 | 1903 |
1904 | 1904 |
1905 void Simulator::WriteH(int64_t addr, int16_t value, Instruction* instr) { | 1905 void Simulator::WriteH(int64_t addr, int16_t value, Instruction* instr) { |
1906 if ((addr & 1) == 0) { | 1906 if ((addr & 1) == 0 || kArchVariant == kMips64r6) { |
1907 TraceMemWr(addr, value, HALF); | 1907 TraceMemWr(addr, value, HALF); |
1908 int16_t* ptr = reinterpret_cast<int16_t*>(addr); | 1908 int16_t* ptr = reinterpret_cast<int16_t*>(addr); |
1909 *ptr = value; | 1909 *ptr = value; |
1910 return; | 1910 return; |
1911 } | 1911 } |
1912 PrintF("Unaligned halfword write at 0x%08" PRIx64 " , pc=0x%08" V8PRIxPTR | 1912 PrintF("Unaligned halfword write at 0x%08" PRIx64 " , pc=0x%08" V8PRIxPTR |
1913 "\n", | 1913 "\n", |
1914 addr, reinterpret_cast<intptr_t>(instr)); | 1914 addr, reinterpret_cast<intptr_t>(instr)); |
1915 DieOrDebug(); | 1915 DieOrDebug(); |
1916 } | 1916 } |
(...skipping 2237 matching lines...) Loading... |
4154 // Used for conditional branch instructions. | 4154 // Used for conditional branch instructions. |
4155 bool execute_branch_delay_instruction = false; | 4155 bool execute_branch_delay_instruction = false; |
4156 | 4156 |
4157 // Used for arithmetic instructions. | 4157 // Used for arithmetic instructions. |
4158 int64_t alu_out = 0; | 4158 int64_t alu_out = 0; |
4159 | 4159 |
4160 // Used for memory instructions. | 4160 // Used for memory instructions. |
4161 int64_t addr = 0x0; | 4161 int64_t addr = 0x0; |
4162 // Alignment for 32-bit integers used in LWL, LWR, etc. | 4162 // Alignment for 32-bit integers used in LWL, LWR, etc. |
4163 const int kInt32AlignmentMask = sizeof(uint32_t) - 1; | 4163 const int kInt32AlignmentMask = sizeof(uint32_t) - 1; |
| 4164 // Alignment for 64-bit integers used in LDL, LDR, etc. |
| 4165 const int kInt64AlignmentMask = sizeof(uint64_t) - 1; |
4164 | 4166 |
4165 // Branch instructions common part. | 4167 // Branch instructions common part. |
4166 auto BranchAndLinkHelper = [this, instr, &next_pc, | 4168 auto BranchAndLinkHelper = [this, instr, &next_pc, |
4167 &execute_branch_delay_instruction]( | 4169 &execute_branch_delay_instruction]( |
4168 bool do_branch) { | 4170 bool do_branch) { |
4169 execute_branch_delay_instruction = true; | 4171 execute_branch_delay_instruction = true; |
4170 int64_t current_pc = get_pc(); | 4172 int64_t current_pc = get_pc(); |
4171 if (do_branch) { | 4173 if (do_branch) { |
4172 int16_t imm16 = instr->Imm16Value(); | 4174 int16_t imm16 = instr->Imm16Value(); |
4173 next_pc = current_pc + (imm16 << 2) + Instruction::kInstrSize; | 4175 next_pc = current_pc + (imm16 << 2) + Instruction::kInstrSize; |
(...skipping 281 matching lines...) Loading... |
4455 break; | 4457 break; |
4456 case LH: | 4458 case LH: |
4457 set_register(rt_reg, ReadH(rs + se_imm16, instr)); | 4459 set_register(rt_reg, ReadH(rs + se_imm16, instr)); |
4458 break; | 4460 break; |
4459 case LWL: { | 4461 case LWL: { |
4460 // al_offset is offset of the effective address within an aligned word. | 4462 // al_offset is offset of the effective address within an aligned word. |
4461 uint8_t al_offset = (rs + se_imm16) & kInt32AlignmentMask; | 4463 uint8_t al_offset = (rs + se_imm16) & kInt32AlignmentMask; |
4462 uint8_t byte_shift = kInt32AlignmentMask - al_offset; | 4464 uint8_t byte_shift = kInt32AlignmentMask - al_offset; |
4463 uint32_t mask = (1 << byte_shift * 8) - 1; | 4465 uint32_t mask = (1 << byte_shift * 8) - 1; |
4464 addr = rs + se_imm16 - al_offset; | 4466 addr = rs + se_imm16 - al_offset; |
4465 alu_out = ReadW(addr, instr); | 4467 int32_t val = ReadW(addr, instr); |
4466 alu_out <<= byte_shift * 8; | 4468 val <<= byte_shift * 8; |
4467 alu_out |= rt & mask; | 4469 val |= rt & mask; |
4468 set_register(rt_reg, alu_out); | 4470 set_register(rt_reg, static_cast<int64_t>(val)); |
4469 break; | 4471 break; |
4470 } | 4472 } |
4471 case LW: | 4473 case LW: |
4472 set_register(rt_reg, ReadW(rs + se_imm16, instr)); | 4474 set_register(rt_reg, ReadW(rs + se_imm16, instr)); |
4473 break; | 4475 break; |
4474 case LWU: | 4476 case LWU: |
4475 set_register(rt_reg, ReadWU(rs + se_imm16, instr)); | 4477 set_register(rt_reg, ReadWU(rs + se_imm16, instr)); |
4476 break; | 4478 break; |
4477 case LD: | 4479 case LD: |
4478 set_register(rt_reg, Read2W(rs + se_imm16, instr)); | 4480 set_register(rt_reg, Read2W(rs + se_imm16, instr)); |
4479 break; | 4481 break; |
4480 case LBU: | 4482 case LBU: |
4481 set_register(rt_reg, ReadBU(rs + se_imm16)); | 4483 set_register(rt_reg, ReadBU(rs + se_imm16)); |
4482 break; | 4484 break; |
4483 case LHU: | 4485 case LHU: |
4484 set_register(rt_reg, ReadHU(rs + se_imm16, instr)); | 4486 set_register(rt_reg, ReadHU(rs + se_imm16, instr)); |
4485 break; | 4487 break; |
4486 case LWR: { | 4488 case LWR: { |
4487 // al_offset is offset of the effective address within an aligned word. | 4489 // al_offset is offset of the effective address within an aligned word. |
4488 uint8_t al_offset = (rs + se_imm16) & kInt32AlignmentMask; | 4490 uint8_t al_offset = (rs + se_imm16) & kInt32AlignmentMask; |
4489 uint8_t byte_shift = kInt32AlignmentMask - al_offset; | 4491 uint8_t byte_shift = kInt32AlignmentMask - al_offset; |
4490 uint32_t mask = al_offset ? (~0 << (byte_shift + 1) * 8) : 0; | 4492 uint32_t mask = al_offset ? (~0 << (byte_shift + 1) * 8) : 0; |
4491 addr = rs + se_imm16 - al_offset; | 4493 addr = rs + se_imm16 - al_offset; |
4492 alu_out = ReadW(addr, instr); | 4494 alu_out = ReadW(addr, instr); |
4493 alu_out = static_cast<uint32_t> (alu_out) >> al_offset * 8; | 4495 alu_out = static_cast<uint32_t> (alu_out) >> al_offset * 8; |
4494 alu_out |= rt & mask; | 4496 alu_out |= rt & mask; |
4495 set_register(rt_reg, alu_out); | 4497 set_register(rt_reg, alu_out); |
4496 break; | 4498 break; |
4497 } | 4499 } |
| 4500 case LDL: { |
| 4501 // al_offset is offset of the effective address within an aligned word. |
| 4502 uint8_t al_offset = (rs + se_imm16) & kInt64AlignmentMask; |
| 4503 uint8_t byte_shift = kInt64AlignmentMask - al_offset; |
| 4504 uint64_t mask = (1UL << byte_shift * 8) - 1; |
| 4505 addr = rs + se_imm16 - al_offset; |
| 4506 alu_out = Read2W(addr, instr); |
| 4507 alu_out <<= byte_shift * 8; |
| 4508 alu_out |= rt & mask; |
| 4509 set_register(rt_reg, alu_out); |
| 4510 break; |
| 4511 } |
| 4512 case LDR: { |
| 4513 // al_offset is offset of the effective address within an aligned word. |
| 4514 uint8_t al_offset = (rs + se_imm16) & kInt64AlignmentMask; |
| 4515 uint8_t byte_shift = kInt64AlignmentMask - al_offset; |
| 4516 uint64_t mask = al_offset ? (~0UL << (byte_shift + 1) * 8) : 0UL; |
| 4517 addr = rs + se_imm16 - al_offset; |
| 4518 alu_out = Read2W(addr, instr); |
| 4519 alu_out = alu_out >> al_offset * 8; |
| 4520 alu_out |= rt & mask; |
| 4521 set_register(rt_reg, alu_out); |
| 4522 break; |
| 4523 } |
4498 case SB: | 4524 case SB: |
4499 WriteB(rs + se_imm16, static_cast<int8_t>(rt)); | 4525 WriteB(rs + se_imm16, static_cast<int8_t>(rt)); |
4500 break; | 4526 break; |
4501 case SH: | 4527 case SH: |
4502 WriteH(rs + se_imm16, static_cast<uint16_t>(rt), instr); | 4528 WriteH(rs + se_imm16, static_cast<uint16_t>(rt), instr); |
4503 break; | 4529 break; |
4504 case SWL: { | 4530 case SWL: { |
4505 uint8_t al_offset = (rs + se_imm16) & kInt32AlignmentMask; | 4531 uint8_t al_offset = (rs + se_imm16) & kInt32AlignmentMask; |
4506 uint8_t byte_shift = kInt32AlignmentMask - al_offset; | 4532 uint8_t byte_shift = kInt32AlignmentMask - al_offset; |
4507 uint32_t mask = byte_shift ? (~0 << (al_offset + 1) * 8) : 0; | 4533 uint32_t mask = byte_shift ? (~0 << (al_offset + 1) * 8) : 0; |
(...skipping 11 matching lines...) Loading... |
4519 break; | 4545 break; |
4520 case SWR: { | 4546 case SWR: { |
4521 uint8_t al_offset = (rs + se_imm16) & kInt32AlignmentMask; | 4547 uint8_t al_offset = (rs + se_imm16) & kInt32AlignmentMask; |
4522 uint32_t mask = (1 << al_offset * 8) - 1; | 4548 uint32_t mask = (1 << al_offset * 8) - 1; |
4523 addr = rs + se_imm16 - al_offset; | 4549 addr = rs + se_imm16 - al_offset; |
4524 uint64_t mem_value = ReadW(addr, instr); | 4550 uint64_t mem_value = ReadW(addr, instr); |
4525 mem_value = (rt << al_offset * 8) | (mem_value & mask); | 4551 mem_value = (rt << al_offset * 8) | (mem_value & mask); |
4526 WriteW(addr, static_cast<int32_t>(mem_value), instr); | 4552 WriteW(addr, static_cast<int32_t>(mem_value), instr); |
4527 break; | 4553 break; |
4528 } | 4554 } |
| 4555 case SDL: { |
| 4556 uint8_t al_offset = (rs + se_imm16) & kInt64AlignmentMask; |
| 4557 uint8_t byte_shift = kInt64AlignmentMask - al_offset; |
| 4558 uint64_t mask = byte_shift ? (~0UL << (al_offset + 1) * 8) : 0; |
| 4559 addr = rs + se_imm16 - al_offset; |
| 4560 uint64_t mem_value = Read2W(addr, instr) & mask; |
| 4561 mem_value |= rt >> byte_shift * 8; |
| 4562 Write2W(addr, mem_value, instr); |
| 4563 break; |
| 4564 } |
| 4565 case SDR: { |
| 4566 uint8_t al_offset = (rs + se_imm16) & kInt64AlignmentMask; |
| 4567 uint64_t mask = (1UL << al_offset * 8) - 1; |
| 4568 addr = rs + se_imm16 - al_offset; |
| 4569 uint64_t mem_value = Read2W(addr, instr); |
| 4570 mem_value = (rt << al_offset * 8) | (mem_value & mask); |
| 4571 Write2W(addr, mem_value, instr); |
| 4572 break; |
| 4573 } |
4529 case LWC1: | 4574 case LWC1: |
4530 set_fpu_register(ft_reg, kFPUInvalidResult); // Trash upper 32 bits. | 4575 set_fpu_register(ft_reg, kFPUInvalidResult); // Trash upper 32 bits. |
4531 set_fpu_register_word(ft_reg, ReadW(rs + se_imm16, instr)); | 4576 set_fpu_register_word(ft_reg, ReadW(rs + se_imm16, instr)); |
4532 break; | 4577 break; |
4533 case LDC1: | 4578 case LDC1: |
4534 set_fpu_register_double(ft_reg, ReadD(rs + se_imm16, instr)); | 4579 set_fpu_register_double(ft_reg, ReadD(rs + se_imm16, instr)); |
4535 break; | 4580 break; |
4536 case SWC1: { | 4581 case SWC1: { |
4537 int32_t alu_out_32 = static_cast<int32_t>(get_fpu_register(ft_reg)); | 4582 int32_t alu_out_32 = static_cast<int32_t>(get_fpu_register(ft_reg)); |
4538 WriteW(rs + se_imm16, alu_out_32, instr); | 4583 WriteW(rs + se_imm16, alu_out_32, instr); |
(...skipping 350 matching lines...) Loading... |
4889 } | 4934 } |
4890 | 4935 |
4891 | 4936 |
4892 #undef UNSUPPORTED | 4937 #undef UNSUPPORTED |
4893 } // namespace internal | 4938 } // namespace internal |
4894 } // namespace v8 | 4939 } // namespace v8 |
4895 | 4940 |
4896 #endif // USE_SIMULATOR | 4941 #endif // USE_SIMULATOR |
4897 | 4942 |
4898 #endif // V8_TARGET_ARCH_MIPS64 | 4943 #endif // V8_TARGET_ARCH_MIPS64 |
OLD | NEW |