Commit f23c346e69e293d26fdbb2bd06310b4e261b4749
1 parent
c52ab6f5
target-ppc: use the new fp functions
Signed-off-by: Aurelien Jarno <aurelien@aurel32.net> git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@6051 c046a42c-6fe2-441c-8c8c-71466251a162
Showing
1 changed file
with
23 additions
and
50 deletions
target-ppc/op_helper.c
... | ... | @@ -554,15 +554,6 @@ uint32_t helper_float64_to_float32(uint64_t arg) |
554 | 554 | return f.l; |
555 | 555 | } |
556 | 556 | |
557 | -static always_inline int fpisneg (float64 d) | |
558 | -{ | |
559 | - CPU_DoubleU u; | |
560 | - | |
561 | - u.d = d; | |
562 | - | |
563 | - return u.ll >> 63 != 0; | |
564 | -} | |
565 | - | |
566 | 557 | static always_inline int isden (float64 d) |
567 | 558 | { |
568 | 559 | CPU_DoubleU u; |
... | ... | @@ -572,24 +563,6 @@ static always_inline int isden (float64 d) |
572 | 563 | return ((u.ll >> 52) & 0x7FF) == 0; |
573 | 564 | } |
574 | 565 | |
575 | -static always_inline int iszero (float64 d) | |
576 | -{ | |
577 | - CPU_DoubleU u; | |
578 | - | |
579 | - u.d = d; | |
580 | - | |
581 | - return (u.ll & ~0x8000000000000000ULL) == 0; | |
582 | -} | |
583 | - | |
584 | -static always_inline int isinfinity (float64 d) | |
585 | -{ | |
586 | - CPU_DoubleU u; | |
587 | - | |
588 | - u.d = d; | |
589 | - | |
590 | - return ((u.ll >> 52) & 0x7FF) == 0x7FF && | |
591 | - (u.ll & 0x000FFFFFFFFFFFFFULL) == 0; | |
592 | -} | |
593 | 566 | |
594 | 567 | #ifdef CONFIG_SOFTFLOAT |
595 | 568 | static always_inline int isfinite (float64 d) |
... | ... | @@ -618,7 +591,7 @@ uint32_t helper_compute_fprf (uint64_t arg, uint32_t set_fprf) |
618 | 591 | int isneg; |
619 | 592 | int ret; |
620 | 593 | farg.ll = arg; |
621 | - isneg = fpisneg(farg.d); | |
594 | + isneg = float64_is_neg(farg.d); | |
622 | 595 | if (unlikely(float64_is_nan(farg.d))) { |
623 | 596 | if (float64_is_signaling_nan(farg.d)) { |
624 | 597 | /* Signaling NaN: flags are undefined */ |
... | ... | @@ -627,14 +600,14 @@ uint32_t helper_compute_fprf (uint64_t arg, uint32_t set_fprf) |
627 | 600 | /* Quiet NaN */ |
628 | 601 | ret = 0x11; |
629 | 602 | } |
630 | - } else if (unlikely(isinfinity(farg.d))) { | |
603 | + } else if (unlikely(float64_is_infinity(farg.d))) { | |
631 | 604 | /* +/- infinity */ |
632 | 605 | if (isneg) |
633 | 606 | ret = 0x09; |
634 | 607 | else |
635 | 608 | ret = 0x05; |
636 | 609 | } else { |
637 | - if (iszero(farg.d)) { | |
610 | + if (float64_is_zero(farg.d)) { | |
638 | 611 | /* +/- zero */ |
639 | 612 | if (isneg) |
640 | 613 | ret = 0x12; |
... | ... | @@ -1056,7 +1029,7 @@ uint64_t helper_fadd (uint64_t arg1, uint64_t arg2) |
1056 | 1029 | /* sNaN addition */ |
1057 | 1030 | farg1.ll = fload_invalid_op_excp(POWERPC_EXCP_FP_VXSNAN); |
1058 | 1031 | } else if (likely(isfinite(farg1.d) || isfinite(farg2.d) || |
1059 | - fpisneg(farg1.d) == fpisneg(farg2.d))) { | |
1032 | + float64_is_neg(farg1.d) == float64_is_neg(farg2.d))) { | |
1060 | 1033 | farg1.d = float64_add(farg1.d, farg2.d, &env->fp_status); |
1061 | 1034 | } else { |
1062 | 1035 | /* Magnitude subtraction of infinities */ |
... | ... | @@ -1082,7 +1055,7 @@ uint64_t helper_fsub (uint64_t arg1, uint64_t arg2) |
1082 | 1055 | /* sNaN subtraction */ |
1083 | 1056 | farg1.ll = fload_invalid_op_excp(POWERPC_EXCP_FP_VXSNAN); |
1084 | 1057 | } else if (likely(isfinite(farg1.d) || isfinite(farg2.d) || |
1085 | - fpisneg(farg1.d) != fpisneg(farg2.d))) { | |
1058 | + float64_is_neg(farg1.d) != float64_is_neg(farg2.d))) { | |
1086 | 1059 | farg1.d = float64_sub(farg1.d, farg2.d, &env->fp_status); |
1087 | 1060 | } else { |
1088 | 1061 | /* Magnitude subtraction of infinities */ |
... | ... | @@ -1107,8 +1080,8 @@ uint64_t helper_fmul (uint64_t arg1, uint64_t arg2) |
1107 | 1080 | float64_is_signaling_nan(farg2.d))) { |
1108 | 1081 | /* sNaN multiplication */ |
1109 | 1082 | farg1.ll = fload_invalid_op_excp(POWERPC_EXCP_FP_VXSNAN); |
1110 | - } else if (unlikely((isinfinity(farg1.d) && iszero(farg2.d)) || | |
1111 | - (iszero(farg1.d) && isinfinity(farg2.d)))) { | |
1083 | + } else if (unlikely((float64_is_infinity(farg1.d) && float64_is_zero(farg2.d)) || | |
1084 | + (float64_is_zero(farg1.d) && float64_is_infinity(farg2.d)))) { | |
1112 | 1085 | /* Multiplication of zero by infinity */ |
1113 | 1086 | farg1.ll = fload_invalid_op_excp(POWERPC_EXCP_FP_VXIMZ); |
1114 | 1087 | } else { |
... | ... | @@ -1132,11 +1105,11 @@ uint64_t helper_fdiv (uint64_t arg1, uint64_t arg2) |
1132 | 1105 | float64_is_signaling_nan(farg2.d))) { |
1133 | 1106 | /* sNaN division */ |
1134 | 1107 | farg1.ll = fload_invalid_op_excp(POWERPC_EXCP_FP_VXSNAN); |
1135 | - } else if (unlikely(isinfinity(farg1.d) && isinfinity(farg2.d))) { | |
1108 | + } else if (unlikely(float64_is_infinity(farg1.d) && float64_is_infinity(farg2.d))) { | |
1136 | 1109 | /* Division of infinity by infinity */ |
1137 | 1110 | farg1.ll = fload_invalid_op_excp(POWERPC_EXCP_FP_VXIDI); |
1138 | - } else if (unlikely(!float64_is_nan(farg1.d) && iszero(farg2.d))) { | |
1139 | - if (iszero(farg1.d)) { | |
1111 | + } else if (unlikely(!float64_is_nan(farg1.d) && float64_is_zero(farg2.d))) { | |
1112 | + if (float64_is_zero(farg1.d)) { | |
1140 | 1113 | /* Division of zero by zero */ |
1141 | 1114 | farg1.ll = fload_invalid_op_excp(POWERPC_EXCP_FP_VXZDZ); |
1142 | 1115 | } else { |
... | ... | @@ -1192,7 +1165,7 @@ uint64_t helper_fctiw (uint64_t arg) |
1192 | 1165 | if (unlikely(float64_is_signaling_nan(farg.d))) { |
1193 | 1166 | /* sNaN conversion */ |
1194 | 1167 | farg.ll = fload_invalid_op_excp(POWERPC_EXCP_FP_VXSNAN | POWERPC_EXCP_FP_VXCVI); |
1195 | - } else if (unlikely(float64_is_nan(farg.d) || isinfinity(farg.d))) { | |
1168 | + } else if (unlikely(float64_is_nan(farg.d) || float64_is_infinity(farg.d))) { | |
1196 | 1169 | /* qNan / infinity conversion */ |
1197 | 1170 | farg.ll = fload_invalid_op_excp(POWERPC_EXCP_FP_VXCVI); |
1198 | 1171 | } else { |
... | ... | @@ -1216,7 +1189,7 @@ uint64_t helper_fctiwz (uint64_t arg) |
1216 | 1189 | if (unlikely(float64_is_signaling_nan(farg.d))) { |
1217 | 1190 | /* sNaN conversion */ |
1218 | 1191 | farg.ll = fload_invalid_op_excp(POWERPC_EXCP_FP_VXSNAN | POWERPC_EXCP_FP_VXCVI); |
1219 | - } else if (unlikely(float64_is_nan(farg.d) || isinfinity(farg.d))) { | |
1192 | + } else if (unlikely(float64_is_nan(farg.d) || float64_is_infinity(farg.d))) { | |
1220 | 1193 | /* qNan / infinity conversion */ |
1221 | 1194 | farg.ll = fload_invalid_op_excp(POWERPC_EXCP_FP_VXCVI); |
1222 | 1195 | } else { |
... | ... | @@ -1249,7 +1222,7 @@ uint64_t helper_fctid (uint64_t arg) |
1249 | 1222 | if (unlikely(float64_is_signaling_nan(farg.d))) { |
1250 | 1223 | /* sNaN conversion */ |
1251 | 1224 | farg.ll = fload_invalid_op_excp(POWERPC_EXCP_FP_VXSNAN | POWERPC_EXCP_FP_VXCVI); |
1252 | - } else if (unlikely(float64_is_nan(farg.d) || isinfinity(farg.d))) { | |
1225 | + } else if (unlikely(float64_is_nan(farg.d) || float64_is_infinity(farg.d))) { | |
1253 | 1226 | /* qNan / infinity conversion */ |
1254 | 1227 | farg.ll = fload_invalid_op_excp(POWERPC_EXCP_FP_VXCVI); |
1255 | 1228 | } else { |
... | ... | @@ -1267,7 +1240,7 @@ uint64_t helper_fctidz (uint64_t arg) |
1267 | 1240 | if (unlikely(float64_is_signaling_nan(farg.d))) { |
1268 | 1241 | /* sNaN conversion */ |
1269 | 1242 | farg.ll = fload_invalid_op_excp(POWERPC_EXCP_FP_VXSNAN | POWERPC_EXCP_FP_VXCVI); |
1270 | - } else if (unlikely(float64_is_nan(farg.d) || isinfinity(farg.d))) { | |
1243 | + } else if (unlikely(float64_is_nan(farg.d) || float64_is_infinity(farg.d))) { | |
1271 | 1244 | /* qNan / infinity conversion */ |
1272 | 1245 | farg.ll = fload_invalid_op_excp(POWERPC_EXCP_FP_VXCVI); |
1273 | 1246 | } else { |
... | ... | @@ -1286,7 +1259,7 @@ static always_inline uint64_t do_fri (uint64_t arg, int rounding_mode) |
1286 | 1259 | if (unlikely(float64_is_signaling_nan(farg.d))) { |
1287 | 1260 | /* sNaN round */ |
1288 | 1261 | farg.ll = fload_invalid_op_excp(POWERPC_EXCP_FP_VXSNAN | POWERPC_EXCP_FP_VXCVI); |
1289 | - } else if (unlikely(float64_is_nan(farg.d) || isinfinity(farg.d))) { | |
1262 | + } else if (unlikely(float64_is_nan(farg.d) || float64_is_infinity(farg.d))) { | |
1290 | 1263 | /* qNan / infinity round */ |
1291 | 1264 | farg.ll = fload_invalid_op_excp(POWERPC_EXCP_FP_VXCVI); |
1292 | 1265 | } else { |
... | ... | @@ -1503,7 +1476,7 @@ uint64_t helper_fsqrt (uint64_t arg) |
1503 | 1476 | if (unlikely(float64_is_signaling_nan(farg.d))) { |
1504 | 1477 | /* sNaN square root */ |
1505 | 1478 | farg.ll = fload_invalid_op_excp(POWERPC_EXCP_FP_VXSNAN); |
1506 | - } else if (unlikely(fpisneg(farg.d) && !iszero(farg.d))) { | |
1479 | + } else if (unlikely(float64_is_neg(farg.d) && !float64_is_zero(farg.d))) { | |
1507 | 1480 | /* Square root of a negative nonzero number */ |
1508 | 1481 | farg.ll = fload_invalid_op_excp(POWERPC_EXCP_FP_VXSQRT); |
1509 | 1482 | } else { |
... | ... | @@ -1522,7 +1495,7 @@ uint64_t helper_fre (uint64_t arg) |
1522 | 1495 | if (unlikely(float64_is_signaling_nan(farg.d))) { |
1523 | 1496 | /* sNaN reciprocal */ |
1524 | 1497 | farg.ll = fload_invalid_op_excp(POWERPC_EXCP_FP_VXSNAN); |
1525 | - } else if (unlikely(iszero(farg.d))) { | |
1498 | + } else if (unlikely(float64_is_zero(farg.d))) { | |
1526 | 1499 | /* Zero reciprocal */ |
1527 | 1500 | farg.ll = float_zero_divide_excp(fone.d, farg.d); |
1528 | 1501 | } else if (likely(isnormal(farg.d))) { |
... | ... | @@ -1534,7 +1507,7 @@ uint64_t helper_fre (uint64_t arg) |
1534 | 1507 | farg.ll = 0x7FF0000000000000ULL; |
1535 | 1508 | } else if (float64_is_nan(farg.d)) { |
1536 | 1509 | farg.ll = 0x7FF8000000000000ULL; |
1537 | - } else if (fpisneg(farg.d)) { | |
1510 | + } else if (float64_is_neg(farg.d)) { | |
1538 | 1511 | farg.ll = 0x8000000000000000ULL; |
1539 | 1512 | } else { |
1540 | 1513 | farg.ll = 0x0000000000000000ULL; |
... | ... | @@ -1553,7 +1526,7 @@ uint64_t helper_fres (uint64_t arg) |
1553 | 1526 | if (unlikely(float64_is_signaling_nan(farg.d))) { |
1554 | 1527 | /* sNaN reciprocal */ |
1555 | 1528 | farg.ll = fload_invalid_op_excp(POWERPC_EXCP_FP_VXSNAN); |
1556 | - } else if (unlikely(iszero(farg.d))) { | |
1529 | + } else if (unlikely(float64_is_zero(farg.d))) { | |
1557 | 1530 | /* Zero reciprocal */ |
1558 | 1531 | farg.ll = float_zero_divide_excp(fone.d, farg.d); |
1559 | 1532 | } else if (likely(isnormal(farg.d))) { |
... | ... | @@ -1570,7 +1543,7 @@ uint64_t helper_fres (uint64_t arg) |
1570 | 1543 | farg.ll = 0x7FF0000000000000ULL; |
1571 | 1544 | } else if (float64_is_nan(farg.d)) { |
1572 | 1545 | farg.ll = 0x7FF8000000000000ULL; |
1573 | - } else if (fpisneg(farg.d)) { | |
1546 | + } else if (float64_is_neg(farg.d)) { | |
1574 | 1547 | farg.ll = 0x8000000000000000ULL; |
1575 | 1548 | } else { |
1576 | 1549 | farg.ll = 0x0000000000000000ULL; |
... | ... | @@ -1589,7 +1562,7 @@ uint64_t helper_frsqrte (uint64_t arg) |
1589 | 1562 | if (unlikely(float64_is_signaling_nan(farg.d))) { |
1590 | 1563 | /* sNaN reciprocal square root */ |
1591 | 1564 | farg.ll = fload_invalid_op_excp(POWERPC_EXCP_FP_VXSNAN); |
1592 | - } else if (unlikely(fpisneg(farg.d) && !iszero(farg.d))) { | |
1565 | + } else if (unlikely(float64_is_neg(farg.d) && !float64_is_zero(farg.d))) { | |
1593 | 1566 | /* Reciprocal square root of a negative nonzero number */ |
1594 | 1567 | farg.ll = fload_invalid_op_excp(POWERPC_EXCP_FP_VXSQRT); |
1595 | 1568 | } else if (likely(isnormal(farg.d))) { |
... | ... | @@ -1602,7 +1575,7 @@ uint64_t helper_frsqrte (uint64_t arg) |
1602 | 1575 | farg.ll = 0x7FF0000000000000ULL; |
1603 | 1576 | } else if (float64_is_nan(farg.d)) { |
1604 | 1577 | farg.ll |= 0x000FFFFFFFFFFFFFULL; |
1605 | - } else if (fpisneg(farg.d)) { | |
1578 | + } else if (float64_is_neg(farg.d)) { | |
1606 | 1579 | farg.ll = 0x7FF8000000000000ULL; |
1607 | 1580 | } else { |
1608 | 1581 | farg.ll = 0x0000000000000000ULL; |
... | ... | @@ -1618,7 +1591,7 @@ uint64_t helper_fsel (uint64_t arg1, uint64_t arg2, uint64_t arg3) |
1618 | 1591 | |
1619 | 1592 | farg1.ll = arg1; |
1620 | 1593 | |
1621 | - if (!fpisneg(farg1.d) || iszero(farg1.d)) | |
1594 | + if (!float64_is_neg(farg1.d) || float64_is_zero(farg1.d)) | |
1622 | 1595 | return arg2; |
1623 | 1596 | else |
1624 | 1597 | return arg3; | ... | ... |