| OLD | NEW |
| 1 // Copyright 2013 the V8 project authors. All rights reserved. | 1 // Copyright 2013 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 2372 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2383 case FMOV_s: set_sreg(fd, sreg(fn)); break; | 2383 case FMOV_s: set_sreg(fd, sreg(fn)); break; |
| 2384 case FMOV_d: set_dreg(fd, dreg(fn)); break; | 2384 case FMOV_d: set_dreg(fd, dreg(fn)); break; |
| 2385 case FABS_s: set_sreg(fd, std::fabs(sreg(fn))); break; | 2385 case FABS_s: set_sreg(fd, std::fabs(sreg(fn))); break; |
| 2386 case FABS_d: set_dreg(fd, std::fabs(dreg(fn))); break; | 2386 case FABS_d: set_dreg(fd, std::fabs(dreg(fn))); break; |
| 2387 case FNEG_s: set_sreg(fd, -sreg(fn)); break; | 2387 case FNEG_s: set_sreg(fd, -sreg(fn)); break; |
| 2388 case FNEG_d: set_dreg(fd, -dreg(fn)); break; | 2388 case FNEG_d: set_dreg(fd, -dreg(fn)); break; |
| 2389 case FSQRT_s: set_sreg(fd, FPSqrt(sreg(fn))); break; | 2389 case FSQRT_s: set_sreg(fd, FPSqrt(sreg(fn))); break; |
| 2390 case FSQRT_d: set_dreg(fd, FPSqrt(dreg(fn))); break; | 2390 case FSQRT_d: set_dreg(fd, FPSqrt(dreg(fn))); break; |
| 2391 case FRINTA_s: set_sreg(fd, FPRoundInt(sreg(fn), FPTieAway)); break; | 2391 case FRINTA_s: set_sreg(fd, FPRoundInt(sreg(fn), FPTieAway)); break; |
| 2392 case FRINTA_d: set_dreg(fd, FPRoundInt(dreg(fn), FPTieAway)); break; | 2392 case FRINTA_d: set_dreg(fd, FPRoundInt(dreg(fn), FPTieAway)); break; |
| 2393 case FRINTM_s: |
| 2394 set_sreg(fd, FPRoundInt(sreg(fn), FPNegativeInfinity)); break; |
| 2395 case FRINTM_d: |
| 2396 set_dreg(fd, FPRoundInt(dreg(fn), FPNegativeInfinity)); break; |
| 2393 case FRINTN_s: set_sreg(fd, FPRoundInt(sreg(fn), FPTieEven)); break; | 2397 case FRINTN_s: set_sreg(fd, FPRoundInt(sreg(fn), FPTieEven)); break; |
| 2394 case FRINTN_d: set_dreg(fd, FPRoundInt(dreg(fn), FPTieEven)); break; | 2398 case FRINTN_d: set_dreg(fd, FPRoundInt(dreg(fn), FPTieEven)); break; |
| 2395 case FRINTZ_s: set_sreg(fd, FPRoundInt(sreg(fn), FPZero)); break; | 2399 case FRINTZ_s: set_sreg(fd, FPRoundInt(sreg(fn), FPZero)); break; |
| 2396 case FRINTZ_d: set_dreg(fd, FPRoundInt(dreg(fn), FPZero)); break; | 2400 case FRINTZ_d: set_dreg(fd, FPRoundInt(dreg(fn), FPZero)); break; |
| 2397 case FCVT_ds: set_dreg(fd, FPToDouble(sreg(fn))); break; | 2401 case FCVT_ds: set_dreg(fd, FPToDouble(sreg(fn))); break; |
| 2398 case FCVT_sd: set_sreg(fd, FPToFloat(dreg(fn), FPTieEven)); break; | 2402 case FCVT_sd: set_sreg(fd, FPToFloat(dreg(fn), FPTieEven)); break; |
| 2399 default: UNIMPLEMENTED(); | 2403 default: UNIMPLEMENTED(); |
| 2400 } | 2404 } |
| 2401 } | 2405 } |
| 2402 | 2406 |
| (...skipping 246 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2649 (value == kFP64NegativeInfinity)) { | 2653 (value == kFP64NegativeInfinity)) { |
| 2650 return value; | 2654 return value; |
| 2651 } else if (std::isnan(value)) { | 2655 } else if (std::isnan(value)) { |
| 2652 return FPProcessNaN(value); | 2656 return FPProcessNaN(value); |
| 2653 } | 2657 } |
| 2654 | 2658 |
| 2655 double int_result = floor(value); | 2659 double int_result = floor(value); |
| 2656 double error = value - int_result; | 2660 double error = value - int_result; |
| 2657 switch (round_mode) { | 2661 switch (round_mode) { |
| 2658 case FPTieAway: { | 2662 case FPTieAway: { |
| 2659 // If the error is greater than 0.5, or is equal to 0.5 and the integer | 2663 // Take care of correctly handling the range ]-0.5, -0.0], which must |
| 2660 // result is positive, round up. | 2664 // yield -0.0. |
| 2661 if ((error > 0.5) || ((error == 0.5) && (int_result >= 0.0))) { | 2665 if ((-0.5 < value) && (value < 0.0)) { |
| 2666 int_result = -0.0; |
| 2667 |
| 2668 } else if ((error > 0.5) || ((error == 0.5) && (int_result >= 0.0))) { |
| 2669 // If the error is greater than 0.5, or is equal to 0.5 and the integer |
| 2670 // result is positive, round up. |
| 2662 int_result++; | 2671 int_result++; |
| 2663 } | 2672 } |
| 2664 break; | 2673 break; |
| 2665 } | 2674 } |
| 2666 case FPTieEven: { | 2675 case FPTieEven: { |
| 2676 // Take care of correctly handling the range [-0.5, -0.0], which must |
| 2677 // yield -0.0. |
| 2678 if ((-0.5 <= value) && (value < 0.0)) { |
| 2679 int_result = -0.0; |
| 2680 |
| 2667 // If the error is greater than 0.5, or is equal to 0.5 and the integer | 2681 // If the error is greater than 0.5, or is equal to 0.5 and the integer |
| 2668 // result is odd, round up. | 2682 // result is odd, round up. |
| 2669 if ((error > 0.5) || | 2683 } else if ((error > 0.5) || |
| 2670 ((error == 0.5) && (fmod(int_result, 2) != 0))) { | 2684 ((error == 0.5) && (fmod(int_result, 2) != 0))) { |
| 2671 int_result++; | 2685 int_result++; |
| 2672 } | 2686 } |
| 2673 break; | 2687 break; |
| 2674 } | 2688 } |
| 2675 case FPZero: { | 2689 case FPZero: { |
| 2676 // If value > 0 then we take floor(value) | 2690 // If value > 0 then we take floor(value) |
| 2677 // otherwise, ceil(value) | 2691 // otherwise, ceil(value) |
| 2678 if (value < 0) { | 2692 if (value < 0) { |
| 2679 int_result = ceil(value); | 2693 int_result = ceil(value); |
| (...skipping 957 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3637 default: | 3651 default: |
| 3638 UNIMPLEMENTED(); | 3652 UNIMPLEMENTED(); |
| 3639 } | 3653 } |
| 3640 } | 3654 } |
| 3641 | 3655 |
| 3642 #endif // USE_SIMULATOR | 3656 #endif // USE_SIMULATOR |
| 3643 | 3657 |
| 3644 } } // namespace v8::internal | 3658 } } // namespace v8::internal |
| 3645 | 3659 |
| 3646 #endif // V8_TARGET_ARCH_ARM64 | 3660 #endif // V8_TARGET_ARCH_ARM64 |
| OLD | NEW |