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

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

Issue 14784011: Fixes for integer division on ARM hardware so that assembler tests pass. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 7 years, 7 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
OLDNEW
1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2013, 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_ARM) 6 #if defined(TARGET_ARCH_ARM)
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 1371 matching lines...) Expand 10 before | Expand all | Expand 10 after
1382 EXPECT(test != NULL); 1382 EXPECT(test != NULL);
1383 typedef int (*Tst)(); 1383 typedef int (*Tst)();
1384 EXPECT_EQ(42, EXECUTE_TEST_CODE_INT32(Tst, test->entry())); 1384 EXPECT_EQ(42, EXECUTE_TEST_CODE_INT32(Tst, test->entry()));
1385 } 1385 }
1386 1386
1387 1387
1388 // Check that assembler mrc instruction encoding, and simulator decoding 1388 // Check that assembler mrc instruction encoding, and simulator decoding
1389 // are in agreement. 1389 // are in agreement.
1390 #if defined(USING_SIMULATOR) 1390 #if defined(USING_SIMULATOR)
1391 ASSEMBLER_TEST_GENERATE(MrcHaveDiv, assembler) { 1391 ASSEMBLER_TEST_GENERATE(MrcHaveDiv, assembler) {
1392 __ mrc(R0, 15, 0, 0, 2, 0); 1392 __ mrc(R0, 15, 0, 0, 2, 0);
regis 2013/05/07 17:14:35 Could you add a comment here explaining what bits
zra 2013/05/07 17:50:18 Done.
1393 __ Lsr(R0, R0, 24); 1393 __ Lsr(R0, R0, 24);
1394 __ and_(R0, R0, ShifterOperand(0xf)); 1394 __ and_(R0, R0, ShifterOperand(0xf));
1395 __ mov(PC, ShifterOperand(LR)); 1395 __ mov(PC, ShifterOperand(LR));
1396 } 1396 }
1397 1397
1398 1398
1399 ASSEMBLER_TEST_RUN(MrcHaveDiv, test) { 1399 ASSEMBLER_TEST_RUN(MrcHaveDiv, test) {
1400 EXPECT(test != NULL); 1400 EXPECT(test != NULL);
1401 typedef int (*Tst)(); 1401 typedef int (*Tst)();
1402 bool b = CPUFeatures::integer_division_supported(); 1402 bool b = CPUFeatures::integer_division_supported();
(...skipping 12 matching lines...) Expand all
1415 1415
1416 1416
1417 ASSEMBLER_TEST_RUN(MrcNoDiv, test) { 1417 ASSEMBLER_TEST_RUN(MrcNoDiv, test) {
1418 EXPECT(test != NULL); 1418 EXPECT(test != NULL);
1419 typedef int (*Tst)(); 1419 typedef int (*Tst)();
1420 bool b = CPUFeatures::integer_division_supported(); 1420 bool b = CPUFeatures::integer_division_supported();
1421 CPUFeatures::set_integer_division_supported(false); 1421 CPUFeatures::set_integer_division_supported(false);
1422 EXPECT_EQ(0, EXECUTE_TEST_CODE_INT32(Tst, test->entry())); 1422 EXPECT_EQ(0, EXECUTE_TEST_CODE_INT32(Tst, test->entry()));
1423 CPUFeatures::set_integer_division_supported(b); 1423 CPUFeatures::set_integer_division_supported(b);
1424 } 1424 }
1425 #endif // defined(USING_SIMULATOR)
1426 1425
1427 1426
1428 ASSEMBLER_TEST_GENERATE(MrcReal, assembler) { 1427 ASSEMBLER_TEST_GENERATE(MrcReal, assembler) {
1429 __ mrc(R0, 15, 0, 0, 2, 0); 1428 __ mrc(R0, 15, 0, 0, 2, 0);
1430 __ Lsr(R0, R0, 24); 1429 __ Lsr(R0, R0, 24);
1431 __ and_(R0, R0, ShifterOperand(0xf)); 1430 __ and_(R0, R0, ShifterOperand(0xf));
1432 __ mov(PC, ShifterOperand(LR)); 1431 __ mov(PC, ShifterOperand(LR));
1433 } 1432 }
1434 1433
1435 1434
1436 ASSEMBLER_TEST_RUN(MrcReal, test) { 1435 ASSEMBLER_TEST_RUN(MrcReal, test) {
1437 EXPECT(test != NULL); 1436 EXPECT(test != NULL);
1438 typedef int (*Tst)(); 1437 typedef int (*Tst)();
1439 bool have_div = CPUFeatures::integer_division_supported(); 1438 bool have_div = CPUFeatures::integer_division_supported();
1440 int32_t r = EXECUTE_TEST_CODE_INT32(Tst, test->entry()); 1439 int32_t r = EXECUTE_TEST_CODE_INT32(Tst, test->entry());
1441 if (have_div) { 1440 if (have_div) {
1442 EXPECT_LT(0, r); 1441 EXPECT_LT(0, r);
1443 } else { 1442 } else {
1444 EXPECT_EQ(0, r); 1443 EXPECT_EQ(0, r);
1445 } 1444 }
1446 } 1445 }
1446 #endif // defined(USING_SIMULATOR)
1447 1447
1448 1448
1449 ASSEMBLER_TEST_GENERATE(Udiv, assembler) { 1449 ASSEMBLER_TEST_GENERATE(Udiv, assembler) {
1450 __ mov(R0, ShifterOperand(27)); 1450 if (CPUFeatures::integer_division_supported()) {
1451 __ mov(R1, ShifterOperand(9)); 1451 __ mov(R0, ShifterOperand(27));
1452 __ udiv(R2, R0, R1); 1452 __ mov(R1, ShifterOperand(9));
1453 __ Mov(R0, R2); 1453 __ udiv(R2, R0, R1);
1454 __ Mov(R0, R2);
1455 } else {
1456 __ mov(R0, ShifterOperand(3));
1457 }
1454 __ mov(PC, ShifterOperand(LR)); 1458 __ mov(PC, ShifterOperand(LR));
1455 } 1459 }
1456 1460
1457 1461
1458 ASSEMBLER_TEST_RUN(Udiv, test) { 1462 ASSEMBLER_TEST_RUN(Udiv, test) {
1459 EXPECT(test != NULL); 1463 EXPECT(test != NULL);
1460 typedef int (*Tst)(); 1464 typedef int (*Tst)();
1461 EXPECT_EQ(3, EXECUTE_TEST_CODE_INT32(Tst, test->entry())); 1465 EXPECT_EQ(3, EXECUTE_TEST_CODE_INT32(Tst, test->entry()));
1462 } 1466 }
1463 1467
1464 1468
1465 ASSEMBLER_TEST_GENERATE(Sdiv, assembler) { 1469 ASSEMBLER_TEST_GENERATE(Sdiv, assembler) {
1466 __ mov(R0, ShifterOperand(27)); 1470 if (CPUFeatures::integer_division_supported()) {
1467 __ LoadImmediate(R1, -9); 1471 __ mov(R0, ShifterOperand(27));
1468 __ sdiv(R2, R0, R1); 1472 __ LoadImmediate(R1, -9);
1469 __ Mov(R0, R2); 1473 __ sdiv(R2, R0, R1);
1474 __ Mov(R0, R2);
1475 } else {
1476 __ LoadImmediate(R0, -3);
1477 }
1470 __ mov(PC, ShifterOperand(LR)); 1478 __ mov(PC, ShifterOperand(LR));
1471 } 1479 }
1472 1480
1473 1481
1474 ASSEMBLER_TEST_RUN(Sdiv, test) { 1482 ASSEMBLER_TEST_RUN(Sdiv, test) {
1475 EXPECT(test != NULL); 1483 EXPECT(test != NULL);
1476 typedef int (*Tst)(); 1484 typedef int (*Tst)();
1477 EXPECT_EQ(-3, EXECUTE_TEST_CODE_INT32(Tst, test->entry())); 1485 EXPECT_EQ(-3, EXECUTE_TEST_CODE_INT32(Tst, test->entry()));
1478 } 1486 }
1479 1487
1480 1488
1481 ASSEMBLER_TEST_GENERATE(Udiv_zero, assembler) { 1489 ASSEMBLER_TEST_GENERATE(Udiv_zero, assembler) {
1482 __ mov(R0, ShifterOperand(27)); 1490 if (CPUFeatures::integer_division_supported()) {
1483 __ mov(R1, ShifterOperand(0)); 1491 __ mov(R0, ShifterOperand(27));
1484 __ udiv(R2, R0, R1); 1492 __ mov(R1, ShifterOperand(0));
1485 __ Mov(R0, R2); 1493 __ udiv(R2, R0, R1);
1494 __ Mov(R0, R2);
1495 } else {
1496 __ LoadImmediate(R0, 0);
1497 }
1486 __ mov(PC, ShifterOperand(LR)); 1498 __ mov(PC, ShifterOperand(LR));
1487 } 1499 }
1488 1500
1489 1501
1490 ASSEMBLER_TEST_RUN(Udiv_zero, test) { 1502 ASSEMBLER_TEST_RUN(Udiv_zero, test) {
1491 EXPECT(test != NULL); 1503 EXPECT(test != NULL);
1492 typedef int (*Tst)(); 1504 typedef int (*Tst)();
1493 EXPECT_EQ(0, EXECUTE_TEST_CODE_INT32(Tst, test->entry())); 1505 EXPECT_EQ(0, EXECUTE_TEST_CODE_INT32(Tst, test->entry()));
1494 } 1506 }
1495 1507
1496 1508
1497 ASSEMBLER_TEST_GENERATE(Sdiv_zero, assembler) { 1509 ASSEMBLER_TEST_GENERATE(Sdiv_zero, assembler) {
1498 __ mov(R0, ShifterOperand(27)); 1510 if (CPUFeatures::integer_division_supported()) {
1499 __ mov(R1, ShifterOperand(0)); 1511 __ mov(R0, ShifterOperand(27));
1500 __ udiv(R2, R0, R1); 1512 __ mov(R1, ShifterOperand(0));
1501 __ Mov(R0, R2); 1513 __ udiv(R2, R0, R1);
1514 __ Mov(R0, R2);
1515 } else {
1516 __ LoadImmediate(R0, 0);
1517 }
1502 __ mov(PC, ShifterOperand(LR)); 1518 __ mov(PC, ShifterOperand(LR));
1503 } 1519 }
1504 1520
1505 1521
1506 ASSEMBLER_TEST_RUN(Sdiv_zero, test) { 1522 ASSEMBLER_TEST_RUN(Sdiv_zero, test) {
1507 EXPECT(test != NULL); 1523 EXPECT(test != NULL);
1508 typedef int (*Tst)(); 1524 typedef int (*Tst)();
1509 EXPECT_EQ(0, EXECUTE_TEST_CODE_INT32(Tst, test->entry())); 1525 EXPECT_EQ(0, EXECUTE_TEST_CODE_INT32(Tst, test->entry()));
1510 } 1526 }
1511 1527
1512 1528
1513 ASSEMBLER_TEST_GENERATE(Udiv_corner, assembler) { 1529 ASSEMBLER_TEST_GENERATE(Udiv_corner, assembler) {
1514 __ LoadImmediate(R0, 0x80000000); 1530 if (CPUFeatures::integer_division_supported()) {
1515 __ LoadImmediate(R1, 0xffffffff); 1531 __ LoadImmediate(R0, 0x80000000);
1516 __ udiv(R2, R0, R1); 1532 __ LoadImmediate(R1, 0xffffffff);
1517 __ Mov(R0, R2); 1533 __ udiv(R2, R0, R1);
1534 __ Mov(R0, R2);
1535 } else {
1536 __ LoadImmediate(R0, 0);
1537 }
1518 __ mov(PC, ShifterOperand(LR)); 1538 __ mov(PC, ShifterOperand(LR));
1519 } 1539 }
1520 1540
1521 1541
1522 ASSEMBLER_TEST_RUN(Udiv_corner, test) { 1542 ASSEMBLER_TEST_RUN(Udiv_corner, test) {
1523 EXPECT(test != NULL); 1543 EXPECT(test != NULL);
1524 typedef int (*Tst)(); 1544 typedef int (*Tst)();
1525 EXPECT_EQ(0, EXECUTE_TEST_CODE_INT32(Tst, test->entry())); 1545 EXPECT_EQ(0, EXECUTE_TEST_CODE_INT32(Tst, test->entry()));
1526 } 1546 }
1527 1547
1528 1548
1529 ASSEMBLER_TEST_GENERATE(Sdiv_corner, assembler) { 1549 ASSEMBLER_TEST_GENERATE(Sdiv_corner, assembler) {
1530 __ LoadImmediate(R0, 0x80000000); 1550 if (CPUFeatures::integer_division_supported()) {
1531 __ LoadImmediate(R1, 0xffffffff); 1551 __ LoadImmediate(R0, 0x80000000);
1532 __ sdiv(R2, R0, R1); 1552 __ LoadImmediate(R1, 0xffffffff);
1533 __ Mov(R0, R2); 1553 __ sdiv(R2, R0, R1);
1554 __ Mov(R0, R2);
1555 } else {
1556 __ LoadImmediate(R0, 0x80000000);
1557 }
1534 __ mov(PC, ShifterOperand(LR)); 1558 __ mov(PC, ShifterOperand(LR));
1535 } 1559 }
1536 1560
1537 1561
1538 ASSEMBLER_TEST_RUN(Sdiv_corner, test) { 1562 ASSEMBLER_TEST_RUN(Sdiv_corner, test) {
1539 EXPECT(test != NULL); 1563 EXPECT(test != NULL);
1540 typedef int (*Tst)(); 1564 typedef int (*Tst)();
1541 EXPECT_EQ(static_cast<int32_t>(0x80000000), 1565 EXPECT_EQ(static_cast<int32_t>(0x80000000),
1542 EXECUTE_TEST_CODE_INT32(Tst, test->entry())); 1566 EXECUTE_TEST_CODE_INT32(Tst, test->entry()));
1543 } 1567 }
(...skipping 26 matching lines...) Expand all
1570 __ StoreIntoObject(R2, 1594 __ StoreIntoObject(R2,
1571 FieldAddress(R2, GrowableObjectArray::data_offset()), 1595 FieldAddress(R2, GrowableObjectArray::data_offset()),
1572 R1); 1596 R1);
1573 __ PopList((1 << CTX) | (1 << LR)); 1597 __ PopList((1 << CTX) | (1 << LR));
1574 __ Ret(); 1598 __ Ret();
1575 } 1599 }
1576 1600
1577 } // namespace dart 1601 } // namespace dart
1578 1602
1579 #endif // defined TARGET_ARCH_ARM 1603 #endif // defined TARGET_ARCH_ARM
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698