OLD | NEW |
1 // Copyright 2011 the V8 project authors. All rights reserved. | 1 // Copyright 2011 the V8 project authors. All rights reserved. |
2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
4 // met: | 4 // met: |
5 // | 5 // |
6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
(...skipping 1704 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1715 } | 1715 } |
1716 | 1716 |
1717 | 1717 |
1718 // Handle execution based on instruction types. | 1718 // Handle execution based on instruction types. |
1719 | 1719 |
1720 void Simulator::ConfigureTypeRegister(Instruction* instr, | 1720 void Simulator::ConfigureTypeRegister(Instruction* instr, |
1721 int32_t& alu_out, | 1721 int32_t& alu_out, |
1722 int64_t& i64hilo, | 1722 int64_t& i64hilo, |
1723 uint64_t& u64hilo, | 1723 uint64_t& u64hilo, |
1724 int32_t& next_pc, | 1724 int32_t& next_pc, |
| 1725 int32_t& return_addr_reg, |
1725 bool& do_interrupt) { | 1726 bool& do_interrupt) { |
1726 // Every local variable declared here needs to be const. | 1727 // Every local variable declared here needs to be const. |
1727 // This is to make sure that changed values are sent back to | 1728 // This is to make sure that changed values are sent back to |
1728 // DecodeTypeRegister correctly. | 1729 // DecodeTypeRegister correctly. |
1729 | 1730 |
1730 // Instruction fields. | 1731 // Instruction fields. |
1731 const Opcode op = instr->OpcodeFieldRaw(); | 1732 const Opcode op = instr->OpcodeFieldRaw(); |
1732 const int32_t rs_reg = instr->RsValue(); | 1733 const int32_t rs_reg = instr->RsValue(); |
1733 const int32_t rs = get_register(rs_reg); | 1734 const int32_t rs = get_register(rs_reg); |
1734 const uint32_t rs_u = static_cast<uint32_t>(rs); | 1735 const uint32_t rs_u = static_cast<uint32_t>(rs); |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1775 UNIMPLEMENTED_MIPS(); | 1776 UNIMPLEMENTED_MIPS(); |
1776 }; | 1777 }; |
1777 break; | 1778 break; |
1778 case COP1X: | 1779 case COP1X: |
1779 break; | 1780 break; |
1780 case SPECIAL: | 1781 case SPECIAL: |
1781 switch (instr->FunctionFieldRaw()) { | 1782 switch (instr->FunctionFieldRaw()) { |
1782 case JR: | 1783 case JR: |
1783 case JALR: | 1784 case JALR: |
1784 next_pc = get_register(instr->RsValue()); | 1785 next_pc = get_register(instr->RsValue()); |
| 1786 return_addr_reg = instr->RdValue(); |
1785 break; | 1787 break; |
1786 case SLL: | 1788 case SLL: |
1787 alu_out = rt << sa; | 1789 alu_out = rt << sa; |
1788 break; | 1790 break; |
1789 case SRL: | 1791 case SRL: |
1790 if (rs_reg == 0) { | 1792 if (rs_reg == 0) { |
1791 // Regular logical right shift of a word by a fixed number of | 1793 // Regular logical right shift of a word by a fixed number of |
1792 // bits instruction. RS field is always equal to 0. | 1794 // bits instruction. RS field is always equal to 0. |
1793 alu_out = rt_u >> sa; | 1795 alu_out = rt_u >> sa; |
1794 } else { | 1796 } else { |
(...skipping 184 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1979 int32_t alu_out = 0x12345678; | 1981 int32_t alu_out = 0x12345678; |
1980 | 1982 |
1981 // For break and trap instructions. | 1983 // For break and trap instructions. |
1982 bool do_interrupt = false; | 1984 bool do_interrupt = false; |
1983 | 1985 |
1984 // For jr and jalr. | 1986 // For jr and jalr. |
1985 // Get current pc. | 1987 // Get current pc. |
1986 int32_t current_pc = get_pc(); | 1988 int32_t current_pc = get_pc(); |
1987 // Next pc | 1989 // Next pc |
1988 int32_t next_pc = 0; | 1990 int32_t next_pc = 0; |
| 1991 int32_t return_addr_reg = 31; |
1989 | 1992 |
1990 // Set up the variables if needed before executing the instruction. | 1993 // Set up the variables if needed before executing the instruction. |
1991 ConfigureTypeRegister(instr, | 1994 ConfigureTypeRegister(instr, |
1992 alu_out, | 1995 alu_out, |
1993 i64hilo, | 1996 i64hilo, |
1994 u64hilo, | 1997 u64hilo, |
1995 next_pc, | 1998 next_pc, |
| 1999 return_addr_reg, |
1996 do_interrupt); | 2000 do_interrupt); |
1997 | 2001 |
1998 // ---------- Raise exceptions triggered. | 2002 // ---------- Raise exceptions triggered. |
1999 SignalExceptions(); | 2003 SignalExceptions(); |
2000 | 2004 |
2001 // ---------- Execution. | 2005 // ---------- Execution. |
2002 switch (op) { | 2006 switch (op) { |
2003 case COP1: | 2007 case COP1: |
2004 switch (instr->RsFieldRaw()) { | 2008 switch (instr->RsFieldRaw()) { |
2005 case BC1: // Branch on coprocessor condition. | 2009 case BC1: // Branch on coprocessor condition. |
(...skipping 245 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2251 current_pc+Instruction::kInstrSize); | 2255 current_pc+Instruction::kInstrSize); |
2252 BranchDelayInstructionDecode(branch_delay_instr); | 2256 BranchDelayInstructionDecode(branch_delay_instr); |
2253 set_pc(next_pc); | 2257 set_pc(next_pc); |
2254 pc_modified_ = true; | 2258 pc_modified_ = true; |
2255 break; | 2259 break; |
2256 } | 2260 } |
2257 case JALR: { | 2261 case JALR: { |
2258 Instruction* branch_delay_instr = reinterpret_cast<Instruction*>( | 2262 Instruction* branch_delay_instr = reinterpret_cast<Instruction*>( |
2259 current_pc+Instruction::kInstrSize); | 2263 current_pc+Instruction::kInstrSize); |
2260 BranchDelayInstructionDecode(branch_delay_instr); | 2264 BranchDelayInstructionDecode(branch_delay_instr); |
2261 set_register(31, current_pc + 2 * Instruction::kInstrSize); | 2265 set_register(return_addr_reg, |
| 2266 current_pc + 2 * Instruction::kInstrSize); |
2262 set_pc(next_pc); | 2267 set_pc(next_pc); |
2263 pc_modified_ = true; | 2268 pc_modified_ = true; |
2264 break; | 2269 break; |
2265 } | 2270 } |
2266 // Instructions using HI and LO registers. | 2271 // Instructions using HI and LO registers. |
2267 case MULT: | 2272 case MULT: |
2268 set_register(LO, static_cast<int32_t>(i64hilo & 0xffffffff)); | 2273 set_register(LO, static_cast<int32_t>(i64hilo & 0xffffffff)); |
2269 set_register(HI, static_cast<int32_t>(i64hilo >> 32)); | 2274 set_register(HI, static_cast<int32_t>(i64hilo >> 32)); |
2270 break; | 2275 break; |
2271 case MULTU: | 2276 case MULTU: |
(...skipping 649 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2921 } | 2926 } |
2922 | 2927 |
2923 | 2928 |
2924 #undef UNSUPPORTED | 2929 #undef UNSUPPORTED |
2925 | 2930 |
2926 } } // namespace v8::internal | 2931 } } // namespace v8::internal |
2927 | 2932 |
2928 #endif // USE_SIMULATOR | 2933 #endif // USE_SIMULATOR |
2929 | 2934 |
2930 #endif // V8_TARGET_ARCH_MIPS | 2935 #endif // V8_TARGET_ARCH_MIPS |
OLD | NEW |