mirror of
https://github.com/Motorhead1991/qemu.git
synced 2025-08-04 00:03:54 -06:00
fpu/softfloat: re-factor div
We can now add float16_div and use the common decompose and canonicalize functions to have a single implementation for float16/32/64 versions. Signed-off-by: Alex Bennée <alex.bennee@linaro.org> Signed-off-by: Richard Henderson <richard.henderson@linaro.org> Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
This commit is contained in:
parent
74d707e2cc
commit
cf07323d49
3 changed files with 137 additions and 148 deletions
|
@ -625,6 +625,54 @@ static uint64_t estimateDiv128To64( uint64_t a0, uint64_t a1, uint64_t b )
|
|||
|
||||
}
|
||||
|
||||
/* From the GNU Multi Precision Library - longlong.h __udiv_qrnnd
|
||||
* (https://gmplib.org/repo/gmp/file/tip/longlong.h)
|
||||
*
|
||||
* Licensed under the GPLv2/LGPLv3
|
||||
*/
|
||||
static uint64_t div128To64(uint64_t n0, uint64_t n1, uint64_t d)
|
||||
{
|
||||
uint64_t d0, d1, q0, q1, r1, r0, m;
|
||||
|
||||
d0 = (uint32_t)d;
|
||||
d1 = d >> 32;
|
||||
|
||||
r1 = n1 % d1;
|
||||
q1 = n1 / d1;
|
||||
m = q1 * d0;
|
||||
r1 = (r1 << 32) | (n0 >> 32);
|
||||
if (r1 < m) {
|
||||
q1 -= 1;
|
||||
r1 += d;
|
||||
if (r1 >= d) {
|
||||
if (r1 < m) {
|
||||
q1 -= 1;
|
||||
r1 += d;
|
||||
}
|
||||
}
|
||||
}
|
||||
r1 -= m;
|
||||
|
||||
r0 = r1 % d1;
|
||||
q0 = r1 / d1;
|
||||
m = q0 * d0;
|
||||
r0 = (r0 << 32) | (uint32_t)n0;
|
||||
if (r0 < m) {
|
||||
q0 -= 1;
|
||||
r0 += d;
|
||||
if (r0 >= d) {
|
||||
if (r0 < m) {
|
||||
q0 -= 1;
|
||||
r0 += d;
|
||||
}
|
||||
}
|
||||
}
|
||||
r0 -= m;
|
||||
|
||||
/* Return remainder in LSB */
|
||||
return (q1 << 32) | q0 | (r0 != 0);
|
||||
}
|
||||
|
||||
/*----------------------------------------------------------------------------
|
||||
| Returns an approximation to the square root of the 32-bit significand given
|
||||
| by `a'. Considered as an integer, `a' must be at least 2^31. If bit 0 of
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue