Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(57)

Side by Side Diff: runtime/vm/assembler_x64_test.cc

Issue 130803013: IA32 and X64 assembler Float64x2 additions (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « runtime/vm/assembler_x64.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 #include "vm/globals.h" 5 #include "vm/globals.h"
6 #if defined(TARGET_ARCH_X64) 6 #if defined(TARGET_ARCH_X64)
7 7
8 #include "vm/assembler.h" 8 #include "vm/assembler.h"
9 #include "vm/os.h" 9 #include "vm/os.h"
10 #include "vm/unit_test.h" 10 #include "vm/unit_test.h"
(...skipping 1398 matching lines...) Expand 10 before | Expand all | Expand 10 after
1409 __ ret(); 1409 __ ret();
1410 } 1410 }
1411 1411
1412 1412
1413 ASSEMBLER_TEST_RUN(SingleFPMoves2, test) { 1413 ASSEMBLER_TEST_RUN(SingleFPMoves2, test) {
1414 typedef float (*SingleFPMoves2Code)(); 1414 typedef float (*SingleFPMoves2Code)();
1415 EXPECT_EQ(234, reinterpret_cast<SingleFPMoves2Code>(test->entry())()); 1415 EXPECT_EQ(234, reinterpret_cast<SingleFPMoves2Code>(test->entry())());
1416 } 1416 }
1417 1417
1418 1418
1419 ASSEMBLER_TEST_GENERATE(PackedDoubleAdd, assembler) {
1420 static const struct ALIGN16 {
1421 double a;
1422 double b;
1423 } constant0 = { 1.0, 2.0 };
1424 static const struct ALIGN16 {
1425 double a;
1426 double b;
1427 } constant1 = { 3.0, 4.0 };
1428 __ movq(RAX, Immediate(reinterpret_cast<uword>(&constant0)));
1429 __ movups(XMM10, Address(RAX, 0));
1430 __ movq(RAX, Immediate(reinterpret_cast<uword>(&constant1)));
1431 __ movups(XMM11, Address(RAX, 0));
1432 __ addpd(XMM10, XMM11);
1433 __ movaps(XMM0, XMM10);
1434 __ ret();
1435 }
1436
1437
1438 ASSEMBLER_TEST_RUN(PackedDoubleAdd, test) {
1439 typedef double (*PackedDoubleAdd)();
1440 double res = reinterpret_cast<PackedDoubleAdd>(test->entry())();
1441 EXPECT_FLOAT_EQ(4.0, res, 0.000001f);
1442 }
1443
1444
1445 ASSEMBLER_TEST_GENERATE(PackedDoubleSub, assembler) {
1446 static const struct ALIGN16 {
1447 double a;
1448 double b;
1449 } constant0 = { 1.0, 2.0 };
1450 static const struct ALIGN16 {
1451 double a;
1452 double b;
1453 } constant1 = { 3.0, 4.0 };
1454 __ movq(RAX, Immediate(reinterpret_cast<uword>(&constant0)));
1455 __ movups(XMM10, Address(RAX, 0));
1456 __ movq(RAX, Immediate(reinterpret_cast<uword>(&constant1)));
1457 __ movups(XMM11, Address(RAX, 0));
1458 __ subpd(XMM10, XMM11);
1459 __ movaps(XMM0, XMM10);
1460 __ ret();
1461 }
1462
1463
1464 ASSEMBLER_TEST_RUN(PackedDoubleSub, test) {
1465 typedef double (*PackedDoubleSub)();
1466 double res = reinterpret_cast<PackedDoubleSub>(test->entry())();
1467 EXPECT_FLOAT_EQ(-2.0, res, 0.000001f);
1468 }
1469
1470
1471 ASSEMBLER_TEST_GENERATE(PackedDoubleNegate, assembler) {
1472 static const struct ALIGN16 {
1473 double a;
1474 double b;
1475 } constant0 = { 1.0, 2.0 };
1476 __ movq(RAX, Immediate(reinterpret_cast<uword>(&constant0)));
1477 __ movups(XMM10, Address(RAX, 0));
1478 __ negatepd(XMM10);
1479 __ movaps(XMM0, XMM10);
1480 __ ret();
1481 }
1482
1483
1484 ASSEMBLER_TEST_RUN(PackedDoubleNegate, test) {
1485 typedef double (*PackedDoubleNegate)();
1486 double res = reinterpret_cast<PackedDoubleNegate>(test->entry())();
1487 EXPECT_FLOAT_EQ(-1.0, res, 0.000001f);
1488 }
1489
1490
1491 ASSEMBLER_TEST_GENERATE(PackedDoubleAbsolute, assembler) {
1492 static const struct ALIGN16 {
1493 double a;
1494 double b;
1495 } constant0 = { -1.0, 2.0 };
1496 __ movq(RAX, Immediate(reinterpret_cast<uword>(&constant0)));
1497 __ movups(XMM10, Address(RAX, 0));
1498 __ abspd(XMM10);
1499 __ movaps(XMM0, XMM10);
1500 __ ret();
1501 }
1502
1503
1504 ASSEMBLER_TEST_RUN(PackedDoubleAbsolute, test) {
1505 typedef double (*PackedDoubleAbsolute)();
1506 double res = reinterpret_cast<PackedDoubleAbsolute>(test->entry())();
1507 EXPECT_FLOAT_EQ(1.0, res, 0.000001f);
1508 }
1509
1510
1511 ASSEMBLER_TEST_GENERATE(PackedDoubleMul, assembler) {
1512 static const struct ALIGN16 {
1513 double a;
1514 double b;
1515 } constant0 = { 3.0, 2.0 };
1516 static const struct ALIGN16 {
1517 double a;
1518 double b;
1519 } constant1 = { 3.0, 4.0 };
1520 __ movq(RAX, Immediate(reinterpret_cast<uword>(&constant0)));
1521 __ movups(XMM10, Address(RAX, 0));
1522 __ movq(RAX, Immediate(reinterpret_cast<uword>(&constant1)));
1523 __ movups(XMM11, Address(RAX, 0));
1524 __ mulpd(XMM10, XMM11);
1525 __ movaps(XMM0, XMM10);
1526 __ ret();
1527 }
1528
1529
1530 ASSEMBLER_TEST_RUN(PackedDoubleMul, test) {
1531 typedef double (*PackedDoubleMul)();
1532 double res = reinterpret_cast<PackedDoubleMul>(test->entry())();
1533 EXPECT_FLOAT_EQ(9.0, res, 0.000001f);
1534 }
1535
1536
1537 ASSEMBLER_TEST_GENERATE(PackedDoubleDiv, assembler) {
1538 static const struct ALIGN16 {
1539 double a;
1540 double b;
1541 } constant0 = { 9.0, 2.0 };
1542 static const struct ALIGN16 {
1543 double a;
1544 double b;
1545 } constant1 = { 3.0, 4.0 };
1546 __ movq(RAX, Immediate(reinterpret_cast<uword>(&constant0)));
1547 __ movups(XMM10, Address(RAX, 0));
1548 __ movq(RAX, Immediate(reinterpret_cast<uword>(&constant1)));
1549 __ movups(XMM11, Address(RAX, 0));
1550 __ divpd(XMM10, XMM11);
1551 __ movaps(XMM0, XMM10);
1552 __ ret();
1553 }
1554
1555
1556 ASSEMBLER_TEST_RUN(PackedDoubleDiv, test) {
1557 typedef double (*PackedDoubleDiv)();
1558 double res = reinterpret_cast<PackedDoubleDiv>(test->entry())();
1559 EXPECT_FLOAT_EQ(3.0, res, 0.000001f);
1560 }
1561
1562
1563 ASSEMBLER_TEST_GENERATE(PackedDoubleSqrt, assembler) {
1564 static const struct ALIGN16 {
1565 double a;
1566 double b;
1567 } constant0 = { 16.0, 2.0 };
1568 __ movq(RAX, Immediate(reinterpret_cast<uword>(&constant0)));
1569 __ movups(XMM10, Address(RAX, 0));
1570 __ sqrtpd(XMM10);
1571 __ movaps(XMM0, XMM10);
1572 __ ret();
1573 }
1574
1575
1576 ASSEMBLER_TEST_RUN(PackedDoubleSqrt, test) {
1577 typedef double (*PackedDoubleSqrt)();
1578 double res = reinterpret_cast<PackedDoubleSqrt>(test->entry())();
1579 EXPECT_FLOAT_EQ(4.0, res, 0.000001f);
1580 }
1581
1582
1583 ASSEMBLER_TEST_GENERATE(PackedDoubleMin, assembler) {
1584 static const struct ALIGN16 {
1585 double a;
1586 double b;
1587 } constant0 = { 9.0, 2.0 };
1588 static const struct ALIGN16 {
1589 double a;
1590 double b;
1591 } constant1 = { 3.0, 4.0 };
1592 __ movq(RAX, Immediate(reinterpret_cast<uword>(&constant0)));
1593 __ movups(XMM10, Address(RAX, 0));
1594 __ movq(RAX, Immediate(reinterpret_cast<uword>(&constant1)));
1595 __ movups(XMM11, Address(RAX, 0));
1596 __ minpd(XMM10, XMM11);
1597 __ movaps(XMM0, XMM10);
1598 __ ret();
1599 }
1600
1601
1602 ASSEMBLER_TEST_RUN(PackedDoubleMin, test) {
1603 typedef double (*PackedDoubleMin)();
1604 double res = reinterpret_cast<PackedDoubleMin>(test->entry())();
1605 EXPECT_FLOAT_EQ(3.0, res, 0.000001f);
1606 }
1607
1608
1609 ASSEMBLER_TEST_GENERATE(PackedDoubleMax, assembler) {
1610 static const struct ALIGN16 {
1611 double a;
1612 double b;
1613 } constant0 = { 9.0, 2.0 };
1614 static const struct ALIGN16 {
1615 double a;
1616 double b;
1617 } constant1 = { 3.0, 4.0 };
1618 __ movq(RAX, Immediate(reinterpret_cast<uword>(&constant0)));
1619 __ movups(XMM10, Address(RAX, 0));
1620 __ movq(RAX, Immediate(reinterpret_cast<uword>(&constant1)));
1621 __ movups(XMM11, Address(RAX, 0));
1622 __ maxpd(XMM10, XMM11);
1623 __ movaps(XMM0, XMM10);
1624 __ ret();
1625 }
1626
1627
1628 ASSEMBLER_TEST_RUN(PackedDoubleMax, test) {
1629 typedef double (*PackedDoubleMax)();
1630 double res = reinterpret_cast<PackedDoubleMax>(test->entry())();
1631 EXPECT_FLOAT_EQ(9.0, res, 0.000001f);
1632 }
1633
1634
1635 ASSEMBLER_TEST_GENERATE(PackedDoubleToSingle, assembler) {
1636 static const struct ALIGN16 {
1637 double a;
1638 double b;
1639 } constant0 = { 9.0, 2.0 };
1640 __ movq(RAX, Immediate(reinterpret_cast<uword>(&constant0)));
1641 __ movups(XMM11, Address(RAX, 0));
1642 __ cvtpd2ps(XMM10, XMM11);
1643 __ movaps(XMM0, XMM10);
1644 __ ret();
1645 }
1646
1647
1648 ASSEMBLER_TEST_RUN(PackedDoubleToSingle, test) {
1649 typedef float (*PackedDoubleToSingle)();
1650 float res = reinterpret_cast<PackedDoubleToSingle>(test->entry())();
1651 EXPECT_FLOAT_EQ(9.0f, res, 0.000001f);
1652 }
1653
1654
1655 ASSEMBLER_TEST_GENERATE(PackedSingleToDouble, assembler) {
1656 static const struct ALIGN16 {
1657 float a;
1658 float b;
1659 float c;
1660 float d;
1661 } constant0 = { 9.0f, 2.0f, 3.0f, 4.0f };
1662 __ movq(RAX, Immediate(reinterpret_cast<uword>(&constant0)));
1663 __ movups(XMM11, Address(RAX, 0));
1664 __ cvtps2pd(XMM10, XMM11);
1665 __ movaps(XMM0, XMM10);
1666 __ ret();
1667 }
1668
1669
1670 ASSEMBLER_TEST_RUN(PackedSingleToDouble, test) {
1671 typedef double (*PackedSingleToDouble)();
1672 double res = reinterpret_cast<PackedSingleToDouble>(test->entry())();
1673 EXPECT_FLOAT_EQ(9.0f, res, 0.000001f);
1674 }
1675
1676
1419 ASSEMBLER_TEST_GENERATE(SingleFPOperations, assembler) { 1677 ASSEMBLER_TEST_GENERATE(SingleFPOperations, assembler) {
1420 __ pushq(RBX); 1678 __ pushq(RBX);
1421 __ pushq(RCX); 1679 __ pushq(RCX);
1422 __ movq(RBX, Immediate(bit_cast<int32_t, float>(12.3f))); 1680 __ movq(RBX, Immediate(bit_cast<int32_t, float>(12.3f)));
1423 __ movd(XMM0, RBX); 1681 __ movd(XMM0, RBX);
1424 __ movd(XMM8, RBX); 1682 __ movd(XMM8, RBX);
1425 __ movq(RCX, Immediate(bit_cast<int32_t, float>(3.4f))); 1683 __ movq(RCX, Immediate(bit_cast<int32_t, float>(3.4f)));
1426 __ movd(XMM1, RCX); 1684 __ movd(XMM1, RCX);
1427 __ movd(XMM9, RCX); 1685 __ movd(XMM9, RCX);
1428 __ addss(XMM0, XMM1); // 15.7f 1686 __ addss(XMM0, XMM1); // 15.7f
(...skipping 1227 matching lines...) Expand 10 before | Expand all | Expand 10 after
2656 EXPECT_EQ(1, res); // Greater equal. 2914 EXPECT_EQ(1, res); // Greater equal.
2657 res = reinterpret_cast<ConditionalMovesCompareCode>(test->entry())(5, 5); 2915 res = reinterpret_cast<ConditionalMovesCompareCode>(test->entry())(5, 5);
2658 EXPECT_EQ(1, res); // Greater equal. 2916 EXPECT_EQ(1, res); // Greater equal.
2659 res = reinterpret_cast<ConditionalMovesCompareCode>(test->entry())(2, 5); 2917 res = reinterpret_cast<ConditionalMovesCompareCode>(test->entry())(2, 5);
2660 EXPECT_EQ(-1, res); // Less. 2918 EXPECT_EQ(-1, res); // Less.
2661 } 2919 }
2662 2920
2663 } // namespace dart 2921 } // namespace dart
2664 2922
2665 #endif // defined TARGET_ARCH_X64 2923 #endif // defined TARGET_ARCH_X64
OLDNEW
« no previous file with comments | « runtime/vm/assembler_x64.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698