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

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

Issue 2313623002: MIPS: Implement MADD.S, MSUB, MADDF and MSUBF. (Closed)
Patch Set: Added blocks and unreachable sections. Created 4 years, 3 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 5368 matching lines...) Expand 10 before | Expand all | Expand 10 after
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
5389 template <class T>
5390 struct TestCaseMaddMsub {
5391 T fr, fs, ft, fd_add, fd_sub;
5392 };
5393
5394 template <typename T, typename F>
5395 void helper_madd_msub_maddf_msubf(F func) {
5396 CcTest::InitializeVM();
5397 Isolate* isolate = CcTest::i_isolate();
5398 HandleScope scope(isolate);
5399 MacroAssembler assm(isolate, NULL, 0, v8::internal::CodeObjectRequired::kYes);
5400
5401 T x = std::sqrt(static_cast<T>(2.0));
5402 T y = std::sqrt(static_cast<T>(3.0));
5403 T z = std::sqrt(static_cast<T>(5.0));
5404 T x2 = 11.11, y2 = 22.22, z2 = 33.33;
5405 TestCaseMaddMsub<T> test_cases[] = {
5406 {x, y, z, 0.0, 0.0},
5407 {x, y, -z, 0.0, 0.0},
5408 {x, -y, z, 0.0, 0.0},
5409 {x, -y, -z, 0.0, 0.0},
5410 {-x, y, z, 0.0, 0.0},
5411 {-x, y, -z, 0.0, 0.0},
5412 {-x, -y, z, 0.0, 0.0},
5413 {-x, -y, -z, 0.0, 0.0},
5414 {-3.14, 0.2345, -123.000056, 0.0, 0.0},
5415 {7.3, -23.257, -357.1357, 0.0, 0.0},
5416 {x2, y2, z2, 0.0, 0.0},
5417 {x2, y2, -z2, 0.0, 0.0},
5418 {x2, -y2, z2, 0.0, 0.0},
5419 {x2, -y2, -z2, 0.0, 0.0},
5420 {-x2, y2, z2, 0.0, 0.0},
5421 {-x2, y2, -z2, 0.0, 0.0},
5422 {-x2, -y2, z2, 0.0, 0.0},
5423 {-x2, -y2, -z2, 0.0, 0.0},
5424 };
5425
5426 if (std::is_same<T, float>::value) {
5427 __ lwc1(f4, MemOperand(a0, offsetof(TestCaseMaddMsub<T>, fr)));
5428 __ lwc1(f6, MemOperand(a0, offsetof(TestCaseMaddMsub<T>, fs)));
5429 __ lwc1(f8, MemOperand(a0, offsetof(TestCaseMaddMsub<T>, ft)));
5430 __ lwc1(f16, MemOperand(a0, offsetof(TestCaseMaddMsub<T>, fr)));
5431 } else if (std::is_same<T, double>::value) {
5432 __ ldc1(f4, MemOperand(a0, offsetof(TestCaseMaddMsub<T>, fr)));
5433 __ ldc1(f6, MemOperand(a0, offsetof(TestCaseMaddMsub<T>, fs)));
5434 __ ldc1(f8, MemOperand(a0, offsetof(TestCaseMaddMsub<T>, ft)));
5435 __ ldc1(f16, MemOperand(a0, offsetof(TestCaseMaddMsub<T>, fr)));
5436 } else {
5437 UNREACHABLE();
5438 }
5439
5440 func(assm);
5441
5442 __ jr(ra);
5443 __ nop();
5444
5445 CodeDesc desc;
5446 assm.GetCode(&desc);
5447 Handle<Code> code = isolate->factory()->NewCode(
5448 desc, Code::ComputeFlags(Code::STUB), Handle<Code>());
5449 F3 f = FUNCTION_CAST<F3>(code->entry());
5450
5451 const size_t kTableLength = sizeof(test_cases) / sizeof(TestCaseMaddMsub<T>);
5452 TestCaseMaddMsub<T> tc;
5453 for (size_t i = 0; i < kTableLength; i++) {
5454 tc.fr = test_cases[i].fr;
5455 tc.fs = test_cases[i].fs;
5456 tc.ft = test_cases[i].ft;
5457
5458 (CALL_GENERATED_CODE(isolate, f, &tc, 0, 0, 0, 0));
5459
5460 T res_add = tc.fr + (tc.fs * tc.ft);
5461 T res_sub;
5462 if (IsMipsArchVariant(kMips32r2)) {
5463 res_sub = (tc.fs * tc.ft) - tc.fr;
5464 } else if (IsMipsArchVariant(kMips32r6)) {
5465 res_sub = tc.fr - (tc.fs * tc.ft);
5466 }
5467
5468 CHECK_EQ(tc.fd_add, res_add);
5469 CHECK_EQ(tc.fd_sub, res_sub);
5470 }
5471 }
5472
5473 TEST(madd_msub_s) {
5474 if (!IsMipsArchVariant(kMips32r2)) return;
5475 helper_madd_msub_maddf_msubf<float>([](MacroAssembler& assm) {
5476 __ madd_s(f10, f4, f6, f8);
5477 __ swc1(f10, MemOperand(a0, offsetof(TestCaseMaddMsub<float>, fd_add)));
5478 __ msub_s(f16, f4, f6, f8);
5479 __ swc1(f16, MemOperand(a0, offsetof(TestCaseMaddMsub<float>, fd_sub)));
5480 });
5481 }
5482
5483 TEST(madd_msub_d) {
5484 if (!IsMipsArchVariant(kMips32r2)) return;
5485 helper_madd_msub_maddf_msubf<double>([](MacroAssembler& assm) {
5486 __ madd_d(f10, f4, f6, f8);
5487 __ sdc1(f10, MemOperand(a0, offsetof(TestCaseMaddMsub<double>, fd_add)));
5488 __ msub_d(f16, f4, f6, f8);
5489 __ sdc1(f16, MemOperand(a0, offsetof(TestCaseMaddMsub<double>, fd_sub)));
5490 });
5491 }
5492
5493 TEST(maddf_msubf_s) {
5494 if (!IsMipsArchVariant(kMips32r6)) return;
5495 helper_madd_msub_maddf_msubf<float>([](MacroAssembler& assm) {
5496 __ maddf_s(f4, f6, f8);
5497 __ swc1(f4, MemOperand(a0, offsetof(TestCaseMaddMsub<float>, fd_add)));
5498 __ msubf_s(f16, f6, f8);
5499 __ swc1(f16, MemOperand(a0, offsetof(TestCaseMaddMsub<float>, fd_sub)));
5500 });
5501 }
5502
5503 TEST(maddf_msubf_d) {
5504 if (!IsMipsArchVariant(kMips32r6)) return;
5505 helper_madd_msub_maddf_msubf<double>([](MacroAssembler& assm) {
5506 __ maddf_d(f4, f6, f8);
5507 __ sdc1(f4, MemOperand(a0, offsetof(TestCaseMaddMsub<double>, fd_add)));
5508 __ msubf_d(f16, f6, f8);
5509 __ sdc1(f16, MemOperand(a0, offsetof(TestCaseMaddMsub<double>, fd_sub)));
5510 });
5511 }
5512
5389 #undef __ 5513 #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