Commit f23c346e69e293d26fdbb2bd06310b4e261b4749

Authored by aurel32
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,15 +554,6 @@ uint32_t helper_float64_to_float32(uint64_t arg)
554 return f.l; 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 static always_inline int isden (float64 d) 557 static always_inline int isden (float64 d)
567 { 558 {
568 CPU_DoubleU u; 559 CPU_DoubleU u;
@@ -572,24 +563,6 @@ static always_inline int isden (float64 d) @@ -572,24 +563,6 @@ static always_inline int isden (float64 d)
572 return ((u.ll >> 52) & 0x7FF) == 0; 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 #ifdef CONFIG_SOFTFLOAT 567 #ifdef CONFIG_SOFTFLOAT
595 static always_inline int isfinite (float64 d) 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,7 +591,7 @@ uint32_t helper_compute_fprf (uint64_t arg, uint32_t set_fprf)
618 int isneg; 591 int isneg;
619 int ret; 592 int ret;
620 farg.ll = arg; 593 farg.ll = arg;
621 - isneg = fpisneg(farg.d); 594 + isneg = float64_is_neg(farg.d);
622 if (unlikely(float64_is_nan(farg.d))) { 595 if (unlikely(float64_is_nan(farg.d))) {
623 if (float64_is_signaling_nan(farg.d)) { 596 if (float64_is_signaling_nan(farg.d)) {
624 /* Signaling NaN: flags are undefined */ 597 /* Signaling NaN: flags are undefined */
@@ -627,14 +600,14 @@ uint32_t helper_compute_fprf (uint64_t arg, uint32_t set_fprf) @@ -627,14 +600,14 @@ uint32_t helper_compute_fprf (uint64_t arg, uint32_t set_fprf)
627 /* Quiet NaN */ 600 /* Quiet NaN */
628 ret = 0x11; 601 ret = 0x11;
629 } 602 }
630 - } else if (unlikely(isinfinity(farg.d))) { 603 + } else if (unlikely(float64_is_infinity(farg.d))) {
631 /* +/- infinity */ 604 /* +/- infinity */
632 if (isneg) 605 if (isneg)
633 ret = 0x09; 606 ret = 0x09;
634 else 607 else
635 ret = 0x05; 608 ret = 0x05;
636 } else { 609 } else {
637 - if (iszero(farg.d)) { 610 + if (float64_is_zero(farg.d)) {
638 /* +/- zero */ 611 /* +/- zero */
639 if (isneg) 612 if (isneg)
640 ret = 0x12; 613 ret = 0x12;
@@ -1056,7 +1029,7 @@ uint64_t helper_fadd (uint64_t arg1, uint64_t arg2) @@ -1056,7 +1029,7 @@ uint64_t helper_fadd (uint64_t arg1, uint64_t arg2)
1056 /* sNaN addition */ 1029 /* sNaN addition */
1057 farg1.ll = fload_invalid_op_excp(POWERPC_EXCP_FP_VXSNAN); 1030 farg1.ll = fload_invalid_op_excp(POWERPC_EXCP_FP_VXSNAN);
1058 } else if (likely(isfinite(farg1.d) || isfinite(farg2.d) || 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 farg1.d = float64_add(farg1.d, farg2.d, &env->fp_status); 1033 farg1.d = float64_add(farg1.d, farg2.d, &env->fp_status);
1061 } else { 1034 } else {
1062 /* Magnitude subtraction of infinities */ 1035 /* Magnitude subtraction of infinities */
@@ -1082,7 +1055,7 @@ uint64_t helper_fsub (uint64_t arg1, uint64_t arg2) @@ -1082,7 +1055,7 @@ uint64_t helper_fsub (uint64_t arg1, uint64_t arg2)
1082 /* sNaN subtraction */ 1055 /* sNaN subtraction */
1083 farg1.ll = fload_invalid_op_excp(POWERPC_EXCP_FP_VXSNAN); 1056 farg1.ll = fload_invalid_op_excp(POWERPC_EXCP_FP_VXSNAN);
1084 } else if (likely(isfinite(farg1.d) || isfinite(farg2.d) || 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 farg1.d = float64_sub(farg1.d, farg2.d, &env->fp_status); 1059 farg1.d = float64_sub(farg1.d, farg2.d, &env->fp_status);
1087 } else { 1060 } else {
1088 /* Magnitude subtraction of infinities */ 1061 /* Magnitude subtraction of infinities */
@@ -1107,8 +1080,8 @@ uint64_t helper_fmul (uint64_t arg1, uint64_t arg2) @@ -1107,8 +1080,8 @@ uint64_t helper_fmul (uint64_t arg1, uint64_t arg2)
1107 float64_is_signaling_nan(farg2.d))) { 1080 float64_is_signaling_nan(farg2.d))) {
1108 /* sNaN multiplication */ 1081 /* sNaN multiplication */
1109 farg1.ll = fload_invalid_op_excp(POWERPC_EXCP_FP_VXSNAN); 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 /* Multiplication of zero by infinity */ 1085 /* Multiplication of zero by infinity */
1113 farg1.ll = fload_invalid_op_excp(POWERPC_EXCP_FP_VXIMZ); 1086 farg1.ll = fload_invalid_op_excp(POWERPC_EXCP_FP_VXIMZ);
1114 } else { 1087 } else {
@@ -1132,11 +1105,11 @@ uint64_t helper_fdiv (uint64_t arg1, uint64_t arg2) @@ -1132,11 +1105,11 @@ uint64_t helper_fdiv (uint64_t arg1, uint64_t arg2)
1132 float64_is_signaling_nan(farg2.d))) { 1105 float64_is_signaling_nan(farg2.d))) {
1133 /* sNaN division */ 1106 /* sNaN division */
1134 farg1.ll = fload_invalid_op_excp(POWERPC_EXCP_FP_VXSNAN); 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 /* Division of infinity by infinity */ 1109 /* Division of infinity by infinity */
1137 farg1.ll = fload_invalid_op_excp(POWERPC_EXCP_FP_VXIDI); 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 /* Division of zero by zero */ 1113 /* Division of zero by zero */
1141 farg1.ll = fload_invalid_op_excp(POWERPC_EXCP_FP_VXZDZ); 1114 farg1.ll = fload_invalid_op_excp(POWERPC_EXCP_FP_VXZDZ);
1142 } else { 1115 } else {
@@ -1192,7 +1165,7 @@ uint64_t helper_fctiw (uint64_t arg) @@ -1192,7 +1165,7 @@ uint64_t helper_fctiw (uint64_t arg)
1192 if (unlikely(float64_is_signaling_nan(farg.d))) { 1165 if (unlikely(float64_is_signaling_nan(farg.d))) {
1193 /* sNaN conversion */ 1166 /* sNaN conversion */
1194 farg.ll = fload_invalid_op_excp(POWERPC_EXCP_FP_VXSNAN | POWERPC_EXCP_FP_VXCVI); 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 /* qNan / infinity conversion */ 1169 /* qNan / infinity conversion */
1197 farg.ll = fload_invalid_op_excp(POWERPC_EXCP_FP_VXCVI); 1170 farg.ll = fload_invalid_op_excp(POWERPC_EXCP_FP_VXCVI);
1198 } else { 1171 } else {
@@ -1216,7 +1189,7 @@ uint64_t helper_fctiwz (uint64_t arg) @@ -1216,7 +1189,7 @@ uint64_t helper_fctiwz (uint64_t arg)
1216 if (unlikely(float64_is_signaling_nan(farg.d))) { 1189 if (unlikely(float64_is_signaling_nan(farg.d))) {
1217 /* sNaN conversion */ 1190 /* sNaN conversion */
1218 farg.ll = fload_invalid_op_excp(POWERPC_EXCP_FP_VXSNAN | POWERPC_EXCP_FP_VXCVI); 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 /* qNan / infinity conversion */ 1193 /* qNan / infinity conversion */
1221 farg.ll = fload_invalid_op_excp(POWERPC_EXCP_FP_VXCVI); 1194 farg.ll = fload_invalid_op_excp(POWERPC_EXCP_FP_VXCVI);
1222 } else { 1195 } else {
@@ -1249,7 +1222,7 @@ uint64_t helper_fctid (uint64_t arg) @@ -1249,7 +1222,7 @@ uint64_t helper_fctid (uint64_t arg)
1249 if (unlikely(float64_is_signaling_nan(farg.d))) { 1222 if (unlikely(float64_is_signaling_nan(farg.d))) {
1250 /* sNaN conversion */ 1223 /* sNaN conversion */
1251 farg.ll = fload_invalid_op_excp(POWERPC_EXCP_FP_VXSNAN | POWERPC_EXCP_FP_VXCVI); 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 /* qNan / infinity conversion */ 1226 /* qNan / infinity conversion */
1254 farg.ll = fload_invalid_op_excp(POWERPC_EXCP_FP_VXCVI); 1227 farg.ll = fload_invalid_op_excp(POWERPC_EXCP_FP_VXCVI);
1255 } else { 1228 } else {
@@ -1267,7 +1240,7 @@ uint64_t helper_fctidz (uint64_t arg) @@ -1267,7 +1240,7 @@ uint64_t helper_fctidz (uint64_t arg)
1267 if (unlikely(float64_is_signaling_nan(farg.d))) { 1240 if (unlikely(float64_is_signaling_nan(farg.d))) {
1268 /* sNaN conversion */ 1241 /* sNaN conversion */
1269 farg.ll = fload_invalid_op_excp(POWERPC_EXCP_FP_VXSNAN | POWERPC_EXCP_FP_VXCVI); 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 /* qNan / infinity conversion */ 1244 /* qNan / infinity conversion */
1272 farg.ll = fload_invalid_op_excp(POWERPC_EXCP_FP_VXCVI); 1245 farg.ll = fload_invalid_op_excp(POWERPC_EXCP_FP_VXCVI);
1273 } else { 1246 } else {
@@ -1286,7 +1259,7 @@ static always_inline uint64_t do_fri (uint64_t arg, int rounding_mode) @@ -1286,7 +1259,7 @@ static always_inline uint64_t do_fri (uint64_t arg, int rounding_mode)
1286 if (unlikely(float64_is_signaling_nan(farg.d))) { 1259 if (unlikely(float64_is_signaling_nan(farg.d))) {
1287 /* sNaN round */ 1260 /* sNaN round */
1288 farg.ll = fload_invalid_op_excp(POWERPC_EXCP_FP_VXSNAN | POWERPC_EXCP_FP_VXCVI); 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 /* qNan / infinity round */ 1263 /* qNan / infinity round */
1291 farg.ll = fload_invalid_op_excp(POWERPC_EXCP_FP_VXCVI); 1264 farg.ll = fload_invalid_op_excp(POWERPC_EXCP_FP_VXCVI);
1292 } else { 1265 } else {
@@ -1503,7 +1476,7 @@ uint64_t helper_fsqrt (uint64_t arg) @@ -1503,7 +1476,7 @@ uint64_t helper_fsqrt (uint64_t arg)
1503 if (unlikely(float64_is_signaling_nan(farg.d))) { 1476 if (unlikely(float64_is_signaling_nan(farg.d))) {
1504 /* sNaN square root */ 1477 /* sNaN square root */
1505 farg.ll = fload_invalid_op_excp(POWERPC_EXCP_FP_VXSNAN); 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 /* Square root of a negative nonzero number */ 1480 /* Square root of a negative nonzero number */
1508 farg.ll = fload_invalid_op_excp(POWERPC_EXCP_FP_VXSQRT); 1481 farg.ll = fload_invalid_op_excp(POWERPC_EXCP_FP_VXSQRT);
1509 } else { 1482 } else {
@@ -1522,7 +1495,7 @@ uint64_t helper_fre (uint64_t arg) @@ -1522,7 +1495,7 @@ uint64_t helper_fre (uint64_t arg)
1522 if (unlikely(float64_is_signaling_nan(farg.d))) { 1495 if (unlikely(float64_is_signaling_nan(farg.d))) {
1523 /* sNaN reciprocal */ 1496 /* sNaN reciprocal */
1524 farg.ll = fload_invalid_op_excp(POWERPC_EXCP_FP_VXSNAN); 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 /* Zero reciprocal */ 1499 /* Zero reciprocal */
1527 farg.ll = float_zero_divide_excp(fone.d, farg.d); 1500 farg.ll = float_zero_divide_excp(fone.d, farg.d);
1528 } else if (likely(isnormal(farg.d))) { 1501 } else if (likely(isnormal(farg.d))) {
@@ -1534,7 +1507,7 @@ uint64_t helper_fre (uint64_t arg) @@ -1534,7 +1507,7 @@ uint64_t helper_fre (uint64_t arg)
1534 farg.ll = 0x7FF0000000000000ULL; 1507 farg.ll = 0x7FF0000000000000ULL;
1535 } else if (float64_is_nan(farg.d)) { 1508 } else if (float64_is_nan(farg.d)) {
1536 farg.ll = 0x7FF8000000000000ULL; 1509 farg.ll = 0x7FF8000000000000ULL;
1537 - } else if (fpisneg(farg.d)) { 1510 + } else if (float64_is_neg(farg.d)) {
1538 farg.ll = 0x8000000000000000ULL; 1511 farg.ll = 0x8000000000000000ULL;
1539 } else { 1512 } else {
1540 farg.ll = 0x0000000000000000ULL; 1513 farg.ll = 0x0000000000000000ULL;
@@ -1553,7 +1526,7 @@ uint64_t helper_fres (uint64_t arg) @@ -1553,7 +1526,7 @@ uint64_t helper_fres (uint64_t arg)
1553 if (unlikely(float64_is_signaling_nan(farg.d))) { 1526 if (unlikely(float64_is_signaling_nan(farg.d))) {
1554 /* sNaN reciprocal */ 1527 /* sNaN reciprocal */
1555 farg.ll = fload_invalid_op_excp(POWERPC_EXCP_FP_VXSNAN); 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 /* Zero reciprocal */ 1530 /* Zero reciprocal */
1558 farg.ll = float_zero_divide_excp(fone.d, farg.d); 1531 farg.ll = float_zero_divide_excp(fone.d, farg.d);
1559 } else if (likely(isnormal(farg.d))) { 1532 } else if (likely(isnormal(farg.d))) {
@@ -1570,7 +1543,7 @@ uint64_t helper_fres (uint64_t arg) @@ -1570,7 +1543,7 @@ uint64_t helper_fres (uint64_t arg)
1570 farg.ll = 0x7FF0000000000000ULL; 1543 farg.ll = 0x7FF0000000000000ULL;
1571 } else if (float64_is_nan(farg.d)) { 1544 } else if (float64_is_nan(farg.d)) {
1572 farg.ll = 0x7FF8000000000000ULL; 1545 farg.ll = 0x7FF8000000000000ULL;
1573 - } else if (fpisneg(farg.d)) { 1546 + } else if (float64_is_neg(farg.d)) {
1574 farg.ll = 0x8000000000000000ULL; 1547 farg.ll = 0x8000000000000000ULL;
1575 } else { 1548 } else {
1576 farg.ll = 0x0000000000000000ULL; 1549 farg.ll = 0x0000000000000000ULL;
@@ -1589,7 +1562,7 @@ uint64_t helper_frsqrte (uint64_t arg) @@ -1589,7 +1562,7 @@ uint64_t helper_frsqrte (uint64_t arg)
1589 if (unlikely(float64_is_signaling_nan(farg.d))) { 1562 if (unlikely(float64_is_signaling_nan(farg.d))) {
1590 /* sNaN reciprocal square root */ 1563 /* sNaN reciprocal square root */
1591 farg.ll = fload_invalid_op_excp(POWERPC_EXCP_FP_VXSNAN); 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 /* Reciprocal square root of a negative nonzero number */ 1566 /* Reciprocal square root of a negative nonzero number */
1594 farg.ll = fload_invalid_op_excp(POWERPC_EXCP_FP_VXSQRT); 1567 farg.ll = fload_invalid_op_excp(POWERPC_EXCP_FP_VXSQRT);
1595 } else if (likely(isnormal(farg.d))) { 1568 } else if (likely(isnormal(farg.d))) {
@@ -1602,7 +1575,7 @@ uint64_t helper_frsqrte (uint64_t arg) @@ -1602,7 +1575,7 @@ uint64_t helper_frsqrte (uint64_t arg)
1602 farg.ll = 0x7FF0000000000000ULL; 1575 farg.ll = 0x7FF0000000000000ULL;
1603 } else if (float64_is_nan(farg.d)) { 1576 } else if (float64_is_nan(farg.d)) {
1604 farg.ll |= 0x000FFFFFFFFFFFFFULL; 1577 farg.ll |= 0x000FFFFFFFFFFFFFULL;
1605 - } else if (fpisneg(farg.d)) { 1578 + } else if (float64_is_neg(farg.d)) {
1606 farg.ll = 0x7FF8000000000000ULL; 1579 farg.ll = 0x7FF8000000000000ULL;
1607 } else { 1580 } else {
1608 farg.ll = 0x0000000000000000ULL; 1581 farg.ll = 0x0000000000000000ULL;
@@ -1618,7 +1591,7 @@ uint64_t helper_fsel (uint64_t arg1, uint64_t arg2, uint64_t arg3) @@ -1618,7 +1591,7 @@ uint64_t helper_fsel (uint64_t arg1, uint64_t arg2, uint64_t arg3)
1618 1591
1619 farg1.ll = arg1; 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 return arg2; 1595 return arg2;
1623 else 1596 else
1624 return arg3; 1597 return arg3;