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

Unified Diff: test/cctest/test-assembler-mips64.cc

Issue 1245173002: MIPS: Fix simulator data trace for DSLL and BAL/BGEZAL. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 5 years, 5 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « test/cctest/test-assembler-mips.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: test/cctest/test-assembler-mips64.cc
diff --git a/test/cctest/test-assembler-mips64.cc b/test/cctest/test-assembler-mips64.cc
index bb7b05ca768c09b897b04ce0e881e7c9f6416a5f..1fe7cfeb39e6f7b2ee2996923ac9cf172fb8381f 100644
--- a/test/cctest/test-assembler-mips64.cc
+++ b/test/cctest/test-assembler-mips64.cc
@@ -5366,4 +5366,104 @@ TEST(r6_balc) {
}
+uint64_t run_dsll(uint64_t rt_value, uint16_t sa_value) {
+ Isolate* isolate = CcTest::i_isolate();
+ HandleScope scope(isolate);
+
+ MacroAssembler assm(isolate, NULL, 0);
+
+ __ dsll(v0, a0, sa_value);
+ __ jr(ra);
+ __ nop();
+
+ CodeDesc desc;
+ assm.GetCode(&desc);
+ Handle<Code> code = isolate->factory()->NewCode(
+ desc, Code::ComputeFlags(Code::STUB), Handle<Code>());
+
+ F2 f = FUNCTION_CAST<F2>(code->entry());
+
+ uint64_t res =
+ reinterpret_cast<uint64_t>(CALL_GENERATED_CODE(f, rt_value, 0, 0, 0, 0));
+
+ return res;
+}
+
+
+TEST(dsll) {
+ CcTest::InitializeVM();
+
+ struct TestCaseDsll {
+ uint64_t rt_value;
+ uint16_t sa_value;
+ uint64_t expected_res;
+ };
+
+ struct TestCaseDsll tc[] = {
+ // rt_value, sa_value, expected_res
+ { 0xffffffffffffffff, 0, 0xffffffffffffffff },
+ { 0xffffffffffffffff, 16, 0xffffffffffff0000 },
+ { 0xffffffffffffffff, 31, 0xffffffff80000000 },
+ };
+
+ size_t nr_test_cases = sizeof(tc) / sizeof(TestCaseDsll);
+ for (size_t i = 0; i < nr_test_cases; ++i) {
+ CHECK_EQ(tc[i].expected_res,
+ run_dsll(tc[i].rt_value, tc[i].sa_value));
+ }
+}
+
+
+uint64_t run_bal(int16_t offset) {
+ Isolate* isolate = CcTest::i_isolate();
+ HandleScope scope(isolate);
+
+ MacroAssembler assm(isolate, NULL, 0);
+
+ __ mov(t0, ra);
+ __ bal(offset); // Equivalent for "BGEZAL zero_reg, offset".
+ __ nop();
+
+ __ mov(ra, t0);
+ __ jr(ra);
+ __ nop();
+
+ __ li(v0, 1);
+ __ jr(ra);
+ __ nop();
+
+ CodeDesc desc;
+ assm.GetCode(&desc);
+ Handle<Code> code = isolate->factory()->NewCode(
+ desc, Code::ComputeFlags(Code::STUB), Handle<Code>());
+
+ F2 f = FUNCTION_CAST<F2>(code->entry());
+
+ uint64_t res =
+ reinterpret_cast<uint64_t>(CALL_GENERATED_CODE(f, 0, 0, 0, 0, 0));
+
+ return res;
+}
+
+
+TEST(bal) {
+ CcTest::InitializeVM();
+
+ struct TestCaseBal {
+ int16_t offset;
+ uint64_t expected_res;
+ };
+
+ struct TestCaseBal tc[] = {
+ // offset, expected_res
+ { 4, 1 },
+ };
+
+ size_t nr_test_cases = sizeof(tc) / sizeof(TestCaseBal);
+ for (size_t i = 0; i < nr_test_cases; ++i) {
+ CHECK_EQ(tc[i].expected_res, run_bal(tc[i].offset));
+ }
+}
+
+
#undef __
« no previous file with comments | « test/cctest/test-assembler-mips.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698