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

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

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