OLD | NEW |
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 790 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
801 __ nop(); | 801 __ nop(); |
802 | 802 |
803 CodeDesc desc; | 803 CodeDesc desc; |
804 assm.GetCode(&desc); | 804 assm.GetCode(&desc); |
805 isolate->factory()->NewCode( | 805 isolate->factory()->NewCode( |
806 desc, Code::ComputeFlags(Code::STUB), Handle<Code>()); | 806 desc, Code::ComputeFlags(Code::STUB), Handle<Code>()); |
807 } | 807 } |
808 | 808 |
809 | 809 |
810 TEST(MIPS10) { | 810 TEST(MIPS10) { |
811 // Test conversions between doubles and words. | 811 // Test conversions between doubles and long integers. |
812 // Test maps double to FP reg pairs in fp32 mode | 812 // Test hos the long ints map to FP regs pairs. |
813 // and into FP reg in fp64 mode. | |
814 CcTest::InitializeVM(); | 813 CcTest::InitializeVM(); |
815 Isolate* isolate = CcTest::i_isolate(); | 814 Isolate* isolate = CcTest::i_isolate(); |
816 HandleScope scope(isolate); | 815 HandleScope scope(isolate); |
817 | 816 |
818 typedef struct { | 817 typedef struct { |
819 double a; | 818 double a; |
820 double b; | 819 double b; |
821 int32_t dbl_mant; | 820 int32_t dbl_mant; |
822 int32_t dbl_exp; | 821 int32_t dbl_exp; |
823 int32_t word; | 822 int32_t word; |
824 int32_t b_word; | 823 int32_t b_word; |
825 } T; | 824 } T; |
826 T t; | 825 T t; |
827 | 826 |
828 Assembler assm(isolate, NULL, 0); | 827 Assembler assm(isolate, NULL, 0); |
829 Label L, C; | 828 Label L, C; |
830 | 829 |
831 if (!IsMipsArchVariant(kMips32r2)) return; | 830 if (!IsMipsArchVariant(kMips32r2)) return; |
832 | 831 |
833 // Load all structure elements to registers. | 832 // Load all structure elements to registers. |
834 // (f0, f1) = a (fp32), f0 = a (fp64) | |
835 __ ldc1(f0, MemOperand(a0, OFFSET_OF(T, a))); | 833 __ ldc1(f0, MemOperand(a0, OFFSET_OF(T, a))); |
836 | 834 |
837 if (IsFp64Mode()) { | 835 // Save the raw bits of the double. |
838 __ mfc1(t0, f0); // t0 = f0(31..0) | 836 __ mfc1(t0, f0); |
839 __ mfhc1(t1, f0); // t1 = sign_extend(f0(63..32)) | 837 __ mfc1(t1, f1); |
840 __ sw(t0, MemOperand(a0, OFFSET_OF(T, dbl_mant))); // dbl_mant = t0 | 838 __ sw(t0, MemOperand(a0, OFFSET_OF(T, dbl_mant))); |
841 __ sw(t1, MemOperand(a0, OFFSET_OF(T, dbl_exp))); // dbl_exp = t1 | 839 __ sw(t1, MemOperand(a0, OFFSET_OF(T, dbl_exp))); |
842 } else { | |
843 // Save the raw bits of the double. | |
844 __ mfc1(t0, f0); // t0 = a1 | |
845 __ mfc1(t1, f1); // t1 = a2 | |
846 __ sw(t0, MemOperand(a0, OFFSET_OF(T, dbl_mant))); // dbl_mant = t0 | |
847 __ sw(t1, MemOperand(a0, OFFSET_OF(T, dbl_exp))); // dbl_exp = t1 | |
848 } | |
849 | 840 |
850 // Convert double in f0 to word, save hi/lo parts. | 841 // Convert double in f0 to long, save hi/lo parts. |
851 __ cvt_w_d(f0, f0); // a_word = (word)a | 842 __ cvt_w_d(f0, f0); |
852 __ mfc1(t0, f0); // f0 has a 32-bits word. t0 = a_word | 843 __ mfc1(t0, f0); // f0 has a 32-bits word. |
853 __ sw(t0, MemOperand(a0, OFFSET_OF(T, word))); // word = a_word | 844 __ sw(t0, MemOperand(a0, OFFSET_OF(T, word))); |
854 | 845 |
855 // Convert the b word to double b. | 846 // Convert the b long integers to double b. |
856 __ lw(t0, MemOperand(a0, OFFSET_OF(T, b_word))); | 847 __ lw(t0, MemOperand(a0, OFFSET_OF(T, b_word))); |
857 __ mtc1(t0, f8); // f8 has a 32-bits word. | 848 __ mtc1(t0, f8); // f8 has a 32-bits word. |
858 __ cvt_d_w(f10, f8); | 849 __ cvt_d_w(f10, f8); |
859 __ sdc1(f10, MemOperand(a0, OFFSET_OF(T, b))); | 850 __ sdc1(f10, MemOperand(a0, OFFSET_OF(T, b))); |
860 | 851 |
861 __ jr(ra); | 852 __ jr(ra); |
862 __ nop(); | 853 __ nop(); |
863 | 854 |
864 CodeDesc desc; | 855 CodeDesc desc; |
865 assm.GetCode(&desc); | 856 assm.GetCode(&desc); |
866 Handle<Code> code = isolate->factory()->NewCode( | 857 Handle<Code> code = isolate->factory()->NewCode( |
867 desc, Code::ComputeFlags(Code::STUB), Handle<Code>()); | 858 desc, Code::ComputeFlags(Code::STUB), Handle<Code>()); |
868 F3 f = FUNCTION_CAST<F3>(code->entry()); | 859 F3 f = FUNCTION_CAST<F3>(code->entry()); |
869 t.a = 2.147483646e+09; // 0x7FFFFFFE -> 0xFF80000041DFFFFF as double. | 860 t.a = 2.147483646e+09; // 0x7FFFFFFE -> 0xFF80000041DFFFFF as double. |
870 t.b_word = 0x0ff00ff0; // 0x0FF00FF0 -> 0x as double. | 861 t.b_word = 0x0ff00ff0; // 0x0FF00FF0 -> 0x as double. |
871 Object* dummy = CALL_GENERATED_CODE(f, &t, 0, 0, 0, 0); | 862 Object* dummy = CALL_GENERATED_CODE(f, &t, 0, 0, 0, 0); |
872 USE(dummy); | 863 USE(dummy); |
| 864 |
873 CHECK_EQ(static_cast<int32_t>(0x41DFFFFF), t.dbl_exp); | 865 CHECK_EQ(static_cast<int32_t>(0x41DFFFFF), t.dbl_exp); |
874 CHECK_EQ(static_cast<int32_t>(0xFF800000), t.dbl_mant); | 866 CHECK_EQ(static_cast<int32_t>(0xFF800000), t.dbl_mant); |
875 CHECK_EQ(static_cast<int32_t>(0x7FFFFFFE), t.word); | 867 CHECK_EQ(static_cast<int32_t>(0x7FFFFFFE), t.word); |
876 // 0x0FF00FF0 -> 2.6739096+e08 | 868 // 0x0FF00FF0 -> 2.6739096+e08 |
877 CHECK_EQ(2.6739096e08, t.b); | 869 CHECK_EQ(2.6739096e08, t.b); |
878 } | 870 } |
879 | 871 |
880 | 872 |
881 TEST(MIPS11) { | 873 TEST(MIPS11) { |
882 // Do not run test on MIPS32r6, as these instructions are removed. | 874 // Do not run test on MIPS32r6, as these instructions are removed. |
(...skipping 447 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1330 Label target; | 1322 Label target; |
1331 __ beq(v0, v1, &target); | 1323 __ beq(v0, v1, &target); |
1332 __ nop(); | 1324 __ nop(); |
1333 __ bne(v0, v1, &target); | 1325 __ bne(v0, v1, &target); |
1334 __ nop(); | 1326 __ nop(); |
1335 __ bind(&target); | 1327 __ bind(&target); |
1336 __ nop(); | 1328 __ nop(); |
1337 } | 1329 } |
1338 | 1330 |
1339 | 1331 |
1340 // ----------------------mips32r6 specific tests---------------------- | 1332 TEST(MIPS16) { |
1341 TEST(seleqz_selnez) { | |
1342 if (IsMipsArchVariant(kMips32r6)) { | 1333 if (IsMipsArchVariant(kMips32r6)) { |
1343 CcTest::InitializeVM(); | 1334 CcTest::InitializeVM(); |
1344 Isolate* isolate = CcTest::i_isolate(); | 1335 Isolate* isolate = CcTest::i_isolate(); |
1345 HandleScope scope(isolate); | 1336 HandleScope scope(isolate); |
1346 MacroAssembler assm(isolate, NULL, 0); | 1337 MacroAssembler assm(isolate, NULL, 0); |
1347 | 1338 |
1348 typedef struct test { | 1339 typedef struct test { |
1349 int a; | 1340 int a; |
1350 int b; | 1341 int b; |
1351 int c; | 1342 int c; |
1352 int d; | 1343 int d; |
1353 double e; | 1344 double e; |
1354 double f; | 1345 double f; |
1355 double g; | 1346 double g; |
1356 double h; | 1347 double h; |
1357 float i; | |
1358 float j; | |
1359 float k; | |
1360 float l; | |
1361 } Test; | 1348 } Test; |
1362 | 1349 |
1363 Test test; | 1350 Test test; |
1364 // Integer part of test. | 1351 // Integer part of test. |
1365 __ addiu(t1, zero_reg, 1); // t1 = 1 | 1352 __ addiu(t1, zero_reg, 1); // t1 = 1 |
1366 __ seleqz(t3, t1, zero_reg); // t3 = 1 | 1353 __ seleqz(t3, t1, zero_reg); // t3 = 1 |
1367 __ sw(t3, MemOperand(a0, OFFSET_OF(Test, a))); // a = 1 | 1354 __ sw(t3, MemOperand(a0, OFFSET_OF(Test, a))); // a = 1 |
1368 __ seleqz(t2, t1, t1); // t2 = 0 | 1355 __ seleqz(t2, t1, t1); // t2 = 0 |
1369 __ sw(t2, MemOperand(a0, OFFSET_OF(Test, b))); // b = 0 | 1356 __ sw(t2, MemOperand(a0, OFFSET_OF(Test, b))); // b = 0 |
1370 __ selnez(t3, t1, zero_reg); // t3 = 1; | 1357 __ selnez(t3, t1, zero_reg); // t3 = 1; |
1371 __ sw(t3, MemOperand(a0, OFFSET_OF(Test, c))); // c = 0 | 1358 __ sw(t3, MemOperand(a0, OFFSET_OF(Test, c))); // c = 0 |
1372 __ selnez(t3, t1, t1); // t3 = 1 | 1359 __ selnez(t3, t1, t1); // t3 = 1 |
1373 __ sw(t3, MemOperand(a0, OFFSET_OF(Test, d))); // d = 1 | 1360 __ sw(t3, MemOperand(a0, OFFSET_OF(Test, d))); // d = 1 |
1374 // Floating point part of test. | 1361 // Floating point part of test. |
1375 __ ldc1(f0, MemOperand(a0, OFFSET_OF(Test, e)) ); // src | 1362 __ ldc1(f0, MemOperand(a0, OFFSET_OF(Test, e)) ); // src |
1376 __ ldc1(f2, MemOperand(a0, OFFSET_OF(Test, f)) ); // test | 1363 __ ldc1(f2, MemOperand(a0, OFFSET_OF(Test, f)) ); // test |
1377 __ lwc1(f8, MemOperand(a0, OFFSET_OF(Test, i)) ); // src | 1364 __ seleqz(D, f4, f0, f2); |
1378 __ lwc1(f10, MemOperand(a0, OFFSET_OF(Test, j)) ); // test | 1365 __ selnez(D, f6, f0, f2); |
1379 __ seleqz_d(f4, f0, f2); | |
1380 __ selnez_d(f6, f0, f2); | |
1381 __ seleqz_s(f12, f8, f10); | |
1382 __ selnez_s(f14, f8, f10); | |
1383 __ sdc1(f4, MemOperand(a0, OFFSET_OF(Test, g)) ); // src | 1366 __ sdc1(f4, MemOperand(a0, OFFSET_OF(Test, g)) ); // src |
1384 __ sdc1(f6, MemOperand(a0, OFFSET_OF(Test, h)) ); // src | 1367 __ sdc1(f6, MemOperand(a0, OFFSET_OF(Test, h)) ); // src |
1385 __ swc1(f12, MemOperand(a0, OFFSET_OF(Test, k)) ); // src | |
1386 __ swc1(f14, MemOperand(a0, OFFSET_OF(Test, l)) ); // src | |
1387 __ jr(ra); | 1368 __ jr(ra); |
1388 __ nop(); | 1369 __ nop(); |
1389 CodeDesc desc; | 1370 CodeDesc desc; |
1390 assm.GetCode(&desc); | 1371 assm.GetCode(&desc); |
1391 Handle<Code> code = isolate->factory()->NewCode( | 1372 Handle<Code> code = isolate->factory()->NewCode( |
1392 desc, Code::ComputeFlags(Code::STUB), Handle<Code>()); | 1373 desc, Code::ComputeFlags(Code::STUB), Handle<Code>()); |
1393 F3 f = FUNCTION_CAST<F3>(code->entry()); | 1374 F3 f = FUNCTION_CAST<F3>(code->entry()); |
1394 | 1375 |
1395 (CALL_GENERATED_CODE(f, &test, 0, 0, 0, 0)); | 1376 (CALL_GENERATED_CODE(f, &test, 0, 0, 0, 0)); |
1396 | 1377 |
1397 CHECK_EQ(test.a, 1); | 1378 CHECK_EQ(test.a, 1); |
1398 CHECK_EQ(test.b, 0); | 1379 CHECK_EQ(test.b, 0); |
1399 CHECK_EQ(test.c, 0); | 1380 CHECK_EQ(test.c, 0); |
1400 CHECK_EQ(test.d, 1); | 1381 CHECK_EQ(test.d, 1); |
1401 | 1382 |
1402 const int test_size = 3; | 1383 const int test_size = 3; |
1403 const int input_size = 5; | 1384 const int input_size = 5; |
1404 | 1385 |
1405 double inputs_D[input_size] = {0.0, 65.2, -70.32, | 1386 double inputs[input_size] = {0.0, 65.2, -70.32, |
1406 18446744073709551621.0, -18446744073709551621.0}; | 1387 18446744073709551621.0, -18446744073709551621.0}; |
1407 double outputs_D[input_size] = {0.0, 65.2, -70.32, | 1388 double outputs[input_size] = {0.0, 65.2, -70.32, |
1408 18446744073709551621.0, -18446744073709551621.0}; | 1389 18446744073709551621.0, -18446744073709551621.0}; |
1409 double tests_D[test_size*2] = {2.8, 2.9, -2.8, -2.9, | 1390 double tests[test_size*2] = {2.8, 2.9, -2.8, -2.9, |
1410 18446744073709551616.0, 18446744073709555712.0}; | 1391 18446744073709551616.0, 18446744073709555712.0}; |
1411 float inputs_S[input_size] = {0.0, 65.2, -70.32, | |
1412 18446744073709551621.0, -18446744073709551621.0}; | |
1413 float outputs_S[input_size] = {0.0, 65.2, -70.32, | |
1414 18446744073709551621.0, -18446744073709551621.0}; | |
1415 float tests_S[test_size*2] = {2.9, 2.8, -2.9, -2.8, | |
1416 18446744073709551616.0, 18446746272732807168.0}; | |
1417 for (int j=0; j < test_size; j+=2) { | 1392 for (int j=0; j < test_size; j+=2) { |
1418 for (int i=0; i < input_size; i++) { | 1393 for (int i=0; i < input_size; i++) { |
1419 test.e = inputs_D[i]; | 1394 test.e = inputs[i]; |
1420 test.f = tests_D[j]; | 1395 test.f = tests[j]; |
1421 test.i = inputs_S[i]; | |
1422 test.j = tests_S[j]; | |
1423 (CALL_GENERATED_CODE(f, &test, 0, 0, 0, 0)); | 1396 (CALL_GENERATED_CODE(f, &test, 0, 0, 0, 0)); |
1424 CHECK_EQ(test.g, outputs_D[i]); | 1397 CHECK_EQ(test.g, outputs[i]); |
1425 CHECK_EQ(test.h, 0); | 1398 CHECK_EQ(test.h, 0); |
1426 CHECK_EQ(test.k, outputs_S[i]); | |
1427 CHECK_EQ(test.l, 0); | |
1428 | 1399 |
1429 test.f = tests_D[j+1]; | 1400 test.f = tests[j+1]; |
1430 test.j = tests_S[j+1]; | |
1431 (CALL_GENERATED_CODE(f, &test, 0, 0, 0, 0)); | 1401 (CALL_GENERATED_CODE(f, &test, 0, 0, 0, 0)); |
1432 CHECK_EQ(test.g, 0); | 1402 CHECK_EQ(test.g, 0); |
1433 CHECK_EQ(test.h, outputs_D[i]); | 1403 CHECK_EQ(test.h, outputs[i]); |
1434 CHECK_EQ(test.k, 0); | |
1435 CHECK_EQ(test.l, outputs_S[i]); | |
1436 } | 1404 } |
1437 } | 1405 } |
1438 } | 1406 } |
1439 } | 1407 } |
1440 | 1408 |
1441 | 1409 |
1442 TEST(min_max) { | 1410 TEST(MIPS17) { |
1443 if (IsMipsArchVariant(kMips32r6)) { | 1411 if (IsMipsArchVariant(kMips32r6)) { |
1444 CcTest::InitializeVM(); | 1412 CcTest::InitializeVM(); |
1445 Isolate* isolate = CcTest::i_isolate(); | 1413 Isolate* isolate = CcTest::i_isolate(); |
1446 HandleScope scope(isolate); | 1414 HandleScope scope(isolate); |
1447 MacroAssembler assm(isolate, NULL, 0); | 1415 MacroAssembler assm(isolate, NULL, 0); |
1448 | 1416 |
1449 typedef struct test_float { | 1417 typedef struct test_float { |
1450 double a; | 1418 double a; |
1451 double b; | 1419 double b; |
1452 double c; | 1420 double c; |
1453 double d; | 1421 double d; |
1454 float e; | |
1455 float f; | |
1456 float g; | |
1457 float h; | |
1458 } TestFloat; | 1422 } TestFloat; |
1459 | 1423 |
1460 TestFloat test; | 1424 TestFloat test; |
1461 const double dblNaN = std::numeric_limits<double>::quiet_NaN(); | |
1462 const float fltNaN = std::numeric_limits<float>::quiet_NaN(); | |
1463 const int tableLength = 5; | |
1464 double inputsa[tableLength] = {2.0, 3.0, dblNaN, 3.0, dblNaN}; | |
1465 double inputsb[tableLength] = {3.0, 2.0, 3.0, dblNaN, dblNaN}; | |
1466 double outputsdmin[tableLength] = {2.0, 2.0, 3.0, 3.0, dblNaN}; | |
1467 double outputsdmax[tableLength] = {3.0, 3.0, 3.0, 3.0, dblNaN}; | |
1468 | |
1469 float inputse[tableLength] = {2.0, 3.0, fltNaN, 3.0, fltNaN}; | |
1470 float inputsf[tableLength] = {3.0, 2.0, 3.0, fltNaN, fltNaN}; | |
1471 float outputsfmin[tableLength] = {2.0, 2.0, 3.0, 3.0, fltNaN}; | |
1472 float outputsfmax[tableLength] = {3.0, 3.0, 3.0, 3.0, fltNaN}; | |
1473 | 1425 |
1474 __ ldc1(f4, MemOperand(a0, OFFSET_OF(TestFloat, a))); | 1426 __ ldc1(f4, MemOperand(a0, OFFSET_OF(TestFloat, a))); |
1475 __ ldc1(f8, MemOperand(a0, OFFSET_OF(TestFloat, b))); | 1427 __ ldc1(f8, MemOperand(a0, OFFSET_OF(TestFloat, b))); |
1476 __ lwc1(f2, MemOperand(a0, OFFSET_OF(TestFloat, e))); | |
1477 __ lwc1(f6, MemOperand(a0, OFFSET_OF(TestFloat, f))); | |
1478 __ min_d(f10, f4, f8); | 1428 __ min_d(f10, f4, f8); |
1479 __ max_d(f12, f4, f8); | 1429 __ max_d(f12, f4, f8); |
1480 __ min_s(f14, f2, f6); | |
1481 __ max_s(f16, f2, f6); | |
1482 __ sdc1(f10, MemOperand(a0, OFFSET_OF(TestFloat, c))); | 1430 __ sdc1(f10, MemOperand(a0, OFFSET_OF(TestFloat, c))); |
1483 __ sdc1(f12, MemOperand(a0, OFFSET_OF(TestFloat, d))); | 1431 __ sdc1(f12, MemOperand(a0, OFFSET_OF(TestFloat, d))); |
1484 __ swc1(f14, MemOperand(a0, OFFSET_OF(TestFloat, g))); | |
1485 __ swc1(f16, MemOperand(a0, OFFSET_OF(TestFloat, h))); | |
1486 __ jr(ra); | 1432 __ jr(ra); |
1487 __ nop(); | 1433 __ nop(); |
1488 | 1434 |
1489 CodeDesc desc; | 1435 CodeDesc desc; |
1490 assm.GetCode(&desc); | 1436 assm.GetCode(&desc); |
1491 Handle<Code> code = isolate->factory()->NewCode( | 1437 Handle<Code> code = isolate->factory()->NewCode( |
1492 desc, Code::ComputeFlags(Code::STUB), Handle<Code>()); | 1438 desc, Code::ComputeFlags(Code::STUB), Handle<Code>()); |
1493 F3 f = FUNCTION_CAST<F3>(code->entry()); | 1439 F3 f = FUNCTION_CAST<F3>(code->entry()); |
1494 for (int i = 0; i < tableLength; i++) { | 1440 test.a = 2.0; // a goes to fs |
1495 test.a = inputsa[i]; | 1441 test.b = 3.0; // b goes to ft |
1496 test.b = inputsb[i]; | 1442 (CALL_GENERATED_CODE(f, &test, 0, 0, 0, 0)); |
1497 test.e = inputse[i]; | 1443 CHECK_EQ(test.c, 2.0); |
1498 test.f = inputsf[i]; | 1444 CHECK_EQ(test.d, 3.0); |
1499 | 1445 |
1500 (CALL_GENERATED_CODE(f, &test, 0, 0, 0, 0)); | 1446 test.a = 3.0; // a goes to fs |
| 1447 test.b = 2.0; // b goes to ft |
| 1448 (CALL_GENERATED_CODE(f, &test, 0, 0, 0, 0)); |
| 1449 CHECK_EQ(test.c, 2.0); |
| 1450 CHECK_EQ(test.d, 3.0); |
1501 | 1451 |
1502 if (i < tableLength - 1) { | 1452 test.a = std::numeric_limits<double>::quiet_NaN(); |
1503 CHECK_EQ(test.c, outputsdmin[i]); | 1453 test.b = 3.0; // b goes to ft |
1504 CHECK_EQ(test.d, outputsdmax[i]); | 1454 (CALL_GENERATED_CODE(f, &test, 0, 0, 0, 0)); |
1505 CHECK_EQ(test.g, outputsfmin[i]); | 1455 CHECK_EQ(test.c, 3.0); |
1506 CHECK_EQ(test.h, outputsfmax[i]); | 1456 CHECK_EQ(test.d, 3.0); |
1507 } else { | 1457 |
1508 DCHECK(std::isnan(test.c)); | 1458 test.b = std::numeric_limits<double>::quiet_NaN(); |
1509 DCHECK(std::isnan(test.d)); | 1459 test.a = 3.0; // b goes to ft |
1510 DCHECK(std::isnan(test.g)); | 1460 (CALL_GENERATED_CODE(f, &test, 0, 0, 0, 0)); |
1511 DCHECK(std::isnan(test.h)); | 1461 CHECK_EQ(test.c, 3.0); |
1512 } | 1462 CHECK_EQ(test.d, 3.0); |
1513 } | 1463 |
| 1464 test.a = std::numeric_limits<double>::quiet_NaN(); |
| 1465 test.b = std::numeric_limits<double>::quiet_NaN(); |
| 1466 (CALL_GENERATED_CODE(f, &test, 0, 0, 0, 0)); |
| 1467 DCHECK(std::isnan(test.c)); |
| 1468 DCHECK(std::isnan(test.d)); |
1514 } | 1469 } |
1515 } | 1470 } |
1516 | 1471 |
1517 | 1472 |
1518 TEST(rint_d) { | 1473 TEST(MIPS18) { |
1519 if (IsMipsArchVariant(kMips32r6)) { | 1474 if (IsMipsArchVariant(kMips32r6)) { |
1520 const int tableLength = 30; | 1475 const int tableLength = 30; |
1521 CcTest::InitializeVM(); | 1476 CcTest::InitializeVM(); |
1522 Isolate* isolate = CcTest::i_isolate(); | 1477 Isolate* isolate = CcTest::i_isolate(); |
1523 HandleScope scope(isolate); | 1478 HandleScope scope(isolate); |
1524 MacroAssembler assm(isolate, NULL, 0); | 1479 MacroAssembler assm(isolate, NULL, 0); |
1525 | 1480 |
1526 typedef struct test_float { | 1481 typedef struct test_float { |
1527 double a; | 1482 double a; |
1528 double b; | 1483 double b; |
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1606 CodeDesc desc; | 1561 CodeDesc desc; |
1607 assm.GetCode(&desc); | 1562 assm.GetCode(&desc); |
1608 Handle<Code> code = isolate->factory()->NewCode( | 1563 Handle<Code> code = isolate->factory()->NewCode( |
1609 desc, Code::ComputeFlags(Code::STUB), Handle<Code>()); | 1564 desc, Code::ComputeFlags(Code::STUB), Handle<Code>()); |
1610 F3 f = FUNCTION_CAST<F3>(code->entry()); | 1565 F3 f = FUNCTION_CAST<F3>(code->entry()); |
1611 | 1566 |
1612 for (int j = 0; j < 4; j++) { | 1567 for (int j = 0; j < 4; j++) { |
1613 test.fcsr = fcsr_inputs[j]; | 1568 test.fcsr = fcsr_inputs[j]; |
1614 for (int i = 0; i < tableLength; i++) { | 1569 for (int i = 0; i < tableLength; i++) { |
1615 test.a = inputs[i]; | 1570 test.a = inputs[i]; |
| 1571 std::cout << j << " " << i << "\n"; |
1616 (CALL_GENERATED_CODE(f, &test, 0, 0, 0, 0)); | 1572 (CALL_GENERATED_CODE(f, &test, 0, 0, 0, 0)); |
1617 CHECK_EQ(test.b, outputs[j][i]); | 1573 CHECK_EQ(test.b, outputs[j][i]); |
1618 } | 1574 } |
1619 } | 1575 } |
1620 } | 1576 } |
1621 } | 1577 } |
1622 | 1578 |
1623 | 1579 |
1624 TEST(sel) { | 1580 TEST(MIPS19) { |
1625 if (IsMipsArchVariant(kMips32r6)) { | |
1626 CcTest::InitializeVM(); | |
1627 Isolate* isolate = CcTest::i_isolate(); | |
1628 HandleScope scope(isolate); | |
1629 MacroAssembler assm(isolate, NULL, 0); | |
1630 | |
1631 typedef struct test { | |
1632 double dd; | |
1633 double ds; | |
1634 double dt; | |
1635 float fd; | |
1636 float fs; | |
1637 float ft; | |
1638 } Test; | |
1639 | |
1640 Test test; | |
1641 __ ldc1(f0, MemOperand(a0, OFFSET_OF(Test, dd)) ); // test | |
1642 __ ldc1(f2, MemOperand(a0, OFFSET_OF(Test, ds)) ); // src1 | |
1643 __ ldc1(f4, MemOperand(a0, OFFSET_OF(Test, dt)) ); // src2 | |
1644 __ lwc1(f6, MemOperand(a0, OFFSET_OF(Test, fd)) ); // test | |
1645 __ lwc1(f8, MemOperand(a0, OFFSET_OF(Test, fs)) ); // src1 | |
1646 __ lwc1(f10, MemOperand(a0, OFFSET_OF(Test, ft)) ); // src2 | |
1647 __ sel_d(f0, f2, f4); | |
1648 __ sel_s(f6, f8, f10); | |
1649 __ sdc1(f0, MemOperand(a0, OFFSET_OF(Test, dd)) ); | |
1650 __ swc1(f6, MemOperand(a0, OFFSET_OF(Test, fd)) ); | |
1651 __ jr(ra); | |
1652 __ nop(); | |
1653 CodeDesc desc; | |
1654 assm.GetCode(&desc); | |
1655 Handle<Code> code = isolate->factory()->NewCode( | |
1656 desc, Code::ComputeFlags(Code::STUB), Handle<Code>()); | |
1657 F3 f = FUNCTION_CAST<F3>(code->entry()); | |
1658 | |
1659 const int test_size = 3; | |
1660 const int input_size = 5; | |
1661 | |
1662 double inputs_dt[input_size] = {0.0, 65.2, -70.32, | |
1663 18446744073709551621.0, -18446744073709551621.0}; | |
1664 double inputs_ds[input_size] = {0.1, 69.88, -91.325, | |
1665 18446744073709551625.0, -18446744073709551625.0}; | |
1666 float inputs_ft[input_size] = {0.0, 65.2, -70.32, | |
1667 18446744073709551621.0, -18446744073709551621.0}; | |
1668 float inputs_fs[input_size] = {0.1, 69.88, -91.325, | |
1669 18446744073709551625.0, -18446744073709551625.0}; | |
1670 double tests_D[test_size*2] = {2.8, 2.9, -2.8, -2.9, | |
1671 18446744073709551616.0, 18446744073709555712.0}; | |
1672 float tests_S[test_size*2] = {2.9, 2.8, -2.9, -2.8, | |
1673 18446744073709551616.0, 18446746272732807168.0}; | |
1674 for (int j=0; j < test_size; j+=2) { | |
1675 for (int i=0; i < input_size; i++) { | |
1676 test.dt = inputs_dt[i]; | |
1677 test.dd = tests_D[j]; | |
1678 test.ds = inputs_ds[i]; | |
1679 test.ft = inputs_ft[i]; | |
1680 test.fd = tests_S[j]; | |
1681 test.fs = inputs_fs[i]; | |
1682 (CALL_GENERATED_CODE(f, &test, 0, 0, 0, 0)); | |
1683 CHECK_EQ(test.dd, inputs_ds[i]); | |
1684 CHECK_EQ(test.fd, inputs_fs[i]); | |
1685 | |
1686 test.dd = tests_D[j+1]; | |
1687 test.fd = tests_S[j+1]; | |
1688 (CALL_GENERATED_CODE(f, &test, 0, 0, 0, 0)); | |
1689 CHECK_EQ(test.dd, inputs_dt[i]); | |
1690 CHECK_EQ(test.fd, inputs_ft[i]); | |
1691 } | |
1692 } | |
1693 } | |
1694 } | |
1695 | |
1696 | |
1697 TEST(rint_s) { | |
1698 if (IsMipsArchVariant(kMips32r6)) { | |
1699 const int tableLength = 30; | |
1700 CcTest::InitializeVM(); | |
1701 Isolate* isolate = CcTest::i_isolate(); | |
1702 HandleScope scope(isolate); | |
1703 MacroAssembler assm(isolate, NULL, 0); | |
1704 | |
1705 typedef struct test_float { | |
1706 float a; | |
1707 float b; | |
1708 int fcsr; | |
1709 }TestFloat; | |
1710 | |
1711 TestFloat test; | |
1712 float inputs[tableLength] = {18446744073709551617.0, | |
1713 4503599627370496.0, -4503599627370496.0, | |
1714 1.26782468584154733584017312973E30, 1.44860108245951772690707170478E37, | |
1715 1.7976931348623157E+38, 6.27463370218383111104242366943E-37, | |
1716 309485009821345068724781056.89, | |
1717 2.1, 2.6, 2.5, 3.1, 3.6, 3.5, | |
1718 -2.1, -2.6, -2.5, -3.1, -3.6, -3.5, | |
1719 37778931862957161709568.0, 37778931862957161709569.0, | |
1720 37778931862957161709580.0, 37778931862957161709581.0, | |
1721 37778931862957161709582.0, 37778931862957161709583.0, | |
1722 37778931862957161709584.0, 37778931862957161709585.0, | |
1723 37778931862957161709586.0, 37778931862957161709587.0}; | |
1724 float outputs_RN[tableLength] = {18446744073709551617.0, | |
1725 4503599627370496.0, -4503599627370496.0, | |
1726 1.26782468584154733584017312973E30, 1.44860108245951772690707170478E37, | |
1727 1.7976931348623157E38, 0, | |
1728 309485009821345068724781057.0, | |
1729 2.0, 3.0, 2.0, 3.0, 4.0, 4.0, | |
1730 -2.0, -3.0, -2.0, -3.0, -4.0, -4.0, | |
1731 37778931862957161709568.0, 37778931862957161709569.0, | |
1732 37778931862957161709580.0, 37778931862957161709581.0, | |
1733 37778931862957161709582.0, 37778931862957161709583.0, | |
1734 37778931862957161709584.0, 37778931862957161709585.0, | |
1735 37778931862957161709586.0, 37778931862957161709587.0}; | |
1736 float outputs_RZ[tableLength] = {18446744073709551617.0, | |
1737 4503599627370496.0, -4503599627370496.0, | |
1738 1.26782468584154733584017312973E30, 1.44860108245951772690707170478E37, | |
1739 1.7976931348623157E38, 0, | |
1740 309485009821345068724781057.0, | |
1741 2.0, 2.0, 2.0, 3.0, 3.0, 3.0, | |
1742 -2.0, -2.0, -2.0, -3.0, -3.0, -3.0, | |
1743 37778931862957161709568.0, 37778931862957161709569.0, | |
1744 37778931862957161709580.0, 37778931862957161709581.0, | |
1745 37778931862957161709582.0, 37778931862957161709583.0, | |
1746 37778931862957161709584.0, 37778931862957161709585.0, | |
1747 37778931862957161709586.0, 37778931862957161709587.0}; | |
1748 float outputs_RP[tableLength] = {18446744073709551617.0, | |
1749 4503599627370496.0, -4503599627370496.0, | |
1750 1.26782468584154733584017312973E30, 1.44860108245951772690707170478E37, | |
1751 1.7976931348623157E38, 1, | |
1752 309485009821345068724781057.0, | |
1753 3.0, 3.0, 3.0, 4.0, 4.0, 4.0, | |
1754 -2.0, -2.0, -2.0, -3.0, -3.0, -3.0, | |
1755 37778931862957161709568.0, 37778931862957161709569.0, | |
1756 37778931862957161709580.0, 37778931862957161709581.0, | |
1757 37778931862957161709582.0, 37778931862957161709583.0, | |
1758 37778931862957161709584.0, 37778931862957161709585.0, | |
1759 37778931862957161709586.0, 37778931862957161709587.0}; | |
1760 float outputs_RM[tableLength] = {18446744073709551617.0, | |
1761 4503599627370496.0, -4503599627370496.0, | |
1762 1.26782468584154733584017312973E30, 1.44860108245951772690707170478E37, | |
1763 1.7976931348623157E38, 0, | |
1764 309485009821345068724781057.0, | |
1765 2.0, 2.0, 2.0, 3.0, 3.0, 3.0, | |
1766 -3.0, -3.0, -3.0, -4.0, -4.0, -4.0, | |
1767 37778931862957161709568.0, 37778931862957161709569.0, | |
1768 37778931862957161709580.0, 37778931862957161709581.0, | |
1769 37778931862957161709582.0, 37778931862957161709583.0, | |
1770 37778931862957161709584.0, 37778931862957161709585.0, | |
1771 37778931862957161709586.0, 37778931862957161709587.0}; | |
1772 int fcsr_inputs[4] = | |
1773 {kRoundToNearest, kRoundToZero, kRoundToPlusInf, kRoundToMinusInf}; | |
1774 float* outputs[4] = {outputs_RN, outputs_RZ, outputs_RP, outputs_RM}; | |
1775 __ lwc1(f4, MemOperand(a0, OFFSET_OF(TestFloat, a)) ); | |
1776 __ lw(t0, MemOperand(a0, OFFSET_OF(TestFloat, fcsr)) ); | |
1777 __ cfc1(t1, FCSR); | |
1778 __ ctc1(t0, FCSR); | |
1779 __ rint_s(f8, f4); | |
1780 __ swc1(f8, MemOperand(a0, OFFSET_OF(TestFloat, b)) ); | |
1781 __ ctc1(t1, FCSR); | |
1782 __ jr(ra); | |
1783 __ nop(); | |
1784 | |
1785 CodeDesc desc; | |
1786 assm.GetCode(&desc); | |
1787 Handle<Code> code = isolate->factory()->NewCode( | |
1788 desc, Code::ComputeFlags(Code::STUB), Handle<Code>()); | |
1789 F3 f = FUNCTION_CAST<F3>(code->entry()); | |
1790 | |
1791 for (int j = 0; j < 4; j++) { | |
1792 test.fcsr = fcsr_inputs[j]; | |
1793 for (int i = 0; i < tableLength; i++) { | |
1794 test.a = inputs[i]; | |
1795 (CALL_GENERATED_CODE(f, &test, 0, 0, 0, 0)); | |
1796 CHECK_EQ(test.b, outputs[j][i]); | |
1797 } | |
1798 } | |
1799 } | |
1800 } | |
1801 | |
1802 | |
1803 TEST(mina_maxa) { | |
1804 if (IsMipsArchVariant(kMips32r6)) { | |
1805 const int tableLength = 12; | |
1806 CcTest::InitializeVM(); | |
1807 Isolate* isolate = CcTest::i_isolate(); | |
1808 HandleScope scope(isolate); | |
1809 MacroAssembler assm(isolate, NULL, 0); | |
1810 | |
1811 typedef struct test_float { | |
1812 double a; | |
1813 double b; | |
1814 double resd; | |
1815 double resd1; | |
1816 float c; | |
1817 float d; | |
1818 float resf; | |
1819 float resf1; | |
1820 }TestFloat; | |
1821 | |
1822 TestFloat test; | |
1823 double inputsa[tableLength] = { | |
1824 5.3, 4.8, 6.1, | |
1825 9.8, 9.8, 9.8, | |
1826 -10.0, -8.9, -9.8, | |
1827 -10.0, -8.9, -9.8 | |
1828 }; | |
1829 double inputsb[tableLength] = { | |
1830 4.8, 5.3, 6.1, | |
1831 -10.0, -8.9, -9.8, | |
1832 9.8, 9.8, 9.8, | |
1833 -9.8, -11.2, -9.8 | |
1834 }; | |
1835 double resd[tableLength] = { | |
1836 4.8, 4.8, 6.1, | |
1837 9.8, -8.9, 9.8, | |
1838 9.8, -8.9, 9.8, | |
1839 -9.8, -8.9, -9.8 | |
1840 }; | |
1841 double resd1[tableLength] = { | |
1842 5.3, 5.3, 6.1, | |
1843 -10.0, 9.8, 9.8, | |
1844 -10.0, 9.8, 9.8, | |
1845 -10.0, -11.2, -9.8 | |
1846 }; | |
1847 float inputsc[tableLength] = { | |
1848 5.3, 4.8, 6.1, | |
1849 9.8, 9.8, 9.8, | |
1850 -10.0, -8.9, -9.8, | |
1851 -10.0, -8.9, -9.8 | |
1852 }; | |
1853 float inputsd[tableLength] = { | |
1854 4.8, 5.3, 6.1, | |
1855 -10.0, -8.9, -9.8, | |
1856 9.8, 9.8, 9.8, | |
1857 -9.8, -11.2, -9.8 | |
1858 }; | |
1859 float resf[tableLength] = { | |
1860 4.8, 4.8, 6.1, | |
1861 9.8, -8.9, 9.8, | |
1862 9.8, -8.9, 9.8, | |
1863 -9.8, -8.9, -9.8 | |
1864 }; | |
1865 float resf1[tableLength] = { | |
1866 5.3, 5.3, 6.1, | |
1867 -10.0, 9.8, 9.8, | |
1868 -10.0, 9.8, 9.8, | |
1869 -10.0, -11.2, -9.8 | |
1870 }; | |
1871 | |
1872 __ ldc1(f2, MemOperand(a0, OFFSET_OF(TestFloat, a)) ); | |
1873 __ ldc1(f4, MemOperand(a0, OFFSET_OF(TestFloat, b)) ); | |
1874 __ lwc1(f8, MemOperand(a0, OFFSET_OF(TestFloat, c)) ); | |
1875 __ lwc1(f10, MemOperand(a0, OFFSET_OF(TestFloat, d)) ); | |
1876 __ mina_d(f6, f2, f4); | |
1877 __ mina_s(f12, f8, f10); | |
1878 __ maxa_d(f14, f2, f4); | |
1879 __ maxa_s(f16, f8, f10); | |
1880 __ swc1(f12, MemOperand(a0, OFFSET_OF(TestFloat, resf)) ); | |
1881 __ sdc1(f6, MemOperand(a0, OFFSET_OF(TestFloat, resd)) ); | |
1882 __ swc1(f16, MemOperand(a0, OFFSET_OF(TestFloat, resf1)) ); | |
1883 __ sdc1(f14, MemOperand(a0, OFFSET_OF(TestFloat, resd1)) ); | |
1884 __ jr(ra); | |
1885 __ nop(); | |
1886 | |
1887 CodeDesc desc; | |
1888 assm.GetCode(&desc); | |
1889 Handle<Code> code = isolate->factory()->NewCode( | |
1890 desc, Code::ComputeFlags(Code::STUB), Handle<Code>()); | |
1891 F3 f = FUNCTION_CAST<F3>(code->entry()); | |
1892 for (int i = 0; i < tableLength; i++) { | |
1893 test.a = inputsa[i]; | |
1894 test.b = inputsb[i]; | |
1895 test.c = inputsc[i]; | |
1896 test.d = inputsd[i]; | |
1897 (CALL_GENERATED_CODE(f, &test, 0, 0, 0, 0)); | |
1898 CHECK_EQ(test.resd, resd[i]); | |
1899 CHECK_EQ(test.resf, resf[i]); | |
1900 CHECK_EQ(test.resd1, resd1[i]); | |
1901 CHECK_EQ(test.resf1, resf1[i]); | |
1902 } | |
1903 } | |
1904 } | |
1905 | |
1906 | |
1907 // ----------------------mips32r2 specific tests---------------------- | |
1908 TEST(trunc_l) { | |
1909 if (IsMipsArchVariant(kMips32r2) && IsFp64Mode()) { | |
1910 CcTest::InitializeVM(); | |
1911 Isolate* isolate = CcTest::i_isolate(); | |
1912 HandleScope scope(isolate); | |
1913 MacroAssembler assm(isolate, NULL, 0); | |
1914 const double dFPU64InvalidResult = static_cast<double>(kFPU64InvalidResult); | |
1915 typedef struct test_float { | |
1916 double a; | |
1917 float b; | |
1918 int64_t c; // a trunc result | |
1919 int64_t d; // b trunc result | |
1920 }Test; | |
1921 const int tableLength = 16; | |
1922 double inputs_D[tableLength] = { | |
1923 2.1, 2.6, 2.5, 3.1, 3.6, 3.5, | |
1924 -2.1, -2.6, -2.5, -3.1, -3.6, -3.5, | |
1925 2147483648.0, | |
1926 std::numeric_limits<double>::quiet_NaN(), | |
1927 std::numeric_limits<double>::infinity(), | |
1928 9223372036854775808.0 | |
1929 }; | |
1930 float inputs_S[tableLength] = { | |
1931 2.1, 2.6, 2.5, 3.1, 3.6, 3.5, | |
1932 -2.1, -2.6, -2.5, -3.1, -3.6, -3.5, | |
1933 2147483648.0, | |
1934 std::numeric_limits<float>::quiet_NaN(), | |
1935 std::numeric_limits<float>::infinity(), | |
1936 9223372036854775808.0 | |
1937 }; | |
1938 double outputs[tableLength] = { | |
1939 2.0, 2.0, 2.0, 3.0, 3.0, 3.0, | |
1940 -2.0, -2.0, -2.0, -3.0, -3.0, -3.0, | |
1941 2147483648.0, dFPU64InvalidResult, | |
1942 dFPU64InvalidResult, dFPU64InvalidResult}; | |
1943 | |
1944 __ ldc1(f4, MemOperand(a0, OFFSET_OF(Test, a)) ); | |
1945 __ lwc1(f6, MemOperand(a0, OFFSET_OF(Test, b)) ); | |
1946 __ trunc_l_d(f8, f4); | |
1947 __ trunc_l_s(f10, f6); | |
1948 __ sdc1(f8, MemOperand(a0, OFFSET_OF(Test, c)) ); | |
1949 __ sdc1(f10, MemOperand(a0, OFFSET_OF(Test, d)) ); | |
1950 __ jr(ra); | |
1951 __ nop(); | |
1952 Test test; | |
1953 CodeDesc desc; | |
1954 assm.GetCode(&desc); | |
1955 Handle<Code> code = isolate->factory()->NewCode( | |
1956 desc, Code::ComputeFlags(Code::STUB), Handle<Code>()); | |
1957 F3 f = FUNCTION_CAST<F3>(code->entry()); | |
1958 for (int i = 0; i < tableLength; i++) { | |
1959 test.a = inputs_D[i]; | |
1960 test.b = inputs_S[i]; | |
1961 (CALL_GENERATED_CODE(f, &test, 0, 0, 0, 0)); | |
1962 CHECK_EQ(test.c, outputs[i]); | |
1963 CHECK_EQ(test.d, test.c); | |
1964 } | |
1965 } | |
1966 } | |
1967 | |
1968 | |
1969 TEST(movz_movn) { | |
1970 if (IsMipsArchVariant(kMips32r2)) { | |
1971 const int tableLength = 4; | |
1972 CcTest::InitializeVM(); | |
1973 Isolate* isolate = CcTest::i_isolate(); | |
1974 HandleScope scope(isolate); | |
1975 MacroAssembler assm(isolate, NULL, 0); | |
1976 | |
1977 typedef struct test_float { | |
1978 int64_t rt; | |
1979 double a; | |
1980 double b; | |
1981 double bold; | |
1982 double b1; | |
1983 double bold1; | |
1984 float c; | |
1985 float d; | |
1986 float dold; | |
1987 float d1; | |
1988 float dold1; | |
1989 }TestFloat; | |
1990 | |
1991 TestFloat test; | |
1992 double inputs_D[tableLength] = { | |
1993 5.3, -5.3, 5.3, -2.9 | |
1994 }; | |
1995 double inputs_S[tableLength] = { | |
1996 4.8, 4.8, -4.8, -0.29 | |
1997 }; | |
1998 | |
1999 float outputs_S[tableLength] = { | |
2000 4.8, 4.8, -4.8, -0.29 | |
2001 }; | |
2002 double outputs_D[tableLength] = { | |
2003 5.3, -5.3, 5.3, -2.9 | |
2004 }; | |
2005 | |
2006 __ ldc1(f2, MemOperand(a0, OFFSET_OF(TestFloat, a)) ); | |
2007 __ lwc1(f6, MemOperand(a0, OFFSET_OF(TestFloat, c)) ); | |
2008 __ lw(t0, MemOperand(a0, OFFSET_OF(TestFloat, rt)) ); | |
2009 __ li(t1, 0x0); | |
2010 __ mtc1(t1, f12); | |
2011 __ mtc1(t1, f10); | |
2012 __ mtc1(t1, f16); | |
2013 __ mtc1(t1, f14); | |
2014 __ sdc1(f12, MemOperand(a0, OFFSET_OF(TestFloat, bold)) ); | |
2015 __ swc1(f10, MemOperand(a0, OFFSET_OF(TestFloat, dold)) ); | |
2016 __ sdc1(f16, MemOperand(a0, OFFSET_OF(TestFloat, bold1)) ); | |
2017 __ swc1(f14, MemOperand(a0, OFFSET_OF(TestFloat, dold1)) ); | |
2018 __ movz_s(f10, f6, t0); | |
2019 __ movz_d(f12, f2, t0); | |
2020 __ movn_s(f14, f6, t0); | |
2021 __ movn_d(f16, f2, t0); | |
2022 __ swc1(f10, MemOperand(a0, OFFSET_OF(TestFloat, d)) ); | |
2023 __ sdc1(f12, MemOperand(a0, OFFSET_OF(TestFloat, b)) ); | |
2024 __ swc1(f14, MemOperand(a0, OFFSET_OF(TestFloat, d1)) ); | |
2025 __ sdc1(f16, MemOperand(a0, OFFSET_OF(TestFloat, b1)) ); | |
2026 __ jr(ra); | |
2027 __ nop(); | |
2028 | |
2029 CodeDesc desc; | |
2030 assm.GetCode(&desc); | |
2031 Handle<Code> code = isolate->factory()->NewCode( | |
2032 desc, Code::ComputeFlags(Code::STUB), Handle<Code>()); | |
2033 F3 f = FUNCTION_CAST<F3>(code->entry()); | |
2034 for (int i = 0; i < tableLength; i++) { | |
2035 test.a = inputs_D[i]; | |
2036 test.c = inputs_S[i]; | |
2037 | |
2038 test.rt = 1; | |
2039 (CALL_GENERATED_CODE(f, &test, 0, 0, 0, 0)); | |
2040 CHECK_EQ(test.b, test.bold); | |
2041 CHECK_EQ(test.d, test.dold); | |
2042 CHECK_EQ(test.b1, outputs_D[i]); | |
2043 CHECK_EQ(test.d1, outputs_S[i]); | |
2044 | |
2045 test.rt = 0; | |
2046 (CALL_GENERATED_CODE(f, &test, 0, 0, 0, 0)); | |
2047 CHECK_EQ(test.b, outputs_D[i]); | |
2048 CHECK_EQ(test.d, outputs_S[i]); | |
2049 CHECK_EQ(test.b1, test.bold1); | |
2050 CHECK_EQ(test.d1, test.dold1); | |
2051 } | |
2052 } | |
2053 } | |
2054 | |
2055 | |
2056 TEST(movt_movd) { | |
2057 if (IsMipsArchVariant(kMips32r2)) { | |
2058 const int tableLength = 4; | |
2059 CcTest::InitializeVM(); | |
2060 Isolate* isolate = CcTest::i_isolate(); | |
2061 | |
2062 typedef struct test_float { | |
2063 double srcd; | |
2064 double dstd; | |
2065 double dstdold; | |
2066 double dstd1; | |
2067 double dstdold1; | |
2068 float srcf; | |
2069 float dstf; | |
2070 float dstfold; | |
2071 float dstf1; | |
2072 float dstfold1; | |
2073 int32_t cc; | |
2074 int32_t fcsr; | |
2075 }TestFloat; | |
2076 | |
2077 TestFloat test; | |
2078 double inputs_D[tableLength] = { | |
2079 5.3, -5.3, 20.8, -2.9 | |
2080 }; | |
2081 double inputs_S[tableLength] = { | |
2082 4.88, 4.8, -4.8, -0.29 | |
2083 }; | |
2084 | |
2085 float outputs_S[tableLength] = { | |
2086 4.88, 4.8, -4.8, -0.29 | |
2087 }; | |
2088 double outputs_D[tableLength] = { | |
2089 5.3, -5.3, 20.8, -2.9 | |
2090 }; | |
2091 int condition_flags[8] = {0, 1, 2, 3, 4, 5, 6, 7}; | |
2092 | |
2093 for (int i = 0; i < tableLength; i++) { | |
2094 test.srcd = inputs_D[i]; | |
2095 test.srcf = inputs_S[i]; | |
2096 | |
2097 for (int j = 0; j< 8; j++) { | |
2098 test.cc = condition_flags[j]; | |
2099 if (test.cc == 0) { | |
2100 test.fcsr = 1 << 23; | |
2101 } else { | |
2102 test.fcsr = 1 << (24+condition_flags[j]); | |
2103 } | |
2104 HandleScope scope(isolate); | |
2105 MacroAssembler assm(isolate, NULL, 0); | |
2106 __ ldc1(f2, MemOperand(a0, OFFSET_OF(TestFloat, srcd)) ); | |
2107 __ lwc1(f4, MemOperand(a0, OFFSET_OF(TestFloat, srcf)) ); | |
2108 __ lw(t1, MemOperand(a0, OFFSET_OF(TestFloat, fcsr)) ); | |
2109 __ cfc1(t0, FCSR); | |
2110 __ ctc1(t1, FCSR); | |
2111 __ li(t2, 0x0); | |
2112 __ mtc1(t2, f12); | |
2113 __ mtc1(t2, f10); | |
2114 __ sdc1(f10, MemOperand(a0, OFFSET_OF(TestFloat, dstdold)) ); | |
2115 __ swc1(f12, MemOperand(a0, OFFSET_OF(TestFloat, dstfold)) ); | |
2116 __ movt_s(f12, f4, test.cc); | |
2117 __ movt_d(f10, f2, test.cc); | |
2118 __ swc1(f12, MemOperand(a0, OFFSET_OF(TestFloat, dstf)) ); | |
2119 __ sdc1(f10, MemOperand(a0, OFFSET_OF(TestFloat, dstd)) ); | |
2120 __ sdc1(f10, MemOperand(a0, OFFSET_OF(TestFloat, dstdold1)) ); | |
2121 __ swc1(f12, MemOperand(a0, OFFSET_OF(TestFloat, dstfold1)) ); | |
2122 __ movf_s(f12, f4, test.cc); | |
2123 __ movf_d(f10, f2, test.cc); | |
2124 __ swc1(f12, MemOperand(a0, OFFSET_OF(TestFloat, dstf1)) ); | |
2125 __ sdc1(f10, MemOperand(a0, OFFSET_OF(TestFloat, dstd1)) ); | |
2126 __ ctc1(t0, FCSR); | |
2127 __ jr(ra); | |
2128 __ nop(); | |
2129 | |
2130 CodeDesc desc; | |
2131 assm.GetCode(&desc); | |
2132 Handle<Code> code = isolate->factory()->NewCode( | |
2133 desc, Code::ComputeFlags(Code::STUB), Handle<Code>()); | |
2134 F3 f = FUNCTION_CAST<F3>(code->entry()); | |
2135 | |
2136 (CALL_GENERATED_CODE(f, &test, 0, 0, 0, 0)); | |
2137 CHECK_EQ(test.dstf, outputs_S[i]); | |
2138 CHECK_EQ(test.dstd, outputs_D[i]); | |
2139 CHECK_EQ(test.dstf1, test.dstfold1); | |
2140 CHECK_EQ(test.dstd1, test.dstdold1); | |
2141 test.fcsr = 0; | |
2142 (CALL_GENERATED_CODE(f, &test, 0, 0, 0, 0)); | |
2143 CHECK_EQ(test.dstf, test.dstfold); | |
2144 CHECK_EQ(test.dstd, test.dstdold); | |
2145 CHECK_EQ(test.dstf1, outputs_S[i]); | |
2146 CHECK_EQ(test.dstd1, outputs_D[i]); | |
2147 } | |
2148 } | |
2149 } | |
2150 } | |
2151 | |
2152 | |
2153 // ----------------------tests for all archs-------------------------- | |
2154 TEST(cvt_w_d) { | |
2155 CcTest::InitializeVM(); | 1581 CcTest::InitializeVM(); |
2156 Isolate* isolate = CcTest::i_isolate(); | 1582 Isolate* isolate = CcTest::i_isolate(); |
2157 HandleScope scope(isolate); | 1583 HandleScope scope(isolate); |
2158 MacroAssembler assm(isolate, NULL, 0); | 1584 MacroAssembler assm(isolate, NULL, 0); |
2159 | 1585 |
2160 typedef struct test_float { | 1586 typedef struct test_float { |
2161 double a; | 1587 double a; |
2162 int32_t b; | 1588 int32_t b; |
2163 int32_t fcsr; | 1589 int32_t fcsr; |
2164 }Test; | 1590 }Test; |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2214 Test test; | 1640 Test test; |
2215 CodeDesc desc; | 1641 CodeDesc desc; |
2216 assm.GetCode(&desc); | 1642 assm.GetCode(&desc); |
2217 Handle<Code> code = isolate->factory()->NewCode( | 1643 Handle<Code> code = isolate->factory()->NewCode( |
2218 desc, Code::ComputeFlags(Code::STUB), Handle<Code>()); | 1644 desc, Code::ComputeFlags(Code::STUB), Handle<Code>()); |
2219 F3 f = FUNCTION_CAST<F3>(code->entry()); | 1645 F3 f = FUNCTION_CAST<F3>(code->entry()); |
2220 for (int j = 0; j < 4; j++) { | 1646 for (int j = 0; j < 4; j++) { |
2221 test.fcsr = fcsr_inputs[j]; | 1647 test.fcsr = fcsr_inputs[j]; |
2222 for (int i = 0; i < tableLength; i++) { | 1648 for (int i = 0; i < tableLength; i++) { |
2223 test.a = inputs[i]; | 1649 test.a = inputs[i]; |
| 1650 std::cout << i << " " << j << "\n"; |
2224 (CALL_GENERATED_CODE(f, &test, 0, 0, 0, 0)); | 1651 (CALL_GENERATED_CODE(f, &test, 0, 0, 0, 0)); |
2225 CHECK_EQ(test.b, outputs[j][i]); | 1652 CHECK_EQ(test.b, outputs[j][i]); |
2226 } | 1653 } |
2227 } | 1654 } |
2228 } | 1655 } |
2229 | 1656 |
2230 | 1657 |
2231 TEST(trunc_w) { | |
2232 CcTest::InitializeVM(); | |
2233 Isolate* isolate = CcTest::i_isolate(); | |
2234 HandleScope scope(isolate); | |
2235 MacroAssembler assm(isolate, NULL, 0); | |
2236 | |
2237 typedef struct test_float { | |
2238 double a; | |
2239 float b; | |
2240 int32_t c; // a trunc result | |
2241 int32_t d; // b trunc result | |
2242 }Test; | |
2243 const int tableLength = 15; | |
2244 double inputs_D[tableLength] = { | |
2245 2.1, 2.6, 2.5, 3.1, 3.6, 3.5, | |
2246 -2.1, -2.6, -2.5, -3.1, -3.6, -3.5, | |
2247 2147483648.0, | |
2248 std::numeric_limits<double>::quiet_NaN(), | |
2249 std::numeric_limits<double>::infinity() | |
2250 }; | |
2251 float inputs_S[tableLength] = { | |
2252 2.1, 2.6, 2.5, 3.1, 3.6, 3.5, | |
2253 -2.1, -2.6, -2.5, -3.1, -3.6, -3.5, | |
2254 2147483648.0, | |
2255 std::numeric_limits<float>::quiet_NaN(), | |
2256 std::numeric_limits<float>::infinity() | |
2257 }; | |
2258 double outputs[tableLength] = { | |
2259 2.0, 2.0, 2.0, 3.0, 3.0, 3.0, | |
2260 -2.0, -2.0, -2.0, -3.0, -3.0, -3.0, | |
2261 kFPUInvalidResult, kFPUInvalidResult, | |
2262 kFPUInvalidResult}; | |
2263 | |
2264 __ ldc1(f4, MemOperand(a0, OFFSET_OF(Test, a)) ); | |
2265 __ lwc1(f6, MemOperand(a0, OFFSET_OF(Test, b)) ); | |
2266 __ trunc_w_d(f8, f4); | |
2267 __ trunc_w_s(f10, f6); | |
2268 __ swc1(f8, MemOperand(a0, OFFSET_OF(Test, c)) ); | |
2269 __ swc1(f10, MemOperand(a0, OFFSET_OF(Test, d)) ); | |
2270 __ jr(ra); | |
2271 __ nop(); | |
2272 Test test; | |
2273 CodeDesc desc; | |
2274 assm.GetCode(&desc); | |
2275 Handle<Code> code = isolate->factory()->NewCode( | |
2276 desc, Code::ComputeFlags(Code::STUB), Handle<Code>()); | |
2277 F3 f = FUNCTION_CAST<F3>(code->entry()); | |
2278 for (int i = 0; i < tableLength; i++) { | |
2279 test.a = inputs_D[i]; | |
2280 test.b = inputs_S[i]; | |
2281 (CALL_GENERATED_CODE(f, &test, 0, 0, 0, 0)); | |
2282 CHECK_EQ(test.c, outputs[i]); | |
2283 CHECK_EQ(test.d, test.c); | |
2284 } | |
2285 } | |
2286 | |
2287 | |
2288 TEST(round_w) { | |
2289 CcTest::InitializeVM(); | |
2290 Isolate* isolate = CcTest::i_isolate(); | |
2291 HandleScope scope(isolate); | |
2292 MacroAssembler assm(isolate, NULL, 0); | |
2293 | |
2294 typedef struct test_float { | |
2295 double a; | |
2296 float b; | |
2297 int32_t c; // a trunc result | |
2298 int32_t d; // b trunc result | |
2299 }Test; | |
2300 const int tableLength = 15; | |
2301 double inputs_D[tableLength] = { | |
2302 2.1, 2.6, 2.5, 3.1, 3.6, 3.5, | |
2303 -2.1, -2.6, -2.5, -3.1, -3.6, -3.5, | |
2304 2147483648.0, | |
2305 std::numeric_limits<double>::quiet_NaN(), | |
2306 std::numeric_limits<double>::infinity() | |
2307 }; | |
2308 float inputs_S[tableLength] = { | |
2309 2.1, 2.6, 2.5, 3.1, 3.6, 3.5, | |
2310 -2.1, -2.6, -2.5, -3.1, -3.6, -3.5, | |
2311 2147483648.0, | |
2312 std::numeric_limits<float>::quiet_NaN(), | |
2313 std::numeric_limits<float>::infinity() | |
2314 }; | |
2315 double outputs[tableLength] = { | |
2316 2.0, 3.0, 2.0, 3.0, 4.0, 4.0, | |
2317 -2.0, -3.0, -2.0, -3.0, -4.0, -4.0, | |
2318 kFPUInvalidResult, kFPUInvalidResult, | |
2319 kFPUInvalidResult}; | |
2320 | |
2321 __ ldc1(f4, MemOperand(a0, OFFSET_OF(Test, a)) ); | |
2322 __ lwc1(f6, MemOperand(a0, OFFSET_OF(Test, b)) ); | |
2323 __ round_w_d(f8, f4); | |
2324 __ round_w_s(f10, f6); | |
2325 __ swc1(f8, MemOperand(a0, OFFSET_OF(Test, c)) ); | |
2326 __ swc1(f10, MemOperand(a0, OFFSET_OF(Test, d)) ); | |
2327 __ jr(ra); | |
2328 __ nop(); | |
2329 Test test; | |
2330 CodeDesc desc; | |
2331 assm.GetCode(&desc); | |
2332 Handle<Code> code = isolate->factory()->NewCode( | |
2333 desc, Code::ComputeFlags(Code::STUB), Handle<Code>()); | |
2334 F3 f = FUNCTION_CAST<F3>(code->entry()); | |
2335 for (int i = 0; i < tableLength; i++) { | |
2336 test.a = inputs_D[i]; | |
2337 test.b = inputs_S[i]; | |
2338 (CALL_GENERATED_CODE(f, &test, 0, 0, 0, 0)); | |
2339 CHECK_EQ(test.c, outputs[i]); | |
2340 CHECK_EQ(test.d, test.c); | |
2341 } | |
2342 } | |
2343 | |
2344 | |
2345 TEST(round_l) { | |
2346 if (IsFp64Mode()) { | |
2347 CcTest::InitializeVM(); | |
2348 Isolate* isolate = CcTest::i_isolate(); | |
2349 HandleScope scope(isolate); | |
2350 MacroAssembler assm(isolate, NULL, 0); | |
2351 const double dFPU64InvalidResult = static_cast<double>(kFPU64InvalidResult); | |
2352 typedef struct test_float { | |
2353 double a; | |
2354 float b; | |
2355 int64_t c; | |
2356 int64_t d; | |
2357 }Test; | |
2358 const int tableLength = 16; | |
2359 double inputs_D[tableLength] = { | |
2360 2.1, 2.6, 2.5, 3.1, 3.6, 3.5, | |
2361 -2.1, -2.6, -2.5, -3.1, -3.6, -3.5, | |
2362 2147483648.0, | |
2363 std::numeric_limits<double>::quiet_NaN(), | |
2364 std::numeric_limits<double>::infinity(), | |
2365 9223372036854775808.0 | |
2366 }; | |
2367 float inputs_S[tableLength] = { | |
2368 2.1, 2.6, 2.5, 3.1, 3.6, 3.5, | |
2369 -2.1, -2.6, -2.5, -3.1, -3.6, -3.5, | |
2370 2147483648.0, | |
2371 std::numeric_limits<float>::quiet_NaN(), | |
2372 std::numeric_limits<float>::infinity(), | |
2373 9223372036854775808.0 | |
2374 }; | |
2375 double outputs[tableLength] = { | |
2376 2.0, 3.0, 2.0, 3.0, 4.0, 4.0, | |
2377 -2.0, -3.0, -2.0, -3.0, -4.0, -4.0, | |
2378 2147483648.0, dFPU64InvalidResult, | |
2379 dFPU64InvalidResult, dFPU64InvalidResult}; | |
2380 | |
2381 __ ldc1(f4, MemOperand(a0, OFFSET_OF(Test, a)) ); | |
2382 __ lwc1(f6, MemOperand(a0, OFFSET_OF(Test, b)) ); | |
2383 __ round_l_d(f8, f4); | |
2384 __ round_l_s(f10, f6); | |
2385 __ sdc1(f8, MemOperand(a0, OFFSET_OF(Test, c)) ); | |
2386 __ sdc1(f10, MemOperand(a0, OFFSET_OF(Test, d)) ); | |
2387 __ jr(ra); | |
2388 __ nop(); | |
2389 Test test; | |
2390 CodeDesc desc; | |
2391 assm.GetCode(&desc); | |
2392 Handle<Code> code = isolate->factory()->NewCode( | |
2393 desc, Code::ComputeFlags(Code::STUB), Handle<Code>()); | |
2394 F3 f = FUNCTION_CAST<F3>(code->entry()); | |
2395 for (int i = 0; i < tableLength; i++) { | |
2396 test.a = inputs_D[i]; | |
2397 test.b = inputs_S[i]; | |
2398 (CALL_GENERATED_CODE(f, &test, 0, 0, 0, 0)); | |
2399 CHECK_EQ(test.c, outputs[i]); | |
2400 CHECK_EQ(test.d, test.c); | |
2401 } | |
2402 } | |
2403 } | |
2404 | |
2405 | |
2406 TEST(sub) { | |
2407 const int tableLength = 12; | |
2408 CcTest::InitializeVM(); | |
2409 Isolate* isolate = CcTest::i_isolate(); | |
2410 HandleScope scope(isolate); | |
2411 MacroAssembler assm(isolate, NULL, 0); | |
2412 | |
2413 typedef struct test_float { | |
2414 float a; | |
2415 float b; | |
2416 float resultS; | |
2417 double c; | |
2418 double d; | |
2419 double resultD; | |
2420 }TestFloat; | |
2421 | |
2422 TestFloat test; | |
2423 double inputfs_D[tableLength] = { | |
2424 5.3, 4.8, 2.9, -5.3, -4.8, -2.9, | |
2425 5.3, 4.8, 2.9, -5.3, -4.8, -2.9 | |
2426 }; | |
2427 double inputft_D[tableLength] = { | |
2428 4.8, 5.3, 2.9, 4.8, 5.3, 2.9, | |
2429 -4.8, -5.3, -2.9, -4.8, -5.3, -2.9 | |
2430 }; | |
2431 double outputs_D[tableLength] = { | |
2432 0.5, -0.5, 0.0, -10.1, -10.1, -5.8, | |
2433 10.1, 10.1, 5.8, -0.5, 0.5, 0.0 | |
2434 }; | |
2435 float inputfs_S[tableLength] = { | |
2436 5.3, 4.8, 2.9, -5.3, -4.8, -2.9, | |
2437 5.3, 4.8, 2.9, -5.3, -4.8, -2.9 | |
2438 }; | |
2439 float inputft_S[tableLength] = { | |
2440 4.8, 5.3, 2.9, 4.8, 5.3, 2.9, | |
2441 -4.8, -5.3, -2.9, -4.8, -5.3, -2.9 | |
2442 }; | |
2443 float outputs_S[tableLength] = { | |
2444 0.5, -0.5, 0.0, -10.1, -10.1, -5.8, | |
2445 10.1, 10.1, 5.8, -0.5, 0.5, 0.0 | |
2446 }; | |
2447 __ lwc1(f2, MemOperand(a0, OFFSET_OF(TestFloat, a)) ); | |
2448 __ lwc1(f4, MemOperand(a0, OFFSET_OF(TestFloat, b)) ); | |
2449 __ ldc1(f8, MemOperand(a0, OFFSET_OF(TestFloat, c)) ); | |
2450 __ ldc1(f10, MemOperand(a0, OFFSET_OF(TestFloat, d)) ); | |
2451 __ sub_s(f6, f2, f4); | |
2452 __ sub_d(f12, f8, f10); | |
2453 __ swc1(f6, MemOperand(a0, OFFSET_OF(TestFloat, resultS)) ); | |
2454 __ sdc1(f12, MemOperand(a0, OFFSET_OF(TestFloat, resultD)) ); | |
2455 __ jr(ra); | |
2456 __ nop(); | |
2457 | |
2458 CodeDesc desc; | |
2459 assm.GetCode(&desc); | |
2460 Handle<Code> code = isolate->factory()->NewCode( | |
2461 desc, Code::ComputeFlags(Code::STUB), Handle<Code>()); | |
2462 F3 f = FUNCTION_CAST<F3>(code->entry()); | |
2463 for (int i = 0; i < tableLength; i++) { | |
2464 test.a = inputfs_S[i]; | |
2465 test.b = inputft_S[i]; | |
2466 test.c = inputfs_D[i]; | |
2467 test.d = inputft_D[i]; | |
2468 (CALL_GENERATED_CODE(f, &test, 0, 0, 0, 0)); | |
2469 CHECK_EQ(test.resultS, outputs_S[i]); | |
2470 CHECK_EQ(test.resultD, outputs_D[i]); | |
2471 } | |
2472 } | |
2473 | |
2474 | |
2475 TEST(sqrt_rsqrt_recip) { | |
2476 const int tableLength = 4; | |
2477 const double deltaDouble = 2E-15; | |
2478 const float deltaFloat = 2E-7; | |
2479 const float sqrt2_s = sqrt(2); | |
2480 const double sqrt2_d = sqrt(2); | |
2481 CcTest::InitializeVM(); | |
2482 Isolate* isolate = CcTest::i_isolate(); | |
2483 HandleScope scope(isolate); | |
2484 MacroAssembler assm(isolate, NULL, 0); | |
2485 | |
2486 typedef struct test_float { | |
2487 float a; | |
2488 float resultS; | |
2489 float resultS1; | |
2490 float resultS2; | |
2491 double c; | |
2492 double resultD; | |
2493 double resultD1; | |
2494 double resultD2; | |
2495 }TestFloat; | |
2496 TestFloat test; | |
2497 | |
2498 double inputs_D[tableLength] = { | |
2499 0.0L, 4.0L, 2.0L, 4e-28L | |
2500 }; | |
2501 | |
2502 double outputs_D[tableLength] = { | |
2503 0.0L, 2.0L, sqrt2_d, 2e-14L | |
2504 }; | |
2505 float inputs_S[tableLength] = { | |
2506 0.0, 4.0, 2.0, 4e-28 | |
2507 }; | |
2508 | |
2509 float outputs_S[tableLength] = { | |
2510 0.0, 2.0, sqrt2_s, 2e-14 | |
2511 }; | |
2512 | |
2513 | |
2514 __ lwc1(f2, MemOperand(a0, OFFSET_OF(TestFloat, a)) ); | |
2515 __ ldc1(f8, MemOperand(a0, OFFSET_OF(TestFloat, c)) ); | |
2516 __ sqrt_s(f6, f2); | |
2517 __ sqrt_d(f12, f8); | |
2518 __ rsqrt_d(f14, f8); | |
2519 __ rsqrt_s(f16, f2); | |
2520 __ recip_d(f18, f8); | |
2521 __ recip_s(f20, f2); | |
2522 __ swc1(f6, MemOperand(a0, OFFSET_OF(TestFloat, resultS)) ); | |
2523 __ sdc1(f12, MemOperand(a0, OFFSET_OF(TestFloat, resultD)) ); | |
2524 __ swc1(f16, MemOperand(a0, OFFSET_OF(TestFloat, resultS1)) ); | |
2525 __ sdc1(f14, MemOperand(a0, OFFSET_OF(TestFloat, resultD1)) ); | |
2526 __ swc1(f20, MemOperand(a0, OFFSET_OF(TestFloat, resultS2)) ); | |
2527 __ sdc1(f18, MemOperand(a0, OFFSET_OF(TestFloat, resultD2)) ); | |
2528 __ jr(ra); | |
2529 __ nop(); | |
2530 | |
2531 CodeDesc desc; | |
2532 assm.GetCode(&desc); | |
2533 Handle<Code> code = isolate->factory()->NewCode( | |
2534 desc, Code::ComputeFlags(Code::STUB), Handle<Code>()); | |
2535 F3 f = FUNCTION_CAST<F3>(code->entry()); | |
2536 | |
2537 for (int i = 0; i < tableLength; i++) { | |
2538 float f1; | |
2539 double d1; | |
2540 test.a = inputs_S[i]; | |
2541 test.c = inputs_D[i]; | |
2542 | |
2543 (CALL_GENERATED_CODE(f, &test, 0, 0, 0, 0)); | |
2544 | |
2545 CHECK_EQ(test.resultS, outputs_S[i]); | |
2546 CHECK_EQ(test.resultD, outputs_D[i]); | |
2547 | |
2548 if (i != 0) { | |
2549 f1 = test.resultS1 - 1.0F/outputs_S[i]; | |
2550 f1 = (f1 < 0) ? f1 : -f1; | |
2551 CHECK(f1 <= deltaFloat); | |
2552 d1 = test.resultD1 - 1.0L/outputs_D[i]; | |
2553 d1 = (d1 < 0) ? d1 : -d1; | |
2554 CHECK(d1 <= deltaDouble); | |
2555 f1 = test.resultS2 - 1.0F/inputs_S[i]; | |
2556 f1 = (f1 < 0) ? f1 : -f1; | |
2557 CHECK(f1 <= deltaFloat); | |
2558 d1 = test.resultD2 - 1.0L/inputs_D[i]; | |
2559 d1 = (d1 < 0) ? d1 : -d1; | |
2560 CHECK(d1 <= deltaDouble); | |
2561 } else { | |
2562 CHECK_EQ(test.resultS1, 1.0F/outputs_S[i]); | |
2563 CHECK_EQ(test.resultD1, 1.0L/outputs_D[i]); | |
2564 CHECK_EQ(test.resultS2, 1.0F/inputs_S[i]); | |
2565 CHECK_EQ(test.resultD2, 1.0L/inputs_D[i]); | |
2566 } | |
2567 } | |
2568 } | |
2569 | |
2570 | |
2571 TEST(neg) { | |
2572 const int tableLength = 3; | |
2573 CcTest::InitializeVM(); | |
2574 Isolate* isolate = CcTest::i_isolate(); | |
2575 HandleScope scope(isolate); | |
2576 MacroAssembler assm(isolate, NULL, 0); | |
2577 | |
2578 typedef struct test_float { | |
2579 float a; | |
2580 float resultS; | |
2581 double c; | |
2582 double resultD; | |
2583 }TestFloat; | |
2584 | |
2585 TestFloat test; | |
2586 double inputs_D[tableLength] = { | |
2587 0.0, 4.0, -2.0 | |
2588 }; | |
2589 | |
2590 double outputs_D[tableLength] = { | |
2591 0.0, -4.0, 2.0 | |
2592 }; | |
2593 float inputs_S[tableLength] = { | |
2594 0.0, 4.0, -2.0 | |
2595 }; | |
2596 | |
2597 float outputs_S[tableLength] = { | |
2598 0.0, -4.0, 2.0 | |
2599 }; | |
2600 __ lwc1(f2, MemOperand(a0, OFFSET_OF(TestFloat, a)) ); | |
2601 __ ldc1(f8, MemOperand(a0, OFFSET_OF(TestFloat, c)) ); | |
2602 __ neg_s(f6, f2); | |
2603 __ neg_d(f12, f8); | |
2604 __ swc1(f6, MemOperand(a0, OFFSET_OF(TestFloat, resultS)) ); | |
2605 __ sdc1(f12, MemOperand(a0, OFFSET_OF(TestFloat, resultD)) ); | |
2606 __ jr(ra); | |
2607 __ nop(); | |
2608 | |
2609 CodeDesc desc; | |
2610 assm.GetCode(&desc); | |
2611 Handle<Code> code = isolate->factory()->NewCode( | |
2612 desc, Code::ComputeFlags(Code::STUB), Handle<Code>()); | |
2613 F3 f = FUNCTION_CAST<F3>(code->entry()); | |
2614 for (int i = 0; i < tableLength; i++) { | |
2615 test.a = inputs_S[i]; | |
2616 test.c = inputs_D[i]; | |
2617 (CALL_GENERATED_CODE(f, &test, 0, 0, 0, 0)); | |
2618 CHECK_EQ(test.resultS, outputs_S[i]); | |
2619 CHECK_EQ(test.resultD, outputs_D[i]); | |
2620 } | |
2621 } | |
2622 | |
2623 | |
2624 TEST(mul) { | |
2625 const int tableLength = 4; | |
2626 CcTest::InitializeVM(); | |
2627 Isolate* isolate = CcTest::i_isolate(); | |
2628 HandleScope scope(isolate); | |
2629 MacroAssembler assm(isolate, NULL, 0); | |
2630 | |
2631 typedef struct test_float { | |
2632 float a; | |
2633 float b; | |
2634 float resultS; | |
2635 double c; | |
2636 double d; | |
2637 double resultD; | |
2638 }TestFloat; | |
2639 | |
2640 TestFloat test; | |
2641 double inputfs_D[tableLength] = { | |
2642 5.3, -5.3, 5.3, -2.9 | |
2643 }; | |
2644 double inputft_D[tableLength] = { | |
2645 4.8, 4.8, -4.8, -0.29 | |
2646 }; | |
2647 | |
2648 float inputfs_S[tableLength] = { | |
2649 5.3, -5.3, 5.3, -2.9 | |
2650 }; | |
2651 float inputft_S[tableLength] = { | |
2652 4.8, 4.8, -4.8, -0.29 | |
2653 }; | |
2654 | |
2655 __ lwc1(f2, MemOperand(a0, OFFSET_OF(TestFloat, a)) ); | |
2656 __ lwc1(f4, MemOperand(a0, OFFSET_OF(TestFloat, b)) ); | |
2657 __ ldc1(f6, MemOperand(a0, OFFSET_OF(TestFloat, c)) ); | |
2658 __ ldc1(f8, MemOperand(a0, OFFSET_OF(TestFloat, d)) ); | |
2659 __ mul_s(f10, f2, f4); | |
2660 __ mul_d(f12, f6, f8); | |
2661 __ swc1(f10, MemOperand(a0, OFFSET_OF(TestFloat, resultS)) ); | |
2662 __ sdc1(f12, MemOperand(a0, OFFSET_OF(TestFloat, resultD)) ); | |
2663 __ jr(ra); | |
2664 __ nop(); | |
2665 | |
2666 CodeDesc desc; | |
2667 assm.GetCode(&desc); | |
2668 Handle<Code> code = isolate->factory()->NewCode( | |
2669 desc, Code::ComputeFlags(Code::STUB), Handle<Code>()); | |
2670 F3 f = FUNCTION_CAST<F3>(code->entry()); | |
2671 for (int i = 0; i < tableLength; i++) { | |
2672 test.a = inputfs_S[i]; | |
2673 test.b = inputft_S[i]; | |
2674 test.c = inputfs_D[i]; | |
2675 test.d = inputft_D[i]; | |
2676 (CALL_GENERATED_CODE(f, &test, 0, 0, 0, 0)); | |
2677 CHECK_EQ(test.resultS, inputfs_S[i]*inputft_S[i]); | |
2678 CHECK_EQ(test.resultD, inputfs_D[i]*inputft_D[i]); | |
2679 } | |
2680 } | |
2681 | |
2682 | |
2683 TEST(mov) { | |
2684 const int tableLength = 4; | |
2685 CcTest::InitializeVM(); | |
2686 Isolate* isolate = CcTest::i_isolate(); | |
2687 HandleScope scope(isolate); | |
2688 MacroAssembler assm(isolate, NULL, 0); | |
2689 | |
2690 typedef struct test_float { | |
2691 double a; | |
2692 double b; | |
2693 float c; | |
2694 float d; | |
2695 }TestFloat; | |
2696 | |
2697 TestFloat test; | |
2698 double inputs_D[tableLength] = { | |
2699 5.3, -5.3, 5.3, -2.9 | |
2700 }; | |
2701 double inputs_S[tableLength] = { | |
2702 4.8, 4.8, -4.8, -0.29 | |
2703 }; | |
2704 | |
2705 float outputs_S[tableLength] = { | |
2706 4.8, 4.8, -4.8, -0.29 | |
2707 }; | |
2708 double outputs_D[tableLength] = { | |
2709 5.3, -5.3, 5.3, -2.9 | |
2710 }; | |
2711 | |
2712 __ ldc1(f2, MemOperand(a0, OFFSET_OF(TestFloat, a)) ); | |
2713 __ lwc1(f6, MemOperand(a0, OFFSET_OF(TestFloat, c)) ); | |
2714 __ mov_s(f18, f6); | |
2715 __ mov_d(f20, f2); | |
2716 __ swc1(f18, MemOperand(a0, OFFSET_OF(TestFloat, d)) ); | |
2717 __ sdc1(f20, MemOperand(a0, OFFSET_OF(TestFloat, b)) ); | |
2718 __ jr(ra); | |
2719 __ nop(); | |
2720 | |
2721 CodeDesc desc; | |
2722 assm.GetCode(&desc); | |
2723 Handle<Code> code = isolate->factory()->NewCode( | |
2724 desc, Code::ComputeFlags(Code::STUB), Handle<Code>()); | |
2725 F3 f = FUNCTION_CAST<F3>(code->entry()); | |
2726 for (int i = 0; i < tableLength; i++) { | |
2727 test.a = inputs_D[i]; | |
2728 test.c = inputs_S[i]; | |
2729 | |
2730 (CALL_GENERATED_CODE(f, &test, 0, 0, 0, 0)); | |
2731 CHECK_EQ(test.b, outputs_D[i]); | |
2732 CHECK_EQ(test.d, outputs_S[i]); | |
2733 } | |
2734 } | |
2735 | |
2736 | |
2737 TEST(floor_w) { | |
2738 CcTest::InitializeVM(); | |
2739 Isolate* isolate = CcTest::i_isolate(); | |
2740 HandleScope scope(isolate); | |
2741 MacroAssembler assm(isolate, NULL, 0); | |
2742 | |
2743 typedef struct test_float { | |
2744 double a; | |
2745 float b; | |
2746 int32_t c; // a floor result | |
2747 int32_t d; // b floor result | |
2748 }Test; | |
2749 const int tableLength = 15; | |
2750 double inputs_D[tableLength] = { | |
2751 2.1, 2.6, 2.5, 3.1, 3.6, 3.5, | |
2752 -2.1, -2.6, -2.5, -3.1, -3.6, -3.5, | |
2753 2147483648.0, | |
2754 std::numeric_limits<double>::quiet_NaN(), | |
2755 std::numeric_limits<double>::infinity() | |
2756 }; | |
2757 float inputs_S[tableLength] = { | |
2758 2.1, 2.6, 2.5, 3.1, 3.6, 3.5, | |
2759 -2.1, -2.6, -2.5, -3.1, -3.6, -3.5, | |
2760 2147483648.0, | |
2761 std::numeric_limits<float>::quiet_NaN(), | |
2762 std::numeric_limits<float>::infinity() | |
2763 }; | |
2764 double outputs[tableLength] = { | |
2765 2.0, 2.0, 2.0, 3.0, 3.0, 3.0, | |
2766 -3.0, -3.0, -3.0, -4.0, -4.0, -4.0, | |
2767 kFPUInvalidResult, kFPUInvalidResult, | |
2768 kFPUInvalidResult}; | |
2769 | |
2770 __ ldc1(f4, MemOperand(a0, OFFSET_OF(Test, a)) ); | |
2771 __ lwc1(f6, MemOperand(a0, OFFSET_OF(Test, b)) ); | |
2772 __ floor_w_d(f8, f4); | |
2773 __ floor_w_s(f10, f6); | |
2774 __ swc1(f8, MemOperand(a0, OFFSET_OF(Test, c)) ); | |
2775 __ swc1(f10, MemOperand(a0, OFFSET_OF(Test, d)) ); | |
2776 __ jr(ra); | |
2777 __ nop(); | |
2778 Test test; | |
2779 CodeDesc desc; | |
2780 assm.GetCode(&desc); | |
2781 Handle<Code> code = isolate->factory()->NewCode( | |
2782 desc, Code::ComputeFlags(Code::STUB), Handle<Code>()); | |
2783 F3 f = FUNCTION_CAST<F3>(code->entry()); | |
2784 for (int i = 0; i < tableLength; i++) { | |
2785 test.a = inputs_D[i]; | |
2786 test.b = inputs_S[i]; | |
2787 (CALL_GENERATED_CODE(f, &test, 0, 0, 0, 0)); | |
2788 CHECK_EQ(test.c, outputs[i]); | |
2789 CHECK_EQ(test.d, test.c); | |
2790 } | |
2791 } | |
2792 | |
2793 | |
2794 TEST(floor_l) { | |
2795 if (IsFp64Mode()) { | |
2796 CcTest::InitializeVM(); | |
2797 Isolate* isolate = CcTest::i_isolate(); | |
2798 HandleScope scope(isolate); | |
2799 MacroAssembler assm(isolate, NULL, 0); | |
2800 const double dFPU64InvalidResult = static_cast<double>(kFPU64InvalidResult); | |
2801 typedef struct test_float { | |
2802 double a; | |
2803 float b; | |
2804 int64_t c; | |
2805 int64_t d; | |
2806 }Test; | |
2807 const int tableLength = 16; | |
2808 double inputs_D[tableLength] = { | |
2809 2.1, 2.6, 2.5, 3.1, 3.6, 3.5, | |
2810 -2.1, -2.6, -2.5, -3.1, -3.6, -3.5, | |
2811 2147483648.0, | |
2812 std::numeric_limits<double>::quiet_NaN(), | |
2813 std::numeric_limits<double>::infinity(), | |
2814 9223372036854775808.0 | |
2815 }; | |
2816 float inputs_S[tableLength] = { | |
2817 2.1, 2.6, 2.5, 3.1, 3.6, 3.5, | |
2818 -2.1, -2.6, -2.5, -3.1, -3.6, -3.5, | |
2819 2147483648.0, | |
2820 std::numeric_limits<float>::quiet_NaN(), | |
2821 std::numeric_limits<float>::infinity(), | |
2822 9223372036854775808.0 | |
2823 }; | |
2824 double outputs[tableLength] = { | |
2825 2.0, 2.0, 2.0, 3.0, 3.0, 3.0, | |
2826 -3.0, -3.0, -3.0, -4.0, -4.0, -4.0, | |
2827 2147483648.0, dFPU64InvalidResult, | |
2828 dFPU64InvalidResult, dFPU64InvalidResult}; | |
2829 | |
2830 __ ldc1(f4, MemOperand(a0, OFFSET_OF(Test, a)) ); | |
2831 __ lwc1(f6, MemOperand(a0, OFFSET_OF(Test, b)) ); | |
2832 __ floor_l_d(f8, f4); | |
2833 __ floor_l_s(f10, f6); | |
2834 __ sdc1(f8, MemOperand(a0, OFFSET_OF(Test, c)) ); | |
2835 __ sdc1(f10, MemOperand(a0, OFFSET_OF(Test, d)) ); | |
2836 __ jr(ra); | |
2837 __ nop(); | |
2838 Test test; | |
2839 CodeDesc desc; | |
2840 assm.GetCode(&desc); | |
2841 Handle<Code> code = isolate->factory()->NewCode( | |
2842 desc, Code::ComputeFlags(Code::STUB), Handle<Code>()); | |
2843 F3 f = FUNCTION_CAST<F3>(code->entry()); | |
2844 for (int i = 0; i < tableLength; i++) { | |
2845 test.a = inputs_D[i]; | |
2846 test.b = inputs_S[i]; | |
2847 (CALL_GENERATED_CODE(f, &test, 0, 0, 0, 0)); | |
2848 CHECK_EQ(test.c, outputs[i]); | |
2849 CHECK_EQ(test.d, test.c); | |
2850 } | |
2851 } | |
2852 } | |
2853 | |
2854 | |
2855 TEST(ceil_w) { | |
2856 CcTest::InitializeVM(); | |
2857 Isolate* isolate = CcTest::i_isolate(); | |
2858 HandleScope scope(isolate); | |
2859 MacroAssembler assm(isolate, NULL, 0); | |
2860 | |
2861 typedef struct test_float { | |
2862 double a; | |
2863 float b; | |
2864 int32_t c; // a floor result | |
2865 int32_t d; // b floor result | |
2866 }Test; | |
2867 const int tableLength = 15; | |
2868 double inputs_D[tableLength] = { | |
2869 2.1, 2.6, 2.5, 3.1, 3.6, 3.5, | |
2870 -2.1, -2.6, -2.5, -3.1, -3.6, -3.5, | |
2871 2147483648.0, | |
2872 std::numeric_limits<double>::quiet_NaN(), | |
2873 std::numeric_limits<double>::infinity() | |
2874 }; | |
2875 float inputs_S[tableLength] = { | |
2876 2.1, 2.6, 2.5, 3.1, 3.6, 3.5, | |
2877 -2.1, -2.6, -2.5, -3.1, -3.6, -3.5, | |
2878 2147483648.0, | |
2879 std::numeric_limits<float>::quiet_NaN(), | |
2880 std::numeric_limits<float>::infinity() | |
2881 }; | |
2882 double outputs[tableLength] = { | |
2883 3.0, 3.0, 3.0, 4.0, 4.0, 4.0, | |
2884 -2.0, -2.0, -2.0, -3.0, -3.0, -3.0, | |
2885 kFPUInvalidResult, kFPUInvalidResult, | |
2886 kFPUInvalidResult}; | |
2887 | |
2888 __ ldc1(f4, MemOperand(a0, OFFSET_OF(Test, a)) ); | |
2889 __ lwc1(f6, MemOperand(a0, OFFSET_OF(Test, b)) ); | |
2890 __ ceil_w_d(f8, f4); | |
2891 __ ceil_w_s(f10, f6); | |
2892 __ swc1(f8, MemOperand(a0, OFFSET_OF(Test, c)) ); | |
2893 __ swc1(f10, MemOperand(a0, OFFSET_OF(Test, d)) ); | |
2894 __ jr(ra); | |
2895 __ nop(); | |
2896 Test test; | |
2897 CodeDesc desc; | |
2898 assm.GetCode(&desc); | |
2899 Handle<Code> code = isolate->factory()->NewCode( | |
2900 desc, Code::ComputeFlags(Code::STUB), Handle<Code>()); | |
2901 F3 f = FUNCTION_CAST<F3>(code->entry()); | |
2902 for (int i = 0; i < tableLength; i++) { | |
2903 test.a = inputs_D[i]; | |
2904 test.b = inputs_S[i]; | |
2905 (CALL_GENERATED_CODE(f, &test, 0, 0, 0, 0)); | |
2906 CHECK_EQ(test.c, outputs[i]); | |
2907 CHECK_EQ(test.d, test.c); | |
2908 } | |
2909 } | |
2910 | |
2911 | |
2912 TEST(ceil_l) { | |
2913 if (IsFp64Mode()) { | |
2914 CcTest::InitializeVM(); | |
2915 Isolate* isolate = CcTest::i_isolate(); | |
2916 HandleScope scope(isolate); | |
2917 MacroAssembler assm(isolate, NULL, 0); | |
2918 const double dFPU64InvalidResult = static_cast<double>(kFPU64InvalidResult); | |
2919 typedef struct test_float { | |
2920 double a; | |
2921 float b; | |
2922 int64_t c; | |
2923 int64_t d; | |
2924 }Test; | |
2925 const int tableLength = 16; | |
2926 double inputs_D[tableLength] = { | |
2927 2.1, 2.6, 2.5, 3.1, 3.6, 3.5, | |
2928 -2.1, -2.6, -2.5, -3.1, -3.6, -3.5, | |
2929 2147483648.0, | |
2930 std::numeric_limits<double>::quiet_NaN(), | |
2931 std::numeric_limits<double>::infinity(), | |
2932 9223372036854775808.0 | |
2933 }; | |
2934 float inputs_S[tableLength] = { | |
2935 2.1, 2.6, 2.5, 3.1, 3.6, 3.5, | |
2936 -2.1, -2.6, -2.5, -3.1, -3.6, -3.5, | |
2937 2147483648.0, | |
2938 std::numeric_limits<float>::quiet_NaN(), | |
2939 std::numeric_limits<float>::infinity(), | |
2940 9223372036854775808.0 | |
2941 }; | |
2942 double outputs[tableLength] = { | |
2943 3.0, 3.0, 3.0, 4.0, 4.0, 4.0, | |
2944 -2.0, -2.0, -2.0, -3.0, -3.0, -3.0, | |
2945 2147483648.0, dFPU64InvalidResult, | |
2946 dFPU64InvalidResult, dFPU64InvalidResult}; | |
2947 | |
2948 __ ldc1(f4, MemOperand(a0, OFFSET_OF(Test, a)) ); | |
2949 __ lwc1(f6, MemOperand(a0, OFFSET_OF(Test, b)) ); | |
2950 __ ceil_l_d(f8, f4); | |
2951 __ ceil_l_s(f10, f6); | |
2952 __ sdc1(f8, MemOperand(a0, OFFSET_OF(Test, c)) ); | |
2953 __ sdc1(f10, MemOperand(a0, OFFSET_OF(Test, d)) ); | |
2954 __ jr(ra); | |
2955 __ nop(); | |
2956 Test test; | |
2957 CodeDesc desc; | |
2958 assm.GetCode(&desc); | |
2959 Handle<Code> code = isolate->factory()->NewCode( | |
2960 desc, Code::ComputeFlags(Code::STUB), Handle<Code>()); | |
2961 F3 f = FUNCTION_CAST<F3>(code->entry()); | |
2962 for (int i = 0; i < tableLength; i++) { | |
2963 test.a = inputs_D[i]; | |
2964 test.b = inputs_S[i]; | |
2965 (CALL_GENERATED_CODE(f, &test, 0, 0, 0, 0)); | |
2966 CHECK_EQ(test.c, outputs[i]); | |
2967 CHECK_EQ(test.d, test.c); | |
2968 } | |
2969 } | |
2970 } | |
2971 | |
2972 | |
2973 TEST(jump_tables1) { | 1658 TEST(jump_tables1) { |
2974 // Test jump tables with forward jumps. | 1659 // Test jump tables with forward jumps. |
2975 CcTest::InitializeVM(); | 1660 CcTest::InitializeVM(); |
2976 Isolate* isolate = CcTest::i_isolate(); | 1661 Isolate* isolate = CcTest::i_isolate(); |
2977 HandleScope scope(isolate); | 1662 HandleScope scope(isolate); |
2978 Assembler assm(isolate, nullptr, 0); | 1663 Assembler assm(isolate, nullptr, 0); |
2979 | 1664 |
2980 const int kNumCases = 512; | 1665 const int kNumCases = 512; |
2981 int values[kNumCases]; | 1666 int values[kNumCases]; |
2982 isolate->random_number_generator()->NextBytes(values, sizeof(values)); | 1667 isolate->random_number_generator()->NextBytes(values, sizeof(values)); |
(...skipping 192 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3175 ::printf("f(%d) = ", i); | 1860 ::printf("f(%d) = ", i); |
3176 result->Print(std::cout); | 1861 result->Print(std::cout); |
3177 ::printf("\n"); | 1862 ::printf("\n"); |
3178 #endif | 1863 #endif |
3179 CHECK(values[i].is_identical_to(result)); | 1864 CHECK(values[i].is_identical_to(result)); |
3180 } | 1865 } |
3181 } | 1866 } |
3182 | 1867 |
3183 | 1868 |
3184 #undef __ | 1869 #undef __ |
OLD | NEW |