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

Side by Side Diff: test/cctest/test-assembler-mips64.cc

Issue 1057323002: MIPS: Major fixes and clean-up in asm. for instruction encoding. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Typos addressed. Created 5 years, 8 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
« no previous file with comments | « test/cctest/test-assembler-mips.cc ('k') | test/cctest/test-disasm-mips.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 1430 matching lines...) Expand 10 before | Expand all | Expand 10 after
1441 CcTest::InitializeVM(); 1441 CcTest::InitializeVM();
1442 Isolate* isolate = CcTest::i_isolate(); 1442 Isolate* isolate = CcTest::i_isolate();
1443 HandleScope scope(isolate); 1443 HandleScope scope(isolate);
1444 MacroAssembler assm(isolate, NULL, 0); 1444 MacroAssembler assm(isolate, NULL, 0);
1445 1445
1446 typedef struct test { 1446 typedef struct test {
1447 int a; 1447 int a;
1448 int b; 1448 int b;
1449 int c; 1449 int c;
1450 int d; 1450 int d;
1451 double i; 1451 double e;
1452 double j; 1452 double f;
1453 double k; 1453 double g;
1454 double l; 1454 double h;
1455 } Test; 1455 } Test;
1456 1456
1457 Test test; 1457 Test test;
1458 // Integer part of test. 1458 // Integer part of test.
1459 __ addiu(t1, zero_reg, 1); // t1 = 1 1459 __ addiu(t1, zero_reg, 1); // t1 = 1
1460 __ seleqz(t1, zero_reg, t3); // t3 = 1 1460 __ seleqz(t3, t1, zero_reg); // t3 = 1
1461 __ sw(t3, MemOperand(a0, OFFSET_OF(Test, a))); // a = 1 1461 __ sw(t3, MemOperand(a0, OFFSET_OF(Test, a))); // a = 1
1462 __ seleqz(t1, t1, t2); // t2 = 0 1462 __ seleqz(t2, t1, t1); // t2 = 0
1463 __ sw(t2, MemOperand(a0, OFFSET_OF(Test, b))); // b = 0 1463 __ sw(t2, MemOperand(a0, OFFSET_OF(Test, b))); // b = 0
1464 __ selnez(t1, zero_reg, t3); // t3 = 1; 1464 __ selnez(t3, t1, zero_reg); // t3 = 1;
1465 __ sw(t3, MemOperand(a0, OFFSET_OF(Test, c))); // c = 0 1465 __ sw(t3, MemOperand(a0, OFFSET_OF(Test, c))); // c = 0
1466 __ selnez(t1, t1, t3); // t3 = 1 1466 __ selnez(t3, t1, t1); // t3 = 1
1467 __ sw(t3, MemOperand(a0, OFFSET_OF(Test, d))); // d = 1 1467 __ sw(t3, MemOperand(a0, OFFSET_OF(Test, d))); // d = 1
1468 // Floating point part of test. 1468 // Floating point part of test.
1469 __ li(t0, 0x80); 1469 __ ldc1(f0, MemOperand(a0, OFFSET_OF(Test, e)) ); // src
1470 __ mtc1(t0, f4); 1470 __ ldc1(f2, MemOperand(a0, OFFSET_OF(Test, f)) ); // test
1471 __ cvt_d_w(f4, f4); // f4=0x80 1471 __ seleqz(D, f4, f0, f2);
1472 __ li(t0, 0xf3); 1472 __ selnez(D, f6, f0, f2);
1473 __ mtc1(t0, f6); 1473 __ sdc1(f4, MemOperand(a0, OFFSET_OF(Test, g)) ); // src
1474 __ cvt_d_w(f6, f6); // f6 = 0xf3 1474 __ sdc1(f6, MemOperand(a0, OFFSET_OF(Test, h)) ); // src
1475 __ seleqz(D, f8, f4, f6); // f8 = 0xf3
1476 __ seleqz(D, f10, f6, f6); // f10 = 0
1477 __ sdc1(f8, MemOperand(a0, OFFSET_OF(Test, i))); // i = 0xf3
1478 __ sdc1(f10, MemOperand(a0, OFFSET_OF(Test, j))); // j = 0
1479 __ selnez(D, f8, f4, f6); // f8 = 0
1480 __ selnez(D, f10, f6, f6); // f10 = 0xf3
1481 __ sdc1(f8, MemOperand(a0, OFFSET_OF(Test, k))); // k = 0
1482 __ sdc1(f10, MemOperand(a0, OFFSET_OF(Test, l))); // l = 0xf3
1483 __ jr(ra); 1475 __ jr(ra);
1484 __ nop(); 1476 __ nop();
1485 CodeDesc desc; 1477 CodeDesc desc;
1486 assm.GetCode(&desc); 1478 assm.GetCode(&desc);
1487 Handle<Code> code = isolate->factory()->NewCode( 1479 Handle<Code> code = isolate->factory()->NewCode(
1488 desc, Code::ComputeFlags(Code::STUB), Handle<Code>()); 1480 desc, Code::ComputeFlags(Code::STUB), Handle<Code>());
1489 F3 f = FUNCTION_CAST<F3>(code->entry()); 1481 F3 f = FUNCTION_CAST<F3>(code->entry());
1490 1482
1491 (CALL_GENERATED_CODE(f, &test, 0, 0, 0, 0)); 1483 (CALL_GENERATED_CODE(f, &test, 0, 0, 0, 0));
1492 1484
1493 CHECK_EQ(test.a, 1); 1485 CHECK_EQ(test.a, 1);
1494 CHECK_EQ(test.b, 0); 1486 CHECK_EQ(test.b, 0);
1495 CHECK_EQ(test.c, 0); 1487 CHECK_EQ(test.c, 0);
1496 CHECK_EQ(test.d, 1); 1488 CHECK_EQ(test.d, 1);
1497 1489
1498 CHECK_EQ(test.i, 0xf3); 1490 const int test_size = 3;
1499 CHECK_EQ(test.j, 0x0); 1491 const int input_size = 5;
1500 CHECK_EQ(test.k, 0); 1492
1501 CHECK_EQ(test.l, 0xf3); 1493 double inputs[input_size] = {0.0, 65.2, -70.32,
1494 18446744073709551621.0, -18446744073709551621.0};
1495 double outputs[input_size] = {0.0, 65.2, -70.32,
1496 18446744073709551621.0, -18446744073709551621.0};
1497 double tests[test_size*2] = {2.8, 2.9, -2.8, -2.9,
1498 18446744073709551616.0, 18446744073709555712.0};
1499 for (int j=0;j < test_size;j+=2) {
1500 for (int i=0;i < input_size;i++) {
1501 test.e = inputs[i];
1502 test.f = tests[j];
1503 (CALL_GENERATED_CODE(f, &test, 0, 0, 0, 0));
1504 CHECK_EQ(test.g, outputs[i]);
1505 CHECK_EQ(test.h, 0);
1506
1507 test.f = tests[j+1];
1508 (CALL_GENERATED_CODE(f, &test, 0, 0, 0, 0));
1509 CHECK_EQ(test.g, 0);
1510 CHECK_EQ(test.h, outputs[i]);
1511 }
1512 }
1502 } 1513 }
1503 } 1514 }
1504 1515
1516
1517 TEST(MIPS18) {
1518 if (kArchVariant == kMips64r6) {
1519 CcTest::InitializeVM();
1520 Isolate* isolate = CcTest::i_isolate();
1521 HandleScope scope(isolate);
1522 MacroAssembler assm(isolate, NULL, 0);
1523
1524 typedef struct test_float {
1525 double a;
1526 double b;
1527 double c;
1528 double d;
1529 } TestFloat;
1530
1531 TestFloat test;
1532
1533 __ ldc1(f4, MemOperand(a0, OFFSET_OF(TestFloat, a)));
1534 __ ldc1(f8, MemOperand(a0, OFFSET_OF(TestFloat, b)));
1535 __ min(D, f10, f8, f4);
1536 __ max(D, f12, f8, f4);
1537 __ sdc1(f10, MemOperand(a0, OFFSET_OF(TestFloat, c)));
1538 __ sdc1(f12, MemOperand(a0, OFFSET_OF(TestFloat, d)));
1539 __ jr(ra);
1540 __ nop();
1541
1542 CodeDesc desc;
1543 assm.GetCode(&desc);
1544 Handle<Code> code = isolate->factory()->NewCode(
1545 desc, Code::ComputeFlags(Code::STUB), Handle<Code>());
1546 F3 f = FUNCTION_CAST<F3>(code->entry());
1547 test.a = 2.0; // a goes to fs
1548 test.b = 3.0; // b goes to ft
1549 (CALL_GENERATED_CODE(f, &test, 0, 0, 0, 0));
1550 CHECK_EQ(test.c, 2.0);
1551 CHECK_EQ(test.d, 3.0);
1552
1553 test.a = 3.0; // a goes to fs
1554 test.b = 2.0; // b goes to ft
1555 (CALL_GENERATED_CODE(f, &test, 0, 0, 0, 0));
1556 CHECK_EQ(test.c, 2.0);
1557 CHECK_EQ(test.d, 3.0);
1558
1559 test.a = std::numeric_limits<double>::quiet_NaN();
1560 test.b = 3.0; // b goes to ft
1561 (CALL_GENERATED_CODE(f, &test, 0, 0, 0, 0));
1562 CHECK_EQ(test.c, 3.0);
1563 CHECK_EQ(test.d, 3.0);
1564
1565 test.b = std::numeric_limits<double>::quiet_NaN();
1566 test.a = 3.0; // b goes to ft
1567 (CALL_GENERATED_CODE(f, &test, 0, 0, 0, 0));
1568 CHECK_EQ(test.c, 3.0);
1569 CHECK_EQ(test.d, 3.0);
1570
1571 test.a = std::numeric_limits<double>::quiet_NaN();
1572 test.b = std::numeric_limits<double>::quiet_NaN();
1573 (CALL_GENERATED_CODE(f, &test, 0, 0, 0, 0));
1574 DCHECK(std::isnan(test.c));
1575 DCHECK(std::isnan(test.d));
1576 }
1577 }
1578
1505 1579
1506 TEST(jump_tables1) { 1580 TEST(jump_tables1) {
1507 // Test jump tables with forward jumps. 1581 // Test jump tables with forward jumps.
1508 CcTest::InitializeVM(); 1582 CcTest::InitializeVM();
1509 Isolate* isolate = CcTest::i_isolate(); 1583 Isolate* isolate = CcTest::i_isolate();
1510 HandleScope scope(isolate); 1584 HandleScope scope(isolate);
1511 Assembler assm(isolate, nullptr, 0); 1585 Assembler assm(isolate, nullptr, 0);
1512 1586
1513 const int kNumCases = 512; 1587 const int kNumCases = 512;
1514 int values[kNumCases]; 1588 int values[kNumCases];
(...skipping 205 matching lines...) Expand 10 before | Expand all | Expand 10 after
1720 ::printf("f(%d) = ", i); 1794 ::printf("f(%d) = ", i);
1721 result->Print(std::cout); 1795 result->Print(std::cout);
1722 ::printf("\n"); 1796 ::printf("\n");
1723 #endif 1797 #endif
1724 CHECK(values[i].is_identical_to(result)); 1798 CHECK(values[i].is_identical_to(result));
1725 } 1799 }
1726 } 1800 }
1727 1801
1728 1802
1729 #undef __ 1803 #undef __
OLDNEW
« no previous file with comments | « test/cctest/test-assembler-mips.cc ('k') | test/cctest/test-disasm-mips.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698