73#define FP16_EXP_BITS 5
74#define FP32_EXP_BITS 8
75#define FP64_EXP_BITS 11
77#define FP16_EXP_BIAS 15
78#define FP32_EXP_BIAS 127
79#define FP64_EXP_BIAS 1023
81#define FP16_EXP_INF ((1ULL << FP16_EXP_BITS) - 1)
82#define FP32_EXP_INF ((1ULL << FP32_EXP_BITS) - 1)
83#define FP64_EXP_INF ((1ULL << FP64_EXP_BITS) - 1)
85#define FP16_MANT_BITS (FP16_BITS - FP16_EXP_BITS - 1)
86#define FP32_MANT_BITS (FP32_BITS - FP32_EXP_BITS - 1)
87#define FP64_MANT_BITS (FP64_BITS - FP64_EXP_BITS - 1)
89#define FP16_EXP(x) ((x) >> FP16_MANT_BITS & ((1ULL << FP16_EXP_BITS) - 1))
90#define FP32_EXP(x) ((x) >> FP32_MANT_BITS & ((1ULL << FP32_EXP_BITS) - 1))
91#define FP64_EXP(x) ((x) >> FP64_MANT_BITS & ((1ULL << FP64_EXP_BITS) - 1))
93#define FP16_MANT(x) ((x) & ((1ULL << FP16_MANT_BITS) - 1))
94#define FP32_MANT(x) ((x) & ((1ULL << FP32_MANT_BITS) - 1))
95#define FP64_MANT(x) ((x) & ((1ULL << FP64_MANT_BITS) - 1))
103static inline uint16_t
109static inline uint32_t
115static inline uint32_t
121static inline uint64_t
127static inline uint64_t
139 }
else if (
shift < 64) {
140 *r1 = x1 << shift | x0 >> (64 -
shift);
142 }
else if (
shift < 128) {
143 *r1 = x0 << (
shift - 64);
157 }
else if (
shift < 64) {
160 }
else if (
shift < 128) {
172 uint32_t
mask = ((uint32_t)1 << 31) - 1;
177 uint64_t p0 =
a0 *
b0;
178 uint64_t p2 =
a1 *
b1;
179 uint64_t p1 = (
a0 +
a1) * (
b0 +
b1) - p0 - p2;
181 uint64_t s1 = (s0 >> 31) + p1;
182 uint64_t s2 = (s1 >> 31) + p2;
183 *x0 = (s0 &
mask) | (s1 &
mask) << 31 | s2 << 62;
188void mul64x32(uint64_t *x0, uint64_t *x1, uint64_t
a, uint32_t
b)
190 uint64_t
t0 = (uint64_t)(uint32_t)
a *
b;
191 uint64_t
t1 = (
t0 >> 32) + (
a >> 32) *
b;
192 *x0 =
t1 << 32 | (uint32_t)
t0;
197add128(uint64_t *x0, uint64_t *x1, uint64_t
a0, uint64_t
a1, uint64_t
b0,
201 *x1 =
a1 +
b1 + (*x0 <
a0);
205sub128(uint64_t *x0, uint64_t *x1, uint64_t
a0, uint64_t
a1, uint64_t
b0,
209 *x1 =
a1 -
b1 - (*x0 >
a0);
218static inline uint16_t
228 if (!(mnt >> (16 -
shift))) {
236static inline uint32_t
246 if (!(mnt >> (32 -
shift))) {
254static inline uint64_t
264 if (!(mnt >> (64 -
shift))) {
290 if (!(x1 >> (64 -
shift))) {
291 x1 = x1 << shift | x0 >> (64 -
shift);
301static inline uint16_t
307static inline uint32_t
313static inline uint64_t
319static inline uint16_t
325static inline uint32_t
331static inline uint64_t
337static inline uint16_t
343static inline uint32_t
349static inline uint64_t
355static inline uint16_t
361static inline uint32_t
367static inline uint64_t
373static inline uint16_t
379static inline uint32_t
385static inline uint64_t
534static inline uint16_t
544static inline uint32_t
554static inline uint64_t
785 int_mant =
lsr16(mnt, 3 - exp);
786 error = (
lsr16(mnt, 1 - exp) & 3) | !!(mnt & (
lsl16(1, 1 - exp) - 1));
789 if (!biased_exp && error) {
795 (error == 2 && (int_mant & 1)))) ||
835 return fp16_pack(sgn, biased_exp, int_mant);
869 int_mant =
lsr32(mnt, 3 - exp);
870 error = (
lsr32(mnt, 1 - exp) & 3) | !!(mnt & (
lsl32(1, 1 - exp) - 1));
873 if (!biased_exp && error) {
879 (error == 2 && (int_mant & 1)))) ||
912 return fp32_pack(sgn, biased_exp, int_mant);
946 int_mant =
lsr64(mnt, 3 - exp);
947 error = (
lsr64(mnt, 1 - exp) & 3) | !!(mnt & (
lsl64(1, 1 - exp) - 1));
950 if (!biased_exp && error) {
956 (error == 2 && (int_mant & 1)))) ||
989 return fp64_pack(sgn, biased_exp, int_mant);
1001 int a_sgn, a_exp, b_sgn, b_exp;
1002 uint16_t a_mnt, b_mnt;
1014 return a ==
b || (!a_mnt && !b_mnt);
1020 int a_sgn, a_exp, b_sgn, b_exp;
1021 uint16_t a_mnt, b_mnt;
1031 if (!a_mnt && !b_mnt)
1036 return a_sgn ^ (a_exp > b_exp);
1038 return a_sgn ^ (a_mnt > b_mnt);
1045 int a_sgn, a_exp, b_sgn, b_exp;
1046 uint16_t a_mnt, b_mnt;
1056 if (!a_mnt && !b_mnt)
1061 return a_sgn ^ (a_exp > b_exp);
1063 return a_sgn ^ (a_mnt > b_mnt);
1070 int a_sgn, a_exp, b_sgn, b_exp;
1071 uint16_t a_mnt, b_mnt;
1089 int a_sgn, a_exp, b_sgn, b_exp;
1090 uint32_t a_mnt, b_mnt;
1102 return a ==
b || (!a_mnt && !b_mnt);
1108 int a_sgn, a_exp, b_sgn, b_exp;
1109 uint32_t a_mnt, b_mnt;
1119 if (!a_mnt && !b_mnt)
1124 return a_sgn ^ (a_exp > b_exp);
1126 return a_sgn ^ (a_mnt > b_mnt);
1133 int a_sgn, a_exp, b_sgn, b_exp;
1134 uint32_t a_mnt, b_mnt;
1144 if (!a_mnt && !b_mnt)
1149 return a_sgn ^ (a_exp > b_exp);
1151 return a_sgn ^ (a_mnt > b_mnt);
1158 int a_sgn, a_exp, b_sgn, b_exp;
1159 uint32_t a_mnt, b_mnt;
1177 int a_sgn, a_exp, b_sgn, b_exp;
1178 uint64_t a_mnt, b_mnt;
1190 return a ==
b || (!a_mnt && !b_mnt);
1196 int a_sgn, a_exp, b_sgn, b_exp;
1197 uint64_t a_mnt, b_mnt;
1207 if (!a_mnt && !b_mnt)
1212 return a_sgn ^ (a_exp > b_exp);
1214 return a_sgn ^ (a_mnt > b_mnt);
1221 int a_sgn, a_exp, b_sgn, b_exp;
1222 uint64_t a_mnt, b_mnt;
1232 if (!a_mnt && !b_mnt)
1237 return a_sgn ^ (a_exp > b_exp);
1239 return a_sgn ^ (a_mnt > b_mnt);
1246 int a_sgn, a_exp, b_sgn, b_exp;
1247 uint64_t a_mnt, b_mnt;
1265 int a_sgn, a_exp, b_sgn, b_exp, x_sgn, x_exp;
1266 uint16_t a_mnt, b_mnt,
x, x_mnt;
1285 }
else if (!a_mnt && !b_mnt && a_sgn == b_sgn) {
1291 if (a_exp >= b_exp) {
1292 b_mnt = (
lsr16(b_mnt, a_exp - b_exp) |
1293 !!(b_mnt & (
lsl16(1, a_exp - b_exp) - 1)));
1296 a_mnt = (
lsr16(a_mnt, b_exp - a_exp) |
1297 !!(a_mnt & (
lsl16(1, b_exp - a_exp) - 1)));
1302 if (a_sgn == b_sgn) {
1303 x_mnt = a_mnt + b_mnt;
1304 }
else if (a_mnt >= b_mnt) {
1305 x_mnt = a_mnt - b_mnt;
1308 x_mnt = b_mnt - a_mnt;
1325 int a_sgn, a_exp, b_sgn, b_exp, x_sgn, x_exp;
1326 uint32_t a_mnt, b_mnt,
x, x_mnt;
1345 }
else if (!a_mnt && !b_mnt && a_sgn == b_sgn) {
1351 if (a_exp >= b_exp) {
1352 b_mnt = (
lsr32(b_mnt, a_exp - b_exp) |
1353 !!(b_mnt & (
lsl32(1, a_exp - b_exp) - 1)));
1356 a_mnt = (
lsr32(a_mnt, b_exp - a_exp) |
1357 !!(a_mnt & (
lsl32(1, b_exp - a_exp) - 1)));
1362 if (a_sgn == b_sgn) {
1363 x_mnt = a_mnt + b_mnt;
1364 }
else if (a_mnt >= b_mnt) {
1365 x_mnt = a_mnt - b_mnt;
1368 x_mnt = b_mnt - a_mnt;
1385 int a_sgn, a_exp, b_sgn, b_exp, x_sgn, x_exp;
1386 uint64_t a_mnt, b_mnt,
x, x_mnt;
1405 }
else if (!a_mnt && !b_mnt && a_sgn == b_sgn) {
1411 if (a_exp >= b_exp) {
1412 b_mnt = (
lsr64(b_mnt, a_exp - b_exp) |
1413 !!(b_mnt & (
lsl64(1, a_exp - b_exp) - 1)));
1416 a_mnt = (
lsr64(a_mnt, b_exp - a_exp) |
1417 !!(a_mnt & (
lsl64(1, b_exp - a_exp) - 1)));
1422 if (a_sgn == b_sgn) {
1423 x_mnt = a_mnt + b_mnt;
1424 }
else if (a_mnt >= b_mnt) {
1425 x_mnt = a_mnt - b_mnt;
1428 x_mnt = b_mnt - a_mnt;
1445 int a_sgn, a_exp, b_sgn, b_exp, x_sgn, x_exp;
1446 uint16_t a_mnt, b_mnt,
x, x_mnt;
1465 }
else if (!a_mnt && !b_mnt && a_sgn == b_sgn) {
1471 if (a_exp >= b_exp) {
1472 b_mnt = (
lsr16(b_mnt, a_exp - b_exp) |
1473 !!(b_mnt & (
lsl16(1, a_exp - b_exp) - 1)));
1476 a_mnt = (
lsr16(a_mnt, b_exp - a_exp) |
1477 !!(a_mnt & (
lsl16(1, b_exp - a_exp) - 1)));
1482 if (a_sgn == b_sgn) {
1483 x_mnt = a_mnt + b_mnt;
1484 }
else if (a_mnt >= b_mnt) {
1485 x_mnt = a_mnt - b_mnt;
1488 x_mnt = b_mnt - a_mnt;
1506 int a_sgn, a_exp, b_sgn, b_exp, x_sgn, x_exp;
1507 uint16_t a_mnt, b_mnt,
x;
1524 }
else if (!a_mnt || !b_mnt) {
1529 x_sgn = a_sgn ^ b_sgn;
1531 x_mnt = (uint32_t)a_mnt * b_mnt;
1543 int a_sgn, a_exp, b_sgn, b_exp, x_sgn, x_exp;
1544 uint32_t a_mnt, b_mnt,
x;
1561 }
else if (!a_mnt || !b_mnt) {
1566 x_sgn = a_sgn ^ b_sgn;
1568 x_mnt = (uint64_t)a_mnt * b_mnt;
1580 int a_sgn, a_exp, b_sgn, b_exp, x_sgn, x_exp;
1581 uint64_t a_mnt, b_mnt,
x;
1582 uint64_t x0_mnt, x1_mnt;
1598 }
else if (!a_mnt || !b_mnt) {
1603 x_sgn = a_sgn ^ b_sgn;
1605 mul62x62(&x0_mnt, &x1_mnt, a_mnt, b_mnt);
1609 x0_mnt = x1_mnt << 1 | !!x0_mnt;
1616 int mode,
int *flags)
1618 int a_sgn, a_exp, b_sgn, b_exp, c_sgn, c_exp, x_sgn, x_exp, y_sgn, y_exp;
1619 uint16_t a_mnt, b_mnt, c_mnt,
x;
1620 uint32_t x_mnt, y_mnt;
1645 (a_sgn != (b_sgn ^ c_sgn)))) {
1653 if (!a_mnt && (!b_mnt || !c_mnt) && a_sgn == (b_sgn ^ c_sgn))
1661 y_sgn = b_sgn ^ c_sgn;
1663 y_mnt = (uint32_t)b_mnt * c_mnt << 3;
1669 if (x_exp >= y_exp) {
1670 y_mnt = (
lsr32(y_mnt, x_exp - y_exp) |
1671 !!(y_mnt & (
lsl32(1, x_exp - y_exp) - 1)));
1674 x_mnt = (
lsr32(x_mnt, y_exp - x_exp) |
1675 !!(x_mnt & (
lsl32(1, y_exp - x_exp) - 1)));
1678 if (x_sgn == y_sgn) {
1679 x_mnt = x_mnt + y_mnt;
1680 }
else if (x_mnt >= y_mnt) {
1681 x_mnt = x_mnt - y_mnt;
1684 x_mnt = y_mnt - x_mnt;
1694 x_mnt = x_mnt >> (
FP16_BITS - 1) | !!(uint16_t)(x_mnt << 1);
1701 int mode,
int *flags)
1703 int a_sgn, a_exp, b_sgn, b_exp, c_sgn, c_exp, x_sgn, x_exp, y_sgn, y_exp;
1704 uint32_t a_mnt, b_mnt, c_mnt,
x;
1705 uint64_t x_mnt, y_mnt;
1730 (a_sgn != (b_sgn ^ c_sgn)))) {
1738 if (!a_mnt && (!b_mnt || !c_mnt) && a_sgn == (b_sgn ^ c_sgn))
1746 y_sgn = b_sgn ^ c_sgn;
1748 y_mnt = (uint64_t)b_mnt * c_mnt << 3;
1754 if (x_exp >= y_exp) {
1755 y_mnt = (
lsr64(y_mnt, x_exp - y_exp) |
1756 !!(y_mnt & (
lsl64(1, x_exp - y_exp) - 1)));
1759 x_mnt = (
lsr64(x_mnt, y_exp - x_exp) |
1760 !!(x_mnt & (
lsl64(1, y_exp - x_exp) - 1)));
1763 if (x_sgn == y_sgn) {
1764 x_mnt = x_mnt + y_mnt;
1765 }
else if (x_mnt >= y_mnt) {
1766 x_mnt = x_mnt - y_mnt;
1769 x_mnt = y_mnt - x_mnt;
1779 x_mnt = x_mnt >> (
FP32_BITS - 1) | !!(uint32_t)(x_mnt << 1);
1786 int mode,
int *flags)
1788 int a_sgn, a_exp, b_sgn, b_exp, c_sgn, c_exp, x_sgn, x_exp, y_sgn, y_exp;
1789 uint64_t a_mnt, b_mnt, c_mnt,
x;
1790 uint64_t x0_mnt, x1_mnt, y0_mnt, y1_mnt;
1815 (a_sgn != (b_sgn ^ c_sgn)))) {
1823 if (!a_mnt && (!b_mnt || !c_mnt) && a_sgn == (b_sgn ^ c_sgn))
1832 y_sgn = b_sgn ^ c_sgn;
1834 mul62x62(&y0_mnt, &y1_mnt, b_mnt, c_mnt << 3);
1835 if (!y0_mnt && !y1_mnt) {
1840 if (x_exp >= y_exp) {
1843 x_exp - y_exp < 128 ? 128 - (x_exp - y_exp) : 0);
1844 lsr128(&y0_mnt, &y1_mnt, y0_mnt, y1_mnt, x_exp - y_exp);
1845 y0_mnt |= !!(
t0 |
t1);
1850 y_exp - x_exp < 128 ? 128 - (y_exp - x_exp) : 0);
1851 lsr128(&x0_mnt, &x1_mnt, x0_mnt, x1_mnt, y_exp - x_exp);
1852 x0_mnt |= !!(
t0 |
t1);
1855 if (x_sgn == y_sgn) {
1856 add128(&x0_mnt, &x1_mnt, x0_mnt, x1_mnt, y0_mnt, y1_mnt);
1857 }
else if (
cmp128(x0_mnt, x1_mnt, y0_mnt, y1_mnt) >= 0) {
1858 sub128(&x0_mnt, &x1_mnt, x0_mnt, x1_mnt, y0_mnt, y1_mnt);
1861 sub128(&x0_mnt, &x1_mnt, y0_mnt, y1_mnt, x0_mnt, x1_mnt);
1864 if (!x0_mnt && !x1_mnt) {
1871 x0_mnt = x1_mnt << 1 | !!x0_mnt;
1878 int mode,
int *flags,
bool rm_odd=
false)
1880 int a_sgn, a_exp, b_sgn, b_exp, c_sgn, c_exp, x_sgn, x_exp, y_sgn, y_exp;
1881 uint16_t b_mnt, c_mnt;
1883 uint64_t x_mnt, y_mnt;
1908 (a_sgn != (b_sgn ^ c_sgn)))) {
1916 if (!a_mnt && (!b_mnt || !c_mnt) && a_sgn == (b_sgn ^ c_sgn))
1924 y_sgn = b_sgn ^ c_sgn;
1927 y_mnt = (uint64_t)b_mnt * c_mnt << (3 +
1934 if (x_exp >= y_exp) {
1935 y_mnt = (
lsr64(y_mnt, x_exp - y_exp) |
1936 !!(y_mnt & (
lsl64(1, x_exp - y_exp) - 1)));
1939 x_mnt = (
lsr64(x_mnt, y_exp - x_exp) |
1940 !!(x_mnt & (
lsl64(1, y_exp - x_exp) - 1)));
1943 if (x_sgn == y_sgn) {
1944 x_mnt = x_mnt + y_mnt;
1945 }
else if (x_mnt >= y_mnt) {
1946 x_mnt = x_mnt - y_mnt;
1949 x_mnt = y_mnt - x_mnt;
1963 x_mnt = x_mnt >> (
FP32_BITS - 1) | !!(uint32_t)(x_mnt << 1);
1976 int a_sgn, a_exp, b_sgn, b_exp, x_sgn, x_exp;
1977 uint16_t a_mnt, b_mnt,
x;
1988 (!a_mnt && !b_mnt)) {
2002 x_sgn = a_sgn ^ b_sgn;
2005 x_mnt |= (x_mnt * b_mnt !=
2010 x_mnt = x_mnt >> (
FP16_BITS - 1) | !!(uint16_t)(x_mnt << 1);
2018 int a_sgn, a_exp, b_sgn, b_exp, x_sgn, x_exp;
2019 uint32_t a_mnt, b_mnt,
x;
2030 (!a_mnt && !b_mnt)) {
2044 x_sgn = a_sgn ^ b_sgn;
2047 x_mnt |= (x_mnt * b_mnt !=
2052 x_mnt = x_mnt >> (
FP32_BITS - 1) | !!(uint32_t)(x_mnt << 1);
2060 int a_sgn, a_exp, b_sgn, b_exp, x_sgn, x_exp,
c;
2061 uint64_t a_mnt, b_mnt,
x, x_mnt, x0_mnt, x1_mnt;
2071 (!a_mnt && !b_mnt)) {
2086 x_mnt = ~(uint64_t)0 / (b_mnt >> 31);
2087 mul64x32(&x0_mnt, &x1_mnt, b_mnt, x_mnt);
2088 sub128(&x0_mnt, &x1_mnt, 0, (uint64_t)1 << 32, x0_mnt, x1_mnt);
2089 lsr128(&x0_mnt, &x1_mnt, x0_mnt, x1_mnt, 32);
2090 mul64x32(&x0_mnt, &x1_mnt, x0_mnt, x_mnt);
2091 lsr128(&x0_mnt, &x1_mnt, x0_mnt, x1_mnt, 33);
2094 x_sgn = a_sgn ^ b_sgn;
2096 mul62x62(&x0_mnt, &x1_mnt, x0_mnt, a_mnt >> 2);
2097 lsr128(&x0_mnt, &x1_mnt, x0_mnt, x1_mnt, 4);
2101 mul62x62(&x0_mnt, &x1_mnt, b_mnt >> 2, x_mnt + 1);
2102 c =
cmp128(x0_mnt, x1_mnt, 0, a_mnt >> 11);
2158 b =
b < -300 ? -300 :
b;
2159 b =
b > 300 ? 300 :
b;
2192 b =
b < -300 ? -300 :
b;
2193 b =
b > 300 ? 300 :
b;
2226 b =
b < -3000 ? -3000 :
b;
2227 b =
b > 3000 ? 3000 :
b;
2240 int a_sgn, a_exp, x_sgn, x_exp;
2241 uint16_t a_mnt, x_mnt;
2267 x = ((uint32_t)a_mnt << 14) + ((uint32_t)a_mnt << 13) + ((uint32_t)5 << 28);
2270 x = (((uint32_t)a_mnt << 16) / (
x >> 15) + (
x >> 16)) << 15;
2273 x = (((uint32_t)a_mnt << 16) / (
x >> 15) + (
x >> 16)) << 15;
2276 x_exp = (a_exp + 27) >> 1;
2277 x_mnt = ((
x - (1 << 18)) >> 19) + 1;
2278 t1 = (uint32_t)x_mnt * x_mnt;
2279 t0 = (uint32_t)a_mnt << 9;
2292 int a_sgn, a_exp, x_sgn, x_exp;
2293 uint32_t a_mnt,
x, x_mnt;
2319 x = (a_mnt >> 2) + (a_mnt >> 3) + ((uint32_t)5 << 28);
2322 x = (a_mnt / (
x >> 15) + (
x >> 16)) << 15;
2325 x = (a_mnt / (
x >> 15) + (
x >> 16)) << 15;
2328 x = ((((uint64_t)a_mnt << 32) /
x) >> 2) + (
x >> 1);
2331 x_exp = (a_exp + 147) >> 1;
2332 x_mnt = ((
x - (1 << 5)) >> 6) + 1;
2333 t1 = (uint64_t)x_mnt * x_mnt;
2334 t0 = (uint64_t)a_mnt << 19;
2347 int a_sgn, a_exp, x_sgn, x_exp,
c;
2348 uint64_t a_mnt, x_mnt,
r, x0, x1;
2374 x = (a_mnt >> 34) + (a_mnt >> 35) + ((uint32_t)5 << 28);
2377 x = ((a_mnt >> 32) / (
x >> 15) + (
x >> 16)) << 15;
2380 x = ((a_mnt >> 32) / (
x >> 15) + (
x >> 16)) << 15;
2383 x = ((a_mnt /
x) >> 2) + (
x >> 1);
2386 r = ((uint64_t)1 << 62) /
x;
2390 lsr128(&x0, &x1, x0, x1, 31);
2393 mul62x62(&x0, &x1, a_mnt >> 10, x0 >> 2);
2394 lsl128(&x0, &x1, x0, x1, 5);
2395 lsr128(&x0, &x1, x0, x1, 56);
2397 x0 = ((uint64_t)
x << 31) + (x0 >> 1);
2400 x_exp = (a_exp + 1053) >> 1;
2402 x_mnt = ((x_mnt - (1 << 8)) >> 9) + 1;
2404 lsl128(&x0, &x1, x0, x1, 19);
2417 uint32_t
x = (uint32_t)fpscr;
2418 return (
x >> 22 & 0xf) | (
x >> 19 & 1 ?
FPLIB_FZ16 : 0);
2426 bool underflow =
false;
2443 if ((flags &
FPLIB_IXC) && !(underflow && fpscr.fz)) {
2625 int sgn1, exp1, sgn2, exp2, result;
2626 uint16_t mnt1, mnt2;
2637 if (op1 == op2 || (!mnt1 && !mnt2)) {
2639 }
else if (sgn1 != sgn2) {
2640 result = sgn1 ? 8 : 2;
2641 }
else if (exp1 != exp2) {
2642 result = sgn1 ^ (exp1 < exp2) ? 8 : 2;
2644 result = sgn1 ^ (mnt1 < mnt2) ? 8 : 2;
2659 int sgn1, exp1, sgn2, exp2, result;
2660 uint32_t mnt1, mnt2;
2671 if (op1 == op2 || (!mnt1 && !mnt2)) {
2673 }
else if (sgn1 != sgn2) {
2674 result = sgn1 ? 8 : 2;
2675 }
else if (exp1 != exp2) {
2676 result = sgn1 ^ (exp1 < exp2) ? 8 : 2;
2678 result = sgn1 ^ (mnt1 < mnt2) ? 8 : 2;
2693 int sgn1, exp1, sgn2, exp2, result;
2694 uint64_t mnt1, mnt2;
2705 if (op1 == op2 || (!mnt1 && !mnt2)) {
2707 }
else if (sgn1 != sgn2) {
2708 result = sgn1 ? 8 : 2;
2709 }
else if (exp1 != exp2) {
2710 result = sgn1 ^ (exp1 < exp2) ? 8 : 2;
2712 result = sgn1 ^ (mnt1 < mnt2) ? 8 : 2;
2836 bool alt_hp = fpscr.ahp;
2841 }
else if (fpscr.dn) {
2851 result = ((uint16_t)sgn << (
FP16_BITS - 1) |
2864 rounding, (
mode & 0xf) | alt_hp << 4, &flags);
2885 bool alt_hp = fpscr.ahp;
2890 }
else if (fpscr.dn) {
2900 result = ((uint16_t)sgn << (
FP16_BITS - 1) |
2913 rounding, (
mode & 0xf) | alt_hp << 4, &flags);
2990 rounding,
mode, &flags);
3149 static uint16_t coeff[32] = {
3184 coeff[
op & ((1 << 5) - 1)]);
3191 static uint32_t coeff[64] = {
3258 coeff[
op & ((1 << 6) - 1)]);
3265 static uint64_t coeff[64] = {
3332 coeff[
op & ((1 << 6) - 1)]);
3395 int sgn1, exp1, sgn2, exp2;
3396 uint16_t mnt1, mnt2,
x, result;
3404 result = ((sgn1 != sgn2 ? sgn2 : sgn1 ^ (op1 > op2)) ?
3418 int sgn1, exp1, sgn2, exp2;
3419 uint32_t mnt1, mnt2,
x, result;
3427 result = ((sgn1 != sgn2 ? sgn2 : sgn1 ^ (op1 > op2)) ?
3441 int sgn1, exp1, sgn2, exp2;
3442 uint64_t mnt1, mnt2,
x, result;
3450 result = ((sgn1 != sgn2 ? sgn2 : sgn1 ^ (op1 > op2)) ?
3488 int sgn1, exp1, sgn2, exp2;
3489 uint16_t mnt1, mnt2,
x, result;
3497 result = ((sgn1 != sgn2 ? sgn1 : sgn1 ^ (op1 < op2)) ?
3511 int sgn1, exp1, sgn2, exp2;
3512 uint32_t mnt1, mnt2,
x, result;
3520 result = ((sgn1 != sgn2 ? sgn1 : sgn1 ^ (op1 < op2)) ?
3534 int sgn1, exp1, sgn2, exp2;
3535 uint64_t mnt1, mnt2,
x, result;
3543 result = ((sgn1 != sgn2 ? sgn1 : sgn1 ^ (op1 < op2)) ?
3611 int sgn1, exp1, sgn2, exp2;
3612 uint16_t mnt1, mnt2, result;
3624 }
else if (!mnt1 || !mnt2) {
3642 int sgn1, exp1, sgn2, exp2;
3643 uint32_t mnt1, mnt2, result;
3655 }
else if (!mnt1 || !mnt2) {
3673 int sgn1, exp1, sgn2, exp2;
3674 uint64_t mnt1, mnt2, result;
3686 }
else if (!mnt1 || !mnt2) {
3720 255, 253, 251, 249, 247, 245, 243, 242, 240, 238, 236, 234, 233, 231, 229, 228,
3721 226, 224, 223, 221, 219, 218, 216, 215, 213, 212, 210, 209, 207, 206, 204, 203,
3722 201, 200, 198, 197, 196, 194, 193, 192, 190, 189, 188, 186, 185, 184, 183, 181,
3723 180, 179, 178, 176, 175, 174, 173, 172, 170, 169, 168, 167, 166, 165, 164, 163,
3724 162, 160, 159, 158, 157, 156, 155, 154, 153, 152, 151, 150, 149, 148, 147, 146,
3725 145, 144, 143, 142, 141, 140, 140, 139, 138, 137, 136, 135, 134, 133, 132, 131,
3726 131, 130, 129, 128, 127, 126, 126, 125, 124, 123, 122, 121, 121, 120, 119, 118,
3727 118, 117, 116, 115, 114, 114, 113, 112, 111, 111, 110, 109, 109, 108, 107, 106,
3728 105, 104, 103, 101, 100, 99, 97, 96, 95, 93, 92, 91, 90, 88, 87, 86,
3729 85, 84, 82, 81, 80, 79, 78, 77, 76, 75, 74, 72, 71, 70, 69, 68,
3730 67, 66, 65, 64, 63, 62, 61, 60, 60, 59, 58, 57, 56, 55, 54, 53,
3731 52, 51, 51, 50, 49, 48, 47, 46, 46, 45, 44, 43, 42, 42, 41, 40,
3732 39, 38, 38, 37, 36, 35, 35, 34, 33, 33, 32, 31, 30, 30, 29, 28,
3733 28, 27, 26, 26, 25, 24, 24, 23, 22, 22, 21, 20, 20, 19, 19, 18,
3734 17, 17, 16, 16, 15, 14, 14, 13, 13, 12, 11, 11, 10, 10, 9, 9,
3735 8, 8, 7, 6, 6, 5, 5, 4, 4, 3, 3, 2, 2, 1, 1, 0
3745 uint16_t mnt, result;
3780 uint32_t mnt, result;
3815 uint64_t mnt, result;
3849 int sgn1, exp1, sgn2, exp2;
3850 uint16_t mnt1, mnt2, result;
3879 int sgn1, exp1, sgn2, exp2;
3880 uint32_t mnt1, mnt2, result;
3909 int sgn1, exp1, sgn2, exp2;
3910 uint64_t mnt1, mnt2, result;
3940 uint16_t mnt, result;
3952 bool overflow_to_inf =
false;
3955 overflow_to_inf =
true;
3958 overflow_to_inf = !sgn;
3961 overflow_to_inf = sgn;
3964 overflow_to_inf =
false;
3967 panic(
"Unrecognized FP rounding mode");
3978 uint16_t fraction = (((uint32_t)1 << 19) /
3979 (mnt >> (
FP16_BITS - 10) | 1) + 1) >> 1;
3981 if (result_exp == 0) {
3983 }
else if (result_exp == -1) {
3987 result =
fp16_pack(sgn, result_exp, fraction);
4002 uint32_t mnt, result;
4014 bool overflow_to_inf =
false;
4017 overflow_to_inf =
true;
4020 overflow_to_inf = !sgn;
4023 overflow_to_inf = sgn;
4026 overflow_to_inf =
false;
4029 panic(
"Unrecognized FP rounding mode");
4040 uint32_t fraction = (((uint32_t)1 << 19) /
4041 (mnt >> (
FP32_BITS - 10) | 1) + 1) >> 1;
4043 if (result_exp == 0) {
4045 }
else if (result_exp == -1) {
4049 result =
fp32_pack(sgn, result_exp, fraction);
4064 uint64_t mnt, result;
4076 bool overflow_to_inf =
false;
4079 overflow_to_inf =
true;
4082 overflow_to_inf = !sgn;
4085 overflow_to_inf = sgn;
4088 overflow_to_inf =
false;
4091 panic(
"Unrecognized FP rounding mode");
4102 uint64_t fraction = (((uint32_t)1 << 19) /
4103 (mnt >> (
FP64_BITS - 10) | 1) + 1) >> 1;
4105 if (result_exp == 0) {
4107 }
else if (result_exp == -1) {
4111 result =
fp64_pack(sgn, result_exp, fraction);
4125 int sgn1, exp1, sgn2, exp2;
4126 uint16_t mnt1, mnt2, result;
4155 int sgn1, exp1, sgn2, exp2;
4156 uint32_t mnt1, mnt2, result;
4185 int sgn1, exp1, sgn2, exp2;
4186 uint64_t mnt1, mnt2, result;
4216 uint16_t mnt, result;
4243 uint32_t mnt, result;
4270 uint64_t mnt, result;
4298 uint16_t mnt, result;
4310 }
else if (exp >= expint) {
4315 uint16_t
x = expint - exp >=
FP16_BITS ? 0 : mnt >> (expint - exp);
4317 ((mnt << 1 >> (expint - exp - 1) & 3) |
4318 ((uint16_t)(mnt << 2 << (
FP16_BITS + exp - expint)) != 0));
4321 x += (
err == 3 || (
err == 2 && (
x & 1)));
4335 panic(
"Unrecognized FP rounding mode");
4363 uint32_t mnt, result;
4375 }
else if (exp >= expint) {
4380 uint32_t
x = expint - exp >=
FP32_BITS ? 0 : mnt >> (expint - exp);
4382 ((mnt << 1 >> (expint - exp - 1) & 3) |
4383 ((uint32_t)(mnt << 2 << (
FP32_BITS + exp - expint)) != 0));
4386 x += (
err == 3 || (
err == 2 && (
x & 1)));
4400 panic(
"Unrecognized FP rounding mode");
4428 uint64_t mnt, result;
4440 }
else if (exp >= expint) {
4445 uint64_t
x = expint - exp >=
FP64_BITS ? 0 : mnt >> (expint - exp);
4447 ((mnt << 1 >> (expint - exp - 1) & 3) |
4448 ((uint64_t)(mnt << 2 << (
FP64_BITS + exp - expint)) != 0));
4451 x += (
err == 3 || (
err == 2 && (
x & 1)));
4465 panic(
"Unrecognized FP rounding mode");
4494 uint32_t mnt, result;
4508 }
else if (exp >= expint) {
4511 bool overflow = (exp > (
FP32_EXP_BIAS + intsize - 2) && !sgn) ||
4521 uint32_t
x = expint - exp >=
FP32_BITS ? 0 : mnt >> (expint - exp);
4523 ((mnt << 1 >> (expint - exp - 1) & 3) |
4524 ((uint32_t)(mnt << 2 << (
FP32_BITS + exp - expint)) != 0));
4527 x += (
err == 3 || (
err == 2 && (
x & 1)));
4541 panic(
"Unrecognized FP rounding mode");
4544 bool overflow = (
x > (((uint32_t)1 << (intsize - 1)) - 1) && !sgn) ||
4545 (
x > ((uint32_t)1 << (intsize - 1)) && sgn);
4578 uint64_t mnt, result;
4592 }
else if (exp >= expint) {
4595 bool overflow = (exp > (
FP64_EXP_BIAS + intsize - 2) && !sgn) ||
4599 if (overflow && intsize >= 0) {
4605 uint64_t
x = expint - exp >=
FP64_BITS ? 0 : mnt >> (expint - exp);
4607 ((mnt << 1 >> (expint - exp - 1) & 3) |
4608 ((uint64_t)(mnt << 2 << (
FP64_BITS + exp - expint)) != 0));
4611 x += (
err == 3 || (
err == 2 && (
x & 1)));
4625 panic(
"Unrecognized FP rounding mode");
4628 bool overflow = (
x > (((uint64_t)1 << (intsize - 1)) - 1) && !sgn) ||
4629 (
x > ((uint64_t)1 << (intsize - 1)) && sgn);
4747 static uint16_t coeff[2][8] = {
4781 static uint32_t coeff[2][8] = {
4815 static uint64_t coeff[2][8] = {
4817 0x3ff0000000000000ULL,
4818 0xbfc5555555555543ULL,
4819 0x3f8111111110f30cULL,
4820 0xbf2a01a019b92fc6ULL,
4821 0x3ec71de351f3d22bULL,
4822 0xbe5ae5e2b60f7b91ULL,
4823 0x3de5d8408868552fULL,
4824 0x0000000000000000ULL
4827 0x3ff0000000000000ULL,
4828 0xbfe0000000000000ULL,
4829 0x3fa5555555555536ULL,
4830 0xbf56c16c16c13a0bULL,
4831 0x3efa01a019b1e8d8ULL,
4832 0xbe927e4f7282f468ULL,
4833 0x3e21ee96d2641b13ULL,
4834 0xbda8f76380fbb401ULL
4859 result = (result & ~(1ULL << (
FP16_BITS - 1))) |
4907 static constexpr uint16_t fpOne =
4911 return op1 ^ ((op2 >> 1) << (
FP16_BITS - 1));
4918 static constexpr uint32_t fpOne =
4922 return op1 ^ ((op2 >> 1) << (
FP32_BITS - 1));
4929 static constexpr uint64_t fpOne =
4933 return op1 ^ ((op2 >> 1) << (
FP64_BITS - 1));
4946 return ((uint64_t)!
u << (
FP64_BITS - 1)) - !sgn;
4950 err = (exp > expmax - 2 ? 0 :
4956 x += (
err == 3 || (
err == 2 && (
x & 1)));
4970 panic(
"Unrecognized FP rounding mode");
4973 if (
u ? sgn &&
x :
x > (1ULL << (
FP64_BITS - 1)) - !sgn) {
4975 return ((uint64_t)!
u << (
FP64_BITS - 1)) - !sgn;
4982 return sgn ? -
x :
x;
4992 (uint64_t)-
x <= (uint64_t)1 << (
FP32_BITS - 1))) {
5006 (uint64_t)-
x <= (uint64_t)1 << (
FP16_BITS - 1))) {
5020 uint16_t mnt, result;
5035 u, rounding, &flags);
5067 u, rounding, &flags);
5081 uint32_t mnt, result;
5096 u, rounding, &flags);
5123 result =
FPToFixed_32(sgn, exp + fbits, mnt,
u, rounding, &flags);
5138 uint32_t sgn =
bits(
op, 63);
5139 int32_t exp =
bits(
op, 62, 52);
5140 uint64_t mnt =
bits(
op, 51, 0);
5152 }
else if (exp == 0x7ff) {
5164 }
else if (mnt_shft >= 0) {
5165 result =
lsl64(mnt, mnt_shft);
5166 }
else if (mnt_shft < 0) {
5168 result =
lsr64(mnt, abs(mnt_shft));
5170 uint64_t max_result = (1UL << (
FP32_BITS - 1)) -!sgn;
5178 result = sgn ? -result : result;
5180 if (sgn == 1 && result == 0)
5220 u, rounding, &flags);
5250 u, rounding, &flags);
5264 uint64_t mnt, result;
5276 result =
FPToFixed_64(sgn, exp + fbits, mnt,
u, rounding, &flags);
5289 uint64_t x_mnt = x_sgn ? -
a :
a;
5309 uint64_t x_mnt = x_sgn ? -
a :
a;
5329 uint64_t x_mnt = x_sgn ? -
a :
a;
5348 (
int)rounding | (
modeConv(fpscr) & 0xFC),
5360 (
int)rounding | (
modeConv(fpscr) & 0xFC),
5372 (
int)rounding | (
modeConv(fpscr) & 0xFC),
5427 int sgn1, exp1, sgn2, exp2;
5428 uint16_t mnt1, mnt2, result;
5456 int sgn1, exp1, sgn2, exp2;
5457 uint16_t mnt1, mnt2, result;
Floating-point library code, which will gradually replace vfp.hh.
constexpr T bits(T val, unsigned first, unsigned last)
Extract the bitfield from position 'first' to 'last' (inclusive) from 'val' and right justify it.
#define panic(...)
This implements a cprintf based panic() function.
uint16_t fplibMax(uint16_t op1, uint16_t op2, FPSCR &fpscr)
static uint64_t fp64_FPOnePointFive(int sgn)
uint16_t fplib32RSqrtStep(uint16_t op1, uint16_t op2, FPSCR &fpscr)
uint32_t fplibFPToFixedJS(uint64_t op, FPSCR &fpscr, bool is64, uint8_t &nz)
Floating-point JS convert to a signed integer, with rounding to zero.
uint16_t fplib32RecipStep(uint16_t op1, uint16_t op2, FPSCR &fpscr)
static int fp64_is_infinity(int exp, uint64_t mnt)
static uint32_t fp32_FPConvertNaN_16(uint16_t op)
static FPRounding FPCRRounding(FPSCR &fpscr)
static uint64_t fp64_process_NaNs(uint64_t a, uint64_t b, int mode, int *flags)
uint16_t fplibMinNum(uint16_t op1, uint16_t op2, FPSCR &fpscr)
static uint16_t fp16_normalise(uint16_t mnt, int *exp)
static int fp32_compare_un(uint32_t a, uint32_t b, int mode, int *flags)
static uint32_t fp32_scale(uint32_t a, int32_t b, int mode, int *flags)
static void fp32_unpack(int *sgn, int *exp, uint32_t *mnt, uint32_t x, int mode, int *flags)
uint16_t fplibMaxNum(uint16_t op1, uint16_t op2, FPSCR &fpscr)
static uint64_t fp64_FPConvertNaN_32(uint32_t op)
static int modeConv(FPSCR fpscr)
static uint64_t fp64_round(int sgn, int exp, uint64_t mnt, int mode, int *flags)
uint16_t fplibDiv(uint16_t op1, uint16_t op2, FPSCR &fpscr)
static int fp16_compare_ge(uint16_t a, uint16_t b, int mode, int *flags)
static uint32_t fp32_FPThree(int sgn)
static uint64_t fp64_process_NaN(uint64_t a, int mode, int *flags)
static uint64_t fp64_pack(uint64_t sgn, uint64_t exp, uint64_t mnt)
static void fp64_unpack(int *sgn, int *exp, uint64_t *mnt, uint64_t x, int mode, int *flags)
static uint16_t fp16_scale(uint16_t a, int16_t b, int mode, int *flags)
static uint64_t fp64_process_NaNs3(uint64_t a, uint64_t b, uint64_t c, int mode, int *flags)
uint16_t fplibRSqrtEstimate(uint16_t op, FPSCR &fpscr)
static uint16_t fp16_zero(int sgn)
uint16_t fplibNeg(uint16_t op)
static uint16_t fp16_max_normal(int sgn)
bool fplibCompareGT(uint16_t a, uint16_t b, FPSCR &fpscr)
static uint16_t lsl16(uint16_t x, uint32_t shift)
static int fp64_compare_un(uint64_t a, uint64_t b, int mode, int *flags)
uint16_t fplibRecipEstimate(uint16_t op, FPSCR &fpscr)
static uint16_t fp16_process_NaN(uint16_t a, int mode, int *flags)
static uint16_t fp16_FPConvertNaN_32(uint32_t op)
static int fp16_is_quiet_NaN(int exp, uint16_t mnt)
static uint32_t fp32_round_(int sgn, int exp, uint32_t mnt, int rm, int mode, int *flags)
static void fp16_unpack(int *sgn, int *exp, uint16_t *mnt, uint16_t x, int mode, int *flags)
static uint32_t fp32_defaultNaN()
static uint32_t FPToFixed_32(int sgn, int exp, uint64_t mnt, bool u, FPRounding rounding, int *flags)
static int fp64_compare_ge(uint64_t a, uint64_t b, int mode, int *flags)
static uint32_t lsr32(uint32_t x, uint32_t shift)
static uint64_t FPToFixed_64(int sgn, int exp, uint64_t mnt, bool u, FPRounding rounding, int *flags)
static uint32_t fp32_convert_default_nan(uint16_t op)
static uint16_t fp16_div(uint16_t a, uint16_t b, int mode, int *flags)
uint16_t fplibConvert(uint32_t op, FPRounding rounding, FPSCR &fpscr)
uint16_t fplibExpA(uint16_t op)
static uint32_t fp32_FPTwo(int sgn)
uint16_t fplibTrigSSel(uint16_t op1, uint16_t op2, FPSCR &fpscr)
static int fp32_compare_gt(uint32_t a, uint32_t b, int mode, int *flags)
static uint64_t fp64_FPConvertNaN_16(uint16_t op)
uint16_t fplibFixedToFP(uint64_t op, int fbits, bool u, FPRounding rounding, FPSCR &fpscr)
static uint32_t fp32_muladdh(uint32_t a, uint16_t b, uint16_t c, int scale, int mode, int *flags, bool rm_odd=false)
static uint16_t fp16_FPOnePointFive(int sgn)
static uint16_t fp16_add(uint16_t a, uint16_t b, int neg, int mode, int *flags)
static int fp32_compare_eq(uint32_t a, uint32_t b, int mode, int *flags)
uint16_t fplibSqrt(uint16_t op, FPSCR &fpscr)
static uint16_t fp16_pack(uint16_t sgn, uint16_t exp, uint16_t mnt)
static uint64_t fp64_div(uint64_t a, uint64_t b, int mode, int *flags)
static uint32_t fp32_normalise(uint32_t mnt, int *exp)
static uint32_t fp32_infinity(int sgn)
static uint64_t lsr64(uint64_t x, uint32_t shift)
bool fplibCompareEQ(uint16_t a, uint16_t b, FPSCR &fpscr)
static uint32_t fp32_process_NaNs3(uint32_t a, uint32_t b, uint32_t c, int mode, int *flags)
uint32_t fplibMulAddH(uint32_t addend, uint16_t op1, uint16_t op2, FPSCR &fpscr)
static int fp64_is_NaN(int exp, uint64_t mnt)
uint16_t fplibAdd(uint16_t op1, uint16_t op2, FPSCR &fpscr)
static uint16_t fp16_FPTwo(int sgn)
static uint16_t fp16_sqrt(uint16_t a, int mode, int *flags)
static int fp32_is_NaN(int exp, uint32_t mnt)
static uint64_t fp64_FPTwo(int sgn)
static uint16_t lsr16(uint16_t x, uint32_t shift)
static int fp64_compare_eq(uint64_t a, uint64_t b, int mode, int *flags)
static uint16_t fp16_infinity(int sgn)
uint16_t fplibMulX(uint16_t op1, uint16_t op2, FPSCR &fpscr)
static uint32_t fp32_FPConvertNaN_64(uint64_t op)
static uint16_t fp16_muladd(uint16_t a, uint16_t b, uint16_t c, int scale, int mode, int *flags)
static void set_fpscr0(FPSCR &fpscr, int flags)
static uint64_t fp64_cvtf(uint64_t a, int fbits, int u, int mode, int *flags)
uint16_t fplibAbs(uint16_t op)
static uint16_t FPToFixed_16(int sgn, int exp, uint64_t mnt, bool u, FPRounding rounding, int *flags)
static uint16_t fp16_defaultNaN()
static uint32_t lsl32(uint32_t x, uint32_t shift)
static void add128(uint64_t *x0, uint64_t *x1, uint64_t a0, uint64_t a1, uint64_t b0, uint64_t b1)
static uint32_t fp32_FPOnePointFive(int sgn)
bool fplibCompareGE(uint16_t a, uint16_t b, FPSCR &fpscr)
static uint64_t fp64_infinity(int sgn)
static int fp64_compare_gt(uint64_t a, uint64_t b, int mode, int *flags)
static int fp16_is_infinity(int exp, uint16_t mnt)
uint16_t fplibMul(uint16_t op1, uint16_t op2, FPSCR &fpscr)
static uint64_t fp64_FPThree(int sgn)
static uint64_t fp64_sqrt(uint64_t a, int mode, int *flags)
static void fp64_minmaxnum(uint64_t *op1, uint64_t *op2, int sgn)
static int fp16_compare_eq(uint16_t a, uint16_t b, int mode, int *flags)
static uint16_t fp16_process_NaNs(uint16_t a, uint16_t b, int mode, int *flags)
uint16_t fplibScale(uint16_t op1, uint16_t op2, FPSCR &fpscr)
static int fp32_is_signalling_NaN(int exp, uint32_t mnt)
static int fp32_compare_ge(uint32_t a, uint32_t b, int mode, int *flags)
static uint16_t fp16_round_(int sgn, int exp, uint16_t mnt, int rm, int mode, int *flags)
static int fp16_is_NaN(int exp, uint16_t mnt)
static void fp16_minmaxnum(uint16_t *op1, uint16_t *op2, int sgn)
static uint16_t fp16_mul(uint16_t a, uint16_t b, int mode, int *flags)
static void lsl128(uint64_t *r0, uint64_t *r1, uint64_t x0, uint64_t x1, uint32_t shift)
static uint32_t fp32_round(int sgn, int exp, uint32_t mnt, int mode, int *flags)
static uint32_t fp32_zero(int sgn)
static void lsr128(uint64_t *r0, uint64_t *r1, uint64_t x0, uint64_t x1, uint32_t shift)
static uint32_t fp32_pack(uint32_t sgn, uint32_t exp, uint32_t mnt)
static void mul64x32(uint64_t *x0, uint64_t *x1, uint64_t a, uint32_t b)
uint32_t fplibRoundIntN(uint32_t op, FPRounding rounding, bool exact, int intsize, FPSCR &fpscr)
uint16_t fplibRecpX(uint16_t op, FPSCR &fpscr)
static uint16_t fp16_repack(int sgn, int exp, uint16_t mnt)
static uint64_t fp64_scale(uint64_t a, int64_t b, int mode, int *flags)
static int fp16_is_signalling_NaN(int exp, uint16_t mnt)
static uint64_t fp64_repack(int sgn, int exp, uint64_t mnt)
uint16_t fplibRecipStepFused(uint16_t op1, uint16_t op2, FPSCR &fpscr)
uint16_t fplibTrigSMul(uint16_t op1, uint16_t op2, FPSCR &fpscr)
uint16_t fplibTrigMulAdd(uint8_t coeff_index, uint16_t op1, uint16_t op2, FPSCR &fpscr)
uint16_t fplibRSqrtStepFused(uint16_t op1, uint16_t op2, FPSCR &fpscr)
static void fp32_minmaxnum(uint32_t *op1, uint32_t *op2, int sgn)
int fplibCompare(uint16_t op1, uint16_t op2, bool signal_nans, FPSCR &fpscr)
static uint64_t fp64_add(uint64_t a, uint64_t b, int neg, int mode, int *flags)
uint16_t fplibDefaultNaN()
static uint32_t fp32_process_NaNs(uint32_t a, uint32_t b, int mode, int *flags)
static uint64_t fp64_defaultNaN()
static const uint8_t recip_sqrt_estimate[256]
static uint32_t fp32_process_NaN(uint32_t a, int mode, int *flags)
uint16_t fplibFPToFixed(uint16_t op, int fbits, bool u, FPRounding rounding, FPSCR &fpscr)
uint16_t fplibSub(uint16_t op1, uint16_t op2, FPSCR &fpscr)
static int fp16_compare_gt(uint16_t a, uint16_t b, int mode, int *flags)
static uint16_t fp16_process_NaNs3(uint16_t a, uint16_t b, uint16_t c, int mode, int *flags)
uint16_t fplibMulAdd(uint16_t addend, uint16_t op1, uint16_t op2, FPSCR &fpscr)
static uint64_t lsl64(uint64_t x, uint32_t shift)
static int fp32_is_infinity(int exp, uint32_t mnt)
static uint64_t fp64_zero(int sgn)
static uint32_t fp32_sqrt(uint32_t a, int mode, int *flags)
static int fp64_is_quiet_NaN(int exp, uint64_t mnt)
static uint16_t fp16_cvtf(uint64_t a, int fbits, int u, int mode, int *flags)
static int fp16_compare_un(uint16_t a, uint16_t b, int mode, int *flags)
static uint16_t fp16_FPThree(int sgn)
static uint32_t fp32_process_NaNs3H(uint32_t a, uint16_t b, uint16_t c, int mode, int *flags)
static uint32_t fp32_muladd(uint32_t a, uint32_t b, uint32_t c, int scale, int mode, int *flags)
static uint32_t fp32_add(uint32_t a, uint32_t b, int neg, int mode, int *flags)
static void sub128(uint64_t *x0, uint64_t *x1, uint64_t a0, uint64_t a1, uint64_t b0, uint64_t b1)
static uint16_t fp16_halved_add(uint16_t a, uint16_t b, int neg, int mode, int *flags)
static int fp32_is_quiet_NaN(int exp, uint32_t mnt)
static uint64_t fp64_max_normal(int sgn)
static uint32_t fp32_div(uint32_t a, uint32_t b, int mode, int *flags)
uint16_t fplibInfinity(int sgn)
uint16_t fplibRoundInt(uint16_t op, FPRounding rounding, bool exact, FPSCR &fpscr)
static uint16_t fp16_round(int sgn, int exp, uint16_t mnt, int mode, int *flags)
static void set_fpscr(FPSCR &fpscr, int flags)
static uint64_t fp64_mul(uint64_t a, uint64_t b, int mode, int *flags)
static uint16_t fp16_FPConvertNaN_64(uint64_t op)
static uint32_t fp32_repack(int sgn, int exp, uint32_t mnt)
static uint64_t fp64_round_(int sgn, int exp, uint64_t mnt, int rm, int mode, int *flags)
uint16_t fplibMin(uint16_t op1, uint16_t op2, FPSCR &fpscr)
static uint64_t fp64_muladd(uint64_t a, uint64_t b, uint64_t c, int scale, int mode, int *flags)
static uint32_t fp32_mul(uint32_t a, uint32_t b, int mode, int *flags)
static int fp64_is_signalling_NaN(int exp, uint64_t mnt)
bool fplibCompareUN(uint16_t a, uint16_t b, FPSCR &fpscr)
static uint32_t fp32_cvtf(uint64_t a, int fbits, int u, int mode, int *flags)
static void fp128_normalise(uint64_t *mnt0, uint64_t *mnt1, int *exp)
static uint64_t fp64_normalise(uint64_t mnt, int *exp)
static uint32_t fp32_max_normal(int sgn)
static void mul62x62(uint64_t *x0, uint64_t *x1, uint64_t a, uint64_t b)
static int cmp128(uint64_t a0, uint64_t a1, uint64_t b0, uint64_t b1)
Copyright (c) 2024 Arm Limited All rights reserved.