OLD | NEW |
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 the V8 project authors. All rights reserved. |
2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
4 // met: | 4 // met: |
5 // | 5 // |
6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
(...skipping 1421 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1432 // Signed data, 32 & 64. | 1432 // Signed data, 32 & 64. |
1433 CHECK_EQ(static_cast<int64_t>(0x33333333ffffbbccL), t.r3); | 1433 CHECK_EQ(static_cast<int64_t>(0x33333333ffffbbccL), t.r3); |
1434 CHECK_EQ(static_cast<int64_t>(0xffffffff0000bbccL), t.r4); | 1434 CHECK_EQ(static_cast<int64_t>(0xffffffff0000bbccL), t.r4); |
1435 | 1435 |
1436 // Signed data, 32 & 64. | 1436 // Signed data, 32 & 64. |
1437 CHECK_EQ(static_cast<int64_t>(0x55555555ffffffccL), t.r5); | 1437 CHECK_EQ(static_cast<int64_t>(0x55555555ffffffccL), t.r5); |
1438 CHECK_EQ(static_cast<int64_t>(0x000000003333bbccL), t.r6); | 1438 CHECK_EQ(static_cast<int64_t>(0x000000003333bbccL), t.r6); |
1439 } | 1439 } |
1440 | 1440 |
1441 | 1441 |
1442 // ----------------------mips32r6 specific tests---------------------- | 1442 TEST(MIPS17) { |
1443 TEST(seleqz_selnez) { | |
1444 if (kArchVariant == kMips64r6) { | 1443 if (kArchVariant == kMips64r6) { |
1445 CcTest::InitializeVM(); | 1444 CcTest::InitializeVM(); |
1446 Isolate* isolate = CcTest::i_isolate(); | 1445 Isolate* isolate = CcTest::i_isolate(); |
1447 HandleScope scope(isolate); | 1446 HandleScope scope(isolate); |
1448 MacroAssembler assm(isolate, NULL, 0); | 1447 MacroAssembler assm(isolate, NULL, 0); |
1449 | 1448 |
1450 typedef struct test { | 1449 typedef struct test { |
1451 int a; | 1450 int a; |
1452 int b; | 1451 int b; |
1453 int c; | 1452 int c; |
1454 int d; | 1453 int d; |
1455 double e; | 1454 double e; |
1456 double f; | 1455 double f; |
1457 double g; | 1456 double g; |
1458 double h; | 1457 double h; |
1459 float i; | |
1460 float j; | |
1461 float k; | |
1462 float l; | |
1463 } Test; | 1458 } Test; |
1464 | 1459 |
1465 Test test; | 1460 Test test; |
1466 // Integer part of test. | 1461 // Integer part of test. |
1467 __ addiu(t1, zero_reg, 1); // t1 = 1 | 1462 __ addiu(t1, zero_reg, 1); // t1 = 1 |
1468 __ seleqz(t3, t1, zero_reg); // t3 = 1 | 1463 __ seleqz(t3, t1, zero_reg); // t3 = 1 |
1469 __ sw(t3, MemOperand(a0, OFFSET_OF(Test, a))); // a = 1 | 1464 __ sw(t3, MemOperand(a0, OFFSET_OF(Test, a))); // a = 1 |
1470 __ seleqz(t2, t1, t1); // t2 = 0 | 1465 __ seleqz(t2, t1, t1); // t2 = 0 |
1471 __ sw(t2, MemOperand(a0, OFFSET_OF(Test, b))); // b = 0 | 1466 __ sw(t2, MemOperand(a0, OFFSET_OF(Test, b))); // b = 0 |
1472 __ selnez(t3, t1, zero_reg); // t3 = 1; | 1467 __ selnez(t3, t1, zero_reg); // t3 = 1; |
1473 __ sw(t3, MemOperand(a0, OFFSET_OF(Test, c))); // c = 0 | 1468 __ sw(t3, MemOperand(a0, OFFSET_OF(Test, c))); // c = 0 |
1474 __ selnez(t3, t1, t1); // t3 = 1 | 1469 __ selnez(t3, t1, t1); // t3 = 1 |
1475 __ sw(t3, MemOperand(a0, OFFSET_OF(Test, d))); // d = 1 | 1470 __ sw(t3, MemOperand(a0, OFFSET_OF(Test, d))); // d = 1 |
1476 // Floating point part of test. | 1471 // Floating point part of test. |
1477 __ ldc1(f0, MemOperand(a0, OFFSET_OF(Test, e)) ); // src | 1472 __ ldc1(f0, MemOperand(a0, OFFSET_OF(Test, e)) ); // src |
1478 __ ldc1(f2, MemOperand(a0, OFFSET_OF(Test, f)) ); // test | 1473 __ ldc1(f2, MemOperand(a0, OFFSET_OF(Test, f)) ); // test |
1479 __ lwc1(f8, MemOperand(a0, OFFSET_OF(Test, i)) ); // src | 1474 __ seleqz(D, f4, f0, f2); |
1480 __ lwc1(f10, MemOperand(a0, OFFSET_OF(Test, j)) ); // test | 1475 __ selnez(D, f6, f0, f2); |
1481 __ seleqz_d(f4, f0, f2); | |
1482 __ selnez_d(f6, f0, f2); | |
1483 __ seleqz_s(f12, f8, f10); | |
1484 __ selnez_s(f14, f8, f10); | |
1485 __ sdc1(f4, MemOperand(a0, OFFSET_OF(Test, g)) ); // src | 1476 __ sdc1(f4, MemOperand(a0, OFFSET_OF(Test, g)) ); // src |
1486 __ sdc1(f6, MemOperand(a0, OFFSET_OF(Test, h)) ); // src | 1477 __ sdc1(f6, MemOperand(a0, OFFSET_OF(Test, h)) ); // src |
1487 __ swc1(f12, MemOperand(a0, OFFSET_OF(Test, k)) ); // src | |
1488 __ swc1(f14, MemOperand(a0, OFFSET_OF(Test, l)) ); // src | |
1489 __ jr(ra); | 1478 __ jr(ra); |
1490 __ nop(); | 1479 __ nop(); |
1491 CodeDesc desc; | 1480 CodeDesc desc; |
1492 assm.GetCode(&desc); | 1481 assm.GetCode(&desc); |
1493 Handle<Code> code = isolate->factory()->NewCode( | 1482 Handle<Code> code = isolate->factory()->NewCode( |
1494 desc, Code::ComputeFlags(Code::STUB), Handle<Code>()); | 1483 desc, Code::ComputeFlags(Code::STUB), Handle<Code>()); |
1495 F3 f = FUNCTION_CAST<F3>(code->entry()); | 1484 F3 f = FUNCTION_CAST<F3>(code->entry()); |
1496 | 1485 |
1497 (CALL_GENERATED_CODE(f, &test, 0, 0, 0, 0)); | 1486 (CALL_GENERATED_CODE(f, &test, 0, 0, 0, 0)); |
1498 | 1487 |
1499 CHECK_EQ(test.a, 1); | 1488 CHECK_EQ(test.a, 1); |
1500 CHECK_EQ(test.b, 0); | 1489 CHECK_EQ(test.b, 0); |
1501 CHECK_EQ(test.c, 0); | 1490 CHECK_EQ(test.c, 0); |
1502 CHECK_EQ(test.d, 1); | 1491 CHECK_EQ(test.d, 1); |
1503 | 1492 |
1504 const int test_size = 3; | 1493 const int test_size = 3; |
1505 const int input_size = 5; | 1494 const int input_size = 5; |
1506 | 1495 |
1507 double inputs_D[input_size] = {0.0, 65.2, -70.32, | 1496 double inputs[input_size] = {0.0, 65.2, -70.32, |
1508 18446744073709551621.0, -18446744073709551621.0}; | 1497 18446744073709551621.0, -18446744073709551621.0}; |
1509 double outputs_D[input_size] = {0.0, 65.2, -70.32, | 1498 double outputs[input_size] = {0.0, 65.2, -70.32, |
1510 18446744073709551621.0, -18446744073709551621.0}; | 1499 18446744073709551621.0, -18446744073709551621.0}; |
1511 double tests_D[test_size*2] = {2.8, 2.9, -2.8, -2.9, | 1500 double tests[test_size*2] = {2.8, 2.9, -2.8, -2.9, |
1512 18446744073709551616.0, 18446744073709555712.0}; | 1501 18446744073709551616.0, 18446744073709555712.0}; |
1513 float inputs_S[input_size] = {0.0, 65.2, -70.32, | 1502 for (int j=0;j < test_size;j+=2) { |
1514 18446744073709551621.0, -18446744073709551621.0}; | 1503 for (int i=0;i < input_size;i++) { |
1515 float outputs_S[input_size] = {0.0, 65.2, -70.32, | 1504 test.e = inputs[i]; |
1516 18446744073709551621.0, -18446744073709551621.0}; | 1505 test.f = tests[j]; |
1517 float tests_S[test_size*2] = {2.9, 2.8, -2.9, -2.8, | |
1518 18446744073709551616.0, 18446746272732807168.0}; | |
1519 for (int j=0; j < test_size; j+=2) { | |
1520 for (int i=0; i < input_size; i++) { | |
1521 test.e = inputs_D[i]; | |
1522 test.f = tests_D[j]; | |
1523 test.i = inputs_S[i]; | |
1524 test.j = tests_S[j]; | |
1525 (CALL_GENERATED_CODE(f, &test, 0, 0, 0, 0)); | 1506 (CALL_GENERATED_CODE(f, &test, 0, 0, 0, 0)); |
1526 CHECK_EQ(test.g, outputs_D[i]); | 1507 CHECK_EQ(test.g, outputs[i]); |
1527 CHECK_EQ(test.h, 0); | 1508 CHECK_EQ(test.h, 0); |
1528 CHECK_EQ(test.k, outputs_S[i]); | |
1529 CHECK_EQ(test.l, 0); | |
1530 | 1509 |
1531 test.f = tests_D[j+1]; | 1510 test.f = tests[j+1]; |
1532 test.j = tests_S[j+1]; | |
1533 (CALL_GENERATED_CODE(f, &test, 0, 0, 0, 0)); | 1511 (CALL_GENERATED_CODE(f, &test, 0, 0, 0, 0)); |
1534 CHECK_EQ(test.g, 0); | 1512 CHECK_EQ(test.g, 0); |
1535 CHECK_EQ(test.h, outputs_D[i]); | 1513 CHECK_EQ(test.h, outputs[i]); |
1536 CHECK_EQ(test.k, 0); | |
1537 CHECK_EQ(test.l, outputs_S[i]); | |
1538 } | 1514 } |
1539 } | 1515 } |
1540 } | 1516 } |
1541 } | 1517 } |
1542 | 1518 |
1543 | 1519 |
1544 | 1520 TEST(MIPS18) { |
1545 TEST(min_max) { | |
1546 if (kArchVariant == kMips64r6) { | 1521 if (kArchVariant == kMips64r6) { |
1547 CcTest::InitializeVM(); | 1522 CcTest::InitializeVM(); |
1548 Isolate* isolate = CcTest::i_isolate(); | 1523 Isolate* isolate = CcTest::i_isolate(); |
1549 HandleScope scope(isolate); | 1524 HandleScope scope(isolate); |
1550 MacroAssembler assm(isolate, NULL, 0); | 1525 MacroAssembler assm(isolate, NULL, 0); |
1551 | 1526 |
1552 typedef struct test_float { | 1527 typedef struct test_float { |
1553 double a; | 1528 double a; |
1554 double b; | 1529 double b; |
1555 double c; | 1530 double c; |
1556 double d; | 1531 double d; |
1557 float e; | |
1558 float f; | |
1559 float g; | |
1560 float h; | |
1561 } TestFloat; | 1532 } TestFloat; |
1562 | 1533 |
1563 TestFloat test; | 1534 TestFloat test; |
1564 const double dblNaN = std::numeric_limits<double>::quiet_NaN(); | |
1565 const float fltNaN = std::numeric_limits<float>::quiet_NaN(); | |
1566 const int tableLength = 5; | |
1567 double inputsa[tableLength] = {2.0, 3.0, dblNaN, 3.0, dblNaN}; | |
1568 double inputsb[tableLength] = {3.0, 2.0, 3.0, dblNaN, dblNaN}; | |
1569 double outputsdmin[tableLength] = {2.0, 2.0, 3.0, 3.0, dblNaN}; | |
1570 double outputsdmax[tableLength] = {3.0, 3.0, 3.0, 3.0, dblNaN}; | |
1571 | |
1572 float inputse[tableLength] = {2.0, 3.0, fltNaN, 3.0, fltNaN}; | |
1573 float inputsf[tableLength] = {3.0, 2.0, 3.0, fltNaN, fltNaN}; | |
1574 float outputsfmin[tableLength] = {2.0, 2.0, 3.0, 3.0, fltNaN}; | |
1575 float outputsfmax[tableLength] = {3.0, 3.0, 3.0, 3.0, fltNaN}; | |
1576 | 1535 |
1577 __ ldc1(f4, MemOperand(a0, OFFSET_OF(TestFloat, a))); | 1536 __ ldc1(f4, MemOperand(a0, OFFSET_OF(TestFloat, a))); |
1578 __ ldc1(f8, MemOperand(a0, OFFSET_OF(TestFloat, b))); | 1537 __ ldc1(f8, MemOperand(a0, OFFSET_OF(TestFloat, b))); |
1579 __ lwc1(f2, MemOperand(a0, OFFSET_OF(TestFloat, e))); | |
1580 __ lwc1(f6, MemOperand(a0, OFFSET_OF(TestFloat, f))); | |
1581 __ min_d(f10, f4, f8); | 1538 __ min_d(f10, f4, f8); |
1582 __ max_d(f12, f4, f8); | 1539 __ max_d(f12, f4, f8); |
1583 __ min_s(f14, f2, f6); | |
1584 __ max_s(f16, f2, f6); | |
1585 __ sdc1(f10, MemOperand(a0, OFFSET_OF(TestFloat, c))); | 1540 __ sdc1(f10, MemOperand(a0, OFFSET_OF(TestFloat, c))); |
1586 __ sdc1(f12, MemOperand(a0, OFFSET_OF(TestFloat, d))); | 1541 __ sdc1(f12, MemOperand(a0, OFFSET_OF(TestFloat, d))); |
1587 __ swc1(f14, MemOperand(a0, OFFSET_OF(TestFloat, g))); | |
1588 __ swc1(f16, MemOperand(a0, OFFSET_OF(TestFloat, h))); | |
1589 __ jr(ra); | 1542 __ jr(ra); |
1590 __ nop(); | 1543 __ nop(); |
1591 | 1544 |
1592 CodeDesc desc; | 1545 CodeDesc desc; |
1593 assm.GetCode(&desc); | 1546 assm.GetCode(&desc); |
1594 Handle<Code> code = isolate->factory()->NewCode( | 1547 Handle<Code> code = isolate->factory()->NewCode( |
1595 desc, Code::ComputeFlags(Code::STUB), Handle<Code>()); | 1548 desc, Code::ComputeFlags(Code::STUB), Handle<Code>()); |
1596 F3 f = FUNCTION_CAST<F3>(code->entry()); | 1549 F3 f = FUNCTION_CAST<F3>(code->entry()); |
1597 for (int i = 0; i < tableLength; i++) { | 1550 test.a = 2.0; // a goes to fs |
1598 test.a = inputsa[i]; | 1551 test.b = 3.0; // b goes to ft |
1599 test.b = inputsb[i]; | 1552 (CALL_GENERATED_CODE(f, &test, 0, 0, 0, 0)); |
1600 test.e = inputse[i]; | 1553 CHECK_EQ(test.c, 2.0); |
1601 test.f = inputsf[i]; | 1554 CHECK_EQ(test.d, 3.0); |
1602 | 1555 |
1603 (CALL_GENERATED_CODE(f, &test, 0, 0, 0, 0)); | 1556 test.a = 3.0; // a goes to fs |
| 1557 test.b = 2.0; // b goes to ft |
| 1558 (CALL_GENERATED_CODE(f, &test, 0, 0, 0, 0)); |
| 1559 CHECK_EQ(test.c, 2.0); |
| 1560 CHECK_EQ(test.d, 3.0); |
1604 | 1561 |
1605 if (i < tableLength - 1) { | 1562 test.a = std::numeric_limits<double>::quiet_NaN(); |
1606 CHECK_EQ(test.c, outputsdmin[i]); | 1563 test.b = 3.0; // b goes to ft |
1607 CHECK_EQ(test.d, outputsdmax[i]); | 1564 (CALL_GENERATED_CODE(f, &test, 0, 0, 0, 0)); |
1608 CHECK_EQ(test.g, outputsfmin[i]); | 1565 CHECK_EQ(test.c, 3.0); |
1609 CHECK_EQ(test.h, outputsfmax[i]); | 1566 CHECK_EQ(test.d, 3.0); |
1610 } else { | 1567 |
1611 DCHECK(std::isnan(test.c)); | 1568 test.b = std::numeric_limits<double>::quiet_NaN(); |
1612 DCHECK(std::isnan(test.d)); | 1569 test.a = 3.0; // b goes to ft |
1613 DCHECK(std::isnan(test.g)); | 1570 (CALL_GENERATED_CODE(f, &test, 0, 0, 0, 0)); |
1614 DCHECK(std::isnan(test.h)); | 1571 CHECK_EQ(test.c, 3.0); |
1615 } | 1572 CHECK_EQ(test.d, 3.0); |
1616 } | 1573 |
| 1574 test.a = std::numeric_limits<double>::quiet_NaN(); |
| 1575 test.b = std::numeric_limits<double>::quiet_NaN(); |
| 1576 (CALL_GENERATED_CODE(f, &test, 0, 0, 0, 0)); |
| 1577 DCHECK(std::isnan(test.c)); |
| 1578 DCHECK(std::isnan(test.d)); |
1617 } | 1579 } |
1618 } | 1580 } |
1619 | 1581 |
1620 | 1582 |
1621 TEST(rint_d) { | 1583 TEST(MIPS19) { |
1622 if (kArchVariant == kMips64r6) { | 1584 if (kArchVariant == kMips64r6) { |
1623 const int tableLength = 30; | 1585 const int tableLength = 30; |
1624 CcTest::InitializeVM(); | 1586 CcTest::InitializeVM(); |
1625 Isolate* isolate = CcTest::i_isolate(); | 1587 Isolate* isolate = CcTest::i_isolate(); |
1626 HandleScope scope(isolate); | 1588 HandleScope scope(isolate); |
1627 MacroAssembler assm(isolate, NULL, 0); | 1589 MacroAssembler assm(isolate, NULL, 0); |
1628 | 1590 |
1629 typedef struct test_float { | 1591 typedef struct test_float { |
1630 double a; | 1592 double a; |
1631 double b; | 1593 double b; |
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1703 __ sdc1(f8, MemOperand(a0, OFFSET_OF(TestFloat, b)) ); | 1665 __ sdc1(f8, MemOperand(a0, OFFSET_OF(TestFloat, b)) ); |
1704 __ jr(ra); | 1666 __ jr(ra); |
1705 __ nop(); | 1667 __ nop(); |
1706 | 1668 |
1707 CodeDesc desc; | 1669 CodeDesc desc; |
1708 assm.GetCode(&desc); | 1670 assm.GetCode(&desc); |
1709 Handle<Code> code = isolate->factory()->NewCode( | 1671 Handle<Code> code = isolate->factory()->NewCode( |
1710 desc, Code::ComputeFlags(Code::STUB), Handle<Code>()); | 1672 desc, Code::ComputeFlags(Code::STUB), Handle<Code>()); |
1711 F3 f = FUNCTION_CAST<F3>(code->entry()); | 1673 F3 f = FUNCTION_CAST<F3>(code->entry()); |
1712 | 1674 |
1713 for (int j = 0; j < 4; j++) { | 1675 for (int j = 0;j < 4;j++) { |
1714 test.fcsr = fcsr_inputs[j]; | 1676 test.fcsr = fcsr_inputs[j]; |
1715 for (int i = 0; i < tableLength; i++) { | 1677 for (int i = 0;i < tableLength;i++) { |
1716 test.a = inputs[i]; | 1678 test.a = inputs[i]; |
| 1679 std::cout << j << " " << i << "\n"; |
1717 (CALL_GENERATED_CODE(f, &test, 0, 0, 0, 0)); | 1680 (CALL_GENERATED_CODE(f, &test, 0, 0, 0, 0)); |
1718 CHECK_EQ(test.b, outputs[j][i]); | 1681 CHECK_EQ(test.b, outputs[j][i]); |
1719 } | 1682 } |
1720 } | 1683 } |
1721 } | 1684 } |
1722 } | 1685 } |
1723 | 1686 |
1724 | 1687 |
1725 TEST(sel) { | 1688 TEST(MIPS20) { |
1726 if (kArchVariant == kMips64r6) { | 1689 CcTest::InitializeVM(); |
1727 CcTest::InitializeVM(); | 1690 Isolate* isolate = CcTest::i_isolate(); |
1728 Isolate* isolate = CcTest::i_isolate(); | 1691 HandleScope scope(isolate); |
1729 HandleScope scope(isolate); | 1692 MacroAssembler assm(isolate, NULL, 0); |
1730 MacroAssembler assm(isolate, NULL, 0); | |
1731 | 1693 |
1732 typedef struct test { | 1694 typedef struct test_float { |
1733 double dd; | 1695 double a; |
1734 double ds; | 1696 int32_t b; |
1735 double dt; | 1697 int fcsr; |
1736 float fd; | 1698 }Test; |
1737 float fs; | 1699 const int tableLength = 24; |
1738 float ft; | 1700 double inputs[tableLength] = { |
1739 } Test; | 1701 2.1, 2.6, 2.5, 3.1, 3.6, 3.5, |
1740 | 1702 -2.1, -2.6, -2.5, -3.1, -3.6, -3.5, |
1741 Test test; | 1703 2147483637.0, 2147483638.0, 2147483639.0, |
1742 __ ldc1(f0, MemOperand(a0, OFFSET_OF(Test, dd)) ); // test | 1704 2147483640.0, 2147483641.0, 2147483642.0, |
1743 __ ldc1(f2, MemOperand(a0, OFFSET_OF(Test, ds)) ); // src1 | 1705 2147483643.0, 2147483644.0, 2147483645.0, |
1744 __ ldc1(f4, MemOperand(a0, OFFSET_OF(Test, dt)) ); // src2 | 1706 2147483646.0, 2147483647.0, 2147483653.0 |
1745 __ lwc1(f6, MemOperand(a0, OFFSET_OF(Test, fd)) ); // test | 1707 }; |
1746 __ lwc1(f8, MemOperand(a0, OFFSET_OF(Test, fs)) ); // src1 | 1708 double outputs_RN[tableLength] = { |
1747 __ lwc1(f10, MemOperand(a0, OFFSET_OF(Test, ft)) ); // src2 | 1709 2.0, 3.0, 2.0, 3.0, 4.0, 4.0, |
1748 __ sel_d(f0, f2, f4); | 1710 -2.0, -3.0, -2.0, -3.0, -4.0, -4.0, |
1749 __ sel_s(f6, f8, f10); | 1711 2147483637.0, 2147483638.0, 2147483639.0, |
1750 __ sdc1(f0, MemOperand(a0, OFFSET_OF(Test, dd)) ); | 1712 2147483640.0, 2147483641.0, 2147483642.0, |
1751 __ swc1(f6, MemOperand(a0, OFFSET_OF(Test, fd)) ); | 1713 2147483643.0, 2147483644.0, 2147483645.0, |
1752 __ jr(ra); | 1714 2147483646.0, 2147483647.0, kFPUInvalidResult}; |
1753 __ nop(); | 1715 double outputs_RZ[tableLength] = { |
1754 CodeDesc desc; | 1716 2.0, 2.0, 2.0, 3.0, 3.0, 3.0, |
1755 assm.GetCode(&desc); | 1717 -2.0, -2.0, -2.0, -3.0, -3.0, -3.0, |
1756 Handle<Code> code = isolate->factory()->NewCode( | 1718 2147483637.0, 2147483638.0, 2147483639.0, |
1757 desc, Code::ComputeFlags(Code::STUB), Handle<Code>()); | 1719 2147483640.0, 2147483641.0, 2147483642.0, |
1758 F3 f = FUNCTION_CAST<F3>(code->entry()); | 1720 2147483643.0, 2147483644.0, 2147483645.0, |
1759 | 1721 2147483646.0, 2147483647.0, kFPUInvalidResult}; |
1760 const int test_size = 3; | 1722 double outputs_RP[tableLength] = { |
1761 const int input_size = 5; | 1723 3.0, 3.0, 3.0, 4.0, 4.0, 4.0, |
1762 | 1724 -2.0, -2.0, -2.0, -3.0, -3.0, -3.0, |
1763 double inputs_dt[input_size] = {0.0, 65.2, -70.32, | 1725 2147483637.0, 2147483638.0, 2147483639.0, |
1764 18446744073709551621.0, -18446744073709551621.0}; | 1726 2147483640.0, 2147483641.0, 2147483642.0, |
1765 double inputs_ds[input_size] = {0.1, 69.88, -91.325, | 1727 2147483643.0, 2147483644.0, 2147483645.0, |
1766 18446744073709551625.0, -18446744073709551625.0}; | 1728 2147483646.0, 2147483647.0, kFPUInvalidResult}; |
1767 float inputs_ft[input_size] = {0.0, 65.2, -70.32, | 1729 double outputs_RM[tableLength] = { |
1768 18446744073709551621.0, -18446744073709551621.0}; | 1730 2.0, 2.0, 2.0, 3.0, 3.0, 3.0, |
1769 float inputs_fs[input_size] = {0.1, 69.88, -91.325, | 1731 -3.0, -3.0, -3.0, -4.0, -4.0, -4.0, |
1770 18446744073709551625.0, -18446744073709551625.0}; | 1732 2147483637.0, 2147483638.0, 2147483639.0, |
1771 double tests_D[test_size*2] = {2.8, 2.9, -2.8, -2.9, | 1733 2147483640.0, 2147483641.0, 2147483642.0, |
1772 18446744073709551616.0, 18446744073709555712.0}; | 1734 2147483643.0, 2147483644.0, 2147483645.0, |
1773 float tests_S[test_size*2] = {2.9, 2.8, -2.9, -2.8, | 1735 2147483646.0, 2147483647.0, kFPUInvalidResult}; |
1774 18446744073709551616.0, 18446746272732807168.0}; | 1736 int fcsr_inputs[4] = |
1775 for (int j=0; j < test_size; j+=2) { | 1737 {kRoundToNearest, kRoundToZero, kRoundToPlusInf, kRoundToMinusInf}; |
1776 for (int i=0; i < input_size; i++) { | 1738 double* outputs[4] = {outputs_RN, outputs_RZ, outputs_RP, outputs_RM}; |
1777 test.dt = inputs_dt[i]; | 1739 __ ldc1(f4, MemOperand(a0, OFFSET_OF(Test, a)) ); |
1778 test.dd = tests_D[j]; | 1740 __ lw(t0, MemOperand(a0, OFFSET_OF(Test, fcsr)) ); |
1779 test.ds = inputs_ds[i]; | 1741 __ cfc1(t1, FCSR); |
1780 test.ft = inputs_ft[i]; | 1742 __ ctc1(t0, FCSR); |
1781 test.fd = tests_S[j]; | 1743 __ cvt_w_d(f8, f4); |
1782 test.fs = inputs_fs[i]; | 1744 __ swc1(f8, MemOperand(a0, OFFSET_OF(Test, b)) ); |
1783 (CALL_GENERATED_CODE(f, &test, 0, 0, 0, 0)); | 1745 __ ctc1(t1, FCSR); |
1784 CHECK_EQ(test.dd, inputs_ds[i]); | 1746 __ jr(ra); |
1785 CHECK_EQ(test.fd, inputs_fs[i]); | 1747 __ nop(); |
1786 | 1748 Test test; |
1787 test.dd = tests_D[j+1]; | 1749 CodeDesc desc; |
1788 test.fd = tests_S[j+1]; | 1750 assm.GetCode(&desc); |
1789 (CALL_GENERATED_CODE(f, &test, 0, 0, 0, 0)); | 1751 Handle<Code> code = isolate->factory()->NewCode( |
1790 CHECK_EQ(test.dd, inputs_dt[i]); | 1752 desc, Code::ComputeFlags(Code::STUB), Handle<Code>()); |
1791 CHECK_EQ(test.fd, inputs_ft[i]); | 1753 F3 f = FUNCTION_CAST<F3>(code->entry()); |
1792 } | 1754 for (int j = 0;j < 4;j++) { |
| 1755 test.fcsr = fcsr_inputs[j]; |
| 1756 for (int i = 0;i < tableLength;i++) { |
| 1757 test.a = inputs[i]; |
| 1758 (CALL_GENERATED_CODE(f, &test, 0, 0, 0, 0)); |
| 1759 CHECK_EQ(test.b, outputs[j][i]); |
1793 } | 1760 } |
1794 } | 1761 } |
1795 } | 1762 } |
1796 | 1763 |
1797 | 1764 |
1798 TEST(rint_s) { | 1765 TEST(MIPS21) { |
1799 if (kArchVariant == kMips64r6) { | 1766 if (kArchVariant == kMips64r6) { |
1800 const int tableLength = 30; | 1767 const int tableLength = 30; |
1801 CcTest::InitializeVM(); | 1768 CcTest::InitializeVM(); |
1802 Isolate* isolate = CcTest::i_isolate(); | 1769 Isolate* isolate = CcTest::i_isolate(); |
1803 HandleScope scope(isolate); | 1770 HandleScope scope(isolate); |
1804 MacroAssembler assm(isolate, NULL, 0); | 1771 MacroAssembler assm(isolate, NULL, 0); |
1805 | 1772 |
1806 typedef struct test_float { | 1773 typedef struct test_float { |
1807 float a; | 1774 double a; |
1808 float b; | 1775 double b; |
1809 int fcsr; | 1776 int fcsr; |
1810 }TestFloat; | 1777 }TestFloat; |
1811 | 1778 |
1812 TestFloat test; | 1779 TestFloat test; |
1813 float inputs[tableLength] = {18446744073709551617.0, | 1780 double inputs[tableLength] = {18446744073709551617.0, |
1814 4503599627370496.0, -4503599627370496.0, | 1781 4503599627370496.0, -4503599627370496.0, |
1815 1.26782468584154733584017312973E30, 1.44860108245951772690707170478E37, | 1782 1.26782468584154733584017312973E30, 1.44860108245951772690707170478E147, |
1816 1.7976931348623157E+38, 6.27463370218383111104242366943E-37, | 1783 1.7976931348623157E308, 6.27463370218383111104242366943E-307, |
1817 309485009821345068724781056.89, | 1784 309485009821345068724781056.89, |
1818 2.1, 2.6, 2.5, 3.1, 3.6, 3.5, | 1785 2.1, 2.6, 2.5, 3.1, 3.6, 3.5, |
1819 -2.1, -2.6, -2.5, -3.1, -3.6, -3.5, | 1786 -2.1, -2.6, -2.5, -3.1, -3.6, -3.5, |
1820 37778931862957161709568.0, 37778931862957161709569.0, | 1787 37778931862957161709568.0, 37778931862957161709569.0, |
1821 37778931862957161709580.0, 37778931862957161709581.0, | 1788 37778931862957161709580.0, 37778931862957161709581.0, |
1822 37778931862957161709582.0, 37778931862957161709583.0, | 1789 37778931862957161709582.0, 37778931862957161709583.0, |
1823 37778931862957161709584.0, 37778931862957161709585.0, | 1790 37778931862957161709584.0, 37778931862957161709585.0, |
1824 37778931862957161709586.0, 37778931862957161709587.0}; | 1791 37778931862957161709586.0, 37778931862957161709587.0}; |
1825 float outputs_RN[tableLength] = {18446744073709551617.0, | 1792 double outputs_RN[tableLength] = {18446744073709551617.0, |
1826 4503599627370496.0, -4503599627370496.0, | 1793 4503599627370496.0, -4503599627370496.0, |
1827 1.26782468584154733584017312973E30, 1.44860108245951772690707170478E37, | 1794 1.26782468584154733584017312973E30, 1.44860108245951772690707170478E147, |
1828 1.7976931348623157E38, 0, | 1795 1.7976931348623157E308, 0, |
1829 309485009821345068724781057.0, | 1796 309485009821345068724781057.0, |
1830 2.0, 3.0, 2.0, 3.0, 4.0, 4.0, | 1797 2.0, 3.0, 2.0, 3.0, 4.0, 4.0, |
1831 -2.0, -3.0, -2.0, -3.0, -4.0, -4.0, | 1798 -2.0, -3.0, -2.0, -3.0, -4.0, -4.0, |
1832 37778931862957161709568.0, 37778931862957161709569.0, | 1799 37778931862957161709568.0, 37778931862957161709569.0, |
1833 37778931862957161709580.0, 37778931862957161709581.0, | 1800 37778931862957161709580.0, 37778931862957161709581.0, |
1834 37778931862957161709582.0, 37778931862957161709583.0, | 1801 37778931862957161709582.0, 37778931862957161709583.0, |
1835 37778931862957161709584.0, 37778931862957161709585.0, | 1802 37778931862957161709584.0, 37778931862957161709585.0, |
1836 37778931862957161709586.0, 37778931862957161709587.0}; | 1803 37778931862957161709586.0, 37778931862957161709587.0}; |
1837 float outputs_RZ[tableLength] = {18446744073709551617.0, | 1804 double outputs_RZ[tableLength] = {18446744073709551617.0, |
1838 4503599627370496.0, -4503599627370496.0, | 1805 4503599627370496.0, -4503599627370496.0, |
1839 1.26782468584154733584017312973E30, 1.44860108245951772690707170478E37, | 1806 1.26782468584154733584017312973E30, 1.44860108245951772690707170478E147, |
1840 1.7976931348623157E38, 0, | 1807 1.7976931348623157E308, 0, |
1841 309485009821345068724781057.0, | 1808 309485009821345068724781057.0, |
1842 2.0, 2.0, 2.0, 3.0, 3.0, 3.0, | 1809 2.0, 2.0, 2.0, 3.0, 3.0, 3.0, |
1843 -2.0, -2.0, -2.0, -3.0, -3.0, -3.0, | 1810 -2.0, -2.0, -2.0, -3.0, -3.0, -3.0, |
1844 37778931862957161709568.0, 37778931862957161709569.0, | 1811 37778931862957161709568.0, 37778931862957161709569.0, |
1845 37778931862957161709580.0, 37778931862957161709581.0, | 1812 37778931862957161709580.0, 37778931862957161709581.0, |
1846 37778931862957161709582.0, 37778931862957161709583.0, | 1813 37778931862957161709582.0, 37778931862957161709583.0, |
1847 37778931862957161709584.0, 37778931862957161709585.0, | 1814 37778931862957161709584.0, 37778931862957161709585.0, |
1848 37778931862957161709586.0, 37778931862957161709587.0}; | 1815 37778931862957161709586.0, 37778931862957161709587.0}; |
1849 float outputs_RP[tableLength] = {18446744073709551617.0, | 1816 double outputs_RP[tableLength] = {18446744073709551617.0, |
1850 4503599627370496.0, -4503599627370496.0, | 1817 4503599627370496.0, -4503599627370496.0, |
1851 1.26782468584154733584017312973E30, 1.44860108245951772690707170478E37, | 1818 1.26782468584154733584017312973E30, 1.44860108245951772690707170478E147, |
1852 1.7976931348623157E38, 1, | 1819 1.7976931348623157E308, 1, |
1853 309485009821345068724781057.0, | 1820 309485009821345068724781057.0, |
1854 3.0, 3.0, 3.0, 4.0, 4.0, 4.0, | 1821 3.0, 3.0, 3.0, 4.0, 4.0, 4.0, |
1855 -2.0, -2.0, -2.0, -3.0, -3.0, -3.0, | 1822 -2.0, -2.0, -2.0, -3.0, -3.0, -3.0, |
1856 37778931862957161709568.0, 37778931862957161709569.0, | 1823 37778931862957161709568.0, 37778931862957161709569.0, |
1857 37778931862957161709580.0, 37778931862957161709581.0, | 1824 37778931862957161709580.0, 37778931862957161709581.0, |
1858 37778931862957161709582.0, 37778931862957161709583.0, | 1825 37778931862957161709582.0, 37778931862957161709583.0, |
1859 37778931862957161709584.0, 37778931862957161709585.0, | 1826 37778931862957161709584.0, 37778931862957161709585.0, |
1860 37778931862957161709586.0, 37778931862957161709587.0}; | 1827 37778931862957161709586.0, 37778931862957161709587.0}; |
1861 float outputs_RM[tableLength] = {18446744073709551617.0, | 1828 double outputs_RM[tableLength] = {18446744073709551617.0, |
1862 4503599627370496.0, -4503599627370496.0, | 1829 4503599627370496.0, -4503599627370496.0, |
1863 1.26782468584154733584017312973E30, 1.44860108245951772690707170478E37, | 1830 1.26782468584154733584017312973E30, 1.44860108245951772690707170478E147, |
1864 1.7976931348623157E38, 0, | 1831 1.7976931348623157E308, 0, |
1865 309485009821345068724781057.0, | 1832 309485009821345068724781057.0, |
1866 2.0, 2.0, 2.0, 3.0, 3.0, 3.0, | 1833 2.0, 2.0, 2.0, 3.0, 3.0, 3.0, |
1867 -3.0, -3.0, -3.0, -4.0, -4.0, -4.0, | 1834 -3.0, -3.0, -3.0, -4.0, -4.0, -4.0, |
1868 37778931862957161709568.0, 37778931862957161709569.0, | 1835 37778931862957161709568.0, 37778931862957161709569.0, |
1869 37778931862957161709580.0, 37778931862957161709581.0, | 1836 37778931862957161709580.0, 37778931862957161709581.0, |
1870 37778931862957161709582.0, 37778931862957161709583.0, | 1837 37778931862957161709582.0, 37778931862957161709583.0, |
1871 37778931862957161709584.0, 37778931862957161709585.0, | 1838 37778931862957161709584.0, 37778931862957161709585.0, |
1872 37778931862957161709586.0, 37778931862957161709587.0}; | 1839 37778931862957161709586.0, 37778931862957161709587.0}; |
1873 int fcsr_inputs[4] = | 1840 int fcsr_inputs[4] = |
1874 {kRoundToNearest, kRoundToZero, kRoundToPlusInf, kRoundToMinusInf}; | 1841 {kRoundToNearest, kRoundToZero, kRoundToPlusInf, kRoundToMinusInf}; |
1875 float* outputs[4] = {outputs_RN, outputs_RZ, outputs_RP, outputs_RM}; | 1842 double* outputs[4] = {outputs_RN, outputs_RZ, outputs_RP, outputs_RM}; |
1876 __ lwc1(f4, MemOperand(a0, OFFSET_OF(TestFloat, a)) ); | 1843 __ ldc1(f4, MemOperand(a0, OFFSET_OF(TestFloat, a)) ); |
1877 __ lw(t0, MemOperand(a0, OFFSET_OF(TestFloat, fcsr)) ); | 1844 __ lw(t0, MemOperand(a0, OFFSET_OF(TestFloat, fcsr)) ); |
1878 __ cfc1(t1, FCSR); | 1845 __ cfc1(t1, FCSR); |
1879 __ ctc1(t0, FCSR); | 1846 __ ctc1(t0, FCSR); |
1880 __ rint_s(f8, f4); | 1847 __ rint_d(f8, f4); |
1881 __ swc1(f8, MemOperand(a0, OFFSET_OF(TestFloat, b)) ); | 1848 __ sdc1(f8, MemOperand(a0, OFFSET_OF(TestFloat, b)) ); |
1882 __ ctc1(t1, FCSR); | 1849 __ ctc1(t1, FCSR); |
1883 __ jr(ra); | 1850 __ jr(ra); |
1884 __ nop(); | 1851 __ nop(); |
1885 | 1852 |
1886 CodeDesc desc; | 1853 CodeDesc desc; |
1887 assm.GetCode(&desc); | 1854 assm.GetCode(&desc); |
1888 Handle<Code> code = isolate->factory()->NewCode( | 1855 Handle<Code> code = isolate->factory()->NewCode( |
1889 desc, Code::ComputeFlags(Code::STUB), Handle<Code>()); | 1856 desc, Code::ComputeFlags(Code::STUB), Handle<Code>()); |
1890 F3 f = FUNCTION_CAST<F3>(code->entry()); | 1857 F3 f = FUNCTION_CAST<F3>(code->entry()); |
1891 | 1858 for (int j = 0;j < 4;j++) { |
1892 for (int j = 0; j < 4; j++) { | |
1893 test.fcsr = fcsr_inputs[j]; | 1859 test.fcsr = fcsr_inputs[j]; |
1894 for (int i = 0; i < tableLength; i++) { | 1860 for (int i = 0;i < tableLength;i++) { |
1895 test.a = inputs[i]; | 1861 test.a = inputs[i]; |
1896 (CALL_GENERATED_CODE(f, &test, 0, 0, 0, 0)); | 1862 (CALL_GENERATED_CODE(f, &test, 0, 0, 0, 0)); |
1897 CHECK_EQ(test.b, outputs[j][i]); | 1863 CHECK_EQ(test.b, outputs[j][i]); |
1898 } | 1864 } |
1899 } | 1865 } |
1900 } | 1866 } |
1901 } | 1867 } |
1902 | 1868 |
1903 | 1869 |
1904 TEST(mina_maxa) { | |
1905 if (kArchVariant == kMips64r6) { | |
1906 const int tableLength = 12; | |
1907 CcTest::InitializeVM(); | |
1908 Isolate* isolate = CcTest::i_isolate(); | |
1909 HandleScope scope(isolate); | |
1910 MacroAssembler assm(isolate, NULL, 0); | |
1911 | |
1912 typedef struct test_float { | |
1913 double a; | |
1914 double b; | |
1915 double resd; | |
1916 double resd1; | |
1917 float c; | |
1918 float d; | |
1919 float resf; | |
1920 float resf1; | |
1921 }TestFloat; | |
1922 | |
1923 TestFloat test; | |
1924 double inputsa[tableLength] = { | |
1925 5.3, 4.8, 6.1, | |
1926 9.8, 9.8, 9.8, | |
1927 -10.0, -8.9, -9.8, | |
1928 -10.0, -8.9, -9.8 | |
1929 }; | |
1930 double inputsb[tableLength] = { | |
1931 4.8, 5.3, 6.1, | |
1932 -10.0, -8.9, -9.8, | |
1933 9.8, 9.8, 9.8, | |
1934 -9.8, -11.2, -9.8 | |
1935 }; | |
1936 double resd[tableLength] = { | |
1937 4.8, 4.8, 6.1, | |
1938 9.8, -8.9, 9.8, | |
1939 9.8, -8.9, 9.8, | |
1940 -9.8, -8.9, -9.8 | |
1941 }; | |
1942 double resd1[tableLength] = { | |
1943 5.3, 5.3, 6.1, | |
1944 -10.0, 9.8, 9.8, | |
1945 -10.0, 9.8, 9.8, | |
1946 -10.0, -11.2, -9.8 | |
1947 }; | |
1948 float inputsc[tableLength] = { | |
1949 5.3, 4.8, 6.1, | |
1950 9.8, 9.8, 9.8, | |
1951 -10.0, -8.9, -9.8, | |
1952 -10.0, -8.9, -9.8 | |
1953 }; | |
1954 float inputsd[tableLength] = { | |
1955 4.8, 5.3, 6.1, | |
1956 -10.0, -8.9, -9.8, | |
1957 9.8, 9.8, 9.8, | |
1958 -9.8, -11.2, -9.8 | |
1959 }; | |
1960 float resf[tableLength] = { | |
1961 4.8, 4.8, 6.1, | |
1962 9.8, -8.9, 9.8, | |
1963 9.8, -8.9, 9.8, | |
1964 -9.8, -8.9, -9.8 | |
1965 }; | |
1966 float resf1[tableLength] = { | |
1967 5.3, 5.3, 6.1, | |
1968 -10.0, 9.8, 9.8, | |
1969 -10.0, 9.8, 9.8, | |
1970 -10.0, -11.2, -9.8 | |
1971 }; | |
1972 | |
1973 __ ldc1(f2, MemOperand(a0, OFFSET_OF(TestFloat, a)) ); | |
1974 __ ldc1(f4, MemOperand(a0, OFFSET_OF(TestFloat, b)) ); | |
1975 __ lwc1(f8, MemOperand(a0, OFFSET_OF(TestFloat, c)) ); | |
1976 __ lwc1(f10, MemOperand(a0, OFFSET_OF(TestFloat, d)) ); | |
1977 __ mina_d(f6, f2, f4); | |
1978 __ mina_s(f12, f8, f10); | |
1979 __ maxa_d(f14, f2, f4); | |
1980 __ maxa_s(f16, f8, f10); | |
1981 __ swc1(f12, MemOperand(a0, OFFSET_OF(TestFloat, resf)) ); | |
1982 __ sdc1(f6, MemOperand(a0, OFFSET_OF(TestFloat, resd)) ); | |
1983 __ swc1(f16, MemOperand(a0, OFFSET_OF(TestFloat, resf1)) ); | |
1984 __ sdc1(f14, MemOperand(a0, OFFSET_OF(TestFloat, resd1)) ); | |
1985 __ jr(ra); | |
1986 __ nop(); | |
1987 | |
1988 CodeDesc desc; | |
1989 assm.GetCode(&desc); | |
1990 Handle<Code> code = isolate->factory()->NewCode( | |
1991 desc, Code::ComputeFlags(Code::STUB), Handle<Code>()); | |
1992 F3 f = FUNCTION_CAST<F3>(code->entry()); | |
1993 for (int i = 0; i < tableLength; i++) { | |
1994 test.a = inputsa[i]; | |
1995 test.b = inputsb[i]; | |
1996 test.c = inputsc[i]; | |
1997 test.d = inputsd[i]; | |
1998 (CALL_GENERATED_CODE(f, &test, 0, 0, 0, 0)); | |
1999 | |
2000 CHECK_EQ(test.resd, resd[i]); | |
2001 CHECK_EQ(test.resf, resf[i]); | |
2002 CHECK_EQ(test.resd1, resd1[i]); | |
2003 CHECK_EQ(test.resf1, resf1[i]); | |
2004 } | |
2005 } | |
2006 } | |
2007 | |
2008 | |
2009 | 1870 |
2010 // ----------------------mips32r2 specific tests---------------------- | |
2011 TEST(trunc_l) { | |
2012 if (kArchVariant == kMips64r2) { | |
2013 CcTest::InitializeVM(); | |
2014 Isolate* isolate = CcTest::i_isolate(); | |
2015 HandleScope scope(isolate); | |
2016 MacroAssembler assm(isolate, NULL, 0); | |
2017 const double dFPU64InvalidResult = static_cast<double>(kFPU64InvalidResult); | |
2018 typedef struct test_float { | |
2019 double a; | |
2020 float b; | |
2021 int64_t c; // a trunc result | |
2022 int64_t d; // b trunc result | |
2023 }Test; | |
2024 const int tableLength = 16; | |
2025 double inputs_D[tableLength] = { | |
2026 2.1, 2.6, 2.5, 3.1, 3.6, 3.5, | |
2027 -2.1, -2.6, -2.5, -3.1, -3.6, -3.5, | |
2028 2147483648.0, | |
2029 std::numeric_limits<double>::quiet_NaN(), | |
2030 std::numeric_limits<double>::infinity(), | |
2031 9223372036854775808.0 | |
2032 }; | |
2033 float inputs_S[tableLength] = { | |
2034 2.1, 2.6, 2.5, 3.1, 3.6, 3.5, | |
2035 -2.1, -2.6, -2.5, -3.1, -3.6, -3.5, | |
2036 2147483648.0, | |
2037 std::numeric_limits<float>::quiet_NaN(), | |
2038 std::numeric_limits<float>::infinity(), | |
2039 9223372036854775808.0 | |
2040 }; | |
2041 double outputs[tableLength] = { | |
2042 2.0, 2.0, 2.0, 3.0, 3.0, 3.0, | |
2043 -2.0, -2.0, -2.0, -3.0, -3.0, -3.0, | |
2044 2147483648.0, dFPU64InvalidResult, | |
2045 dFPU64InvalidResult, dFPU64InvalidResult}; | |
2046 | |
2047 __ ldc1(f4, MemOperand(a0, OFFSET_OF(Test, a)) ); | |
2048 __ lwc1(f6, MemOperand(a0, OFFSET_OF(Test, b)) ); | |
2049 __ trunc_l_d(f8, f4); | |
2050 __ trunc_l_s(f10, f6); | |
2051 __ sdc1(f8, MemOperand(a0, OFFSET_OF(Test, c)) ); | |
2052 __ sdc1(f10, MemOperand(a0, OFFSET_OF(Test, d)) ); | |
2053 __ jr(ra); | |
2054 __ nop(); | |
2055 Test test; | |
2056 CodeDesc desc; | |
2057 assm.GetCode(&desc); | |
2058 Handle<Code> code = isolate->factory()->NewCode( | |
2059 desc, Code::ComputeFlags(Code::STUB), Handle<Code>()); | |
2060 F3 f = FUNCTION_CAST<F3>(code->entry()); | |
2061 for (int i = 0; i < tableLength; i++) { | |
2062 test.a = inputs_D[i]; | |
2063 test.b = inputs_S[i]; | |
2064 (CALL_GENERATED_CODE(f, &test, 0, 0, 0, 0)); | |
2065 CHECK_EQ(test.c, outputs[i]); | |
2066 CHECK_EQ(test.d, test.c); | |
2067 } | |
2068 } | |
2069 } | |
2070 | |
2071 | |
2072 TEST(movz_movn) { | |
2073 if (kArchVariant == kMips64r2) { | |
2074 const int tableLength = 4; | |
2075 CcTest::InitializeVM(); | |
2076 Isolate* isolate = CcTest::i_isolate(); | |
2077 HandleScope scope(isolate); | |
2078 MacroAssembler assm(isolate, NULL, 0); | |
2079 | |
2080 typedef struct test_float { | |
2081 int64_t rt; | |
2082 double a; | |
2083 double b; | |
2084 double bold; | |
2085 double b1; | |
2086 double bold1; | |
2087 float c; | |
2088 float d; | |
2089 float dold; | |
2090 float d1; | |
2091 float dold1; | |
2092 }TestFloat; | |
2093 | |
2094 TestFloat test; | |
2095 double inputs_D[tableLength] = { | |
2096 5.3, -5.3, 5.3, -2.9 | |
2097 }; | |
2098 double inputs_S[tableLength] = { | |
2099 4.8, 4.8, -4.8, -0.29 | |
2100 }; | |
2101 | |
2102 float outputs_S[tableLength] = { | |
2103 4.8, 4.8, -4.8, -0.29 | |
2104 }; | |
2105 double outputs_D[tableLength] = { | |
2106 5.3, -5.3, 5.3, -2.9 | |
2107 }; | |
2108 | |
2109 __ ldc1(f2, MemOperand(a0, OFFSET_OF(TestFloat, a)) ); | |
2110 __ lwc1(f6, MemOperand(a0, OFFSET_OF(TestFloat, c)) ); | |
2111 __ lw(t0, MemOperand(a0, OFFSET_OF(TestFloat, rt)) ); | |
2112 __ li(t1, 0x0); | |
2113 __ mtc1(t1, f12); | |
2114 __ mtc1(t1, f10); | |
2115 __ mtc1(t1, f16); | |
2116 __ mtc1(t1, f14); | |
2117 __ sdc1(f12, MemOperand(a0, OFFSET_OF(TestFloat, bold)) ); | |
2118 __ swc1(f10, MemOperand(a0, OFFSET_OF(TestFloat, dold)) ); | |
2119 __ sdc1(f16, MemOperand(a0, OFFSET_OF(TestFloat, bold1)) ); | |
2120 __ swc1(f14, MemOperand(a0, OFFSET_OF(TestFloat, dold1)) ); | |
2121 __ movz_s(f10, f6, t0); | |
2122 __ movz_d(f12, f2, t0); | |
2123 __ movn_s(f14, f6, t0); | |
2124 __ movn_d(f16, f2, t0); | |
2125 __ swc1(f10, MemOperand(a0, OFFSET_OF(TestFloat, d)) ); | |
2126 __ sdc1(f12, MemOperand(a0, OFFSET_OF(TestFloat, b)) ); | |
2127 __ swc1(f14, MemOperand(a0, OFFSET_OF(TestFloat, d1)) ); | |
2128 __ sdc1(f16, MemOperand(a0, OFFSET_OF(TestFloat, b1)) ); | |
2129 __ jr(ra); | |
2130 __ nop(); | |
2131 | |
2132 CodeDesc desc; | |
2133 assm.GetCode(&desc); | |
2134 Handle<Code> code = isolate->factory()->NewCode( | |
2135 desc, Code::ComputeFlags(Code::STUB), Handle<Code>()); | |
2136 F3 f = FUNCTION_CAST<F3>(code->entry()); | |
2137 for (int i = 0; i < tableLength; i++) { | |
2138 test.a = inputs_D[i]; | |
2139 test.c = inputs_S[i]; | |
2140 | |
2141 test.rt = 1; | |
2142 (CALL_GENERATED_CODE(f, &test, 0, 0, 0, 0)); | |
2143 CHECK_EQ(test.b, test.bold); | |
2144 CHECK_EQ(test.d, test.dold); | |
2145 CHECK_EQ(test.b1, outputs_D[i]); | |
2146 CHECK_EQ(test.d1, outputs_S[i]); | |
2147 | |
2148 test.rt = 0; | |
2149 (CALL_GENERATED_CODE(f, &test, 0, 0, 0, 0)); | |
2150 CHECK_EQ(test.b, outputs_D[i]); | |
2151 CHECK_EQ(test.d, outputs_S[i]); | |
2152 CHECK_EQ(test.b1, test.bold1); | |
2153 CHECK_EQ(test.d1, test.dold1); | |
2154 } | |
2155 } | |
2156 } | |
2157 | |
2158 | |
2159 TEST(movt_movd) { | |
2160 if (kArchVariant == kMips64r2) { | |
2161 const int tableLength = 4; | |
2162 CcTest::InitializeVM(); | |
2163 Isolate* isolate = CcTest::i_isolate(); | |
2164 typedef struct test_float { | |
2165 double srcd; | |
2166 double dstd; | |
2167 double dstdold; | |
2168 double dstd1; | |
2169 double dstdold1; | |
2170 float srcf; | |
2171 float dstf; | |
2172 float dstfold; | |
2173 float dstf1; | |
2174 float dstfold1; | |
2175 int32_t cc; | |
2176 int32_t fcsr; | |
2177 }TestFloat; | |
2178 | |
2179 TestFloat test; | |
2180 double inputs_D[tableLength] = { | |
2181 5.3, -5.3, 20.8, -2.9 | |
2182 }; | |
2183 double inputs_S[tableLength] = { | |
2184 4.88, 4.8, -4.8, -0.29 | |
2185 }; | |
2186 | |
2187 float outputs_S[tableLength] = { | |
2188 4.88, 4.8, -4.8, -0.29 | |
2189 }; | |
2190 double outputs_D[tableLength] = { | |
2191 5.3, -5.3, 20.8, -2.9 | |
2192 }; | |
2193 int condition_flags[8] = {0, 1, 2, 3, 4, 5, 6, 7}; | |
2194 | |
2195 for (int i = 0; i < tableLength; i++) { | |
2196 test.srcd = inputs_D[i]; | |
2197 test.srcf = inputs_S[i]; | |
2198 | |
2199 for (int j = 0; j< 8; j++) { | |
2200 test.cc = condition_flags[j]; | |
2201 if (test.cc == 0) { | |
2202 test.fcsr = 1 << 23; | |
2203 } else { | |
2204 test.fcsr = 1 << (24+condition_flags[j]); | |
2205 } | |
2206 HandleScope scope(isolate); | |
2207 MacroAssembler assm(isolate, NULL, 0); | |
2208 __ ldc1(f2, MemOperand(a0, OFFSET_OF(TestFloat, srcd)) ); | |
2209 __ lwc1(f4, MemOperand(a0, OFFSET_OF(TestFloat, srcf)) ); | |
2210 __ lw(t1, MemOperand(a0, OFFSET_OF(TestFloat, fcsr)) ); | |
2211 __ cfc1(t0, FCSR); | |
2212 __ ctc1(t1, FCSR); | |
2213 __ li(t2, 0x0); | |
2214 __ mtc1(t2, f12); | |
2215 __ mtc1(t2, f10); | |
2216 __ sdc1(f10, MemOperand(a0, OFFSET_OF(TestFloat, dstdold)) ); | |
2217 __ swc1(f12, MemOperand(a0, OFFSET_OF(TestFloat, dstfold)) ); | |
2218 __ movt_s(f12, f4, test.cc); | |
2219 __ movt_d(f10, f2, test.cc); | |
2220 __ swc1(f12, MemOperand(a0, OFFSET_OF(TestFloat, dstf)) ); | |
2221 __ sdc1(f10, MemOperand(a0, OFFSET_OF(TestFloat, dstd)) ); | |
2222 __ sdc1(f10, MemOperand(a0, OFFSET_OF(TestFloat, dstdold1)) ); | |
2223 __ swc1(f12, MemOperand(a0, OFFSET_OF(TestFloat, dstfold1)) ); | |
2224 __ movf_s(f12, f4, test.cc); | |
2225 __ movf_d(f10, f2, test.cc); | |
2226 __ swc1(f12, MemOperand(a0, OFFSET_OF(TestFloat, dstf1)) ); | |
2227 __ sdc1(f10, MemOperand(a0, OFFSET_OF(TestFloat, dstd1)) ); | |
2228 __ ctc1(t0, FCSR); | |
2229 __ jr(ra); | |
2230 __ nop(); | |
2231 | |
2232 CodeDesc desc; | |
2233 assm.GetCode(&desc); | |
2234 Handle<Code> code = isolate->factory()->NewCode( | |
2235 desc, Code::ComputeFlags(Code::STUB), Handle<Code>()); | |
2236 F3 f = FUNCTION_CAST<F3>(code->entry()); | |
2237 | |
2238 (CALL_GENERATED_CODE(f, &test, 0, 0, 0, 0)); | |
2239 CHECK_EQ(test.dstf, outputs_S[i]); | |
2240 CHECK_EQ(test.dstd, outputs_D[i]); | |
2241 CHECK_EQ(test.dstf1, test.dstfold1); | |
2242 CHECK_EQ(test.dstd1, test.dstdold1); | |
2243 test.fcsr = 0; | |
2244 (CALL_GENERATED_CODE(f, &test, 0, 0, 0, 0)); | |
2245 CHECK_EQ(test.dstf, test.dstfold); | |
2246 CHECK_EQ(test.dstd, test.dstdold); | |
2247 CHECK_EQ(test.dstf1, outputs_S[i]); | |
2248 CHECK_EQ(test.dstd1, outputs_D[i]); | |
2249 } | |
2250 } | |
2251 } | |
2252 } | |
2253 | |
2254 | |
2255 | |
2256 // ----------------------tests for all archs-------------------------- | |
2257 TEST(cvt_w_d) { | |
2258 CcTest::InitializeVM(); | |
2259 Isolate* isolate = CcTest::i_isolate(); | |
2260 HandleScope scope(isolate); | |
2261 MacroAssembler assm(isolate, NULL, 0); | |
2262 | |
2263 typedef struct test_float { | |
2264 double a; | |
2265 int32_t b; | |
2266 int fcsr; | |
2267 }Test; | |
2268 const int tableLength = 24; | |
2269 double inputs[tableLength] = { | |
2270 2.1, 2.6, 2.5, 3.1, 3.6, 3.5, | |
2271 -2.1, -2.6, -2.5, -3.1, -3.6, -3.5, | |
2272 2147483637.0, 2147483638.0, 2147483639.0, | |
2273 2147483640.0, 2147483641.0, 2147483642.0, | |
2274 2147483643.0, 2147483644.0, 2147483645.0, | |
2275 2147483646.0, 2147483647.0, 2147483653.0 | |
2276 }; | |
2277 double outputs_RN[tableLength] = { | |
2278 2.0, 3.0, 2.0, 3.0, 4.0, 4.0, | |
2279 -2.0, -3.0, -2.0, -3.0, -4.0, -4.0, | |
2280 2147483637.0, 2147483638.0, 2147483639.0, | |
2281 2147483640.0, 2147483641.0, 2147483642.0, | |
2282 2147483643.0, 2147483644.0, 2147483645.0, | |
2283 2147483646.0, 2147483647.0, kFPUInvalidResult}; | |
2284 double outputs_RZ[tableLength] = { | |
2285 2.0, 2.0, 2.0, 3.0, 3.0, 3.0, | |
2286 -2.0, -2.0, -2.0, -3.0, -3.0, -3.0, | |
2287 2147483637.0, 2147483638.0, 2147483639.0, | |
2288 2147483640.0, 2147483641.0, 2147483642.0, | |
2289 2147483643.0, 2147483644.0, 2147483645.0, | |
2290 2147483646.0, 2147483647.0, kFPUInvalidResult}; | |
2291 double outputs_RP[tableLength] = { | |
2292 3.0, 3.0, 3.0, 4.0, 4.0, 4.0, | |
2293 -2.0, -2.0, -2.0, -3.0, -3.0, -3.0, | |
2294 2147483637.0, 2147483638.0, 2147483639.0, | |
2295 2147483640.0, 2147483641.0, 2147483642.0, | |
2296 2147483643.0, 2147483644.0, 2147483645.0, | |
2297 2147483646.0, 2147483647.0, kFPUInvalidResult}; | |
2298 double outputs_RM[tableLength] = { | |
2299 2.0, 2.0, 2.0, 3.0, 3.0, 3.0, | |
2300 -3.0, -3.0, -3.0, -4.0, -4.0, -4.0, | |
2301 2147483637.0, 2147483638.0, 2147483639.0, | |
2302 2147483640.0, 2147483641.0, 2147483642.0, | |
2303 2147483643.0, 2147483644.0, 2147483645.0, | |
2304 2147483646.0, 2147483647.0, kFPUInvalidResult}; | |
2305 int fcsr_inputs[4] = | |
2306 {kRoundToNearest, kRoundToZero, kRoundToPlusInf, kRoundToMinusInf}; | |
2307 double* outputs[4] = {outputs_RN, outputs_RZ, outputs_RP, outputs_RM}; | |
2308 __ ldc1(f4, MemOperand(a0, OFFSET_OF(Test, a)) ); | |
2309 __ lw(t0, MemOperand(a0, OFFSET_OF(Test, fcsr)) ); | |
2310 __ cfc1(t1, FCSR); | |
2311 __ ctc1(t0, FCSR); | |
2312 __ cvt_w_d(f8, f4); | |
2313 __ swc1(f8, MemOperand(a0, OFFSET_OF(Test, b)) ); | |
2314 __ ctc1(t1, FCSR); | |
2315 __ jr(ra); | |
2316 __ nop(); | |
2317 Test test; | |
2318 CodeDesc desc; | |
2319 assm.GetCode(&desc); | |
2320 Handle<Code> code = isolate->factory()->NewCode( | |
2321 desc, Code::ComputeFlags(Code::STUB), Handle<Code>()); | |
2322 F3 f = FUNCTION_CAST<F3>(code->entry()); | |
2323 for (int j = 0; j < 4; j++) { | |
2324 test.fcsr = fcsr_inputs[j]; | |
2325 for (int i = 0; i < tableLength; i++) { | |
2326 test.a = inputs[i]; | |
2327 (CALL_GENERATED_CODE(f, &test, 0, 0, 0, 0)); | |
2328 CHECK_EQ(test.b, outputs[j][i]); | |
2329 } | |
2330 } | |
2331 } | |
2332 | |
2333 | |
2334 TEST(trunc_w) { | |
2335 CcTest::InitializeVM(); | |
2336 Isolate* isolate = CcTest::i_isolate(); | |
2337 HandleScope scope(isolate); | |
2338 MacroAssembler assm(isolate, NULL, 0); | |
2339 | |
2340 typedef struct test_float { | |
2341 double a; | |
2342 float b; | |
2343 int32_t c; // a trunc result | |
2344 int32_t d; // b trunc result | |
2345 }Test; | |
2346 const int tableLength = 15; | |
2347 double inputs_D[tableLength] = { | |
2348 2.1, 2.6, 2.5, 3.1, 3.6, 3.5, | |
2349 -2.1, -2.6, -2.5, -3.1, -3.6, -3.5, | |
2350 2147483648.0, | |
2351 std::numeric_limits<double>::quiet_NaN(), | |
2352 std::numeric_limits<double>::infinity() | |
2353 }; | |
2354 float inputs_S[tableLength] = { | |
2355 2.1, 2.6, 2.5, 3.1, 3.6, 3.5, | |
2356 -2.1, -2.6, -2.5, -3.1, -3.6, -3.5, | |
2357 2147483648.0, | |
2358 std::numeric_limits<float>::quiet_NaN(), | |
2359 std::numeric_limits<float>::infinity() | |
2360 }; | |
2361 double outputs[tableLength] = { | |
2362 2.0, 2.0, 2.0, 3.0, 3.0, 3.0, | |
2363 -2.0, -2.0, -2.0, -3.0, -3.0, -3.0, | |
2364 kFPUInvalidResult, kFPUInvalidResult, | |
2365 kFPUInvalidResult}; | |
2366 | |
2367 __ ldc1(f4, MemOperand(a0, OFFSET_OF(Test, a)) ); | |
2368 __ lwc1(f6, MemOperand(a0, OFFSET_OF(Test, b)) ); | |
2369 __ trunc_w_d(f8, f4); | |
2370 __ trunc_w_s(f10, f6); | |
2371 __ swc1(f8, MemOperand(a0, OFFSET_OF(Test, c)) ); | |
2372 __ swc1(f10, MemOperand(a0, OFFSET_OF(Test, d)) ); | |
2373 __ jr(ra); | |
2374 __ nop(); | |
2375 Test test; | |
2376 CodeDesc desc; | |
2377 assm.GetCode(&desc); | |
2378 Handle<Code> code = isolate->factory()->NewCode( | |
2379 desc, Code::ComputeFlags(Code::STUB), Handle<Code>()); | |
2380 F3 f = FUNCTION_CAST<F3>(code->entry()); | |
2381 for (int i = 0; i < tableLength; i++) { | |
2382 test.a = inputs_D[i]; | |
2383 test.b = inputs_S[i]; | |
2384 (CALL_GENERATED_CODE(f, &test, 0, 0, 0, 0)); | |
2385 CHECK_EQ(test.c, outputs[i]); | |
2386 CHECK_EQ(test.d, test.c); | |
2387 } | |
2388 } | |
2389 | |
2390 | |
2391 TEST(round_w) { | |
2392 CcTest::InitializeVM(); | |
2393 Isolate* isolate = CcTest::i_isolate(); | |
2394 HandleScope scope(isolate); | |
2395 MacroAssembler assm(isolate, NULL, 0); | |
2396 | |
2397 typedef struct test_float { | |
2398 double a; | |
2399 float b; | |
2400 int32_t c; // a trunc result | |
2401 int32_t d; // b trunc result | |
2402 }Test; | |
2403 const int tableLength = 15; | |
2404 double inputs_D[tableLength] = { | |
2405 2.1, 2.6, 2.5, 3.1, 3.6, 3.5, | |
2406 -2.1, -2.6, -2.5, -3.1, -3.6, -3.5, | |
2407 2147483648.0, | |
2408 std::numeric_limits<double>::quiet_NaN(), | |
2409 std::numeric_limits<double>::infinity() | |
2410 }; | |
2411 float inputs_S[tableLength] = { | |
2412 2.1, 2.6, 2.5, 3.1, 3.6, 3.5, | |
2413 -2.1, -2.6, -2.5, -3.1, -3.6, -3.5, | |
2414 2147483648.0, | |
2415 std::numeric_limits<float>::quiet_NaN(), | |
2416 std::numeric_limits<float>::infinity() | |
2417 }; | |
2418 double outputs[tableLength] = { | |
2419 2.0, 3.0, 2.0, 3.0, 4.0, 4.0, | |
2420 -2.0, -3.0, -2.0, -3.0, -4.0, -4.0, | |
2421 kFPUInvalidResult, kFPUInvalidResult, | |
2422 kFPUInvalidResult}; | |
2423 | |
2424 __ ldc1(f4, MemOperand(a0, OFFSET_OF(Test, a)) ); | |
2425 __ lwc1(f6, MemOperand(a0, OFFSET_OF(Test, b)) ); | |
2426 __ round_w_d(f8, f4); | |
2427 __ round_w_s(f10, f6); | |
2428 __ swc1(f8, MemOperand(a0, OFFSET_OF(Test, c)) ); | |
2429 __ swc1(f10, MemOperand(a0, OFFSET_OF(Test, d)) ); | |
2430 __ jr(ra); | |
2431 __ nop(); | |
2432 Test test; | |
2433 CodeDesc desc; | |
2434 assm.GetCode(&desc); | |
2435 Handle<Code> code = isolate->factory()->NewCode( | |
2436 desc, Code::ComputeFlags(Code::STUB), Handle<Code>()); | |
2437 F3 f = FUNCTION_CAST<F3>(code->entry()); | |
2438 for (int i = 0; i < tableLength; i++) { | |
2439 test.a = inputs_D[i]; | |
2440 test.b = inputs_S[i]; | |
2441 (CALL_GENERATED_CODE(f, &test, 0, 0, 0, 0)); | |
2442 CHECK_EQ(test.c, outputs[i]); | |
2443 CHECK_EQ(test.d, test.c); | |
2444 } | |
2445 } | |
2446 | |
2447 | |
2448 TEST(round_l) { | |
2449 CcTest::InitializeVM(); | |
2450 Isolate* isolate = CcTest::i_isolate(); | |
2451 HandleScope scope(isolate); | |
2452 MacroAssembler assm(isolate, NULL, 0); | |
2453 const double dFPU64InvalidResult = static_cast<double>(kFPU64InvalidResult); | |
2454 typedef struct test_float { | |
2455 double a; | |
2456 float b; | |
2457 int64_t c; | |
2458 int64_t d; | |
2459 }Test; | |
2460 const int tableLength = 16; | |
2461 double inputs_D[tableLength] = { | |
2462 2.1, 2.6, 2.5, 3.1, 3.6, 3.5, | |
2463 -2.1, -2.6, -2.5, -3.1, -3.6, -3.5, | |
2464 2147483648.0, | |
2465 std::numeric_limits<double>::quiet_NaN(), | |
2466 std::numeric_limits<double>::infinity(), | |
2467 9223372036854775808.0 | |
2468 }; | |
2469 float inputs_S[tableLength] = { | |
2470 2.1, 2.6, 2.5, 3.1, 3.6, 3.5, | |
2471 -2.1, -2.6, -2.5, -3.1, -3.6, -3.5, | |
2472 2147483648.0, | |
2473 std::numeric_limits<float>::quiet_NaN(), | |
2474 std::numeric_limits<float>::infinity(), | |
2475 9223372036854775808.0 | |
2476 }; | |
2477 double outputs[tableLength] = { | |
2478 2.0, 3.0, 2.0, 3.0, 4.0, 4.0, | |
2479 -2.0, -3.0, -2.0, -3.0, -4.0, -4.0, | |
2480 2147483648.0, dFPU64InvalidResult, | |
2481 dFPU64InvalidResult, dFPU64InvalidResult}; | |
2482 | |
2483 __ ldc1(f4, MemOperand(a0, OFFSET_OF(Test, a)) ); | |
2484 __ lwc1(f6, MemOperand(a0, OFFSET_OF(Test, b)) ); | |
2485 __ round_l_d(f8, f4); | |
2486 __ round_l_s(f10, f6); | |
2487 __ sdc1(f8, MemOperand(a0, OFFSET_OF(Test, c)) ); | |
2488 __ sdc1(f10, MemOperand(a0, OFFSET_OF(Test, d)) ); | |
2489 __ jr(ra); | |
2490 __ nop(); | |
2491 Test test; | |
2492 CodeDesc desc; | |
2493 assm.GetCode(&desc); | |
2494 Handle<Code> code = isolate->factory()->NewCode( | |
2495 desc, Code::ComputeFlags(Code::STUB), Handle<Code>()); | |
2496 F3 f = FUNCTION_CAST<F3>(code->entry()); | |
2497 for (int i = 0; i < tableLength; i++) { | |
2498 test.a = inputs_D[i]; | |
2499 test.b = inputs_S[i]; | |
2500 std::cout<< i<< "\n"; | |
2501 (CALL_GENERATED_CODE(f, &test, 0, 0, 0, 0)); | |
2502 CHECK_EQ(test.c, outputs[i]); | |
2503 CHECK_EQ(test.d, test.c); | |
2504 } | |
2505 } | |
2506 | |
2507 | |
2508 TEST(sub) { | |
2509 const int tableLength = 12; | |
2510 CcTest::InitializeVM(); | |
2511 Isolate* isolate = CcTest::i_isolate(); | |
2512 HandleScope scope(isolate); | |
2513 MacroAssembler assm(isolate, NULL, 0); | |
2514 | |
2515 typedef struct test_float { | |
2516 float a; | |
2517 float b; | |
2518 float resultS; | |
2519 double c; | |
2520 double d; | |
2521 double resultD; | |
2522 }TestFloat; | |
2523 | |
2524 TestFloat test; | |
2525 double inputfs_D[tableLength] = { | |
2526 5.3, 4.8, 2.9, -5.3, -4.8, -2.9, | |
2527 5.3, 4.8, 2.9, -5.3, -4.8, -2.9 | |
2528 }; | |
2529 double inputft_D[tableLength] = { | |
2530 4.8, 5.3, 2.9, 4.8, 5.3, 2.9, | |
2531 -4.8, -5.3, -2.9, -4.8, -5.3, -2.9 | |
2532 }; | |
2533 double outputs_D[tableLength] = { | |
2534 0.5, -0.5, 0.0, -10.1, -10.1, -5.8, | |
2535 10.1, 10.1, 5.8, -0.5, 0.5, 0.0 | |
2536 }; | |
2537 float inputfs_S[tableLength] = { | |
2538 5.3, 4.8, 2.9, -5.3, -4.8, -2.9, | |
2539 5.3, 4.8, 2.9, -5.3, -4.8, -2.9 | |
2540 }; | |
2541 float inputft_S[tableLength] = { | |
2542 4.8, 5.3, 2.9, 4.8, 5.3, 2.9, | |
2543 -4.8, -5.3, -2.9, -4.8, -5.3, -2.9 | |
2544 }; | |
2545 float outputs_S[tableLength] = { | |
2546 0.5, -0.5, 0.0, -10.1, -10.1, -5.8, | |
2547 10.1, 10.1, 5.8, -0.5, 0.5, 0.0 | |
2548 }; | |
2549 __ lwc1(f2, MemOperand(a0, OFFSET_OF(TestFloat, a)) ); | |
2550 __ lwc1(f4, MemOperand(a0, OFFSET_OF(TestFloat, b)) ); | |
2551 __ ldc1(f8, MemOperand(a0, OFFSET_OF(TestFloat, c)) ); | |
2552 __ ldc1(f10, MemOperand(a0, OFFSET_OF(TestFloat, d)) ); | |
2553 __ sub_s(f6, f2, f4); | |
2554 __ sub_d(f12, f8, f10); | |
2555 __ swc1(f6, MemOperand(a0, OFFSET_OF(TestFloat, resultS)) ); | |
2556 __ sdc1(f12, MemOperand(a0, OFFSET_OF(TestFloat, resultD)) ); | |
2557 __ jr(ra); | |
2558 __ nop(); | |
2559 | |
2560 CodeDesc desc; | |
2561 assm.GetCode(&desc); | |
2562 Handle<Code> code = isolate->factory()->NewCode( | |
2563 desc, Code::ComputeFlags(Code::STUB), Handle<Code>()); | |
2564 F3 f = FUNCTION_CAST<F3>(code->entry()); | |
2565 for (int i = 0; i < tableLength; i++) { | |
2566 test.a = inputfs_S[i]; | |
2567 test.b = inputft_S[i]; | |
2568 test.c = inputfs_D[i]; | |
2569 test.d = inputft_D[i]; | |
2570 (CALL_GENERATED_CODE(f, &test, 0, 0, 0, 0)); | |
2571 CHECK_EQ(test.resultS, outputs_S[i]); | |
2572 CHECK_EQ(test.resultD, outputs_D[i]); | |
2573 } | |
2574 } | |
2575 | |
2576 | |
2577 TEST(sqrt_rsqrt_recip) { | |
2578 const int tableLength = 4; | |
2579 const double deltaDouble = 2E-15; | |
2580 const float deltaFloat = 2E-7; | |
2581 const float sqrt2_s = sqrt(2); | |
2582 const double sqrt2_d = sqrt(2); | |
2583 CcTest::InitializeVM(); | |
2584 Isolate* isolate = CcTest::i_isolate(); | |
2585 HandleScope scope(isolate); | |
2586 MacroAssembler assm(isolate, NULL, 0); | |
2587 | |
2588 typedef struct test_float { | |
2589 float a; | |
2590 float resultS; | |
2591 float resultS1; | |
2592 float resultS2; | |
2593 double c; | |
2594 double resultD; | |
2595 double resultD1; | |
2596 double resultD2; | |
2597 }TestFloat; | |
2598 TestFloat test; | |
2599 | |
2600 double inputs_D[tableLength] = { | |
2601 0.0L, 4.0L, 2.0L, 4e-28L | |
2602 }; | |
2603 | |
2604 double outputs_D[tableLength] = { | |
2605 0.0L, 2.0L, sqrt2_d, 2e-14L | |
2606 }; | |
2607 float inputs_S[tableLength] = { | |
2608 0.0, 4.0, 2.0, 4e-28 | |
2609 }; | |
2610 | |
2611 float outputs_S[tableLength] = { | |
2612 0.0, 2.0, sqrt2_s, 2e-14 | |
2613 }; | |
2614 | |
2615 | |
2616 __ lwc1(f2, MemOperand(a0, OFFSET_OF(TestFloat, a)) ); | |
2617 __ ldc1(f8, MemOperand(a0, OFFSET_OF(TestFloat, c)) ); | |
2618 __ sqrt_s(f6, f2); | |
2619 __ sqrt_d(f12, f8); | |
2620 __ rsqrt_d(f14, f8); | |
2621 __ rsqrt_s(f16, f2); | |
2622 __ recip_d(f18, f8); | |
2623 __ recip_s(f20, f2); | |
2624 __ swc1(f6, MemOperand(a0, OFFSET_OF(TestFloat, resultS)) ); | |
2625 __ sdc1(f12, MemOperand(a0, OFFSET_OF(TestFloat, resultD)) ); | |
2626 __ swc1(f16, MemOperand(a0, OFFSET_OF(TestFloat, resultS1)) ); | |
2627 __ sdc1(f14, MemOperand(a0, OFFSET_OF(TestFloat, resultD1)) ); | |
2628 __ swc1(f20, MemOperand(a0, OFFSET_OF(TestFloat, resultS2)) ); | |
2629 __ sdc1(f18, MemOperand(a0, OFFSET_OF(TestFloat, resultD2)) ); | |
2630 __ jr(ra); | |
2631 __ nop(); | |
2632 | |
2633 CodeDesc desc; | |
2634 assm.GetCode(&desc); | |
2635 Handle<Code> code = isolate->factory()->NewCode( | |
2636 desc, Code::ComputeFlags(Code::STUB), Handle<Code>()); | |
2637 F3 f = FUNCTION_CAST<F3>(code->entry()); | |
2638 | |
2639 for (int i = 0; i < tableLength; i++) { | |
2640 float f1; | |
2641 double d1; | |
2642 test.a = inputs_S[i]; | |
2643 test.c = inputs_D[i]; | |
2644 | |
2645 (CALL_GENERATED_CODE(f, &test, 0, 0, 0, 0)); | |
2646 | |
2647 CHECK_EQ(test.resultS, outputs_S[i]); | |
2648 CHECK_EQ(test.resultD, outputs_D[i]); | |
2649 | |
2650 if (i != 0) { | |
2651 f1 = test.resultS1 - 1.0F/outputs_S[i]; | |
2652 f1 = (f1 < 0) ? f1 : -f1; | |
2653 CHECK(f1 <= deltaFloat); | |
2654 d1 = test.resultD1 - 1.0L/outputs_D[i]; | |
2655 d1 = (d1 < 0) ? d1 : -d1; | |
2656 CHECK(d1 <= deltaDouble); | |
2657 f1 = test.resultS2 - 1.0F/inputs_S[i]; | |
2658 f1 = (f1 < 0) ? f1 : -f1; | |
2659 CHECK(f1 <= deltaFloat); | |
2660 d1 = test.resultD2 - 1.0L/inputs_D[i]; | |
2661 d1 = (d1 < 0) ? d1 : -d1; | |
2662 CHECK(d1 <= deltaDouble); | |
2663 } else { | |
2664 CHECK_EQ(test.resultS1, 1.0F/outputs_S[i]); | |
2665 CHECK_EQ(test.resultD1, 1.0L/outputs_D[i]); | |
2666 CHECK_EQ(test.resultS2, 1.0F/inputs_S[i]); | |
2667 CHECK_EQ(test.resultD2, 1.0L/inputs_D[i]); | |
2668 } | |
2669 } | |
2670 } | |
2671 | |
2672 | |
2673 TEST(neg) { | |
2674 const int tableLength = 2; | |
2675 CcTest::InitializeVM(); | |
2676 Isolate* isolate = CcTest::i_isolate(); | |
2677 HandleScope scope(isolate); | |
2678 MacroAssembler assm(isolate, NULL, 0); | |
2679 | |
2680 typedef struct test_float { | |
2681 float a; | |
2682 float resultS; | |
2683 double c; | |
2684 double resultD; | |
2685 }TestFloat; | |
2686 | |
2687 TestFloat test; | |
2688 double inputs_D[tableLength] = { | |
2689 4.0, -2.0 | |
2690 }; | |
2691 | |
2692 double outputs_D[tableLength] = { | |
2693 -4.0, 2.0 | |
2694 }; | |
2695 float inputs_S[tableLength] = { | |
2696 4.0, -2.0 | |
2697 }; | |
2698 | |
2699 float outputs_S[tableLength] = { | |
2700 -4.0, 2.0 | |
2701 }; | |
2702 __ lwc1(f2, MemOperand(a0, OFFSET_OF(TestFloat, a)) ); | |
2703 __ ldc1(f8, MemOperand(a0, OFFSET_OF(TestFloat, c)) ); | |
2704 __ neg_s(f6, f2); | |
2705 __ neg_d(f12, f8); | |
2706 __ swc1(f6, MemOperand(a0, OFFSET_OF(TestFloat, resultS)) ); | |
2707 __ sdc1(f12, MemOperand(a0, OFFSET_OF(TestFloat, resultD)) ); | |
2708 __ jr(ra); | |
2709 __ nop(); | |
2710 | |
2711 CodeDesc desc; | |
2712 assm.GetCode(&desc); | |
2713 Handle<Code> code = isolate->factory()->NewCode( | |
2714 desc, Code::ComputeFlags(Code::STUB), Handle<Code>()); | |
2715 F3 f = FUNCTION_CAST<F3>(code->entry()); | |
2716 for (int i = 0; i < tableLength; i++) { | |
2717 test.a = inputs_S[i]; | |
2718 test.c = inputs_D[i]; | |
2719 (CALL_GENERATED_CODE(f, &test, 0, 0, 0, 0)); | |
2720 CHECK_EQ(test.resultS, outputs_S[i]); | |
2721 CHECK_EQ(test.resultD, outputs_D[i]); | |
2722 } | |
2723 } | |
2724 | |
2725 | |
2726 | |
2727 TEST(mul) { | |
2728 const int tableLength = 4; | |
2729 CcTest::InitializeVM(); | |
2730 Isolate* isolate = CcTest::i_isolate(); | |
2731 HandleScope scope(isolate); | |
2732 MacroAssembler assm(isolate, NULL, 0); | |
2733 | |
2734 typedef struct test_float { | |
2735 float a; | |
2736 float b; | |
2737 float resultS; | |
2738 double c; | |
2739 double d; | |
2740 double resultD; | |
2741 }TestFloat; | |
2742 | |
2743 TestFloat test; | |
2744 double inputfs_D[tableLength] = { | |
2745 5.3, -5.3, 5.3, -2.9 | |
2746 }; | |
2747 double inputft_D[tableLength] = { | |
2748 4.8, 4.8, -4.8, -0.29 | |
2749 }; | |
2750 | |
2751 float inputfs_S[tableLength] = { | |
2752 5.3, -5.3, 5.3, -2.9 | |
2753 }; | |
2754 float inputft_S[tableLength] = { | |
2755 4.8, 4.8, -4.8, -0.29 | |
2756 }; | |
2757 | |
2758 __ lwc1(f2, MemOperand(a0, OFFSET_OF(TestFloat, a)) ); | |
2759 __ lwc1(f4, MemOperand(a0, OFFSET_OF(TestFloat, b)) ); | |
2760 __ ldc1(f6, MemOperand(a0, OFFSET_OF(TestFloat, c)) ); | |
2761 __ ldc1(f8, MemOperand(a0, OFFSET_OF(TestFloat, d)) ); | |
2762 __ mul_s(f10, f2, f4); | |
2763 __ mul_d(f12, f6, f8); | |
2764 __ swc1(f10, MemOperand(a0, OFFSET_OF(TestFloat, resultS)) ); | |
2765 __ sdc1(f12, MemOperand(a0, OFFSET_OF(TestFloat, resultD)) ); | |
2766 __ jr(ra); | |
2767 __ nop(); | |
2768 | |
2769 CodeDesc desc; | |
2770 assm.GetCode(&desc); | |
2771 Handle<Code> code = isolate->factory()->NewCode( | |
2772 desc, Code::ComputeFlags(Code::STUB), Handle<Code>()); | |
2773 F3 f = FUNCTION_CAST<F3>(code->entry()); | |
2774 for (int i = 0; i < tableLength; i++) { | |
2775 test.a = inputfs_S[i]; | |
2776 test.b = inputft_S[i]; | |
2777 test.c = inputfs_D[i]; | |
2778 test.d = inputft_D[i]; | |
2779 (CALL_GENERATED_CODE(f, &test, 0, 0, 0, 0)); | |
2780 CHECK_EQ(test.resultS, inputfs_S[i]*inputft_S[i]); | |
2781 CHECK_EQ(test.resultD, inputfs_D[i]*inputft_D[i]); | |
2782 } | |
2783 } | |
2784 | |
2785 | |
2786 TEST(mov) { | |
2787 const int tableLength = 4; | |
2788 CcTest::InitializeVM(); | |
2789 Isolate* isolate = CcTest::i_isolate(); | |
2790 HandleScope scope(isolate); | |
2791 MacroAssembler assm(isolate, NULL, 0); | |
2792 | |
2793 typedef struct test_float { | |
2794 double a; | |
2795 double b; | |
2796 float c; | |
2797 float d; | |
2798 }TestFloat; | |
2799 | |
2800 TestFloat test; | |
2801 double inputs_D[tableLength] = { | |
2802 5.3, -5.3, 5.3, -2.9 | |
2803 }; | |
2804 double inputs_S[tableLength] = { | |
2805 4.8, 4.8, -4.8, -0.29 | |
2806 }; | |
2807 | |
2808 float outputs_S[tableLength] = { | |
2809 4.8, 4.8, -4.8, -0.29 | |
2810 }; | |
2811 double outputs_D[tableLength] = { | |
2812 5.3, -5.3, 5.3, -2.9 | |
2813 }; | |
2814 | |
2815 __ ldc1(f2, MemOperand(a0, OFFSET_OF(TestFloat, a)) ); | |
2816 __ lwc1(f6, MemOperand(a0, OFFSET_OF(TestFloat, c)) ); | |
2817 __ mov_s(f18, f6); | |
2818 __ mov_d(f20, f2); | |
2819 __ swc1(f18, MemOperand(a0, OFFSET_OF(TestFloat, d)) ); | |
2820 __ sdc1(f20, MemOperand(a0, OFFSET_OF(TestFloat, b)) ); | |
2821 __ jr(ra); | |
2822 __ nop(); | |
2823 | |
2824 CodeDesc desc; | |
2825 assm.GetCode(&desc); | |
2826 Handle<Code> code = isolate->factory()->NewCode( | |
2827 desc, Code::ComputeFlags(Code::STUB), Handle<Code>()); | |
2828 F3 f = FUNCTION_CAST<F3>(code->entry()); | |
2829 for (int i = 0; i < tableLength; i++) { | |
2830 test.a = inputs_D[i]; | |
2831 test.c = inputs_S[i]; | |
2832 | |
2833 (CALL_GENERATED_CODE(f, &test, 0, 0, 0, 0)); | |
2834 CHECK_EQ(test.b, outputs_D[i]); | |
2835 CHECK_EQ(test.d, outputs_S[i]); | |
2836 } | |
2837 } | |
2838 | |
2839 | |
2840 TEST(floor_w) { | |
2841 CcTest::InitializeVM(); | |
2842 Isolate* isolate = CcTest::i_isolate(); | |
2843 HandleScope scope(isolate); | |
2844 MacroAssembler assm(isolate, NULL, 0); | |
2845 | |
2846 typedef struct test_float { | |
2847 double a; | |
2848 float b; | |
2849 int32_t c; // a floor result | |
2850 int32_t d; // b floor result | |
2851 }Test; | |
2852 const int tableLength = 15; | |
2853 double inputs_D[tableLength] = { | |
2854 2.1, 2.6, 2.5, 3.1, 3.6, 3.5, | |
2855 -2.1, -2.6, -2.5, -3.1, -3.6, -3.5, | |
2856 2147483648.0, | |
2857 std::numeric_limits<double>::quiet_NaN(), | |
2858 std::numeric_limits<double>::infinity() | |
2859 }; | |
2860 float inputs_S[tableLength] = { | |
2861 2.1, 2.6, 2.5, 3.1, 3.6, 3.5, | |
2862 -2.1, -2.6, -2.5, -3.1, -3.6, -3.5, | |
2863 2147483648.0, | |
2864 std::numeric_limits<float>::quiet_NaN(), | |
2865 std::numeric_limits<float>::infinity() | |
2866 }; | |
2867 double outputs[tableLength] = { | |
2868 2.0, 2.0, 2.0, 3.0, 3.0, 3.0, | |
2869 -3.0, -3.0, -3.0, -4.0, -4.0, -4.0, | |
2870 kFPUInvalidResult, kFPUInvalidResult, | |
2871 kFPUInvalidResult}; | |
2872 | |
2873 __ ldc1(f4, MemOperand(a0, OFFSET_OF(Test, a)) ); | |
2874 __ lwc1(f6, MemOperand(a0, OFFSET_OF(Test, b)) ); | |
2875 __ floor_w_d(f8, f4); | |
2876 __ floor_w_s(f10, f6); | |
2877 __ swc1(f8, MemOperand(a0, OFFSET_OF(Test, c)) ); | |
2878 __ swc1(f10, MemOperand(a0, OFFSET_OF(Test, d)) ); | |
2879 __ jr(ra); | |
2880 __ nop(); | |
2881 Test test; | |
2882 CodeDesc desc; | |
2883 assm.GetCode(&desc); | |
2884 Handle<Code> code = isolate->factory()->NewCode( | |
2885 desc, Code::ComputeFlags(Code::STUB), Handle<Code>()); | |
2886 F3 f = FUNCTION_CAST<F3>(code->entry()); | |
2887 for (int i = 0; i < tableLength; i++) { | |
2888 test.a = inputs_D[i]; | |
2889 test.b = inputs_S[i]; | |
2890 (CALL_GENERATED_CODE(f, &test, 0, 0, 0, 0)); | |
2891 CHECK_EQ(test.c, outputs[i]); | |
2892 CHECK_EQ(test.d, test.c); | |
2893 } | |
2894 } | |
2895 | |
2896 | |
2897 TEST(floor_l) { | |
2898 CcTest::InitializeVM(); | |
2899 Isolate* isolate = CcTest::i_isolate(); | |
2900 HandleScope scope(isolate); | |
2901 MacroAssembler assm(isolate, NULL, 0); | |
2902 const double dFPU64InvalidResult = static_cast<double>(kFPU64InvalidResult); | |
2903 typedef struct test_float { | |
2904 double a; | |
2905 float b; | |
2906 int64_t c; | |
2907 int64_t d; | |
2908 }Test; | |
2909 const int tableLength = 16; | |
2910 double inputs_D[tableLength] = { | |
2911 2.1, 2.6, 2.5, 3.1, 3.6, 3.5, | |
2912 -2.1, -2.6, -2.5, -3.1, -3.6, -3.5, | |
2913 2147483648.0, | |
2914 std::numeric_limits<double>::quiet_NaN(), | |
2915 std::numeric_limits<double>::infinity(), | |
2916 9223372036854775808.0 | |
2917 }; | |
2918 float inputs_S[tableLength] = { | |
2919 2.1, 2.6, 2.5, 3.1, 3.6, 3.5, | |
2920 -2.1, -2.6, -2.5, -3.1, -3.6, -3.5, | |
2921 2147483648.0, | |
2922 std::numeric_limits<float>::quiet_NaN(), | |
2923 std::numeric_limits<float>::infinity(), | |
2924 9223372036854775808.0 | |
2925 }; | |
2926 double outputs[tableLength] = { | |
2927 2.0, 2.0, 2.0, 3.0, 3.0, 3.0, | |
2928 -3.0, -3.0, -3.0, -4.0, -4.0, -4.0, | |
2929 2147483648.0, dFPU64InvalidResult, | |
2930 dFPU64InvalidResult, dFPU64InvalidResult}; | |
2931 | |
2932 __ ldc1(f4, MemOperand(a0, OFFSET_OF(Test, a)) ); | |
2933 __ lwc1(f6, MemOperand(a0, OFFSET_OF(Test, b)) ); | |
2934 __ floor_l_d(f8, f4); | |
2935 __ floor_l_s(f10, f6); | |
2936 __ sdc1(f8, MemOperand(a0, OFFSET_OF(Test, c)) ); | |
2937 __ sdc1(f10, MemOperand(a0, OFFSET_OF(Test, d)) ); | |
2938 __ jr(ra); | |
2939 __ nop(); | |
2940 Test test; | |
2941 CodeDesc desc; | |
2942 assm.GetCode(&desc); | |
2943 Handle<Code> code = isolate->factory()->NewCode( | |
2944 desc, Code::ComputeFlags(Code::STUB), Handle<Code>()); | |
2945 F3 f = FUNCTION_CAST<F3>(code->entry()); | |
2946 for (int i = 0; i < tableLength; i++) { | |
2947 test.a = inputs_D[i]; | |
2948 test.b = inputs_S[i]; | |
2949 (CALL_GENERATED_CODE(f, &test, 0, 0, 0, 0)); | |
2950 CHECK_EQ(test.c, outputs[i]); | |
2951 CHECK_EQ(test.d, test.c); | |
2952 } | |
2953 } | |
2954 | |
2955 | |
2956 TEST(ceil_w) { | |
2957 CcTest::InitializeVM(); | |
2958 Isolate* isolate = CcTest::i_isolate(); | |
2959 HandleScope scope(isolate); | |
2960 MacroAssembler assm(isolate, NULL, 0); | |
2961 | |
2962 typedef struct test_float { | |
2963 double a; | |
2964 float b; | |
2965 int32_t c; // a floor result | |
2966 int32_t d; // b floor result | |
2967 }Test; | |
2968 const int tableLength = 15; | |
2969 double inputs_D[tableLength] = { | |
2970 2.1, 2.6, 2.5, 3.1, 3.6, 3.5, | |
2971 -2.1, -2.6, -2.5, -3.1, -3.6, -3.5, | |
2972 2147483648.0, | |
2973 std::numeric_limits<double>::quiet_NaN(), | |
2974 std::numeric_limits<double>::infinity() | |
2975 }; | |
2976 float inputs_S[tableLength] = { | |
2977 2.1, 2.6, 2.5, 3.1, 3.6, 3.5, | |
2978 -2.1, -2.6, -2.5, -3.1, -3.6, -3.5, | |
2979 2147483648.0, | |
2980 std::numeric_limits<float>::quiet_NaN(), | |
2981 std::numeric_limits<float>::infinity() | |
2982 }; | |
2983 double outputs[tableLength] = { | |
2984 3.0, 3.0, 3.0, 4.0, 4.0, 4.0, | |
2985 -2.0, -2.0, -2.0, -3.0, -3.0, -3.0, | |
2986 kFPUInvalidResult, kFPUInvalidResult, | |
2987 kFPUInvalidResult}; | |
2988 | |
2989 __ ldc1(f4, MemOperand(a0, OFFSET_OF(Test, a)) ); | |
2990 __ lwc1(f6, MemOperand(a0, OFFSET_OF(Test, b)) ); | |
2991 __ ceil_w_d(f8, f4); | |
2992 __ ceil_w_s(f10, f6); | |
2993 __ swc1(f8, MemOperand(a0, OFFSET_OF(Test, c)) ); | |
2994 __ swc1(f10, MemOperand(a0, OFFSET_OF(Test, d)) ); | |
2995 __ jr(ra); | |
2996 __ nop(); | |
2997 Test test; | |
2998 CodeDesc desc; | |
2999 assm.GetCode(&desc); | |
3000 Handle<Code> code = isolate->factory()->NewCode( | |
3001 desc, Code::ComputeFlags(Code::STUB), Handle<Code>()); | |
3002 F3 f = FUNCTION_CAST<F3>(code->entry()); | |
3003 for (int i = 0; i < tableLength; i++) { | |
3004 test.a = inputs_D[i]; | |
3005 test.b = inputs_S[i]; | |
3006 (CALL_GENERATED_CODE(f, &test, 0, 0, 0, 0)); | |
3007 CHECK_EQ(test.c, outputs[i]); | |
3008 CHECK_EQ(test.d, test.c); | |
3009 } | |
3010 } | |
3011 | |
3012 | |
3013 TEST(ceil_l) { | |
3014 CcTest::InitializeVM(); | |
3015 Isolate* isolate = CcTest::i_isolate(); | |
3016 HandleScope scope(isolate); | |
3017 MacroAssembler assm(isolate, NULL, 0); | |
3018 const double dFPU64InvalidResult = static_cast<double>(kFPU64InvalidResult); | |
3019 typedef struct test_float { | |
3020 double a; | |
3021 float b; | |
3022 int64_t c; | |
3023 int64_t d; | |
3024 }Test; | |
3025 const int tableLength = 16; | |
3026 double inputs_D[tableLength] = { | |
3027 2.1, 2.6, 2.5, 3.1, 3.6, 3.5, | |
3028 -2.1, -2.6, -2.5, -3.1, -3.6, -3.5, | |
3029 2147483648.0, | |
3030 std::numeric_limits<double>::quiet_NaN(), | |
3031 std::numeric_limits<double>::infinity(), | |
3032 9223372036854775808.0 | |
3033 }; | |
3034 float inputs_S[tableLength] = { | |
3035 2.1, 2.6, 2.5, 3.1, 3.6, 3.5, | |
3036 -2.1, -2.6, -2.5, -3.1, -3.6, -3.5, | |
3037 2147483648.0, | |
3038 std::numeric_limits<float>::quiet_NaN(), | |
3039 std::numeric_limits<float>::infinity(), | |
3040 9223372036854775808.0 | |
3041 }; | |
3042 double outputs[tableLength] = { | |
3043 3.0, 3.0, 3.0, 4.0, 4.0, 4.0, | |
3044 -2.0, -2.0, -2.0, -3.0, -3.0, -3.0, | |
3045 2147483648.0, dFPU64InvalidResult, | |
3046 dFPU64InvalidResult, dFPU64InvalidResult}; | |
3047 | |
3048 __ ldc1(f4, MemOperand(a0, OFFSET_OF(Test, a)) ); | |
3049 __ lwc1(f6, MemOperand(a0, OFFSET_OF(Test, b)) ); | |
3050 __ ceil_l_d(f8, f4); | |
3051 __ ceil_l_s(f10, f6); | |
3052 __ sdc1(f8, MemOperand(a0, OFFSET_OF(Test, c)) ); | |
3053 __ sdc1(f10, MemOperand(a0, OFFSET_OF(Test, d)) ); | |
3054 __ jr(ra); | |
3055 __ nop(); | |
3056 Test test; | |
3057 CodeDesc desc; | |
3058 assm.GetCode(&desc); | |
3059 Handle<Code> code = isolate->factory()->NewCode( | |
3060 desc, Code::ComputeFlags(Code::STUB), Handle<Code>()); | |
3061 F3 f = FUNCTION_CAST<F3>(code->entry()); | |
3062 for (int i = 0; i < tableLength; i++) { | |
3063 test.a = inputs_D[i]; | |
3064 test.b = inputs_S[i]; | |
3065 (CALL_GENERATED_CODE(f, &test, 0, 0, 0, 0)); | |
3066 CHECK_EQ(test.c, outputs[i]); | |
3067 CHECK_EQ(test.d, test.c); | |
3068 } | |
3069 } | |
3070 | |
3071 | 1871 |
3072 TEST(jump_tables1) { | 1872 TEST(jump_tables1) { |
3073 // Test jump tables with forward jumps. | 1873 // Test jump tables with forward jumps. |
3074 CcTest::InitializeVM(); | 1874 CcTest::InitializeVM(); |
3075 Isolate* isolate = CcTest::i_isolate(); | 1875 Isolate* isolate = CcTest::i_isolate(); |
3076 HandleScope scope(isolate); | 1876 HandleScope scope(isolate); |
3077 Assembler assm(isolate, nullptr, 0); | 1877 Assembler assm(isolate, nullptr, 0); |
3078 | 1878 |
3079 const int kNumCases = 512; | 1879 const int kNumCases = 512; |
3080 int values[kNumCases]; | 1880 int values[kNumCases]; |
(...skipping 205 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3286 ::printf("f(%d) = ", i); | 2086 ::printf("f(%d) = ", i); |
3287 result->Print(std::cout); | 2087 result->Print(std::cout); |
3288 ::printf("\n"); | 2088 ::printf("\n"); |
3289 #endif | 2089 #endif |
3290 CHECK(values[i].is_identical_to(result)); | 2090 CHECK(values[i].is_identical_to(result)); |
3291 } | 2091 } |
3292 } | 2092 } |
3293 | 2093 |
3294 | 2094 |
3295 #undef __ | 2095 #undef __ |
OLD | NEW |