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

Side by Side Diff: test/cctest/test-assembler-mips.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 | « src/mips64/simulator-mips64.cc ('k') | test/cctest/test-assembler-mips64.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 1324 matching lines...) Expand 10 before | Expand all | Expand 10 after
1335 1335
1336 typedef struct test { 1336 typedef struct test {
1337 int a; 1337 int a;
1338 int b; 1338 int b;
1339 int c; 1339 int c;
1340 int d; 1340 int d;
1341 double e; 1341 double e;
1342 double f; 1342 double f;
1343 double g; 1343 double g;
1344 double h; 1344 double h;
1345 double i;
1346 double j;
1347 double k;
1348 double l;
1349 } Test; 1345 } Test;
1350 1346
1351 Test test; 1347 Test test;
1352 // Integer part of test. 1348 // Integer part of test.
1353 __ addiu(t1, zero_reg, 1); // t1 = 1 1349 __ addiu(t1, zero_reg, 1); // t1 = 1
1354 __ seleqz(t1, zero_reg, t3); // t3 = 1 1350 __ seleqz(t3, t1, zero_reg); // t3 = 1
1355 __ sw(t3, MemOperand(a0, OFFSET_OF(Test, a))); // a = 1 1351 __ sw(t3, MemOperand(a0, OFFSET_OF(Test, a))); // a = 1
1356 __ seleqz(t1, t1, t2); // t2 = 0 1352 __ seleqz(t2, t1, t1); // t2 = 0
1357 __ sw(t2, MemOperand(a0, OFFSET_OF(Test, b))); // b = 0 1353 __ sw(t2, MemOperand(a0, OFFSET_OF(Test, b))); // b = 0
1358 __ selnez(t1, zero_reg, t3); // t3 = 1; 1354 __ selnez(t3, t1, zero_reg); // t3 = 1;
1359 __ sw(t3, MemOperand(a0, OFFSET_OF(Test, c))); // c = 0 1355 __ sw(t3, MemOperand(a0, OFFSET_OF(Test, c))); // c = 0
1360 __ selnez(t1, t1, t3); // t3 = 1 1356 __ selnez(t3, t1, t1); // t3 = 1
1361 __ sw(t3, MemOperand(a0, OFFSET_OF(Test, d))); // d = 1 1357 __ sw(t3, MemOperand(a0, OFFSET_OF(Test, d))); // d = 1
1362 // Floating point part of test S format. 1358 // Floating point part of test.
1363 __ li(t0, 0x80); 1359 __ ldc1(f0, MemOperand(a0, OFFSET_OF(Test, e)) ); // src
1364 __ mtc1(t0, f4); 1360 __ ldc1(f2, MemOperand(a0, OFFSET_OF(Test, f)) ); // test
1365 __ cvt_d_w(f4, f4); // f4 = 0x80 1361 __ seleqz(D, f4, f0, f2);
1366 __ li(t0, 0xf3); 1362 __ selnez(D, f6, f0, f2);
1367 __ mtc1(t0, f6); 1363 __ sdc1(f4, MemOperand(a0, OFFSET_OF(Test, g)) ); // src
1368 __ cvt_d_w(f6, f6); // f6 = 0xf3 1364 __ sdc1(f6, MemOperand(a0, OFFSET_OF(Test, h)) ); // src
1369 __ seleqz(S, f8, f4, f6); // f8 = 0xf3
1370 __ seleqz(S, f10, f6, f6); // f10 = 0
1371 __ sdc1(f8, MemOperand(a0, OFFSET_OF(Test, e))); // e = 0xf3
1372 __ sdc1(f10, MemOperand(a0, OFFSET_OF(Test, f))); // f = 0
1373 __ selnez(S, f8, f4, f6); // f8 = 0
1374 __ selnez(S, f10, f6, f6); // f10 = 0xf3
1375 __ sdc1(f8, MemOperand(a0, OFFSET_OF(Test, g))); // g = 0
1376 __ sdc1(f10, MemOperand(a0, OFFSET_OF(Test, h))); // h = 0xf3
1377
1378 __ li(t0, 0x80);
1379 __ mtc1(t0, f4);
1380 __ cvt_d_w(f4, f4); // f4 = 0x80
1381 __ li(t0, 0xf3);
1382 __ mtc1(t0, f6);
1383 __ cvt_d_w(f6, f6); // f6 = 0xf3
1384 __ seleqz(D, f8, f4, f6); // f8 = 0xf3
1385 __ seleqz(D, f10, f6, f6); // f10 = 0
1386 __ sdc1(f8, MemOperand(a0, OFFSET_OF(Test, i))); // i = 0xf3
1387 __ sdc1(f10, MemOperand(a0, OFFSET_OF(Test, j))); // j = 0
1388 __ selnez(S, f8, f4, f6); // f8 = 0
1389 __ selnez(S, f10, f6, f6); // f10 = 0xf3
1390 __ sdc1(f8, MemOperand(a0, OFFSET_OF(Test, k))); // k = 0
1391 __ sdc1(f10, MemOperand(a0, OFFSET_OF(Test, l))); // l = 0xf3
1392 __ jr(ra); 1365 __ jr(ra);
1393 __ nop(); 1366 __ nop();
1394 CodeDesc desc; 1367 CodeDesc desc;
1395 assm.GetCode(&desc); 1368 assm.GetCode(&desc);
1396 Handle<Code> code = isolate->factory()->NewCode( 1369 Handle<Code> code = isolate->factory()->NewCode(
1397 desc, Code::ComputeFlags(Code::STUB), Handle<Code>()); 1370 desc, Code::ComputeFlags(Code::STUB), Handle<Code>());
1398 F3 f = FUNCTION_CAST<F3>(code->entry()); 1371 F3 f = FUNCTION_CAST<F3>(code->entry());
1399 1372
1400 (CALL_GENERATED_CODE(f, &test, 0, 0, 0, 0)); 1373 (CALL_GENERATED_CODE(f, &test, 0, 0, 0, 0));
1401 1374
1402 CHECK_EQ(test.a, 1); 1375 CHECK_EQ(test.a, 1);
1403 CHECK_EQ(test.b, 0); 1376 CHECK_EQ(test.b, 0);
1404 CHECK_EQ(test.c, 0); 1377 CHECK_EQ(test.c, 0);
1405 CHECK_EQ(test.d, 1); 1378 CHECK_EQ(test.d, 1);
1406 1379
1407 CHECK_EQ(test.e, 0xf3); 1380 const int test_size = 3;
1408 CHECK_EQ(test.f, 0x0); 1381 const int input_size = 5;
1409 CHECK_EQ(test.g, 0);
1410 CHECK_EQ(test.h, 0xf3);
1411 1382
1412 CHECK_EQ(test.i, 0xf3); 1383 double inputs[input_size] = {0.0, 65.2, -70.32,
1413 CHECK_EQ(test.j, 0x0); 1384 18446744073709551621.0, -18446744073709551621.0};
1414 CHECK_EQ(test.k, 0); 1385 double outputs[input_size] = {0.0, 65.2, -70.32,
1415 CHECK_EQ(test.l, 0xf3); 1386 18446744073709551621.0, -18446744073709551621.0};
1387 double tests[test_size*2] = {2.8, 2.9, -2.8, -2.9,
1388 18446744073709551616.0, 18446744073709555712.0};
1389 for (int j=0;j < test_size;j+=2) {
1390 for (int i=0;i < input_size;i++) {
1391 test.e = inputs[i];
1392 test.f = tests[j];
1393 (CALL_GENERATED_CODE(f, &test, 0, 0, 0, 0));
1394 CHECK_EQ(test.g, outputs[i]);
1395 CHECK_EQ(test.h, 0);
1396
1397 test.f = tests[j+1];
1398 (CALL_GENERATED_CODE(f, &test, 0, 0, 0, 0));
1399 CHECK_EQ(test.g, 0);
1400 CHECK_EQ(test.h, outputs[i]);
1401 }
1402 }
1416 } 1403 }
1417 } 1404 }
1418 1405
1406
1407 TEST(MIPS17) {
1408 if (IsMipsArchVariant(kMips32r6)) {
1409 CcTest::InitializeVM();
1410 Isolate* isolate = CcTest::i_isolate();
1411 HandleScope scope(isolate);
1412 MacroAssembler assm(isolate, NULL, 0);
1413
1414 typedef struct test_float {
1415 double a;
1416 double b;
1417 double c;
1418 double d;
1419 } TestFloat;
1420
1421 TestFloat test;
1422
1423 __ ldc1(f4, MemOperand(a0, OFFSET_OF(TestFloat, a)));
1424 __ ldc1(f8, MemOperand(a0, OFFSET_OF(TestFloat, b)));
1425 __ min(D, f10, f8, f4);
1426 __ max(D, f12, f8, f4);
1427 __ sdc1(f10, MemOperand(a0, OFFSET_OF(TestFloat, c)));
1428 __ sdc1(f12, MemOperand(a0, OFFSET_OF(TestFloat, d)));
1429 __ jr(ra);
1430 __ nop();
1431
1432 CodeDesc desc;
1433 assm.GetCode(&desc);
1434 Handle<Code> code = isolate->factory()->NewCode(
1435 desc, Code::ComputeFlags(Code::STUB), Handle<Code>());
1436 F3 f = FUNCTION_CAST<F3>(code->entry());
1437 test.a = 2.0; // a goes to fs
1438 test.b = 3.0; // b goes to ft
1439 (CALL_GENERATED_CODE(f, &test, 0, 0, 0, 0));
1440 CHECK_EQ(test.c, 2.0);
1441 CHECK_EQ(test.d, 3.0);
1442
1443 test.a = 3.0; // a goes to fs
1444 test.b = 2.0; // b goes to ft
1445 (CALL_GENERATED_CODE(f, &test, 0, 0, 0, 0));
1446 CHECK_EQ(test.c, 2.0);
1447 CHECK_EQ(test.d, 3.0);
1448
1449 test.a = std::numeric_limits<double>::quiet_NaN();
1450 test.b = 3.0; // b goes to ft
1451 (CALL_GENERATED_CODE(f, &test, 0, 0, 0, 0));
1452 CHECK_EQ(test.c, 3.0);
1453 CHECK_EQ(test.d, 3.0);
1454
1455 test.b = std::numeric_limits<double>::quiet_NaN();
1456 test.a = 3.0; // b goes to ft
1457 (CALL_GENERATED_CODE(f, &test, 0, 0, 0, 0));
1458 CHECK_EQ(test.c, 3.0);
1459 CHECK_EQ(test.d, 3.0);
1460
1461 test.a = std::numeric_limits<double>::quiet_NaN();
1462 test.b = std::numeric_limits<double>::quiet_NaN();
1463 (CALL_GENERATED_CODE(f, &test, 0, 0, 0, 0));
1464 DCHECK(std::isnan(test.c));
1465 DCHECK(std::isnan(test.d));
1466 }
1467 }
1468
1419 1469
1420 TEST(jump_tables1) { 1470 TEST(jump_tables1) {
1421 // Test jump tables with forward jumps. 1471 // Test jump tables with forward jumps.
1422 CcTest::InitializeVM(); 1472 CcTest::InitializeVM();
1423 Isolate* isolate = CcTest::i_isolate(); 1473 Isolate* isolate = CcTest::i_isolate();
1424 HandleScope scope(isolate); 1474 HandleScope scope(isolate);
1425 Assembler assm(isolate, nullptr, 0); 1475 Assembler assm(isolate, nullptr, 0);
1426 1476
1427 const int kNumCases = 512; 1477 const int kNumCases = 512;
1428 int values[kNumCases]; 1478 int values[kNumCases];
(...skipping 193 matching lines...) Expand 10 before | Expand all | Expand 10 after
1622 ::printf("f(%d) = ", i); 1672 ::printf("f(%d) = ", i);
1623 result->Print(std::cout); 1673 result->Print(std::cout);
1624 ::printf("\n"); 1674 ::printf("\n");
1625 #endif 1675 #endif
1626 CHECK(values[i].is_identical_to(result)); 1676 CHECK(values[i].is_identical_to(result));
1627 } 1677 }
1628 } 1678 }
1629 1679
1630 1680
1631 #undef __ 1681 #undef __
OLDNEW
« no previous file with comments | « src/mips64/simulator-mips64.cc ('k') | test/cctest/test-assembler-mips64.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698