< prev index next >

src/cpu/ppc/vm/templateTable_ppc_64.cpp

Print this page




1455 
1456     case Bytecodes::_l2i:
1457       // Nothing to do, we'll continue to work with the lower bits.
1458       break;
1459 
1460     case Bytecodes::_i2b:
1461       __ extsb(R17_tos, R17_tos);
1462       break;
1463 
1464     case Bytecodes::_i2c:
1465       __ rldicl(R17_tos, R17_tos, 0, 64-2*8);
1466       break;
1467 
1468     case Bytecodes::_i2s:
1469       __ extsh(R17_tos, R17_tos);
1470       break;
1471 
1472     case Bytecodes::_i2d:
1473       __ extsw(R17_tos, R17_tos);
1474     case Bytecodes::_l2d:
1475       __ push_l_pop_d();
1476       __ fcfid(F15_ftos, F15_ftos);
1477       break;
1478 
1479     case Bytecodes::_i2f:
1480       __ extsw(R17_tos, R17_tos);
1481       __ push_l_pop_d();
1482       if (VM_Version::has_fcfids()) { // fcfids is >= Power7 only
1483         // Comment: alternatively, load with sign extend could be done by lfiwax.
1484         __ fcfids(F15_ftos, F15_ftos);
1485       } else {
1486         __ fcfid(F15_ftos, F15_ftos);
1487         __ frsp(F15_ftos, F15_ftos);
1488       }
1489       break;
1490 
1491     case Bytecodes::_l2f:
1492       if (VM_Version::has_fcfids()) { // fcfids is >= Power7 only
1493         __ push_l_pop_d();
1494         __ fcfids(F15_ftos, F15_ftos);
1495       } else {
1496         // Avoid rounding problem when result should be 0x3f800001: need fixup code before fcfid+frsp.
1497         __ mr(R3_ARG1, R17_tos);
1498         __ call_VM_leaf(CAST_FROM_FN_PTR(address, SharedRuntime::l2f));
1499         __ fmr(F15_ftos, F1_RET);
1500       }
1501       break;
1502 
1503     case Bytecodes::_f2d:
1504       // empty
1505       break;
1506 
1507     case Bytecodes::_d2f:
1508       __ frsp(F15_ftos, F15_ftos);
1509       break;
1510 
1511     case Bytecodes::_d2i:
1512     case Bytecodes::_f2i:
1513       __ fcmpu(CCR0, F15_ftos, F15_ftos);
1514       __ li(R17_tos, 0); // 0 in case of NAN
1515       __ bso(CCR0, done);
1516       __ fctiwz(F15_ftos, F15_ftos);
1517       __ push_d_pop_l();
1518       break;
1519 
1520     case Bytecodes::_d2l:
1521     case Bytecodes::_f2l:
1522       __ fcmpu(CCR0, F15_ftos, F15_ftos);
1523       __ li(R17_tos, 0); // 0 in case of NAN
1524       __ bso(CCR0, done);
1525       __ fctidz(F15_ftos, F15_ftos);
1526       __ push_d_pop_l();
1527       break;
1528 
1529     default: ShouldNotReachHere();
1530   }
1531   __ bind(done);
1532 }
1533 
1534 // Long compare
1535 void TemplateTable::lcmp() {
1536   transition(ltos, itos);
1537 
1538   const Register Rscratch = R11_scratch1;
1539   __ pop_l(Rscratch); // first operand, deeper in stack
1540 
1541   __ cmpd(CCR0, Rscratch, R17_tos); // compare
1542   __ mfcr(R17_tos); // set bit 32..33 as follows: <: 0b10, =: 0b00, >: 0b01
1543   __ srwi(Rscratch, R17_tos, 30);
1544   __ srawi(R17_tos, R17_tos, 31);
1545   __ orr(R17_tos, Rscratch, R17_tos); // set result as follows: <: -1, =: 0, >: 1
1546 }




1455 
1456     case Bytecodes::_l2i:
1457       // Nothing to do, we'll continue to work with the lower bits.
1458       break;
1459 
1460     case Bytecodes::_i2b:
1461       __ extsb(R17_tos, R17_tos);
1462       break;
1463 
1464     case Bytecodes::_i2c:
1465       __ rldicl(R17_tos, R17_tos, 0, 64-2*8);
1466       break;
1467 
1468     case Bytecodes::_i2s:
1469       __ extsh(R17_tos, R17_tos);
1470       break;
1471 
1472     case Bytecodes::_i2d:
1473       __ extsw(R17_tos, R17_tos);
1474     case Bytecodes::_l2d:
1475       __ move_l_to_d();
1476       __ fcfid(F15_ftos, F15_ftos);
1477       break;
1478 
1479     case Bytecodes::_i2f:
1480       __ extsw(R17_tos, R17_tos);
1481       __ move_l_to_d();
1482       if (VM_Version::has_fcfids()) { // fcfids is >= Power7 only
1483         // Comment: alternatively, load with sign extend could be done by lfiwax.
1484         __ fcfids(F15_ftos, F15_ftos);
1485       } else {
1486         __ fcfid(F15_ftos, F15_ftos);
1487         __ frsp(F15_ftos, F15_ftos);
1488       }
1489       break;
1490 
1491     case Bytecodes::_l2f:
1492       if (VM_Version::has_fcfids()) { // fcfids is >= Power7 only
1493         __ move_l_to_d();
1494         __ fcfids(F15_ftos, F15_ftos);
1495       } else {
1496         // Avoid rounding problem when result should be 0x3f800001: need fixup code before fcfid+frsp.
1497         __ mr(R3_ARG1, R17_tos);
1498         __ call_VM_leaf(CAST_FROM_FN_PTR(address, SharedRuntime::l2f));
1499         __ fmr(F15_ftos, F1_RET);
1500       }
1501       break;
1502 
1503     case Bytecodes::_f2d:
1504       // empty
1505       break;
1506 
1507     case Bytecodes::_d2f:
1508       __ frsp(F15_ftos, F15_ftos);
1509       break;
1510 
1511     case Bytecodes::_d2i:
1512     case Bytecodes::_f2i:
1513       __ fcmpu(CCR0, F15_ftos, F15_ftos);
1514       __ li(R17_tos, 0); // 0 in case of NAN
1515       __ bso(CCR0, done);
1516       __ fctiwz(F15_ftos, F15_ftos);
1517       __ move_d_to_l();
1518       break;
1519 
1520     case Bytecodes::_d2l:
1521     case Bytecodes::_f2l:
1522       __ fcmpu(CCR0, F15_ftos, F15_ftos);
1523       __ li(R17_tos, 0); // 0 in case of NAN
1524       __ bso(CCR0, done);
1525       __ fctidz(F15_ftos, F15_ftos);
1526       __ move_d_to_l();
1527       break;
1528 
1529     default: ShouldNotReachHere();
1530   }
1531   __ bind(done);
1532 }
1533 
1534 // Long compare
1535 void TemplateTable::lcmp() {
1536   transition(ltos, itos);
1537 
1538   const Register Rscratch = R11_scratch1;
1539   __ pop_l(Rscratch); // first operand, deeper in stack
1540 
1541   __ cmpd(CCR0, Rscratch, R17_tos); // compare
1542   __ mfcr(R17_tos); // set bit 32..33 as follows: <: 0b10, =: 0b00, >: 0b01
1543   __ srwi(Rscratch, R17_tos, 30);
1544   __ srawi(R17_tos, R17_tos, 31);
1545   __ orr(R17_tos, Rscratch, R17_tos); // set result as follows: <: -1, =: 0, >: 1
1546 }


< prev index next >