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

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

Issue 1867503002: MIPS: Enable big endian testing. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Updated according comments. Created 4 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/unittests/unittests.gyp » ('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 1367 matching lines...) Expand 10 before | Expand all | Expand 10 after
1378 1378
1379 1379
1380 // ----- mips64 tests ----------------------------------------------- 1380 // ----- mips64 tests -----------------------------------------------
1381 1381
1382 TEST(MIPS16) { 1382 TEST(MIPS16) {
1383 // Test 64-bit memory loads and stores. 1383 // Test 64-bit memory loads and stores.
1384 CcTest::InitializeVM(); 1384 CcTest::InitializeVM();
1385 Isolate* isolate = CcTest::i_isolate(); 1385 Isolate* isolate = CcTest::i_isolate();
1386 HandleScope scope(isolate); 1386 HandleScope scope(isolate);
1387 1387
1388 typedef struct { 1388 struct T {
1389 int64_t r1; 1389 int64_t r1;
1390 int64_t r2; 1390 int64_t r2;
1391 int64_t r3; 1391 int64_t r3;
1392 int64_t r4; 1392 int64_t r4;
1393 int64_t r5; 1393 int64_t r5;
1394 int64_t r6; 1394 int64_t r6;
1395 int64_t r7;
1396 int64_t r8;
1397 int64_t r9;
1398 int64_t r10;
1399 int64_t r11;
1400 int64_t r12;
1395 uint32_t ui; 1401 uint32_t ui;
1396 int32_t si; 1402 int32_t si;
1397 } T; 1403 };
1398 T t; 1404 T t;
1399 1405
1400 Assembler assm(isolate, NULL, 0); 1406 Assembler assm(isolate, NULL, 0);
1401 Label L, C; 1407 Label L, C;
1402 1408
1403 // Basic 32-bit word load/store, with un-signed data. 1409 // Basic 32-bit word load/store, with un-signed data.
1404 __ lw(a4, MemOperand(a0, offsetof(T, ui))); 1410 __ lw(a4, MemOperand(a0, offsetof(T, ui)));
1405 __ sw(a4, MemOperand(a0, offsetof(T, r1))); 1411 __ sw(a4, MemOperand(a0, offsetof(T, r1)));
1406 1412
1407 // Check that the data got zero-extended into 64-bit a4. 1413 // Check that the data got zero-extended into 64-bit a4.
1408 __ sd(a4, MemOperand(a0, offsetof(T, r2))); 1414 __ sd(a4, MemOperand(a0, offsetof(T, r2)));
1409 1415
1410 // Basic 32-bit word load/store, with SIGNED data. 1416 // Basic 32-bit word load/store, with SIGNED data.
1411 __ lw(a5, MemOperand(a0, offsetof(T, si))); 1417 __ lw(a5, MemOperand(a0, offsetof(T, si)));
1412 __ sw(a5, MemOperand(a0, offsetof(T, r3))); 1418 __ sw(a5, MemOperand(a0, offsetof(T, r3)));
1413 1419
1414 // Check that the data got sign-extended into 64-bit a4. 1420 // Check that the data got sign-extended into 64-bit a4.
1415 __ sd(a5, MemOperand(a0, offsetof(T, r4))); 1421 __ sd(a5, MemOperand(a0, offsetof(T, r4)));
1416 1422
1417 // 32-bit UNSIGNED word load/store, with SIGNED data. 1423 // 32-bit UNSIGNED word load/store, with SIGNED data.
1418 __ lwu(a6, MemOperand(a0, offsetof(T, si))); 1424 __ lwu(a6, MemOperand(a0, offsetof(T, si)));
1419 __ sw(a6, MemOperand(a0, offsetof(T, r5))); 1425 __ sw(a6, MemOperand(a0, offsetof(T, r5)));
1420 1426
1421 // Check that the data got zero-extended into 64-bit a4. 1427 // Check that the data got zero-extended into 64-bit a4.
1422 __ sd(a6, MemOperand(a0, offsetof(T, r6))); 1428 __ sd(a6, MemOperand(a0, offsetof(T, r6)));
1423 1429
1424 // lh with positive data. 1430 // lh with positive data.
1425 __ lh(a5, MemOperand(a0, offsetof(T, ui))); 1431 __ lh(a5, MemOperand(a0, offsetof(T, ui)));
1426 __ sw(a5, MemOperand(a0, offsetof(T, r2))); 1432 __ sw(a5, MemOperand(a0, offsetof(T, r7)));
1427 1433
1428 // lh with negative data. 1434 // lh with negative data.
1429 __ lh(a6, MemOperand(a0, offsetof(T, si))); 1435 __ lh(a6, MemOperand(a0, offsetof(T, si)));
1430 __ sw(a6, MemOperand(a0, offsetof(T, r3))); 1436 __ sw(a6, MemOperand(a0, offsetof(T, r8)));
1431 1437
1432 // lhu with negative data. 1438 // lhu with negative data.
1433 __ lhu(a7, MemOperand(a0, offsetof(T, si))); 1439 __ lhu(a7, MemOperand(a0, offsetof(T, si)));
1434 __ sw(a7, MemOperand(a0, offsetof(T, r4))); 1440 __ sw(a7, MemOperand(a0, offsetof(T, r9)));
1435 1441
1436 // lb with negative data. 1442 // lb with negative data.
1437 __ lb(t0, MemOperand(a0, offsetof(T, si))); 1443 __ lb(t0, MemOperand(a0, offsetof(T, si)));
1438 __ sw(t0, MemOperand(a0, offsetof(T, r5))); 1444 __ sw(t0, MemOperand(a0, offsetof(T, r10)));
1439 1445
1440 // // sh writes only 1/2 of word. 1446 // sh writes only 1/2 of word.
1441 __ lui(t1, 0x3333); 1447 __ lw(a4, MemOperand(a0, offsetof(T, ui)));
1442 __ ori(t1, t1, 0x3333); 1448 __ sh(a4, MemOperand(a0, offsetof(T, r11)));
1443 __ sw(t1, MemOperand(a0, offsetof(T, r6))); 1449 __ lw(a4, MemOperand(a0, offsetof(T, si)));
1444 __ lhu(t1, MemOperand(a0, offsetof(T, si))); 1450 __ sh(a4, MemOperand(a0, offsetof(T, r12)));
1445 __ sh(t1, MemOperand(a0, offsetof(T, r6)));
1446 1451
1447 __ jr(ra); 1452 __ jr(ra);
1448 __ nop(); 1453 __ nop();
1449 1454
1450 CodeDesc desc; 1455 CodeDesc desc;
1451 assm.GetCode(&desc); 1456 assm.GetCode(&desc);
1452 Handle<Code> code = isolate->factory()->NewCode( 1457 Handle<Code> code = isolate->factory()->NewCode(
1453 desc, Code::ComputeFlags(Code::STUB), Handle<Code>()); 1458 desc, Code::ComputeFlags(Code::STUB), Handle<Code>());
1454 F3 f = FUNCTION_CAST<F3>(code->entry()); 1459 F3 f = FUNCTION_CAST<F3>(code->entry());
1455 t.ui = 0x44332211; 1460 t.ui = 0x44332211;
1456 t.si = 0x99aabbcc; 1461 t.si = 0x99aabbcc;
1457 t.r1 = 0x1111111111111111; 1462 t.r1 = 0x5555555555555555;
1458 t.r2 = 0x2222222222222222; 1463 t.r2 = 0x5555555555555555;
1459 t.r3 = 0x3333333333333333; 1464 t.r3 = 0x5555555555555555;
1460 t.r4 = 0x4444444444444444; 1465 t.r4 = 0x5555555555555555;
1461 t.r5 = 0x5555555555555555; 1466 t.r5 = 0x5555555555555555;
1462 t.r6 = 0x6666666666666666; 1467 t.r6 = 0x5555555555555555;
1468 t.r7 = 0x5555555555555555;
1469 t.r8 = 0x5555555555555555;
1470 t.r9 = 0x5555555555555555;
1471 t.r10 = 0x5555555555555555;
1472 t.r11 = 0x5555555555555555;
1473 t.r12 = 0x5555555555555555;
1474
1463 Object* dummy = CALL_GENERATED_CODE(isolate, f, &t, 0, 0, 0, 0); 1475 Object* dummy = CALL_GENERATED_CODE(isolate, f, &t, 0, 0, 0, 0);
1464 USE(dummy); 1476 USE(dummy);
1465 1477
1466 // Unsigned data, 32 & 64. 1478 if (kArchEndian == kLittle) {
1467 CHECK_EQ(static_cast<int64_t>(0x1111111144332211L), t.r1); 1479 // Unsigned data, 32 & 64
1468 CHECK_EQ(static_cast<int64_t>(0x0000000000002211L), t.r2); 1480 CHECK_EQ(static_cast<int64_t>(0x5555555544332211L), t.r1); // lw, sw.
1481 CHECK_EQ(static_cast<int64_t>(0x0000000044332211L), t.r2); // sd.
1469 1482
1470 // Signed data, 32 & 64. 1483 // Signed data, 32 & 64.
1471 CHECK_EQ(static_cast<int64_t>(0x33333333ffffbbccL), t.r3); 1484 CHECK_EQ(static_cast<int64_t>(0x5555555599aabbccL), t.r3); // lw, sw.
1472 CHECK_EQ(static_cast<int64_t>(0xffffffff0000bbccL), t.r4); 1485 CHECK_EQ(static_cast<int64_t>(0xffffffff99aabbccL), t.r4); // sd.
1473 1486
1474 // Signed data, 32 & 64. 1487 // Signed data, 32 & 64.
1475 CHECK_EQ(static_cast<int64_t>(0x55555555ffffffccL), t.r5); 1488 CHECK_EQ(static_cast<int64_t>(0x5555555599aabbccL), t.r5); // lwu, sw.
1476 CHECK_EQ(static_cast<int64_t>(0x000000003333bbccL), t.r6); 1489 CHECK_EQ(static_cast<int64_t>(0x0000000099aabbccL), t.r6); // sd.
1490
1491 // lh with unsigned and signed data.
1492 CHECK_EQ(static_cast<int64_t>(0x5555555500002211L), t.r7); // lh, sw.
1493 CHECK_EQ(static_cast<int64_t>(0x55555555ffffbbccL), t.r8); // lh, sw.
1494
1495 // lhu with signed data.
1496 CHECK_EQ(static_cast<int64_t>(0x555555550000bbccL), t.r9); // lhu, sw.
1497
1498 // lb with signed data.
1499 CHECK_EQ(static_cast<int64_t>(0x55555555ffffffccL), t.r10); // lb, sw.
1500
1501 // sh with unsigned and signed data.
1502 CHECK_EQ(static_cast<int64_t>(0x5555555555552211L), t.r11); // lw, sh.
1503 CHECK_EQ(static_cast<int64_t>(0x555555555555bbccL), t.r12); // lw, sh.
1504 } else {
1505 // Unsigned data, 32 & 64
1506 CHECK_EQ(static_cast<int64_t>(0x4433221155555555L), t.r1); // lw, sw.
1507 CHECK_EQ(static_cast<int64_t>(0x0000000044332211L), t.r2); // sd.
1508
1509 // Signed data, 32 & 64.
1510 CHECK_EQ(static_cast<int64_t>(0x99aabbcc55555555L), t.r3); // lw, sw.
1511 CHECK_EQ(static_cast<int64_t>(0xffffffff99aabbccL), t.r4); // sd.
1512
1513 // Signed data, 32 & 64.
1514 CHECK_EQ(static_cast<int64_t>(0x99aabbcc55555555L), t.r5); // lwu, sw.
1515 CHECK_EQ(static_cast<int64_t>(0x0000000099aabbccL), t.r6); // sd.
1516
1517 // lh with unsigned and signed data.
1518 CHECK_EQ(static_cast<int64_t>(0x0000443355555555L), t.r7); // lh, sw.
1519 CHECK_EQ(static_cast<int64_t>(0xffff99aa55555555L), t.r8); // lh, sw.
1520
1521 // lhu with signed data.
1522 CHECK_EQ(static_cast<int64_t>(0x000099aa55555555L), t.r9); // lhu, sw.
1523
1524 // lb with signed data.
1525 CHECK_EQ(static_cast<int64_t>(0xffffff9955555555L), t.r10); // lb, sw.
1526
1527 // sh with unsigned and signed data.
1528 CHECK_EQ(static_cast<int64_t>(0x2211555555555555L), t.r11); // lw, sh.
1529 CHECK_EQ(static_cast<int64_t>(0xbbcc555555555555L), t.r12); // lw, sh.
1530 }
1477 } 1531 }
1478 1532
1479 1533
1480 // ----------------------mips64r6 specific tests---------------------- 1534 // ----------------------mips64r6 specific tests----------------------
1481 TEST(seleqz_selnez) { 1535 TEST(seleqz_selnez) {
1482 if (kArchVariant == kMips64r6) { 1536 if (kArchVariant == kMips64r6) {
1483 CcTest::InitializeVM(); 1537 CcTest::InitializeVM();
1484 Isolate* isolate = CcTest::i_isolate(); 1538 Isolate* isolate = CcTest::i_isolate();
1485 HandleScope scope(isolate); 1539 HandleScope scope(isolate);
1486 MacroAssembler assm(isolate, NULL, 0, 1540 MacroAssembler assm(isolate, NULL, 0,
(...skipping 668 matching lines...) Expand 10 before | Expand all | Expand 10 after
2155 2209
2156 float outputs_S[kTableLength] = { 2210 float outputs_S[kTableLength] = {
2157 4.8, 4.8, -4.8, -0.29 2211 4.8, 4.8, -4.8, -0.29
2158 }; 2212 };
2159 double outputs_D[kTableLength] = { 2213 double outputs_D[kTableLength] = {
2160 5.3, -5.3, 5.3, -2.9 2214 5.3, -5.3, 5.3, -2.9
2161 }; 2215 };
2162 2216
2163 __ ldc1(f2, MemOperand(a0, offsetof(TestFloat, a)) ); 2217 __ ldc1(f2, MemOperand(a0, offsetof(TestFloat, a)) );
2164 __ lwc1(f6, MemOperand(a0, offsetof(TestFloat, c)) ); 2218 __ lwc1(f6, MemOperand(a0, offsetof(TestFloat, c)) );
2165 __ lw(t0, MemOperand(a0, offsetof(TestFloat, rt)) ); 2219 __ ld(t0, MemOperand(a0, offsetof(TestFloat, rt)));
2166 __ Move(f12, 0.0); 2220 __ Move(f12, 0.0);
2167 __ Move(f10, 0.0); 2221 __ Move(f10, 0.0);
2168 __ Move(f16, 0.0); 2222 __ Move(f16, 0.0);
2169 __ Move(f14, 0.0); 2223 __ Move(f14, 0.0);
2170 __ sdc1(f12, MemOperand(a0, offsetof(TestFloat, bold)) ); 2224 __ sdc1(f12, MemOperand(a0, offsetof(TestFloat, bold)) );
2171 __ swc1(f10, MemOperand(a0, offsetof(TestFloat, dold)) ); 2225 __ swc1(f10, MemOperand(a0, offsetof(TestFloat, dold)) );
2172 __ sdc1(f16, MemOperand(a0, offsetof(TestFloat, bold1)) ); 2226 __ sdc1(f16, MemOperand(a0, offsetof(TestFloat, bold1)) );
2173 __ swc1(f14, MemOperand(a0, offsetof(TestFloat, dold1)) ); 2227 __ swc1(f14, MemOperand(a0, offsetof(TestFloat, dold1)) );
2174 __ movz_s(f10, f6, t0); 2228 __ movz_s(f10, f6, t0);
2175 __ movz_d(f12, f2, t0); 2229 __ movz_d(f12, f2, t0);
(...skipping 3376 matching lines...) Expand 10 before | Expand all | Expand 10 after
5552 5606
5553 TEST(r6_ldpc) { 5607 TEST(r6_ldpc) {
5554 if (kArchVariant == kMips64r6) { 5608 if (kArchVariant == kMips64r6) {
5555 CcTest::InitializeVM(); 5609 CcTest::InitializeVM();
5556 5610
5557 struct TestCaseLdpc { 5611 struct TestCaseLdpc {
5558 int offset; 5612 int offset;
5559 uint64_t expected_res; 5613 uint64_t expected_res;
5560 }; 5614 };
5561 5615
5562 struct TestCaseLdpc tc[] = { 5616 auto doubleword = [](uint32_t word2, uint32_t word1) {
5563 // offset, expected_res 5617 if (kArchEndian == kLittle)
5564 { -131072, 0x250ffffe250fffff }, 5618 return (static_cast<uint64_t>(word2) << 32) + word1;
5565 { -4, 0x250c0006250c0007 }, 5619 else
5566 { -1, 0x250c0000250c0001 }, 5620 return (static_cast<uint64_t>(word1) << 32) + word2;
5567 { 0, 0x03001025ef180000 }, 5621 };
5568 { 1, 0x2508000125080000 }, 5622
5569 { 4, 0x2508000725080006 }, 5623 TestCaseLdpc tc[] = {
5570 { 131071, 0x250bfffd250bfffc }, 5624 // offset, expected_res
5625 {-131072, doubleword(0x250ffffe, 0x250fffff)},
5626 {-4, doubleword(0x250c0006, 0x250c0007)},
5627 {-1, doubleword(0x250c0000, 0x250c0001)},
5628 {0, doubleword(0x03001025, 0xef180000)},
5629 {1, doubleword(0x25080001, 0x25080000)},
5630 {4, doubleword(0x25080007, 0x25080006)},
5631 {131071, doubleword(0x250bfffd, 0x250bfffc)},
5571 }; 5632 };
5572 5633
5573 size_t nr_test_cases = sizeof(tc) / sizeof(TestCaseLdpc); 5634 size_t nr_test_cases = sizeof(tc) / sizeof(TestCaseLdpc);
5574 for (size_t i = 0; i < nr_test_cases; ++i) { 5635 for (size_t i = 0; i < nr_test_cases; ++i) {
5575 uint64_t res = run_ldpc(tc[i].offset); 5636 uint64_t res = run_ldpc(tc[i].offset);
5576 CHECK_EQ(tc[i].expected_res, res); 5637 CHECK_EQ(tc[i].expected_res, res);
5577 } 5638 }
5578 } 5639 }
5579 } 5640 }
5580 5641
(...skipping 285 matching lines...) Expand 10 before | Expand all | Expand 10 after
5866 desc, Code::ComputeFlags(Code::STUB), Handle<Code>()); 5927 desc, Code::ComputeFlags(Code::STUB), Handle<Code>());
5867 F2 f = FUNCTION_CAST<F2>(code->entry()); 5928 F2 f = FUNCTION_CAST<F2>(code->entry());
5868 5929
5869 int64_t res = reinterpret_cast<int64_t>( 5930 int64_t res = reinterpret_cast<int64_t>(
5870 CALL_GENERATED_CODE(isolate, f, 42, 42, 0, 0, 0)); 5931 CALL_GENERATED_CODE(isolate, f, 42, 42, 0, 0, 0));
5871 CHECK_EQ(res, 0); 5932 CHECK_EQ(res, 0);
5872 } 5933 }
5873 5934
5874 5935
5875 #undef __ 5936 #undef __
OLDNEW
« no previous file with comments | « test/cctest/test-assembler-mips.cc ('k') | test/unittests/unittests.gyp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698