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 5367 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
5378 CodeDesc desc; | 5378 CodeDesc desc; |
5379 assm.GetCode(&desc); | 5379 assm.GetCode(&desc); |
5380 Handle<Code> code = isolate->factory()->NewCode( | 5380 Handle<Code> code = isolate->factory()->NewCode( |
5381 desc, Code::ComputeFlags(Code::STUB), Handle<Code>()); | 5381 desc, Code::ComputeFlags(Code::STUB), Handle<Code>()); |
5382 F2 f = FUNCTION_CAST<F2>(code->entry()); | 5382 F2 f = FUNCTION_CAST<F2>(code->entry()); |
5383 | 5383 |
5384 int32_t res = reinterpret_cast<int32_t>( | 5384 int32_t res = reinterpret_cast<int32_t>( |
5385 CALL_GENERATED_CODE(isolate, f, 42, 42, 0, 0, 0)); | 5385 CALL_GENERATED_CODE(isolate, f, 42, 42, 0, 0, 0)); |
5386 CHECK_EQ(res, 0); | 5386 CHECK_EQ(res, 0); |
5387 } | 5387 } |
5388 | 5388 |
balazs.kilvady
2016/09/05 12:54:01
I think you should create common TestCases but dif
Ilija.Pavlovic1
2016/09/07 08:44:29
The test will be broken in two tests: for r2 will
| |
5389 TEST(madd_s_msub_s_maddf_s_msubf_s) { | |
5390 CcTest::InitializeVM(); | |
5391 Isolate* isolate = CcTest::i_isolate(); | |
5392 HandleScope scope(isolate); | |
5393 MacroAssembler assm(isolate, NULL, 0, v8::internal::CodeObjectRequired::kYes); | |
5394 | |
5395 struct TestCase { | |
5396 float fr, fs, ft, fd_add, fd_sub; | |
5397 }; | |
5398 | |
5399 float x = sqrtf(2.0); | |
5400 float y = sqrtf(3.0); | |
5401 float z = sqrtf(5.0); | |
5402 TestCase test_cases[] = { | |
5403 {x, y, z, 0.0, 0.0}, {x, y, -z, 0.0, 0.0}, {x, -y, z, 0.0, 0.0}, | |
5404 {x, -y, -z, 0.0, 0.0}, {-x, y, z, 0.0, 0.0}, {-x, y, -z, 0.0, 0.0}, | |
5405 {-x, -y, z, 0.0, 0.0}, {-x, -y, -z, 0.0, 0.0}, | |
5406 }; | |
5407 | |
5408 __ lwc1(f4, MemOperand(a0, offsetof(TestCase, fr))); | |
5409 __ lwc1(f6, MemOperand(a0, offsetof(TestCase, fs))); | |
5410 __ lwc1(f8, MemOperand(a0, offsetof(TestCase, ft))); | |
5411 __ lwc1(f16, MemOperand(a0, offsetof(TestCase, fr))); | |
5412 | |
5413 if (IsMipsArchVariant(kMips32r2)) { | |
5414 __ madd_s(f10, f4, f6, f8); | |
5415 __ swc1(f10, MemOperand(a0, offsetof(TestCase, fd_add))); | |
5416 __ msub_s(f16, f4, f6, f8); | |
5417 __ swc1(f16, MemOperand(a0, offsetof(TestCase, fd_sub))); | |
5418 } | |
5419 | |
5420 if (IsMipsArchVariant(kMips32r6)) { | |
5421 __ maddf_s(f4, f6, f8); | |
5422 __ swc1(f4, MemOperand(a0, offsetof(TestCase, fd_add))); | |
5423 __ msubf_s(f16, f6, f8); | |
5424 __ swc1(f16, MemOperand(a0, offsetof(TestCase, fd_sub))); | |
5425 } | |
5426 | |
5427 __ jr(ra); | |
5428 __ nop(); | |
5429 | |
5430 CodeDesc desc; | |
5431 assm.GetCode(&desc); | |
5432 Handle<Code> code = isolate->factory()->NewCode( | |
5433 desc, Code::ComputeFlags(Code::STUB), Handle<Code>()); | |
5434 F3 f = FUNCTION_CAST<F3>(code->entry()); | |
5435 | |
5436 const size_t kTableLength = sizeof(test_cases) / sizeof(TestCase); | |
5437 TestCase tc; | |
5438 for (size_t i = 0; i < kTableLength; i++) { | |
5439 tc.fr = test_cases[i].fr; | |
5440 tc.fs = test_cases[i].fs; | |
5441 tc.ft = test_cases[i].ft; | |
5442 | |
5443 (CALL_GENERATED_CODE(isolate, f, &tc, 0, 0, 0, 0)); | |
5444 | |
5445 float res_add = tc.fr + (tc.fs * tc.ft); | |
5446 float res_sub; | |
5447 if (IsMipsArchVariant(kMips32r2)) { | |
5448 res_sub = (tc.fs * tc.ft) - tc.fr; | |
5449 } else if (IsMipsArchVariant(kMips32r6)) { | |
5450 res_sub = tc.fr - (tc.fs * tc.ft); | |
5451 } | |
5452 | |
5453 CHECK_EQ(tc.fd_add, res_add); | |
5454 CHECK_EQ(tc.fd_sub, res_sub); | |
5455 } | |
5456 } | |
5457 | |
5458 TEST(madd_d_msub_d_maddf_d_msubf_d) { | |
5459 CcTest::InitializeVM(); | |
5460 Isolate* isolate = CcTest::i_isolate(); | |
5461 HandleScope scope(isolate); | |
5462 MacroAssembler assm(isolate, NULL, 0, v8::internal::CodeObjectRequired::kYes); | |
5463 | |
5464 struct TestCase { | |
5465 double fr, fs, ft, fd_add, fd_sub; | |
5466 }; | |
5467 | |
5468 double x = sqrt(2.0); | |
5469 double y = sqrt(3.0); | |
5470 double z = sqrt(5.0); | |
5471 TestCase test_cases[] = {{x, y, z, 0.0, 0.0}, {x, y, -z, 0.0, 0.0}, | |
5472 {x, -y, z, 0.0, 0.0}, {x, -y, -z, 0.0, 0.0}, | |
5473 {-x, y, z, 0.0, 0.0}, {-x, y, -z, 0.0, 0.0}, | |
5474 {-x, -y, z, 0.0, 0.0}, {-x, -y, -z, 0.0, 0.0}}; | |
5475 | |
5476 __ ldc1(f4, MemOperand(a0, offsetof(TestCase, fr))); | |
5477 __ ldc1(f6, MemOperand(a0, offsetof(TestCase, fs))); | |
5478 __ ldc1(f8, MemOperand(a0, offsetof(TestCase, ft))); | |
5479 __ ldc1(f16, MemOperand(a0, offsetof(TestCase, fr))); | |
5480 | |
5481 if (IsMipsArchVariant(kMips32r2)) { | |
5482 __ madd_d(f10, f4, f6, f8); | |
5483 __ sdc1(f10, MemOperand(a0, offsetof(TestCase, fd_add))); | |
5484 __ msub_d(f16, f4, f6, f8); | |
5485 __ sdc1(f16, MemOperand(a0, offsetof(TestCase, fd_sub))); | |
5486 } | |
5487 | |
5488 if (IsMipsArchVariant(kMips32r6)) { | |
5489 __ maddf_d(f4, f6, f8); | |
5490 __ sdc1(f4, MemOperand(a0, offsetof(TestCase, fd_add))); | |
5491 __ msubf_d(f16, f6, f8); | |
5492 __ sdc1(f16, MemOperand(a0, offsetof(TestCase, fd_sub))); | |
5493 } | |
5494 | |
5495 __ jr(ra); | |
5496 __ nop(); | |
5497 | |
5498 CodeDesc desc; | |
5499 assm.GetCode(&desc); | |
5500 Handle<Code> code = isolate->factory()->NewCode( | |
5501 desc, Code::ComputeFlags(Code::STUB), Handle<Code>()); | |
5502 F3 f = FUNCTION_CAST<F3>(code->entry()); | |
5503 | |
5504 const size_t kTableLength = sizeof(test_cases) / sizeof(TestCase); | |
5505 TestCase tc; | |
5506 for (size_t i = 0; i < kTableLength; i++) { | |
5507 tc.fr = test_cases[i].fr; | |
5508 tc.fs = test_cases[i].fs; | |
5509 tc.ft = test_cases[i].ft; | |
5510 | |
5511 (CALL_GENERATED_CODE(isolate, f, &tc, 0, 0, 0, 0)); | |
5512 | |
5513 double res_add = tc.fr + (tc.fs * tc.ft); | |
5514 double res_sub; | |
5515 if (IsMipsArchVariant(kMips32r2)) { | |
5516 res_sub = (tc.fs * tc.ft) - tc.fr; | |
5517 } else if (IsMipsArchVariant(kMips32r6)) { | |
5518 res_sub = tc.fr - (tc.fs * tc.ft); | |
5519 } | |
5520 | |
5521 CHECK_EQ(tc.fd_add, res_add); | |
5522 CHECK_EQ(tc.fd_sub, res_sub); | |
5523 } | |
5524 } | |
5525 | |
5389 #undef __ | 5526 #undef __ |
OLD | NEW |