| 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 366 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 377 CHECK_EQ(1.5e6, t.fb); | 377 CHECK_EQ(1.5e6, t.fb); |
| 378 CHECK_EQ(1.5275e06, t.fc); | 378 CHECK_EQ(1.5275e06, t.fc); |
| 379 CHECK_EQ(1.5550e06, t.fd); | 379 CHECK_EQ(1.5550e06, t.fd); |
| 380 CHECK_EQ(1.866e08, t.fe); | 380 CHECK_EQ(1.866e08, t.fe); |
| 381 CHECK_EQ(124.40000152587890625, t.ff); | 381 CHECK_EQ(124.40000152587890625, t.ff); |
| 382 CHECK_EQ(11.1534748077392578125, t.fg); | 382 CHECK_EQ(11.1534748077392578125, t.fg); |
| 383 } | 383 } |
| 384 | 384 |
| 385 | 385 |
| 386 TEST(MIPS4) { | 386 TEST(MIPS4) { |
| 387 // Exchange between GP anf FP registers is done through memory |
| 388 // on FPXX compiled binaries and architectures that do not support |
| 389 // MTHC1 and MTFC1. If this is the case, skipping this test. |
| 390 if (IsFpxxMode() && |
| 391 (IsMipsArchVariant(kMips32r1) || IsMipsArchVariant(kLoongson))) { |
| 392 return; |
| 393 } |
| 394 |
| 387 // Test moves between floating point and integer registers. | 395 // Test moves between floating point and integer registers. |
| 388 CcTest::InitializeVM(); | 396 CcTest::InitializeVM(); |
| 389 Isolate* isolate = CcTest::i_isolate(); | 397 Isolate* isolate = CcTest::i_isolate(); |
| 390 HandleScope scope(isolate); | 398 HandleScope scope(isolate); |
| 391 | 399 |
| 392 typedef struct { | 400 typedef struct { |
| 393 double a; | 401 double a; |
| 394 double b; | 402 double b; |
| 395 double c; | 403 double c; |
| 396 } T; | 404 } T; |
| 397 T t; | 405 T t; |
| 398 | 406 |
| 399 Assembler assm(isolate, NULL, 0); | 407 Assembler assm(isolate, NULL, 0); |
| 400 Label L, C; | 408 Label L, C; |
| 401 | 409 |
| 402 __ ldc1(f4, MemOperand(a0, offsetof(T, a)) ); | 410 __ ldc1(f4, MemOperand(a0, offsetof(T, a)) ); |
| 403 __ ldc1(f6, MemOperand(a0, offsetof(T, b)) ); | 411 __ ldc1(f6, MemOperand(a0, offsetof(T, b)) ); |
| 404 | 412 |
| 405 // Swap f4 and f6, by using four integer registers, t0-t3. | 413 // Swap f4 and f6, by using four integer registers, t0-t3. |
| 406 if (!IsFp64Mode()) { | 414 if (IsFp32Mode()) { |
| 407 __ mfc1(t0, f4); | 415 __ mfc1(t0, f4); |
| 408 __ mfc1(t1, f5); | 416 __ mfc1(t1, f5); |
| 409 __ mfc1(t2, f6); | 417 __ mfc1(t2, f6); |
| 410 __ mfc1(t3, f7); | 418 __ mfc1(t3, f7); |
| 411 | 419 |
| 412 __ mtc1(t0, f6); | 420 __ mtc1(t0, f6); |
| 413 __ mtc1(t1, f7); | 421 __ mtc1(t1, f7); |
| 414 __ mtc1(t2, f4); | 422 __ mtc1(t2, f4); |
| 415 __ mtc1(t3, f5); | 423 __ mtc1(t3, f5); |
| 416 } else { | 424 } else { |
| 417 CHECK(!IsMipsArchVariant(kMips32r1) && !IsMipsArchVariant(kLoongson)); | 425 CHECK(!IsMipsArchVariant(kMips32r1) && !IsMipsArchVariant(kLoongson)); |
| 426 DCHECK(IsFp64Mode() || IsFpxxMode()); |
| 418 __ mfc1(t0, f4); | 427 __ mfc1(t0, f4); |
| 419 __ mfhc1(t1, f4); | 428 __ mfhc1(t1, f4); |
| 420 __ mfc1(t2, f6); | 429 __ mfc1(t2, f6); |
| 421 __ mfhc1(t3, f6); | 430 __ mfhc1(t3, f6); |
| 422 | 431 |
| 423 __ mtc1(t0, f6); | 432 __ mtc1(t0, f6); |
| 424 __ mthc1(t1, f6); | 433 __ mthc1(t1, f6); |
| 425 __ mtc1(t2, f4); | 434 __ mtc1(t2, f4); |
| 426 __ mthc1(t3, f4); | 435 __ mthc1(t3, f4); |
| 427 } | 436 } |
| 437 |
| 428 // Store the swapped f4 and f5 back to memory. | 438 // Store the swapped f4 and f5 back to memory. |
| 429 __ sdc1(f4, MemOperand(a0, offsetof(T, a)) ); | 439 __ sdc1(f4, MemOperand(a0, offsetof(T, a)) ); |
| 430 __ sdc1(f6, MemOperand(a0, offsetof(T, c)) ); | 440 __ sdc1(f6, MemOperand(a0, offsetof(T, c)) ); |
| 431 | 441 |
| 432 __ jr(ra); | 442 __ jr(ra); |
| 433 __ nop(); | 443 __ nop(); |
| 434 | 444 |
| 435 CodeDesc desc; | 445 CodeDesc desc; |
| 436 assm.GetCode(&desc); | 446 assm.GetCode(&desc); |
| 437 Handle<Code> code = isolate->factory()->NewCode( | 447 Handle<Code> code = isolate->factory()->NewCode( |
| (...skipping 366 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 804 | 814 |
| 805 CodeDesc desc; | 815 CodeDesc desc; |
| 806 assm.GetCode(&desc); | 816 assm.GetCode(&desc); |
| 807 isolate->factory()->NewCode( | 817 isolate->factory()->NewCode( |
| 808 desc, Code::ComputeFlags(Code::STUB), Handle<Code>()); | 818 desc, Code::ComputeFlags(Code::STUB), Handle<Code>()); |
| 809 } | 819 } |
| 810 | 820 |
| 811 | 821 |
| 812 TEST(MIPS10) { | 822 TEST(MIPS10) { |
| 813 // Test conversions between doubles and words. | 823 // Test conversions between doubles and words. |
| 814 // Test maps double to FP reg pairs in fp32 mode | |
| 815 // and into FP reg in fp64 mode. | |
| 816 CcTest::InitializeVM(); | 824 CcTest::InitializeVM(); |
| 817 Isolate* isolate = CcTest::i_isolate(); | 825 Isolate* isolate = CcTest::i_isolate(); |
| 818 HandleScope scope(isolate); | 826 HandleScope scope(isolate); |
| 819 | 827 |
| 820 typedef struct { | 828 typedef struct { |
| 821 double a; | 829 double a; |
| 822 double b; | 830 double b; |
| 823 int32_t dbl_mant; | 831 int32_t dbl_mant; |
| 824 int32_t dbl_exp; | 832 int32_t dbl_exp; |
| 825 int32_t word; | 833 int32_t word; |
| 826 int32_t b_word; | 834 int32_t b_word; |
| 827 } T; | 835 } T; |
| 828 T t; | 836 T t; |
| 829 | 837 |
| 830 Assembler assm(isolate, NULL, 0); | 838 Assembler assm(isolate, NULL, 0); |
| 831 Label L, C; | 839 Label L, C; |
| 832 | 840 |
| 833 if (!IsMipsArchVariant(kMips32r2)) return; | 841 if (IsMipsArchVariant(kMips32r1) || IsMipsArchVariant(kLoongson)) return; |
| 834 | 842 |
| 835 // Load all structure elements to registers. | 843 // Load all structure elements to registers. |
| 836 // (f0, f1) = a (fp32), f0 = a (fp64) | 844 // (f0, f1) = a (fp32), f0 = a (fp64) |
| 837 __ ldc1(f0, MemOperand(a0, offsetof(T, a))); | 845 __ ldc1(f0, MemOperand(a0, offsetof(T, a))); |
| 838 | 846 |
| 839 if (IsFp64Mode()) { | 847 __ mfc1(t0, f0); // t0 = f0(31..0) |
| 840 __ mfc1(t0, f0); // t0 = f0(31..0) | 848 __ mfhc1(t1, f0); // t1 = sign_extend(f0(63..32)) |
| 841 __ mfhc1(t1, f0); // t1 = sign_extend(f0(63..32)) | 849 __ sw(t0, MemOperand(a0, offsetof(T, dbl_mant))); // dbl_mant = t0 |
| 842 __ sw(t0, MemOperand(a0, offsetof(T, dbl_mant))); // dbl_mant = t0 | 850 __ sw(t1, MemOperand(a0, offsetof(T, dbl_exp))); // dbl_exp = t1 |
| 843 __ sw(t1, MemOperand(a0, offsetof(T, dbl_exp))); // dbl_exp = t1 | |
| 844 } else { | |
| 845 // Save the raw bits of the double. | |
| 846 __ mfc1(t0, f0); // t0 = a1 | |
| 847 __ mfc1(t1, f1); // t1 = a2 | |
| 848 __ sw(t0, MemOperand(a0, offsetof(T, dbl_mant))); // dbl_mant = t0 | |
| 849 __ sw(t1, MemOperand(a0, offsetof(T, dbl_exp))); // dbl_exp = t1 | |
| 850 } | |
| 851 | 851 |
| 852 // Convert double in f0 to word, save hi/lo parts. | 852 // Convert double in f0 to word, save hi/lo parts. |
| 853 __ cvt_w_d(f0, f0); // a_word = (word)a | 853 __ cvt_w_d(f0, f0); // a_word = (word)a |
| 854 __ mfc1(t0, f0); // f0 has a 32-bits word. t0 = a_word | 854 __ mfc1(t0, f0); // f0 has a 32-bits word. t0 = a_word |
| 855 __ sw(t0, MemOperand(a0, offsetof(T, word))); // word = a_word | 855 __ sw(t0, MemOperand(a0, offsetof(T, word))); // word = a_word |
| 856 | 856 |
| 857 // Convert the b word to double b. | 857 // Convert the b word to double b. |
| 858 __ lw(t0, MemOperand(a0, offsetof(T, b_word))); | 858 __ lw(t0, MemOperand(a0, offsetof(T, b_word))); |
| 859 __ mtc1(t0, f8); // f8 has a 32-bits word. | 859 __ mtc1(t0, f8); // f8 has a 32-bits word. |
| 860 __ cvt_d_w(f10, f8); | 860 __ cvt_d_w(f10, f8); |
| (...skipping 4586 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5447 Handle<Code> code = isolate->factory()->NewCode( | 5447 Handle<Code> code = isolate->factory()->NewCode( |
| 5448 desc, Code::ComputeFlags(Code::STUB), Handle<Code>()); | 5448 desc, Code::ComputeFlags(Code::STUB), Handle<Code>()); |
| 5449 F2 f = FUNCTION_CAST<F2>(code->entry()); | 5449 F2 f = FUNCTION_CAST<F2>(code->entry()); |
| 5450 | 5450 |
| 5451 int32_t res = reinterpret_cast<int32_t>( | 5451 int32_t res = reinterpret_cast<int32_t>( |
| 5452 CALL_GENERATED_CODE(isolate, f, 42, 42, 0, 0, 0)); | 5452 CALL_GENERATED_CODE(isolate, f, 42, 42, 0, 0, 0)); |
| 5453 CHECK_EQ(res, 0); | 5453 CHECK_EQ(res, 0); |
| 5454 } | 5454 } |
| 5455 | 5455 |
| 5456 #undef __ | 5456 #undef __ |
| OLD | NEW |