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

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

Issue 1749263002: MIPS: Improve Lsa/Dlsa implementations. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Rebased. Created 4 years, 9 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/macro-assembler-mips64.cc ('k') | test/cctest/test-macro-assembler-mips.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 5342 matching lines...) Expand 10 before | Expand all | Expand 10 after
5353 { 4, 1 }, 5353 { 4, 1 },
5354 }; 5354 };
5355 5355
5356 size_t nr_test_cases = sizeof(tc) / sizeof(TestCaseBal); 5356 size_t nr_test_cases = sizeof(tc) / sizeof(TestCaseBal);
5357 for (size_t i = 0; i < nr_test_cases; ++i) { 5357 for (size_t i = 0; i < nr_test_cases; ++i) {
5358 CHECK_EQ(tc[i].expected_res, run_bal(tc[i].offset)); 5358 CHECK_EQ(tc[i].expected_res, run_bal(tc[i].offset));
5359 } 5359 }
5360 } 5360 }
5361 5361
5362 5362
5363 static uint32_t run_lsa(uint32_t rt, uint32_t rs, int8_t sa) {
5364 Isolate* isolate = CcTest::i_isolate();
5365 HandleScope scope(isolate);
5366 MacroAssembler assm(isolate, nullptr, 0,
5367 v8::internal::CodeObjectRequired::kYes);
5368
5369 __ lsa(v0, a0, a1, sa);
5370 __ jr(ra);
5371 __ nop();
5372
5373 CodeDesc desc;
5374 assm.GetCode(&desc);
5375 Handle<Code> code = isolate->factory()->NewCode(
5376 desc, Code::ComputeFlags(Code::STUB), Handle<Code>());
5377
5378 F1 f = FUNCTION_CAST<F1>(code->entry());
5379
5380 uint32_t res = reinterpret_cast<uint32_t>(
5381 CALL_GENERATED_CODE(isolate, f, rt, rs, 0, 0, 0));
5382
5383 return res;
5384 }
5385
5386
5387 TEST(lsa) {
5388 if (!IsMipsArchVariant(kMips32r6)) return;
5389
5390 CcTest::InitializeVM();
5391 struct TestCaseLsa {
5392 int32_t rt;
5393 int32_t rs;
5394 uint8_t sa;
5395 uint32_t expected_res;
5396 };
5397
5398 struct TestCaseLsa tc[] = {
5399 // rt, rs, sa, expected_res
5400 {0x4, 0x1, 1, 0x6},
5401 {0x4, 0x1, 2, 0x8},
5402 {0x4, 0x1, 3, 0xc},
5403 {0x4, 0x1, 4, 0x14},
5404 {0x0, 0x1, 1, 0x2},
5405 {0x0, 0x1, 2, 0x4},
5406 {0x0, 0x1, 3, 0x8},
5407 {0x0, 0x1, 4, 0x10},
5408 {0x4, 0x0, 1, 0x4},
5409 {0x4, 0x0, 2, 0x4},
5410 {0x4, 0x0, 3, 0x4},
5411 {0x4, 0x0, 4, 0x4},
5412 {0x4, INT32_MAX, 1, 0x2}, // Shift overflow.
5413 {0x4, INT32_MAX >> 1, 2, 0x0}, // Shift overflow.
5414 {0x4, INT32_MAX >> 2, 3, 0xfffffffc}, // Shift overflow.
5415 {0x4, INT32_MAX >> 3, 4, 0xfffffff4}, // Shift overflow.
5416 {INT32_MAX - 1, 0x1, 1, 0x80000000}, // Signed adition overflow.
5417 {INT32_MAX - 3, 0x1, 2, 0x80000000}, // Signed addition overflow.
5418 {INT32_MAX - 7, 0x1, 3, 0x80000000}, // Signed addition overflow.
5419 {INT32_MAX - 15, 0x1, 4, 0x80000000}, // Signed addition overflow.
5420 {-2, 0x1, 1, 0x0}, // Addition overflow.
5421 {-4, 0x1, 2, 0x0}, // Addition overflow.
5422 {-8, 0x1, 3, 0x0}, // Addition overflow.
5423 {-16, 0x1, 4, 0x0}}; // Addition overflow.
5424
5425 size_t nr_test_cases = sizeof(tc) / sizeof(TestCaseLsa);
5426 for (size_t i = 0; i < nr_test_cases; ++i) {
5427 uint32_t res = run_lsa(tc[i].rt, tc[i].rs, tc[i].sa);
5428 PrintF("0x%x =? 0x%x == lsa(v0, %x, %x, %hhu)\n", tc[i].expected_res, res,
5429 tc[i].rt, tc[i].rs, tc[i].sa);
5430 CHECK_EQ(tc[i].expected_res, res);
5431 }
5432 }
5433
5434
5435 TEST(Trampoline) { 5363 TEST(Trampoline) {
5436 // Private member of Assembler class. 5364 // Private member of Assembler class.
5437 static const int kMaxBranchOffset = (1 << (18 - 1)) - 1; 5365 static const int kMaxBranchOffset = (1 << (18 - 1)) - 1;
5438 5366
5439 CcTest::InitializeVM(); 5367 CcTest::InitializeVM();
5440 Isolate* isolate = CcTest::i_isolate(); 5368 Isolate* isolate = CcTest::i_isolate();
5441 HandleScope scope(isolate); 5369 HandleScope scope(isolate);
5442 5370
5443 MacroAssembler assm(isolate, nullptr, 0, 5371 MacroAssembler assm(isolate, nullptr, 0,
5444 v8::internal::CodeObjectRequired::kYes); 5372 v8::internal::CodeObjectRequired::kYes);
(...skipping 12 matching lines...) Expand all
5457 Handle<Code> code = isolate->factory()->NewCode( 5385 Handle<Code> code = isolate->factory()->NewCode(
5458 desc, Code::ComputeFlags(Code::STUB), Handle<Code>()); 5386 desc, Code::ComputeFlags(Code::STUB), Handle<Code>());
5459 F2 f = FUNCTION_CAST<F2>(code->entry()); 5387 F2 f = FUNCTION_CAST<F2>(code->entry());
5460 5388
5461 int32_t res = reinterpret_cast<int32_t>( 5389 int32_t res = reinterpret_cast<int32_t>(
5462 CALL_GENERATED_CODE(isolate, f, 42, 42, 0, 0, 0)); 5390 CALL_GENERATED_CODE(isolate, f, 42, 42, 0, 0, 0));
5463 CHECK_EQ(res, 0); 5391 CHECK_EQ(res, 0);
5464 } 5392 }
5465 5393
5466 #undef __ 5394 #undef __
OLDNEW
« no previous file with comments | « src/mips64/macro-assembler-mips64.cc ('k') | test/cctest/test-macro-assembler-mips.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698