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 #include "src/v8.h" | 10 #include "src/v8.h" |
(...skipping 2255 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2266 break; | 2266 break; |
2267 default: | 2267 default: |
2268 UNREACHABLE(); | 2268 UNREACHABLE(); |
2269 } | 2269 } |
2270 } | 2270 } |
2271 | 2271 |
2272 | 2272 |
2273 void Simulator::DecodeTypeRegisterSRsType(Instruction* instr, | 2273 void Simulator::DecodeTypeRegisterSRsType(Instruction* instr, |
2274 const int32_t& fs_reg, | 2274 const int32_t& fs_reg, |
2275 const int32_t& ft_reg, | 2275 const int32_t& ft_reg, |
2276 const int64_t& fd_reg) { | 2276 const int32_t& fd_reg) { |
2277 float fs, ft; | 2277 float fs, ft; |
2278 fs = get_fpu_register_float(fs_reg); | 2278 fs = get_fpu_register_float(fs_reg); |
2279 ft = get_fpu_register_float(ft_reg); | 2279 ft = get_fpu_register_float(ft_reg); |
2280 uint32_t cc, fcsr_cc; | 2280 uint32_t cc, fcsr_cc; |
2281 cc = instr->FCccValue(); | 2281 cc = instr->FCccValue(); |
2282 fcsr_cc = get_fcsr_condition_bit(cc); | 2282 fcsr_cc = get_fcsr_condition_bit(cc); |
2283 switch (instr->FunctionFieldRaw()) { | 2283 switch (instr->FunctionFieldRaw()) { |
2284 case ADD_D: | 2284 case ADD_D: |
2285 set_fpu_register_float(fd_reg, fs + ft); | 2285 set_fpu_register_float(fd_reg, fs + ft); |
2286 break; | 2286 break; |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2332 default: | 2332 default: |
2333 // CVT_W_S CVT_L_S TRUNC_W_S ROUND_W_S ROUND_L_S FLOOR_W_S FLOOR_L_S | 2333 // CVT_W_S CVT_L_S TRUNC_W_S ROUND_W_S ROUND_L_S FLOOR_W_S FLOOR_L_S |
2334 // CEIL_W_S CEIL_L_S CVT_PS_S are unimplemented. | 2334 // CEIL_W_S CEIL_L_S CVT_PS_S are unimplemented. |
2335 UNREACHABLE(); | 2335 UNREACHABLE(); |
2336 } | 2336 } |
2337 } | 2337 } |
2338 | 2338 |
2339 | 2339 |
2340 void Simulator::DecodeTypeRegisterDRsType(Instruction* instr, | 2340 void Simulator::DecodeTypeRegisterDRsType(Instruction* instr, |
2341 const int32_t& fs_reg, | 2341 const int32_t& fs_reg, |
2342 const int64_t& ft_reg, | 2342 const int32_t& ft_reg, |
2343 const int32_t& fd_reg) { | 2343 const int32_t& fd_reg) { |
2344 double ft, fs; | 2344 double ft, fs, fd; |
2345 uint32_t cc, fcsr_cc; | 2345 uint32_t cc, fcsr_cc; |
2346 fs = get_fpu_register_double(fs_reg); | 2346 fs = get_fpu_register_double(fs_reg); |
2347 ft = get_fpu_register_double(ft_reg); | 2347 ft = get_fpu_register_double(ft_reg); |
2348 fd = get_fpu_register_double(fd_reg); | |
2348 cc = instr->FCccValue(); | 2349 cc = instr->FCccValue(); |
2349 fcsr_cc = get_fcsr_condition_bit(cc); | 2350 fcsr_cc = get_fcsr_condition_bit(cc); |
2350 int64_t ft_int = static_cast<int64_t>(ft); | 2351 int64_t ft_int = bit_cast<int64_t>(ft); |
2352 int64_t fd_int = bit_cast<int64_t>(fd); | |
2351 switch (instr->FunctionFieldRaw()) { | 2353 switch (instr->FunctionFieldRaw()) { |
2354 case SEL: | |
2355 DCHECK(kArchVariant == kMips64r6); | |
2356 set_fpu_register_double(fd_reg, (fd_int & 0x1) == 0 ? fs : ft); | |
2357 break; | |
2352 case SELEQZ_C: | 2358 case SELEQZ_C: |
2353 DCHECK(kArchVariant == kMips64r6); | 2359 DCHECK(kArchVariant == kMips64r6); |
2354 set_fpu_register_double(fd_reg, (ft_int & 0x1) == 0 ? fs : 0.0); | 2360 set_fpu_register_double(fd_reg, (ft_int & 0x1) == 0 ? fs : 0.0); |
2355 break; | 2361 break; |
2356 case SELNEZ_C: | 2362 case SELNEZ_C: |
2357 DCHECK(kArchVariant == kMips64r6); | 2363 DCHECK(kArchVariant == kMips64r6); |
2358 set_fpu_register_double(fd_reg, (ft_int & 0x1) != 0 ? fs : 0.0); | 2364 set_fpu_register_double(fd_reg, (ft_int & 0x1) != 0 ? fs : 0.0); |
2359 break; | 2365 break; |
2366 case MIN: | |
2367 DCHECK(kArchVariant == kMips64r6); | |
2368 fs = get_fpu_register_double(fs_reg); | |
2369 if (std::isnan(fs) && std::isnan(ft)) { | |
2370 set_fpu_register_double(fd_reg, fs); | |
2371 } else if (std::isnan(fs) && !std::isnan(ft)) { | |
2372 set_fpu_register_double(fd_reg, ft); | |
2373 } else if (!std::isnan(fs) && std::isnan(ft)) { | |
2374 set_fpu_register_double(fd_reg, fs); | |
2375 } else { | |
2376 set_fpu_register_double(fd_reg, (fs >= ft) ? ft : fs); | |
2377 } | |
2378 break; | |
2379 case MAX: | |
2380 DCHECK(kArchVariant == kMips64r6); | |
2381 fs = get_fpu_register_double(fs_reg); | |
2382 if (std::isnan(fs) && std::isnan(ft)) { | |
2383 set_fpu_register_double(fd_reg, fs); | |
2384 } else if (std::isnan(fs) && !std::isnan(ft)) { | |
2385 set_fpu_register_double(fd_reg, ft); | |
2386 } else if (!std::isnan(fs) && std::isnan(ft)) { | |
2387 set_fpu_register_double(fd_reg, fs); | |
2388 } else { | |
2389 set_fpu_register_double(fd_reg, (fs <= ft) ? ft : fs); | |
2390 } | |
2391 break; | |
2360 case ADD_D: | 2392 case ADD_D: |
2361 set_fpu_register_double(fd_reg, fs + ft); | 2393 set_fpu_register_double(fd_reg, fs + ft); |
2362 break; | 2394 break; |
2363 case SUB_D: | 2395 case SUB_D: |
2364 set_fpu_register_double(fd_reg, fs - ft); | 2396 set_fpu_register_double(fd_reg, fs - ft); |
2365 break; | 2397 break; |
2366 case MUL_D: | 2398 case MUL_D: |
2367 set_fpu_register_double(fd_reg, fs * ft); | 2399 set_fpu_register_double(fd_reg, fs * ft); |
2368 break; | 2400 break; |
2369 case DIV_D: | 2401 case DIV_D: |
(...skipping 218 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2588 set_fpu_register(fd_reg, 0); | 2620 set_fpu_register(fd_reg, 0); |
2589 } | 2621 } |
2590 break; | 2622 break; |
2591 default: // CMP_OR CMP_UNE CMP_NE UNIMPLEMENTED | 2623 default: // CMP_OR CMP_UNE CMP_NE UNIMPLEMENTED |
2592 UNREACHABLE(); | 2624 UNREACHABLE(); |
2593 } | 2625 } |
2594 } | 2626 } |
2595 | 2627 |
2596 | 2628 |
2597 void Simulator::DecodeTypeRegisterCOP1( | 2629 void Simulator::DecodeTypeRegisterCOP1( |
2598 Instruction* instr, const int64_t& rs_reg, const int64_t& rs, | 2630 Instruction* instr, const int32_t& rs_reg, const int64_t& rs, |
2599 const uint64_t& rs_u, const int64_t& rt_reg, const int64_t& rt, | 2631 const uint64_t& rs_u, const int32_t& rt_reg, const int64_t& rt, |
2600 const uint64_t& rt_u, const int64_t& rd_reg, const int32_t& fr_reg, | 2632 const uint64_t& rt_u, const int32_t& rd_reg, const int32_t& fr_reg, |
2601 const int32_t& fs_reg, const int32_t& ft_reg, const int64_t& fd_reg, | 2633 const int32_t& fs_reg, const int32_t& ft_reg, const int32_t& fd_reg, |
2602 int64_t& alu_out) { | 2634 int64_t& alu_out) { |
2603 switch (instr->RsFieldRaw()) { | 2635 switch (instr->RsFieldRaw()) { |
2604 case BC1: // Branch on coprocessor condition. | 2636 case BC1: // Branch on coprocessor condition. |
2605 case BC1EQZ: | 2637 case BC1EQZ: |
2606 case BC1NEZ: | 2638 case BC1NEZ: |
2607 UNREACHABLE(); | 2639 UNREACHABLE(); |
2608 break; | 2640 break; |
2609 case CFC1: | 2641 case CFC1: |
2610 set_register(rt_reg, alu_out); | 2642 set_register(rt_reg, alu_out); |
2611 break; | 2643 break; |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2645 default: | 2677 default: |
2646 UNREACHABLE(); | 2678 UNREACHABLE(); |
2647 } | 2679 } |
2648 } | 2680 } |
2649 | 2681 |
2650 | 2682 |
2651 void Simulator::DecodeTypeRegisterCOP1X(Instruction* instr, | 2683 void Simulator::DecodeTypeRegisterCOP1X(Instruction* instr, |
2652 const int32_t& fr_reg, | 2684 const int32_t& fr_reg, |
2653 const int32_t& fs_reg, | 2685 const int32_t& fs_reg, |
2654 const int32_t& ft_reg, | 2686 const int32_t& ft_reg, |
2655 const int64_t& fd_reg) { | 2687 const int32_t& fd_reg) { |
2656 switch (instr->FunctionFieldRaw()) { | 2688 switch (instr->FunctionFieldRaw()) { |
2657 case MADD_D: | 2689 case MADD_D: |
2658 double fr, ft, fs; | 2690 double fr, ft, fs; |
2659 fr = get_fpu_register_double(fr_reg); | 2691 fr = get_fpu_register_double(fr_reg); |
2660 fs = get_fpu_register_double(fs_reg); | 2692 fs = get_fpu_register_double(fs_reg); |
2661 ft = get_fpu_register_double(ft_reg); | 2693 ft = get_fpu_register_double(ft_reg); |
2662 set_fpu_register_double(fd_reg, fs * ft + fr); | 2694 set_fpu_register_double(fd_reg, fs * ft + fr); |
2663 break; | 2695 break; |
2664 default: | 2696 default: |
2665 UNREACHABLE(); | 2697 UNREACHABLE(); |
(...skipping 216 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2882 const int64_t rs = get_register(rs_reg); | 2914 const int64_t rs = get_register(rs_reg); |
2883 const uint64_t rs_u = static_cast<uint32_t>(rs); | 2915 const uint64_t rs_u = static_cast<uint32_t>(rs); |
2884 const int64_t rt_reg = instr->RtValue(); | 2916 const int64_t rt_reg = instr->RtValue(); |
2885 const int64_t rt = get_register(rt_reg); | 2917 const int64_t rt = get_register(rt_reg); |
2886 const uint64_t rt_u = static_cast<uint32_t>(rt); | 2918 const uint64_t rt_u = static_cast<uint32_t>(rt); |
2887 const int64_t rd_reg = instr->RdValue(); | 2919 const int64_t rd_reg = instr->RdValue(); |
2888 | 2920 |
2889 const int32_t fr_reg = instr->FrValue(); | 2921 const int32_t fr_reg = instr->FrValue(); |
2890 const int32_t fs_reg = instr->FsValue(); | 2922 const int32_t fs_reg = instr->FsValue(); |
2891 const int32_t ft_reg = instr->FtValue(); | 2923 const int32_t ft_reg = instr->FtValue(); |
2892 const int64_t fd_reg = instr->FdValue(); | 2924 const int32_t fd_reg = instr->FdValue(); |
paul.l...
2015/04/03 17:56:17
tiny nit of a nit: you changed the pretty alignmen
| |
2893 int64_t i64hilo = 0; | 2925 int64_t i64hilo = 0; |
2894 uint64_t u64hilo = 0; | 2926 uint64_t u64hilo = 0; |
2895 | 2927 |
2896 // ALU output. | 2928 // ALU output. |
2897 // It should not be used as is. Instructions using it should always | 2929 // It should not be used as is. Instructions using it should always |
2898 // initialize it first. | 2930 // initialize it first. |
2899 int64_t alu_out = 0x12345678; | 2931 int64_t alu_out = 0x12345678; |
2900 | 2932 |
2901 // For break and trap instructions. | 2933 // For break and trap instructions. |
2902 bool do_interrupt = false; | 2934 bool do_interrupt = false; |
(...skipping 688 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3591 } | 3623 } |
3592 | 3624 |
3593 | 3625 |
3594 #undef UNSUPPORTED | 3626 #undef UNSUPPORTED |
3595 | 3627 |
3596 } } // namespace v8::internal | 3628 } } // namespace v8::internal |
3597 | 3629 |
3598 #endif // USE_SIMULATOR | 3630 #endif // USE_SIMULATOR |
3599 | 3631 |
3600 #endif // V8_TARGET_ARCH_MIPS64 | 3632 #endif // V8_TARGET_ARCH_MIPS64 |
OLD | NEW |