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